Skip to content

Commit fb01993

Browse files
committed
Keep WiFi alive when no PvtServer clients are conected
1 parent dac39b4 commit fb01993

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Firmware/RTK_Surveyor/PvtServer.ino

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)