Wifi outage wakereason()?

What is the hardware.wakereason() after:
[Exit Code] imp restarted, reason: Wifi outage

I can tell you it’s not the same as before the Wifi outage. Then it was WAKEREASON_POWER_ON.

I’d expect WAKEREASON_TIMER (or possibly WAKEREASON_PIN1 if that’s configured and occurs during the snooze).

If you want to distinguish outages from other wake reasons have a look at server.onunexpecteddisconnect().


I wish there was a unique WAKEREASON for my case. TIMER makes no sense as it implies it was sent to deepsleep. What are the possible "reason"s for your function above? Where are they listed? When I say reason I’m referring to the variable.

There’s a list on the wakereason() API page:


For the default SUSPEND_ON_ERROR policy, the imp snoozes (deep sleeps) for 9 minutes when there’s a wifi problem and so you currently get a TIMER wake reason when this period has elapsed.

A unique wake reason would be useful though. I’ll add your feature request to the ImpOS backlog.

Edit: sorry, thought you were asking about hardware.wakereason() here. See below for onunexpecteddisconnect()

There is no WAKEREASON related to Wifi outage. Are the onunexpecteddisconnect() reasons the same list as WAKEREASON (above)?

No, the reason passed to your onunexpecteddisconnect() handler is from the list on the server.connect page:


I’ll update the documentation to make this clearer.