Intranet only - WiFi disconnects - how to stop?

@ScruffR,

Am running in SEMI_AUTOMATIC_MODE, but I am calling Particle.connect() within setup() and in loop() as part of the @rickkas7 strategy described within my ticket:

I had added Particle.connect(); to this block (not realising the WiFi disconnect side effect until your comments above).

case WIFI_STATE_CONNECTED:
        // Do any one-time initialization here like calling udp.begin() or tcpServer.begin()
        Log.info("WiFi connected");

       // Also connect to the Particle cloud   
       Particle.connect();             // <=== I added this....

       wifiState = WIFI_STATE_RUNNING;
      break;

So, a solution is, as you said, don't call Particle.connect() for this use case. Too easy!

That said, @Elco's point regarding "great to have Particle cloud when it is there" is also a very good point, so it would be nice to solve that problem.

@Elco, wondering if this sorts out your request: pinging some external IP and only if you get a successful return, call Particle.connect()? Something like this:

if (!Particle.connected())
{
       int rc = WiFi.ping(IpAddress(8,8,8,8));
       if (rc > 0) 
               Particle.connect();
}
1 Like