Electron sample code functionality

Hi,

I saw the @rickkas7 Electron Sample code but I have a question about how it really works.

If the device starts with no cloud connection, 2 minutes after Particle.connect() is executed, the device is automatically restarted (I think it’s internally restarted). This produces that CLOUD_WAIT_FOR_REBOOT timeout (3min) is never reached, so connectionEventData.numFailureReboots is never increased. This leads to never sending the command AT+CFUN=16 to the module. If the no cloud connection is produced due some module internal error, the 3G module is not restarted, and it’s never restored.

I haven’t tested it, It’s an hypothetical situation, but I think that is possible. Am I right? Is anything there that I’m missing?

Thank you

What is your concern/problem you would like to tackle?

The main problem here is that I don’t understand why it works like this.

My first thought would be to send the command AT+CFUN=16 to the 3G module if it doesn’t connect after some resets. But in the code, due to the internal reset, smartReboot (at line 191) is never executed, and the command is never sent.

A possible solution to change this behaviour is to decrease CLOUD_WAIT_FOR_REBOOT time, but I’m probably missing something (I’ve been using this platform just for few weeks).

Thank you

Maybe the README does explain what is going on? https://github.com/rickkas7/electronsample#connection-debugging

The README doesn’t cover this case.

If it takes too long to make a connection to the cloud the code will attempt a reset. The connection event log will indicate whether it was able to make a cellular connection or not.

It doesn’t say anything about reseting the modem.

If there is cellular but not cloud, it will also do some additional tests. It currently will ping the Google DNS (8.8.8.8) and also the Particle API server (api.particle.io, which also tests DNS). These results are included in the connection event log.

This case only covers the no-cloud connection (but 3G connection).

It also has listening mode detection, and will reset the Electron if the Electron somehow ends up in listening mode, blinking dark blue, for more than 30 seconds.

The listening mode isn’t a problem here.

The “Smart Reboot” section explain somehow this point, but it doesn’t seem to match with the actual functionality:

Also, because it’s more efficient to leave the modem up on a reset, this code tries to do that first, and if that fails, then resets the modem. It also does certain checks first, so if the modem is really acting strangely, it will immediately do a modem reset.

UPDATE:

I think there might be other errors (or outdated functionalities) in the code. Particle.keepAlive function is executed before Particle.connect. @rickkas7 himself says in it’s own post that should be executed after it.

Is the example code still reliable?
Thank you