Hi all,
I noticed this morning that my Electron was stuck for almost 2 hours blinking cyan quickly but not actually connecting to the cloud. That was a huge battery drain and I’m trying to write a code to put it to sleep for 10 minutes if it can’t establish a connection after 5 minutes (it’s currently in AUTOMATIC mode):
if (!waitFor(Cellular.ready, 300000)) {
System.sleep(600000, SLEEP_NETWORK_STANDBY);
}
Here’s my question: Where exactly should I put this code? If I put it in void setup(), will it actually execute this code as it’s flashing cyan and trying to connect to the cloud? At what point does the Electron actually start to execute code in void setup()? Is it only after it establishes a connection to the cloud? If so, how can I get the Electron to sleep if it’s stuck unable to connect to the cloud?
Thanks!