I’m looking for a robust code to reset the Electron like a cold reset (unplug battery).
Sometime happens that the Electron stop working and I would like to reset it because it’s not easy to go there and physically reset it.
At this moment my software is quite good but I am not using SYSTEM_THREAD and my actual watchdog just perform a system.reset, but I’ve read that the system reset didn’t reset the modem, and most of time I’ve found that connection is the problem.
Is it a good idea to:
- add the SYSTEM_THREAD(ENABLED);
- add ApplicationWatchdog wd(300000, watchdogCallback);
void watchdogCallback() {
Particle.disconnect();
Cellular.command(30000, "AT+CFUN=16\r\n"); // credit here https://github.com/rickkas7/electronsample/blob/master/electronsample.cpp
Cellular.off();
delay(1000);
System.reset();
}
I would keep the automatic mode in the main loop, and it will looks like this:
void loop() {
// every 5 seconds collect data
// after 60 seconds publish data to the cloud
if(Particle.connected()) {
// publish then sleep - reset at the end
System.sleep(SLEEP_MODE_DEEP, _seconds, SLEEP_NETWORK_STANDBY);
} else {
**while(1);**
}
wd.checkin();
}
I have few timers and every 5 seconds it collect data, after 60 seconds it check if is h:00 / h:15 / h:30 / h/45 and it publish to the cloud.
Does it make sense? Any idea to make it simple??