Using Network.isOff() to check if the cellular modem is turned off, does not seem to work here. Am I using it correctly?
Function Sleep2_state always takes 60 seconds matching the timeout set. Power consumption show the modem is in fact off [while sleeping].
...
void SLEEPstate() { // Go to sleep, 0. Disconnect Particle Cloud
if (mainState != lastState) {
stateTime = millis();
if (firmwareUpdateBegin) {mainState = SWUPDT; return;}
Particle.disconnect(CloudDisconnectOptions().graceful(true).timeout(5000));
lastState = mainState;
}
if (Particle.disconnected() || ((millis() - stateTime) >= 5000)) mainState = SLEEP1;
}
void SLEEP1state() { // Go to sleep, 1. Disconnect network
if (mainState != lastState) {
stateTime = millis();
Network.disconnect();
lastState = mainState;
}
if (!Network.ready() || ((millis() - stateTime) >= 5000)) mainState = SLEEP2;
}
void SLEEP2state() { // Go to sleep, 2. Turn network off (cellular or wifi), then sleep.
if (mainState != lastState) {
stateTime = millis();
Network.off();
lastState = mainState;
}
if (Network.isOff() || ((millis() - stateTime) >= 60000)){
devLog("ZZZzzz");
SystemSleepConfiguration config;
config.mode(SystemSleepMode::ULTRA_LOW_POWER)
.duration(14min);
System.sleep(config);
// Sleeping then continue from here
mainState = CONNCT;
}
}
...
OS 4.0.2 and modem is B523