Returns a constant indicating the reason why the imp was woken
Integer — a Wake-up Code
This method tells you what event caused the imp to wake up. The integer code it returns will be one of the following constants. You should note that not all of these constants are valid for a given type of imp.
|WAKEREASON_POWER_ON||0||Powered on (cold boot)|
|WAKEREASON_TIMER||1||Woken after sleep time expired|
|WAKEREASON_SW_RESET||2||Restarted due to a software reset (eg. with imp.reset()) or an out-of-memory error occurred|
|WAKEREASON_PIN||3||Woken by wakeup pin going high|
|WAKEREASON_NEW_SQUIRREL||4||Restarted due to new Squirrel code being loaded|
|WAKEREASON_SQUIRREL_ERROR||5||Restarted due to a Squirrel run-time error|
|WAKEREASON_NEW_FIRMWARE||6||Restarted due to a firmware upgrade|
|WAKEREASON_SNOOZE||7||Woken from a snooze-and-retry event|
|WAKEREASON_HW_RESET||8||Restarted by RESET_L pin (imp003 and above only)|
|WAKEREASON_BLINKUP||9||Restarted following a reconfiguration by BlinkUp|
|WAKEREASON_SW_RESTART||10||Restarted by server.restart()|
|WAKEREASON_POWER_RESTORED||11||VBAT powered during a cold start|
The values assigned to the constants may change in a future impOS release.
Power cellular radio brownouts at start-up are currently reported as reason 11.
This method is not available on the imp005 and is not expected to be added.
A simple function which uses hardware.wakereason() to display the reason why an imp restarted.