Electron OTA can't break into an app with Tmobile SIM

I am using a TMobile SIM with an electron that I have here.
It appears that OTA updates are not working if there is already an application running on the Electron, and the only way that I can get it to receive the new code is by putting the Electron into “safe mode”, and then it will receive the OTA update.

However, using the Particle SIM that came with the device, OTA will work and stop the currently running app.

Is this a known limitation? Is there a workaround for this?
I would like to build the electron into a device where doing a safe-mode reset would not be convenient.

Ping @BDub

Have you set the keepAlive time? It almost certainly will need to be shorter than the default of 23 minutes, usually between 30 seconds and several minutes. One of the things that will fail to work if the keep-alive is too long is OTA flash.

https://docs.particle.io/faq/particle-devices/electron-3rdparty-sims/electron/#about-keep-alive

2 Likes

Your 3rd party SIM probably has a very short UDP NAT timeout that causes it to essentially be deaf to requests from the Particle server, and will require keep alive pings to be changed from the default 23 minutes to every 30 seconds.

https://docs.particle.io/reference/firmware/electron/#particle-keepalive-

void setup() {
  Particle.keepAlive(30);
}

EDIT: Rick, you just beat me! And I’m learning we have more info in the docs about this :slight_smile:

4 Likes

@BDub, does Safe Mode have a short keepAlive setting?

OP states not to have any problems with Safe Mode.
Maybe the OTA problem is rooted in the running code when not in Safe Mode.
@apullin, can you show your code?

Actually safe mode should have the same default keep alive, so I suspect it was just the act of resetting the device, putting in safe mode and trying an OTA again within that first 30-60 seconds of being connected that made it work.

This does raise an issue that 3rd party SIMs could be handled more effectively under all circumstances if we persisted the keep alive value in flash memory, such that it would honor that user modified keep alive during safe mode.

3 Likes

Alternatively going for minimum keep alive in Safe Mode (e.g. if user doesn’t set keep alive correctly)?

There is a properly set keep alive by default for Particle SIMs, but to impose a 30 second ping in Safe Mode unconditionally would be harmful to Particle SIM data usage (default is 23 minutes).

To be honest, I don’t think a user set ping in Safe Mode would be effective until the APN is recalled from flash memory for 3rd party SIMs. Without that, you won’t even have a data connection. There is a case where you connect using your user code settings for a 3rd party SIM, then reboot into safe mode and it connects like magic still. This is because the modem doesn’t get reset or powered off by default when the STM32 is reset via RESET button, or software reset (DFU mode, Safe Mode, etc…). But if you cold booted into Safe Mode with a 3rd party SIM, currently you could not make an initial data connection.

That doesn’t sound good.
Having Safe Mode behave differently depending on the previous state of the device (fresh/cold boot vs. reboot), may be confusing and hard to troubleshoot (one extra point to clarify first).
Maybe it’s time to finally get Cellular.setCredentials() implemented.

@ScruffR , I can’t show the code, it’s a super secret project :wink: (but if one of the Particle folks wanted to give me a walkthrough on how dynalib and the OTA bootloader works, then I’ll def walk over there and show them the prototype…)

But I can confirm that the keepAlive setting does make the OTA flash to work with the TMobile SIM.

1 Like