@@ -107,34 +107,7 @@ void WiFiConnectionHandler::update() {
107107 lastConnectionTickTime = now;
108108
109109 switch (netConnectionState) {
110- case NetworkConnectionState::INIT: {
111- Debug.print (DBG_VERBOSE, " ::INIT" );
112- #if !defined(BOARD_ESP8266)
113- networkStatus = WiFi.status ();
114-
115- Debug.print (DBG_INFO, " WiFi.status(): %d" , networkStatus);
116- if (networkStatus == NETWORK_HARDWARE_ERROR) {
117- // NO FURTHER ACTION WILL FOLLOW THIS
118- changeConnectionState (NetworkConnectionState::ERROR);
119- return ;
120- }
121- Debug.print (DBG_ERROR, " Current WiFi Firmware: %s" , WiFi.firmwareVersion ());
122- if (WiFi.firmwareVersion () < WIFI_FIRMWARE_VERSION_REQUIRED) {
123- Debug.print (DBG_ERROR, " Latest WiFi Firmware: %s" , WIFI_FIRMWARE_VERSION_REQUIRED);
124- Debug.print (DBG_ERROR, " Please update to the latest version for best performance." );
125- delay (5000 );
126- }
127- #else
128- Debug.print (DBG_ERROR, " WiFi status ESP: %d" , WiFi.status ());
129- WiFi.disconnect ();
130- delay (300 );
131- networkStatus = WiFi.begin (ssid, pass);
132- delay (1000 );
133- #endif
134-
135- changeConnectionState (NetworkConnectionState::CONNECTING);
136- }
137- break ;
110+ case NetworkConnectionState::INIT: update_handleInit (networkStatus); break ;
138111 case NetworkConnectionState::CONNECTING: {
139112 Debug.print (DBG_VERBOSE, " ::CONNECTING" );
140113 networkStatus = WiFi.status ();
@@ -294,4 +267,35 @@ void WiFiConnectionHandler::disconnect() {
294267 changeConnectionState (NetworkConnectionState::DISCONNECTING);
295268 keepAlive = false ;
296269}
270+
271+ void WiFiConnectionHandler::update_handleInit (int & networkStatus) {
272+ Debug.print (DBG_VERBOSE, " ::INIT" );
273+
274+ #ifndef BOARD_ESP8266
275+ networkStatus = WiFi.status ();
276+
277+ Debug.print (DBG_INFO, " WiFi.status(): %d" , networkStatus);
278+ if (networkStatus == NETWORK_HARDWARE_ERROR) {
279+ // NO FURTHER ACTION WILL FOLLOW THIS
280+ changeConnectionState (NetworkConnectionState::ERROR);
281+ return ;
282+ }
283+
284+ Debug.print (DBG_ERROR, " Current WiFi Firmware: %s" , WiFi.firmwareVersion ());
285+
286+ if (WiFi.firmwareVersion () < WIFI_FIRMWARE_VERSION_REQUIRED) {
287+ Debug.print (DBG_ERROR, " Latest WiFi Firmware: %s" , WIFI_FIRMWARE_VERSION_REQUIRED);
288+ Debug.print (DBG_ERROR, " Please update to the latest version for best performance." );
289+ delay (5000 );
290+ }
291+ #else
292+ Debug.print (DBG_ERROR, " WiFi status ESP: %d" , WiFi.status ());
293+ WiFi.disconnect ();
294+ delay (300 );
295+ networkStatus = WiFi.begin (ssid, pass);
296+ delay (1000 );
297+ #endif /* ifndef BOARD_ESP8266 */
298+ changeConnectionState (NetworkConnectionState::CONNECTING);
299+ }
300+
297301#endif /* #ifdef BOARD_HAS_WIFI */
0 commit comments