Firmware update sequence

I was wondering, what is the update sequence once the Imp figures out there is a firmware update to apply? I mean if I keep it in deep sleep mode for a long time (I know the maximum is 24 hours right now), when it wakes up does it run my code first or does it do a firmware update (then reboot??) then run the code?

The code I’m running is very time critical (it’s an alarm), so I need it to run when the module wakes up, then it can go ahead and apply whatever firmware update it needs to apply and go back to sleep (I’m already using the new onidle handler to only make it sleep when it’s done with everything).

Right now we jump through some hoops; if a firmware update is pending the imp is sent a blank firmware which when configured then accepts the firmware update message. After the update your code will run again.

Previously we’d only do the update when you processed messages, so anything you did before falling off the main code would always be run - the problem was, people would call server.sleepfor from main and never get updates.

In the long run we’ll allow code to register a handler that will get called when a firmware update notification is received to give it a chance to tidy up before the update happens.