Electron: Cellular Connection Management

I am building a simple device that controls some lights and switches; but nothing that needs rigid timing. The main loop can take between 5-60 seconds.

In AUTOMATIC mode I have noticed that when my Electron loses cellular connection (it’s spotty around here), it will stop processing the application code and attempt to constantly connect. This is no good, because it means my device is useless when the connection dies.

It also looks like after a while it drops into Cellular Module Not Connected, but then reboots, and hangs on the connection attempt.

I read through the docs, but from there it looks like it’s only supposed to take a few seconds to attempt a connection, and if that fails it should return to my code.

Ideally, if there was cellular connection everything would run fine. If cellular connection drops, the device would wait until my loop finished, then attempt a connection for up to X seconds. With no connection, it would go back to my loop. Repeat.

I think I can make that work in semi-automatic mode, but I am not sure if connecting to the cell network is part of the automatic/semi-automatic mode. Also, I don’t see a way to set the cellular connect timeout.

Any suggestions (or another thread where this has been answered? I could not find it)

Lastly, while I am here, is there any way to web function calls to the device to queue up when not delivered? Or will they always be rejected and tossed if not passed on?

It looks as though you're trying to run code while there is no internet, for which there are countless topics already.
System modes are one way to deal with this, system threading another.

With system modes, you can take full control over the connection process, and determine when, when not, and for how long it should (try to) connect. You can use the WaitFor() functions to time-out a connection attempt.

Not sure where you got that from, since cellular connections can take quite a bit of time (~60s isn't unheard of for example), depending on network availability and general situation.

At the moment, queuing of API calls is not implemented. Something like that can be created with the new Rules engine for which you can apply.

Thank you for the info. I’ll check out WaitFor() and system threading.

Also… I suspect there is a difference between a cellular connection and a cloud connection; I think the getting started guide said the cloud connection should only take about 8 seconds max- but I suspect that is after the cellular connection is handled.

Thanks again.

1 Like

Thank you… I enabled the system thread, and that worked. The connection now runs concurrent with the loop() operation. Which honestly, saves the life of this device.

However, it DID NOT work when using the Cloud IDE and flashing. After I used the windows client and compiled in the cloud and then flashed via USB, it worked. Not sure why that would be.

Somewhat frustrating. But I really appreciate your help.