@@ -168,10 +168,9 @@ NetworkConfiguratorClass::ConnectionResult NetworkConfiguratorClass::connectToNe
168
168
WiFi.end ();
169
169
#endif
170
170
#endif
171
- int errorCode;
172
- String errorMsg = decodeConnectionErrorMessage (connectionRes, &errorCode);
171
+ String errorMsg = decodeConnectionErrorMessage (connectionRes, err);
173
172
DEBUG_INFO (" Connection fail: %s" , errorMsg.c_str ());
174
- *err = (StatusMessage)errorCode;
173
+
175
174
_connectionRetryTimer.reload ();
176
175
res = ConnectionResult::FAILED;
177
176
}
@@ -349,28 +348,30 @@ void NetworkConfiguratorClass::handleNewNetworkSettings() {
349
348
_connectionLostStatus = false ; // reset for updating the failure reason
350
349
}
351
350
352
- String NetworkConfiguratorClass::decodeConnectionErrorMessage (NetworkConnectionState err, int *errorCode) {
351
+ String NetworkConfiguratorClass::decodeConnectionErrorMessage (NetworkConnectionState err, StatusMessage *errorCode) {
353
352
switch (err) {
354
353
case NetworkConnectionState::ERROR:
355
- *errorCode = ( int ) StatusMessage::HW_ERROR_CONN_MODULE;
354
+ *errorCode = StatusMessage::HW_ERROR_CONN_MODULE;
356
355
return " HW error" ;
357
356
case NetworkConnectionState::INIT:
358
- *errorCode = (int )StatusMessage::WIFI_IDLE;
359
- return " Peripheral in idle" ;
357
+ // the connection handler doesn't have a state of "Fail to connect", in case of invalid credentials or
358
+ // missing network configuration the FSM stays on Init state so use this state to detect the fail to connect
359
+ *errorCode = StatusMessage::FAILED_TO_CONNECT;
360
+ return " Failed to connect" ;
360
361
case NetworkConnectionState::CLOSED:
361
- *errorCode = ( int ) StatusMessage::WIFI_STOPPED ;
362
+ *errorCode = StatusMessage::HW_CONN_MODULE_STOPPED ;
362
363
return " Peripheral stopped" ;
363
364
case NetworkConnectionState::DISCONNECTED:
364
- *errorCode = ( int ) StatusMessage::DISCONNECTED;
365
+ *errorCode = StatusMessage::DISCONNECTED;
365
366
return " Disconnected" ;
366
- // the connection handler doesn't have a state of "Fail to connect", in case of invalid credentials or
367
- // missing wifi network the FSM stays on Connecting state so use the connecting state to detect the fail to connect
368
367
case NetworkConnectionState::CONNECTING:
369
- *errorCode = (int )StatusMessage::FAILED_TO_CONNECT;
370
- return " failed to connect" ;
368
+ // the connection handler doesn't have a state of "Internet not available", in case of it's impossible to reach internet
369
+ // the FSM stays on Connecting state so use this state to detect if internet is not available
370
+ *errorCode = StatusMessage::INTERNET_NOT_AVAILABLE;
371
+ return " Internet not available" ;
371
372
default :
372
- *errorCode = ( int ) StatusMessage::ERROR;
373
- return " generic error" ;
373
+ *errorCode = StatusMessage::ERROR;
374
+ return " Generic error" ;
374
375
}
375
376
}
376
377
0 commit comments