Hi 
I use the following code:
void smartReboot(){
Particle.disconnect();
Cellular.command(30000, "AT+CFUN=16\r\n");
Cellular.off();
delay(1000);
System.reset();
}
when I want to call this void now which one is correct:
ApplicationWatchdog wd(940000, smartReboot ,1536);
or
ApplicationWatchdog wd(940000, smartReboot() ,1536);
or
ApplicationWatchdog wd(940000, smartReboot(); ,1536);
Thank you!
You should not do that, it will almost certainly fail.
When the watchdog triggers the system is in an unstable state, so calling Particle.disconnect and Cellular.command will only make it worse. You should only call System.reset().
You could set a retained variable in the watchdog function, and check that on reboot, then do your cellular restart there and reboot again instead.
But the first call is the correct one.
3 Likes
Ok
, does AT+CFUN=16 also reset my code?
AT+CFUN=16 requires Cellular.command, which you should not call.
Only call System.reset() from the watchog callback. You can do a AT+CFUN=16 + System.reset() or call System.sleep(SLEEP_MODE_DEEP, 30) on the second reboot.
3 Likes