Electron Semi-Automatic mode good advise

Hi

Using a couple of Electron in area where cellular tower is not reliably all the time I need to use the Semi-Automatic mode to be able to show value on the LCD without connected to cellular tower.

My question is:

1- When using Semi Automatic mode, for publishing, I need to call the Particle.connect() before Particle.publish( … ? During this time, the code is stopped and wait cellular signals ? (waiting to connect maybe long)

2- Do I need to disconnect after the Particle.publish( … ?

I just one to be sure about this way and the standard when it uses.

Thanks

ref. https://docs.particle.io/support/troubleshooting/mode-switching/electron/#semi-automatic-mode

Yes, Particle.connect() should be called and have succeeded before you can publish.
But normally you’d check if (Particle.connected()) before you try to publish and if that check fails take apropriate measures depending on your use-case.

That depends on your use case.

In addition I’d go with SYSTEM_THREAD(ENABLED) to keep your code running in case of a connection loss. SYSTEM_MODE(SEMI_AUTOMATIC) will behave the same way as SYSTEM_MODE(AUTOMATIC) once the connection was established - even when connection is lost.

My use case is very simple : Display data on an LCD while if connected or not connected + send data to Particle.publish every ~5 minutes.

Ok, so using SYSTEM_THREAD(ENABLED) will run my code even connected or not connected. Also, with SYSTEM_MODE(SEMI_AUTOMATIC), when ready for Particle.publish, I’ll call Particle.connect(), validate the state and send data if connected to the cloud. If I lost the connection, I’ll always test again before send data.

Look straight forward for solution.

I’ll test it thanks

2 Likes