Xenon does not recover from stop mode with SYSTEM_THREAD(ENABLED)

Hello,

Since stop mode is now supported for mesh devices with DeviceOS 0.9.0, I fixed my application for Xenon (that sends out some messages every minute) to use it by replacing delay(60000) with like System.sleep(D1, RISING, 60). However, I experienced Xenon behaves almost randomly after waking up and eventually gets stuck with the status LED flashing (sometimes green, sometimes cyan).

As I figured out so far, it seems not working with SYSTEM_THREAD(ENABLED). When I removed SYSTEM_THREAD(ENABLED) just for testing, it started to work as expected.

Now my question is: Am I correct to assume it does not work with SYSTEM_THREAD(ENABLED)? If yes, is it a known issue that will be resolved in the future? Is there any known workaround?

Thanks!

UPDATE: Issue resolved by adding waitUntil() after System.sleep(). It ensures the communication systems ready before sending the next message after waking up from the stop mode.

1 Like

A counter question would be: What are you doing after you wake?
Since your code starts running without time for preparation of any radio communication you might see some “race condition”.
Try adding some delay (e.g. waitUntil(Mesh.ready) and/or waitUntil(Particle.connected)) after the System.sleep() statement and see whether that changes anything.

3 Likes

Thank you for your suggestion! Yes, my code calls Mesh.publish/Particle.publish after waking up. I will add waitUntil() as well as I am doing in setup() and try again.

@ScruffR It worked, thanks! Adding waitUntil() after System.sleep(), it is now working as expected most of the time.

At rare occasions, I encountered the system going through the full reset with a message “spark/device/last_reset: pamic, assert_failed”, which I suspect the system failed to go into stop mode gracefully due to some race conditions, but it is a minor issue to me.

1 Like