Skip to content

Commit 2e5fde5

Browse files
committed
Reset wifi timeout if ethernet connection is lost
1 parent 7ca8bdb commit 2e5fde5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Firmware/RTK_Everywhere/Ethernet.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ void ethernetEvent(arduino_event_id_t event, arduino_event_info_t info)
188188
case ARDUINO_EVENT_ETH_DISCONNECTED:
189189
if (settings.enablePrintEthernetDiag && (!inMainMenu))
190190
systemPrintln("ETH Disconnected");
191+
192+
wifiResetTimeout(); // If we loose ethernet, allow WiFi to immediately try to start
193+
191194
break;
192195

193196
case ARDUINO_EVENT_ETH_STOP:

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ bool wifiForceStart()
485485
// Start WiFi
486486
if (wifiConnect(settings.wifiConnectTimeoutMs))
487487
{
488-
wifiStartTimeout = 0;
488+
wifiResetTimeout();
489489
if (settings.debugWifiState == true)
490490
systemPrintln("WiFi: Start timeout reset to zero");
491491
}
@@ -494,6 +494,15 @@ bool wifiForceStart()
494494
return (wifiStatus == WL_CONNECTED);
495495
}
496496

497+
//----------------------------------------
498+
// Set WiFi timeout back to zero
499+
// Useful if other things (such as a successful ethernet connection) need to reset wifi timeout
500+
//----------------------------------------
501+
void wifiResetTimeout()
502+
{
503+
wifiStartTimeout = 0;
504+
}
505+
497506
//----------------------------------------
498507
// Start WiFi with throttling
499508
//----------------------------------------

0 commit comments

Comments
 (0)