My internet is my cell phone at my house so if I receive a phone call the internet goes down but the wifi stays up. I have a device using a Photon that I need to continue working with or without the internet up. I have set up system mode semiautomatic and threads enabled but I need a way to set up a timer to have the particle connect disable after a period of time when the internet is down and occasionally try to reconnect. I have read similar threads on this but haven’t found anything that would work. Any help would be greatly appreciated.
I’d just let it do it automatically. In SYSTEM_THREAD(ENABLED) with SYSTEM_MODE(SEMI_AUTOMATIC) your code will continue to run when the Internet is down. And it will automatically reconnect by itself.
The only caveat is that your should check Particle.connected() before doing a Particle.publish(). If you don’t, Particle.publish will block trying to reconnect to the cloud and your code will stop until it times out.
There are a few other less common cases that can cause problems, but that’s the most common.
This is the approach I use! Works great!
Thanks @rickkas7. I seem to have misunderstood another thread that says it is blocking. Particle.connect() blocking main loop permanently, even with SYSTEM_THREAD(ENABLED). After your comment I found one possible problem and will pursue it. Thanks again.
My phone is my main WiFi Hot Spot also and I use
So the Photons keep running and automatically reconnect as I come and go with my phone from the house.
Thanks for the help everyone.