Agent behavior on Imp restart

I just wanted to mention something that I just noticed. I came home and my Christmas tree wasn’t on…its is powered by one my Imped switches, and checks the weather channel for sunset times, at which is switches itself on. The agent has a function that is called in the code, and then by imp.wakeup() when it needs to get new data. What happened was that the Imp restarted due to a WiFi error, but on that restart, the agent apparently didn’t get restarted as it had stopped checking the weather channel. Shouldn’t the agent get restarted when the Imp restarts, just like it does if I toggle power or Build and Run new code? Is this normal behavior? It is really nice to have the agent run its own functions, but it does need to be able to handle the WiFi outage.

Here is the Log:
(The log at 6:10 is me doing “Build and Run” from the IDE.

2013-12-13 00:00:45 UTC-5: [Agent] Switch off
2013-12-13 16:40:45 UTC-5: [Agent] Agent getting current conditions for 17601
2013-12-13 16:40:45 UTC-5: [Agent] Sending request to http://api.wunderground.com/api//astronomy/q/17601.json
2013-12-13 16:40:45 UTC-5: [Agent] Response returned with status 200
2013-12-13 16:40:45 UTC-5: [Agent] Sunrise: 7:18
2013-12-13 16:40:45 UTC-5: [Agent] Sunset: 16:40
2013-12-13 16:40:45 UTC-5: [Agent] Current time: 16:40
2013-12-13 16:40:45 UTC-5: [Agent] Minutes since zero hour: 1000
2013-12-13 16:40:45 UTC-5: [Agent] Sunset in Minutes: 1000
2013-12-13 16:40:45 UTC-5: [Agent] Sunrise in Minutes: 438
2013-12-13 16:40:45 UTC-5: [Agent] Switch on.
2013-12-13 16:40:45 UTC-5: [Agent] 440 minutes until 2400 hours.
2013-12-13 18:02:50 UTC-5: [Exit Code] imp restarted, reason: wifi error
2013-12-13 18:02:52 UTC-5: [Status] Device booting; 4.12% program storage used
2013-12-13 18:02:52 UTC-5: [Status] Device configured to be "Wall SwitchMe"
2013-12-13 18:10:51 UTC-5: [Agent] Weather Agent Running
2013-12-13 18:10:51 UTC-5: [Agent] Agent getting current conditions for 17601
2013-12-13 18:10:51 UTC-5: [Agent] Sending request to http://api.wunderground.com/api/
/astronomy/q/17601.json
2013-12-13 18:10:51 UTC-5: [Agent] Response returned with status 200
2013-12-13 18:10:51 UTC-5: [Agent] Sunrise: 7:18
2013-12-13 18:10:51 UTC-5: [Agent] Sunset: 16:40
2013-12-13 18:10:51 UTC-5: [Agent] Current time: 18:10
2013-12-13 18:10:51 UTC-5: [Agent] Minutes since zero hour: 1090
2013-12-13 18:10:51 UTC-5: [Agent] Sunset in Minutes: 1000
2013-12-13 18:10:51 UTC-5: [Agent] Sunrise in Minutes: 438
2013-12-13 18:10:51 UTC-5: [Agent] Switch on.
2013-12-13 18:10:51 UTC-5: [Status] Device booting; 4.12% program storage used
2013-12-13 18:10:52 UTC-5: [Agent] 350 minutes until 2400 hours.
2013-12-13 18:10:52 UTC-5: [Status] Device configured to be “Wall SwitchMe”

The agent can only ever be started by an imp booting; otherwise, the agent just continues to run - a booting imp does not reboot the agent, ever.

In this case, you should probably make the imp ask the agent whether it should be on or not at boot. We’re working on addressing wifi chip crashes (wifi error) in a seamless way in the next release.