Electron Connectivity

I have an application that is running on an Electron. Sometimes (most likely due to cell service interruptions), the Electron loses connectivity and my code experiences problems as I mistakenly assume data had been sent.

How can I check that Electron is connected before sending (Particle.connected().)? When the connection is lost, what happens to the rest of my code if I send anyway? Does checking connectivity before sending incur data costs etc …

Can the community direct me to a link on Electron connectivity issues?

Thanks in advance.

Update:
Particle.connected() on Electron apparently does not work. The code after if below does not execute.

if (Particle.connected())
{

}

It returns false even though I can reach The Electron through the cloud.

Is there a different way to check Electron connectivity status?

Which SYSTEM_MODE are you using? The default is AUTOMATIC.

Are you using SYSTEM_THREAD(ENABLED)? The default is not enabled.

If you are in AUTOMATIC with system thread not enabled (the default), your setup() and loop() code is not executed at all when you’re not cloud connected.

If you want your code to run whether connected or not, you should use:

SYSTEM_THREAD(ENABLED)

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

1 Like

Thank you @rickkas7.

I am using AUTOMATIC with system thread not enabled.

The problem I am having normally does not occur on startup, rather it occurs later most likely as a result of temporary cell interruption. Will SYSTEM_THREAD(ENABLED) help in this case?

Also, does Particle.connected() ever work in the case of the Electron? Is there a way to check connectivity because my code has to find out if the transmission was successful before it updates its variables. I do not need a CRC check or anything like that but just to check that the Electron is connected to the cloud prior to transmission.