UPDATE:
It would appear that the reason why my keepAlive
pings weren't being sent out had to do with the way that I was calling Particle.keepAlive()
. I was calling it from a startup macro, which apparently wasn't actually setting the keepAlive
time. Moving the keepAlive()
call to setup()
resulted in my the pings being sent out correctly. So, in short, it turns out that my problem didn't have anything to do with Particle.process()
calls.
Original post:
Me and @SCM are wondering what role Particle.process() plays when operating an Electron with the following configuration:
SYSTEM_THREAD(ENABLED)
and SYSTEM_MODE(AUTOMATIC)
I am using a 3rd party SIM card and it would appear that the keepAlive
ping is not happening. The symptom that leads me to believe this is the case is that my code attempts to publish an event to the cloud after running for about 15 minutes. About 75 seconds after my code calls Particle.publish()
, the Electron starts rapid cyan blinking indicating it is re-establishing a connection to the cloud. If i then force the Electron to try and publish again once it has reconnected, it works.
I know that the keepAlive
time for my carrier is 180 seconds, and have conservatively configured my code to use a keepAlive
of 100 seconds as per:
void startupMacroCode(){
cellular_credentials_set("znet", "", "", NULL); //Zantel, Tanzania
Particle.keepAlive(100); //Set the keepALive for pinging cell tower to maintain our IP address (test results show keepAlive of 117 seconds for Zantel)
}
STARTUP(startupMacroCode());
I know this keepAlive
time is correct because I have tested it both through toggling LEDs periodically (increasing period) using a modified version of Tinker, and by running a test program I made that configures the keepalive
time to be an hour, then publishes to the particle cloud with decreasing frequency until a publish doesn't work (i.e. waits 10 seconds then publishes, then waits 20 seconds then publishes, etc etc).
At the moment, I do not have any calls to Particle.process()
in my code, because the write-ups in the reference documentation seem to indicate that I shouldn't need it...
Particle.process() and delay() are not needed to keep the background tasks active - they run independently. These functions have a new role in keeping the application events serviced. Application events are:
- cloud function calls
- cloud events
- system events
It would seem to me that the keepAlive
doesn't fall into any of these categories, though I must admit that I don't quite understand what is meant by the statement "Application events are system events".
On the other hand the reference documentation says the following about Particle.process()
:
Particle.process() checks the Wi-Fi module for incoming messages from the Cloud, and processes any messages that have come in. It also sends keep-alive pings to the Cloud, so if it's not called frequently, the connection to the Cloud may be lost.
So what's the verdict? What exactly is Particle.process() actually doing when system threading is enabled?