Watchdog question

I am trying to implement a basic software-based watchdog based on Particle’s Application watchdog.

In order to test it very simply I uploaded the following code to a Photon:

ApplicationWatchdog wd(30000, System.reset);   //(Automatic reset after 30 seconds of inactivity)

long uptime;


void setup() {
    Particle.variable("Up-time", uptime);
}

void loop() {
    //wd.checkin();
    uptime = (millis() / 60000);
}

Since the wd.checkin() is commented out, I was expecting the watchdog to kick in and reset the Photon every 30 seconds. However, the Photon keeps in counting up happily the minutes it is running.

What am I missing here?

wd.checking() is implicitly called whenever you drop out of loop() (or Particle.process() is called - even implicitly by delay()).

Since you are not in sole control of it the Application Watchdog it isn’t that useful IMO.

However, it will trigger when you trap your code flow in a tight loop.

@ScruffR, thanks. I thought that wd.checkin() has to be called implicitly somwhere in loop(). I made another test by deliberately initiating a long delay() function through a Particle.function which then successfully triggers the reset by the watchdog.