Connectivity Watchdog

My fleet of BRN404X devices is steadily growing, and I periodically notice some of them drop offline even when they have good cellular signal then come back online after a while. There’s no consistent pattern, and it’s difficult to accurately diagnose the cause since the devices are distributed across the U.S.

I was thinking about adding a basic connectivity watchdog, something like this:

if (!Particle.connected() && (millis() - lastConnectAttempt > 300000)) {
    Particle.connect();
    lastConnectAttempt = millis();
}

Is there any benefit to doing this, or is similar functionality already incorporated into the Particle OS?

Separately, I’m tracking device uptime using systemUptime = System.uptime();, and I can confirm that the devices are not rebooting during these events.

That code won't do anything. It's always constantly retrying when disconnected.

After 10 minutes, the device should even power down the cellular modem to reset it. Make sure you are using Device OS 6.2.1 or later with the BRN404X because of TAN015 which has an important fix to the reset procedure.

The only way to debug the problem for sure is to enable USB debug logging and get the log from the device locally. Even the cellular strength report isn't necessarily going to help, because it's only sent when the connection is up, and if there was no connectivity, it would not be reported.

The one change that can be helpful is after 15 minutes or so of failing to connect, forcing the device to reboot. If the device has fragmented memory and cannot allocate enough memory to connect, the reboot will clear the heap. An out of memory handler can also help with this.

Hey @oraclerouter ,

there has been a mention about sleeping for 30 seconds that might help force a modem reset in those difficult cases:

Best,

Sleeping for 30 seconds is slightly better than just resetting, however on the Gen 3 (nRF52) devices, since hibernate sleep doesn't support wake on time, you'd instead need to go into stop mode sleep, then System.reset.

1 Like

Got it. Thanks guys for the insight!