Outdated Session Data

electron
Tags: #<Tag:0x00007f1ca123d8a8>

#1

I’m having an issue where after some time (seems to be randomly between few minutes to hours) my Electron loses cell connectivity, and does not reconnect. I’m a bit at a loss on where to begin debugging this issue, let alone to know what code to share with you all.


#2

Here are some basic questions:

  1. What SYSTEM_MODE are you running? and is SYSTEM_THREAD enabled?
  2. Are you using delay() in your code at all?
  3. What code are you using to control cloud connectivity (if any) and what kind of safeguards have you implemented to prevent cloud operations when the connection drops?

Usually, you want to post your full code or if using WebIDE you can do a “Share this revision” and post the link here. If too large, you can post the relevant code that covers the questions above.


#3

Thanks @ninjatill. My code is quite large, but here’s what I think are the relevant answers and snippets.

SYSTEM_MODE(MANUAL);
SYSTEM_THREAD(ENABLED);
  1. No delay()'s

void setup()
{
    Particle.connect();
}

void loop()
{
    Particle.process();
}

I’m actually using Azure for cloud connectivity, but I connect to particle for SW updates. This all started because I’m dropping my MQTT connection to Azure, but I’m finding that it seems to be due to losing all cellular connectivity. All of my attempts to communicate via any cloud connection are wrapped:

if( Particle.connected() )
{
  // do some stuff
}

Since I’m using MANUAL mode, do I need to call Particle.connect() if Particle.connected() ever returns false?


#4

If setup() is the only time you are calling Particle.connect(), then I would probably switch to SYSTEM_MODE(SEMI_AUTOMATIC). Semi-automatic will handle any reconnection attempts automatically. You still call Particle.connect() in setup() like you already are.

Unless there’s a lot more to your loop(), Particle.process(); is not necessary as it automatically gets called in between iterations of loop(). You would typically call Particle.process() inside of long running loop structures or wait points in your code.


#5

Thanks @ninjatill I will try updating the SYSTEM_MODE as you suggested. Agreed on the calls to Particle.process(), I only added that recently while trying to debug this issue.

Even if this allows me to reconnect automatically, any thoughts on how I can determine why I’m losing connection in the first place? I realize the connection isn’t guaranteed, but when I lose connection, I’m not moving or changing the antenna or anything, and my signal strength and everything look good leading up to the loss of connection. I’m suspicious something else is still going on here.


#6

When running with SYSTEM_THREAD(ENABLED) both SYSTEM_MODE(MANUAL) and SYSTEM_MODE(SEMI_AUTOMATIC) are identical. No need to call Particle.process() for manual mode when threading.

Likewise, they only affect default startup state. Once Particle.connect() is called they are also equivalent to SYSTEM_MODE(AUTOMATIC).


#7

What Sim card, Particle or 3rd party? Do you have decent signal strength? You could take and log rssi readings beyond just using the diagnostics view on the console.


#8

Currently using the Particle SIM card.

I added RSSI and some other debug info - will see if that leads to anything.


#9

Another thought, you can flash @rickkas7’s electron cloud debug code for better diagnostics of why the cloud is dropping:


#10

I seem to have fixed the problem. I am connecting to both the Particle cloud (for OTA) and to Azure (for my project). I haven’t bothered to try to debug the root cause, but it seems these two connections don’t play nice together.