Skip to content

Commit 6d351ae

Browse files
committed
WiFi: Always stop WiFi station in WIFI_STATION_STATE_WAIT_NO_USERS
1 parent 86ddf45 commit 6d351ae

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,28 +1001,23 @@ void wifiStationUpdate()
10011001
// No more network users
10021002
else
10031003
{
1004-
// Stop WiFi station if necessary
1005-
if (enabled == false)
1004+
// Display the major state transition
1005+
if (wifiStationRunning)
10061006
{
1007-
// Display the major state transition
1008-
if (wifiStationRunning)
1009-
{
1010-
if (settings.debugWifiState)
1011-
systemPrintf("--------------- %s Stopping ---------------\r\n",
1012-
networkInterfaceTable[NETWORK_WIFI_STATION].name);
1013-
wifiStationOff(__FILE__, __LINE__);
1014-
}
1007+
if (settings.debugWifiState)
1008+
systemPrintf("--------------- %s Stopping ---------------\r\n",
1009+
networkInterfaceTable[NETWORK_WIFI_STATION].name);
1010+
wifiStationOff(__FILE__, __LINE__);
1011+
}
10151012

1013+
// Stop WiFi station if necessary
1014+
if (enabled == false)
10161015
// Reset the start timeout
10171016
wifiStationSetState(WIFI_STATION_STATE_OFF);
1018-
}
10191017

10201018
// Restart WiFi after delay
10211019
else
10221020
{
1023-
// Clear the bits to perform the restart operation
1024-
wifi.clearStarted(WIFI_STA_RECONNECT);
1025-
10261021
// Display the restart delay and then start WiFi station
10271022
if (startTimeout && settings.debugWifiState)
10281023
{
@@ -1033,7 +1028,7 @@ void wifiStationUpdate()
10331028
systemPrintf("WiFi: Delaying %2d:%02d before restarting WiFi\r\n", minutes, seconds);
10341029
}
10351030
timer = millis();
1036-
wifiStationSetState(WIFI_STATION_STATE_STARTING);
1031+
wifiStationSetState(WIFI_STATION_STATE_RESTART_DELAY);
10371032
}
10381033
}
10391034
break;
@@ -1108,6 +1103,7 @@ void wifiStationUpdate()
11081103
// Wait until the WiFi link is stable
11091104
if ((millis() - timer) >= WIFI_CONNECTION_STABLE_MSEC)
11101105
{
1106+
// Reset restart timeout and the connection attempts
11111107
connectionAttempts = 0;
11121108
startTimeout = 0;
11131109
wifiStationSetState(WIFI_STATION_STATE_STABLE);

0 commit comments

Comments
 (0)