Offline mode

I couldn’t really find exact information how the imp supposed to work when it looses the internet connection. For example the wifi router turns off or the the internet provider has a blackout.
My imp seems to turn off after a minute when it looses wifi and it doesn’t seem to try go back online when wifi is back.

Could anyone help me find the information how I can make sure my imp runs it’s program even when the internet has a blackout?

thanks a lot

Miklos

Have a look here: http://www.electricimp.com/docs/resources/wifistatediagram/

With default settings, the imp will attempt to connect for a minute, then sleep for 9 minutes and try again for a minute - forever. If you waited longer, it would have come back again.

If this doesn’t fit your needs, you should read the docs referenced above and write your own connection policy.

thanks Hugo. this helps a lot.

I am using:

server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, 30);

in my Device code coupled with

server.onunexpecteddisconnect(server_out);

The callback function is:

function server_out(reason) { if (reason == NO_WIFI || reason == NO_SERVER || reason == NO_IP_ADDRESS) disconnected_flag = true; if (reason == SERVER_CONNECTED) disconnected_flag = false; }

The second line is there because I elsewhere attempt to reconnect every 30 mins, and a successful reconnection should call this function too.

I don’t think you can share server_out between callbacks like that; the reason codes for different callbacks are likely to overlap (you can print their numeric values to check, but generally this is pretty likely)…