@@ -1001,28 +1001,23 @@ void wifiStationUpdate()
1001
1001
// No more network users
1002
1002
else
1003
1003
{
1004
- // Stop WiFi station if necessary
1005
- if (enabled == false )
1004
+ // Display the major state transition
1005
+ if (wifiStationRunning )
1006
1006
{
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
+ }
1015
1012
1013
+ // Stop WiFi station if necessary
1014
+ if (enabled == false )
1016
1015
// Reset the start timeout
1017
1016
wifiStationSetState (WIFI_STATION_STATE_OFF);
1018
- }
1019
1017
1020
1018
// Restart WiFi after delay
1021
1019
else
1022
1020
{
1023
- // Clear the bits to perform the restart operation
1024
- wifi.clearStarted (WIFI_STA_RECONNECT);
1025
-
1026
1021
// Display the restart delay and then start WiFi station
1027
1022
if (startTimeout && settings.debugWifiState )
1028
1023
{
@@ -1033,7 +1028,7 @@ void wifiStationUpdate()
1033
1028
systemPrintf (" WiFi: Delaying %2d:%02d before restarting WiFi\r\n " , minutes, seconds);
1034
1029
}
1035
1030
timer = millis ();
1036
- wifiStationSetState (WIFI_STATION_STATE_STARTING );
1031
+ wifiStationSetState (WIFI_STATION_STATE_RESTART_DELAY );
1037
1032
}
1038
1033
}
1039
1034
break ;
@@ -1108,6 +1103,7 @@ void wifiStationUpdate()
1108
1103
// Wait until the WiFi link is stable
1109
1104
if ((millis() - timer) >= WIFI_CONNECTION_STABLE_MSEC)
1110
1105
{
1106
+ // Reset restart timeout and the connection attempts
1111
1107
connectionAttempts = 0 ;
1112
1108
startTimeout = 0 ;
1113
1109
wifiStationSetState (WIFI_STATION_STATE_STABLE);
0 commit comments