Sorry for the newb question. I’ve misplaced my photon where I’d normally test this stuff before loading it to an electron.
I’d like to do an app watchdog around a small part of my loop (or what should be a small part of it) but then still sleep for a while. It really comes down to whether or not the ApplicationWachdog gets called every loop and then checkin disables it until called again or if the ApplicationWatchdog sets up a watchdog forever and ever that must get a checkin forever and ever.
Trying to ask this the simplest way possible w/o posting a bunch of pseudocode. I’d basically like to have a watchdog timer just for a little section of my code and then disable it so I can go to sleep for much longer than the timer. Is that possible?
Thanks.
No one answered! No worries…I finally found my photon and was able to run some tests to figure out what I can do w/the watchdog so I figured I’d post it in case anyone needs this later.
The watchdog does expect its checkin to be called every TimeOut milliseconds. So it’s not once and done. Having the loop end and restart counts as well, as does having the firmware call Particle.process() which it does nicely on its own behind your back, just don’t count on it.
Looking at the source though, you can call the dispose() function on the watchdog object and that will set its timeout to 0, essentially disabling it. As the name dispose() implies, once you do this you can never reuse that object later in that same run of the loop. If you want a watchdog somewhere else below, you need to create a new watchdog object. I’m not sure I see a use case to stop and start a watchdog, but maybe. If I can think of a good use case, then I’d like to see that function renamed to disable() and then another one called enable() that would just put the timeout variable back to the original value. Trivial to code that, so maybe I’ll try to figure out how to make that contribution (if that’s allowed) after my project is done and my time frees up a bit.
@gritnix, the ApplicationWatchdog is implemented using a seperate, high-priority thread in FreeRTOS running on the Photon. Though it provides an excellent watchdog implementation, it is nonetheless susceptible to a total CPU freeze and thus is not a 100% as reliable like an external hardware watchdog timer. As you mentioned, a watchdog is not typically disabled once its started so not sure what use case would need that.