I had a problem recently with a pause/unpause cycle on an Electron, which couldn’t be resolved without manual intervention at a very remote site. I’ve reworked my code so that it will reconnect after a paused SIM. And I thought I’d share what I found, as I didn’t find this info anywhere else.
A remote electron used more data than usual in February, and went over it’s data limit. I’m still not sure why it’s data usage was high. The SIM was paused, and shortly after I unpaused it and increased it’s data cap so that it could go about it’s business. It never did reconnect until I got out to it 10 days later and put it into Safe Mode. It took approximately 5 minutes to reconnect, which surprised me.
So I did some testing, and found that if the electron had gone to sleep using SLEEP_MODE_DEEP and SLEEP_NETWORK_STANDBY, it took between 325 and 340 seconds to wake and reconnect the first time after a SIM unpause. (It only took 1-3 seconds in this condition to connect if the SIM was already active).
If the electron was in SLEEP_MODE_DEEP, it would reconnect after the SIM unpause after about 16-18 seconds.
So I have now added a different sleep statement if my electron times out before Particle.connected that will put the electron in SLEEP_MODE_DEEP (without SLEEP_NETWORK_STANDBY), which will better tolerate reconnection after unpausing SIM card.
I have been using SLEEP_NETWORK_STANDBY and a 20 minute publish cycle to keep my cellular data use low, and my code initially waits up to 120 seconds for Particle.connect, and goes to sleep if it doesn’t connect. This is to prevent depleting the battery in case of a network outage like we had earlier this year that knocked out a number of electrons.
Since I used the same sleep statement for any time my electron would sleep, it always went to sleep with SLEEP_NETWORK_STANDBY, and therefore wouldn’t connect.
I didn’t expect that there was any mode that would take that long to reconnect, or that there would be such a drastic increase in connection time between SLEEP_MODE_DEEP with and without SLEEP_NETWORK_STANDBY.