Created
December 21, 2013 00:04
-
-
Save ersatzavian/8063585 to your computer and use it in GitHub Desktop.
Setting up reconnect attempts in an electric imp onunexpecteddisconnect handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server.onunexpecteddisconnect(function(err) { | |
setStatusLight(STATUS_DISCONNECTED); | |
server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, WIFI_TIMEOUT); | |
// this is also a good time to set up some reconnection attempts | |
imp.wakeup((60*RECONNECT_PERIOD), function() { | |
imp.wakeup((60*RECONNECT_PERIOD), this); | |
server.connect(function() { | |
setStatusLed(STATUS_CONNECTED); | |
rtc.sync(); | |
fetchSchedule(); | |
}, WIFI_TIMEOUT); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment