Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/helpers/esp32/SerialWifiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/esp32/SerialWifiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,6 +41,8 @@ class SerialWifiInterface : public BaseSerialInterface {
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;
Expand Down