Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
System.sleep() fails with small values of seconds #1043
With the addition of calls to
Here's some demo code (I used 0.5.1 local build to compile) to reproduce this issue, and what I see from my terminal with an Electron running 0.5.1 firmware before it goes to sleep and doesn't wake up. I'm only using Deep Sleep in my application so I haven't tested behavior with other sleep modes.
An easy fix might be to make the
It looks like this was updated to be "Particle confirmed" a few days ago, though I would have appreciated even a brief followup message so I could get a notification that someone was looking into this.
I've been doing some more research on the issue as my workarounds of setting a minimum value for
Looking through the
I setup two test Electrons to connect to the cloud, and record the time elapsed to call each
After letting both run overnight, the time it takes to call
Hopefully you can see this is undesirable behavior in two ways: it gives the user less control over battery usage if their Electron may stay awake an extra >3 minutes after telling it to sleep, and it may sleep indefinitely if they tell it to sleep for a "small" number of seconds (currently 192 seconds).
My current workaround in my application is to manually call
Here's the code I used for the test. You can change the
@embedded-creations Thanks for additional info!
I'm currently looking into this and another System.sleep issue (#1029).
Great! Let me know if you need any more tests run. I seem to be in an area with not the best coverage. I had an electron enter listening mode last night, and another couldn't make a connection in under 90 seconds after many hours of trying last night.
My workaround doesn't work: even after calling
My other workaround which I've been testing in parallel is to set a flag in retained memory, reset the Electron, call
I updated the Gist. The code with Line 56 enabled is what I used to measure the max of 211 seconds.