Will imp run code (model) when it loses a wifi connection?

I have been doing some testing to see what happens when I lose a wifi connection. I turned on one of the pins on the imp which should have turned off in 60 seconds. I then unplugged my imp before the 60 seconds and the pin never turned off.

Does the code on the imp keep processing or does it die when the wifi connection is lost?

Also, once I plugged the wifi back in I had to recycle the power on the imp to get it to communicate back to the agent.

Is this expected behavior?

Can the imp run its model code even if it loses wifi connectivity?

Thanks!

You need to set the connection policy, and deal with wifi loss events.

See http://devwiki.electricimp.com/doku.php?id=electricimpapi:server:setsendtimeoutpolicy

The default policy is suspend on error, which means when wifi goes away and you try and do anything with the network (eg: a server.log) then it will block waiting for wifi to return, suspending for 9 minutes if it fails to connect in a minute.

If you change the policy to RETURN_ON_ERROR then instead the server.log (and other network commands) will just immediately return an error code, and your code will continue to run. You can install handlers to deal with unexpected disconnects, see http://devwiki.electricimp.com/doku.php?id=electricimpapi:server:onunexpecteddisconnect

Oh fantastic! Thanks Hugo.