Skip to content

Commit 4568c5c

Browse files
committed
WiFi: Properly handle Internet connection loss in stationEventHandler
1 parent 6d04305 commit 4568c5c

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,14 +1877,6 @@ void RTK_WIFI::stationEventHandler(arduino_event_id_t event, arduino_event_info_
18771877
bool success;
18781878
int type;
18791879

1880-
// Take the network offline if necessary
1881-
if (networkInterfaceHasInternet(NETWORK_WIFI_STATION) && (event != ARDUINO_EVENT_WIFI_STA_GOT_IP) &&
1882-
(event != ARDUINO_EVENT_WIFI_STA_GOT_IP6))
1883-
{
1884-
// Stop WiFi to allow it to restart
1885-
networkInterfaceEventStop(NETWORK_WIFI_STATION);
1886-
}
1887-
18881880
//------------------------------
18891881
// WiFi Status Values:
18901882
// WL_CONNECTED: assigned when connected to a WiFi network
@@ -1930,18 +1922,8 @@ void RTK_WIFI::stationEventHandler(arduino_event_id_t event, arduino_event_info_
19301922
// Start the reconnection timer
19311923
if (event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED)
19321924
{
1933-
if (settings.debugWifiState && _verbose && !wifiReconnectionTimer)
1934-
systemPrintf("WiFi: Reconnection timer started\r\n");
1935-
wifiReconnectionTimer = millis();
1936-
if (!wifiReconnectionTimer)
1937-
wifiReconnectionTimer = 1;
1938-
}
1939-
else
1940-
{
1941-
// Stop the reconnection timer
1942-
if (settings.debugWifiState && _verbose && wifiReconnectionTimer)
1943-
systemPrintf("WiFi: Reconnection timer stopped\r\n");
1944-
wifiReconnectionTimer = 0;
1925+
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
1926+
wifiReconnectRequest = true;
19451927
}
19461928

19471929
// Fall through
@@ -1963,6 +1945,12 @@ void RTK_WIFI::stationEventHandler(arduino_event_id_t event, arduino_event_info_
19631945
// V
19641946

19651947
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
1948+
if (event == ARDUINO_EVENT_WIFI_STA_LOST_IP)
1949+
{
1950+
networkInterfaceEventInternetLost(NETWORK_WIFI_STATION, __FILE__, __LINE__);
1951+
wifiReconnectRequest = true;
1952+
}
1953+
19661954
// Mark the WiFi station offline
19671955
if (_started & WIFI_STA_ONLINE)
19681956
systemPrintf("WiFi: Station offline!\r\n");

0 commit comments

Comments
 (0)