IMP program flow/state diagram

I’ve seen the odd post about program flow.
Attached is an updated a flow/state diagram I did when first encounter the imp.
It might help others new to the platform.

Please note: this is how I think things go! please comment & correct.
I know there is no Main() function but it’s implied.
Also added the forthcoming WIFI power save mode.

That’s actually pretty good. (I might not have bothered drawing “wifi power save” and “shallow sleep” as two distinct states – they’re more like one state that has two alternatives for how power-hungry it is.)

In the future things may get more complex (more gradations of depth of sleep) but for now that’s a very good guide, thankyou!

Peter

Oh! except that of course you can’t get into Deep Sleep from main() by EOC. It has to be server.sleepXX.

Peter

Peter, Shallow Sleep – power save for me it is a distinct state as there is no coms to the cloud. Perhaps I should call it Shallow Sleep “Programmatically Offline”.

Have removed EOC for Deep Sleep.

This is great ! It would help commissioning if it included the blink codes.

Well… actually… most of the blink codes would be in the boot state.

Ah, but you do get comms to the cloud in wifi power save mode. (Just with worse receive latency, as the imp checks less often for incoming packets.) What you’re describing is wifi off mode, which is also coming, but not so soon. That one will indeed be worth its own blob in your picture.

Peter

Peter, thanks for the heads up on the off!

ivoknutsel, I’ll do a separate one for blink codes.
But even having imps for a few months I still get confused by “the blinks”.
May be an age thing!!

very useful.
makes even more clear that main() is not really mail, but way more like an init() and all the actual code in event handlers

might want to chance the Sate diagram :slight_smile:

An updated state-diagram for release 25 is now at http://devwiki.electricimp.com/doku.php?id=impwificontrol

Thanks to controlCloud for the inspiration!

Peter

Very nice! Thanks, I was looking for something like this.

Peter this is top notch and snoozing is a great state for man & machine a like. Would be good to see the wiki and e.imp forum posts reference the states and replacing the likes of shallow sleep.

Lawrence

Ah, shallow sleep (imp.wakeup) isn’t really shown on that diagram: it can occur in any of the ACTIVE states, and doesn’t itself change the state. That made depicting it a bit awkward.

Peter