This commit is contained in:
Matt Swann 2026-04-20 13:46:08 +03:00 committed by GitHub
commit 5a9666cc3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View file

@ -53,6 +53,15 @@ void SerialWifiInterface::resetReceivedFrameHeader() {
}
size_t SerialWifiInterface::checkRecvFrame(uint8_t dest[]) {
// periodic WiFi health check (every 60s, only after first successful connection)
if (WiFi.status() == WL_CONNECTED) {
_wifi_was_connected = true;
} else if (_wifi_was_connected && millis() >= _wifi_check_time) {
WIFI_DEBUG_PRINTLN("WiFi disconnected, attempting reconnect...");
WiFi.reconnect();
_wifi_check_time = millis() + 60000;
}
// check if new client connected
auto newClient = server.available();
if (newClient) {

View file

@ -8,6 +8,8 @@ class SerialWifiInterface : public BaseSerialInterface {
bool _isEnabled;
unsigned long _last_write;
unsigned long adv_restart_time;
bool _wifi_was_connected;
unsigned long _wifi_check_time;
WiFiServer server;
WiFiClient client;
@ -39,6 +41,8 @@ public:
deviceConnected = false;
_isEnabled = false;
_last_write = 0;
_wifi_was_connected = false;
_wifi_check_time = 0;
send_queue_len = recv_queue_len = 0;
received_frame_header.type = 0;
received_frame_header.length = 0;