I have a number of devices in the field that seem to lose connectivity and stay disconnected until they get reset. As such, I would like to implement a watchdog timer that basically checks if the device has been connected in the last hour and, if not, reboots the device.
The problem that I’m running into is that when I implement this on the Argon, it seems to reboot every 60 - 90 seconds, and I’m not sure why. IT seems to work just fine on the Boron.
Relevant code below.
//Declare WatchDog
ApplicationWatchdog *wd;
bool hasSetKeepAlive = false; // set whether the KeepAlive is still running for particle.Keepalive workaround
/
void setup() {
wd = new ApplicationWatchdog(3600000, System.reset(RESET_NO_WAIT), 1536);
// initialize methods
Serial.println("Initializing objects");
RegisterList::initialize();
CloudFunctions::initialize();
g_status = "booting";
g_meterPtr = &meter;
meter.enableTXpin(D7);
meter.begin(BAUD_RATE);
// connect particle to cloud
Serial.println("connect to the cloud");
Particle.keepAlive(CELL_KEEP_ALIVE);
Particle.connect();
// setup serial connection for local debugging
Serial.println("Begin delay");
// wait until connection is open
while(!Particle.connected()) {
delay(100);
}
void loop() {
// sync clock with the cloud (once per day)
if (millis() - lastSync > ONE_DAY_MILLIS) {
Particle.syncTime();
lastSync = millis();
}
// set system clock cloud variable
g_systemTime = Time.format(Time.now(),"%F %T");
if (Particle.connected()){
wd -> checkin();
}
}