WiFi.ready() - useful not just at startup?

I’m having WiFi issues at the moment which are causing Publishes to stall the program in my Photon and causing long delays to lights turning on. I’m putting checks on those publishes such that if WiFi.ready() returns false, then I skip the publish and just do the lights. The documentation for WiFi.ready(); Only talks about using it at wifi startup - but I am assuming that if the connection is lost subsequent to startup (i.e. flashing green on the Photon) then it will also return false?

It can be used for that, but it’s better to surround publishes with a check for Particle.connected() instead of WiFi.ready(). If Wi-Fi is not ready, then connected will be false, but it also catches other situations like Wi-Fi is up but Internet is down, or the cloud is not currently connected to. All of those things will cause Particle.publish() to block.

1 Like

Thanks @rickkas7 - that makes good sense - I will go with that!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.