Auto enter the listen mode

Hi,
I have a problem, when i go to the new wifi
How can I auto turn to the listen mode after 5 minutes if not connect to wifi
Thanks

By looking in the docs you might have found these

https://docs.particle.io/reference/firmware/photon/#listen-
https://docs.particle.io/reference/firmware/photon/#ready-
https://docs.particle.io/reference/firmware/photon/#system-thread

Have I turn to SEMI_AUTO mode

You can use SEMI_AUTOMATIC, but SYSTEM_THREAD(ENABLED) should be enough to ensure your code is running even when disconnected and hence being able to check connection status and enter Listening Mode.
But I’m usually going SEMI too - just for safe measure.

1 Like
SYSTEM_THREAD(ENABLED);   
uint8_t retry_count = 0;
void setup()
{
  WiFi.on();
}
void loop()
{
      WiFi.connect();
      if(!WiFi.ready()){
              retry_count += 1;
          }
      if ((retry_count >= 100)&&(WiFi.ready() == false))
      {
        WiFi.listen();
      }
      if (WiFi.ready() == true) Particle.connect();
}

Here is my code, but it’s still not work, can you give me a suggest

Yes, it’s work, thanks you

1 Like