SMS to Electron without internet connection

Have been tasked to set a new APN in EEPROM via SMS while the current APN is wrong (3rd party SIM).

I can receive an SMS and store it’s APN to EEPROM when the device is online.

Particle.connect or cellular.connect seems to keep re-connecting (unsuccessfully) even in MANUAL mode. So I don’t see an option to get the Electron on the GSM network, accepting having a rejected APN and just wait there, for an SMS with a working APN?

Is there a trick to achieve this?

Have you incorporated SYSTEM_THREAD(ENABLED) and a non-AUTOMATIC system mode to ensure your code will run independent of an active cloud connection?

Yes, so I have code running in parallel to look for SMS’s and the modem receives SMS’s. But the modem communication is constantly busy with reconnecting to allow my application to fetch SMS’s.

Maybe this is one of those situations where you need to use a retained variable or similar to store the fact that the APN failed to connect and then reboot the device. When you come up in manual mode, you check the retained variable to see if you should call Particle.connect or Cellular.connect at all or just sit and wait for the SMS with the new APN.

Ah yes. I can then check for already received SMS’s. And if there are none, I run the registration proces (CREG) manually to receive any … thanks!

Is there a “smart” way of knowing that the APN failed, or would that be via timeout?

I don't know of a smart way but perhaps someone else can come up with something.

1 Like

Cellular.on() seems to be what i am after to get the device registered on the network, and not try to get a data pdp context right away.

Then check for existing SMS and save any APN then reboot the system to use that. If there are no existing SMS, then do a cellular.connect for two minutes. If not connected after that, do a system reboot to stop reconnection attempts and wait in cellular.on() for sms.

The reboot seems to be necessary as cellular.disconnect() is not easy to do reliably - the modem can end in a limbo continuing to fire commands to register on the network.

I guess repeatedly trying to connecting with the wrong APN should not cost any data fee’s.