@bko. Does this code work on the latest DEVELOP? It seems that a lot of WiFi features are broken/unreliable on anything more than the default Particle Dev IDE firmware.
The main reasons I left the “official” firmware of the Dev IDE are:
TCPServer.stop()
- smaller firmware size (or at least flexibility to manually reduce it)
- hope for bugfixes and improved reliability.
I got the first two, but apparently not the last one. WiFi.ping()
doesn’t work (I’m not alone with this one: Ping not working on develop branch?)…and with the latest DEVELOP, WiFi.connecting()
doesn’t appear to work either.
I wrote some code to stack all the socket statuses into one variable, via the socket status code you kindly provided. Here’s the code I’m using to stack it all together:
mBase = 0;
for(mWork = 6; mWork <= 0; mWork--)
{
mBase <<= 1;
mBase |= get_socket_active_status(mWork); // Returns SOCKET_STATUS_ACTIVE = 1, INACTIVE = 0. That's the only options.
}
Serial.print("SocketStat: "); Serial.println(mBase, HEX);
```
And I always get...0. Regardless if the Core is connected to the :cloud: or not.
I peeked into the firmware "evnt_handler.c" and found that <code>get_socket_active_status</code> is really bit-masking an internal variable with the socket statuses in it. As in:
//*****************************************************************************
//
//! get_socket_active_status
//!
//! @param Sd Socket IS
//! @return Current status of the socket.
//!
//! @brief Retrieve socket status
//
//*****************************************************************************
INT32 get_socket_active_status(INT32 Sd)
{
long rv = SOCKET_STATUS_INACTIVE;
if(M_IS_VALID_SD(Sd))
{
rv = (socket_active_status & (1 << Sd)) ? SOCKET_STATUS_INACTIVE : SOCKET_STATUS_ACTIVE;
}
return rv;
}
As mentioned before, I always get 0, regardless of whether the TCPClient succeeds or fails to connect to an external server (in this case, [textbelt.com][1]). Any suggestions? Or perhaps I should return to Particle Dev IDE? I suppose the way to synthesize `TCPServer.stop()` is with `WiFi.off(); WiFi.on();`?
[1]: http://textbelt.com