Happy Sunday for everyone.
I´m kind of stuck in a simple thing and I will like to get some help.
My code works really smooth with system thread enabled and I don´t want to disable that. However, I need that the listen mode STOP the code until a successfully connection has been made. My code is 100% dependent on internet and I don´t need to run it until the Photon is connected.
Even worse, I use the RGB LED in my code, so the user can´t tell which mode the device is, if my firmware is executed.
I´m tried all the code listed here, and checked all possible combinations (check for credentials, paired networks)… without luck.
Maybe there are an exception for system thread? Like a modifier to exclude some part of the code to run in parallel? Otherwise I cannot see a clear way to stop the code around Particle.connect until it´s done…
Help is always appreciated.
Thank you for your time!
How about this
if (WiFi.listening() || !Particle.connected()) // or whatever else your prerequisites are
You could also use
waitUtil(Particle.connected) to block the execution at any point if the connection got dropped till it gets reestablished.
Thank you @ScruffR for your kind reply.
Is WiFi.listening() ready to use? The reference page says "We estimate that firmware feature will be released for the Photon in September 2015. I had my doubts about use it because of that.
I use waitFor now, but with a timeout value. Is clear from your answer that I can use it without that value to
Thank you for your help!
waitFor() wants a timeout, but
waitUnitl() will wait indefinetly.
WiFi.listening() was always working but only became useful once your code could execute in parallel.
And Sept 2015 was estiamted time of arrival of RTOS (which is available since the introduction of