I’ve been having some issues with my photon reconnecting to WiFi if it is lost - I’ve been testing with both v0.4.5 and v0.4.6 in MANUAL mode.
I want to post my outcomes here to see if anyone else has noticed this and/or can help in finding a solution / workaround.
I call the following code (snagged from @indraastra - thanks) from my loop (my loop is outputting serial data every second to show its alive):
if (!Particle.connected()) {
if (!WiFi.ready()) {
if (!WiFi.listening() && !WiFi.connecting()) {
Serial.println("Connecting to network!");
WiFi.connect();
}
} else {
if (!_cloudConnecting) {
Serial.println("Connecting to cloud!");
Particle.connect();
_cloudConnecting = true;
}
}
} else {
if (_cloudConnecting) {
Serial.println("Connected to cloud!");
}
_cloudConnecting = false;
Particle.process();
}
v0.4.5 Happy Path
Most of the time, I get a happy path:
- Device breathing cyan, running as normal, loop’s serial output showing every second
- Kill the AP, device begins to flash green, loop output shows every 10secs (assuming
WiFi.connect()
blocking here?) - Restart AP, device flashes more rapidly green, changes to cyan, starts breathing again, loop output returns to 1 sec.
v0.4.5 Sad Path
Sometimes (it can be after 10 succesful reconnects, sometimes 2, its random) I get the sad path with leads to complete failure:
- Device breathing cyan, running as normal, loop’s serial output showing every second
- Kill the AP, device begins to flash green, loop output stops completely as if device has hung.
- Restart AP, device flashes more rapidly green but never recovers until reset.
Its worth noting I get the sad path about 10% of the time but still enough to worry me as I go to deploy my application…
As mentioned I also tried this with v0.4.6 to see if the separate System Thread being enabled would help me. Here I see different behaviour but I am seeing a ratio of about 50-50 between the Happy and Sad…:
v0.4.6 Sad Path 1
- Device breathing cyan, running as normal, loop’s serial output showing every second
- Kill AP, device flashes green as if its on a happy path, running loop output every second.
- Restart AP, device starts to flash rapidly as if it is about to succeed and then SOS’s - seems to be the SOS pattern plus 1 single blip which the documentation says is #1 Hard Fault.
v0.4.6 Sad Path 2 - [ Note I have only observed this one twice in total ]
- Device breathing cyan, running as normal, loop’s serial output showing every second
- Kill AP, loop output continues fine but device goes to breathing blue on the LED
- Device will not ever connect until a reset.
v0.4.6 Happy Path
- Device breathing cyan, running as normal, loop’s serial output showing every second
- Kill the AP, device begins to flash green, loop output shows every 1sec
- Restart AP, device flashes more rapidly green, changes to cyan, starts breathing again
Completely understand that v0.4.6 is just new and introduces a huge piece of functionality in the System Thread so I appreciate there may be issues, just wanted to share my experience in case anyone can advise / help!