File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -543,6 +543,29 @@ void pvtServerUpdate()
543543 // Restart the data verification
544544 pvtServerTimer = millis ();
545545 pvtServerClientDataSent = 0 ;
546+
547+ // Keep WiFi alive for PvtServer when no clients are connected
548+ // Prevents:
549+ // [D][WiFiGeneric.cpp:831] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
550+ // [W][WiFiGeneric.cpp:852] _eventCallback(): Reason: 4 - ASSOC_EXPIRE
551+ if (!pvtServerClientConnected)
552+ {
553+ NETWORK_DATA * network;
554+ network = &networkData;
555+ if (network->type == NETWORK_TYPE_WIFI)
556+ {
557+ // Generate a little DNS traffic
558+ // Use a random host. Checking the same host more than once generates no new traffic...
559+ char randomHost[strlen (" www.00000000.com" ) + 1 ];
560+ snprintf (randomHost, sizeof (randomHost), " www.%08x.com" , millis ());
561+ IPAddress theIP;
562+ unsigned long start = millis ();
563+ WiFi.hostByName (randomHost, theIP);
564+ if (settings.debugPvtServer )
565+ systemPrintf (" PVT Server keep alive: WiFi.hostByName(%s) took %ld ms\r\n " , randomHost, millis () - start);
566+ }
567+ }
568+
546569 }
547570 break ;
548571 }
You can’t perform that action at this time.
0 commit comments