HIBERNATE: Determining initial startup vs wake from hibernate

If I understand correctly, when the Boron is woken up from a Hibernate state, it goes through setup() just as if the Boron was powered up from scratch.

Is this correct and if so, how can I tell that it's just been woken up (and needs to send a status message) vs. being initially powered on (and doesn't need to send anything)?

Thanks.

That is correct.

You can use System.resetReason() to find out. If the wake is from HIBERNATE sleep, the reason will be RESET_REASON_POWER_MANAGEMENT.

Thank you. I also came across

System.sleepResult();

Do you know which is more reliable? And is there something I need to enable similar to what I would need for System.resetReason()?

System.enableFeature(FEATURE_RESET_INFO)

Thanks again.

System.sleepResult() does return whether it was by pin, time, etc. so that might be better.

You shouldn't need to add a feature flag for that to work.

Just one note to anyone using the Boron as I am (where it is only "awake" for a very limited amount of time): Remember to make provisions for allowing OTA updates (or even OTA program changes while debugging your code). It has to be awake (not hibernated) long enough for you to send updates.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.