Skip to content

Instantly share code, notes, and snippets.

@ersatzavian
Created December 21, 2013 00:04
Show Gist options
  • Save ersatzavian/8063585 to your computer and use it in GitHub Desktop.
Save ersatzavian/8063585 to your computer and use it in GitHub Desktop.
Setting up reconnect attempts in an electric imp onunexpecteddisconnect handler
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