The BuilderKit firmware as of May 03, 2016, may stuck in connect()
function if WiFi is bad.
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
This code invokes WiFi.begin
once, and then waits for WiFi to become connected.
However, per WiFi.status() docs, the status may become WL_CONNECT_FAILED
“when the connection fails for all the attempts”.
Arduino example code places the WiFi.begin
line inside the loop, so that the WiFi stack can retry connection indefinitely.
device.connectSecure(wifiClient, LOSANT_ACCESS_KEY, LOSANT_ACCESS_SECRET);
while(!device.connected()) {
delay(500);
}
This code starts a connection to Losant, and then wait for it to become connected.
If WiFi becomes disconnected at this point, it’s impossible to get connected to Losant, and the code is stuck in this loop.
To resolve this issue, check for WiFi connectivity inside the loop, and return
if WiFi get disconnected. After returning, the next loop()
will invoke connect()
to try again.