@@ -33,6 +33,7 @@ NetworkConfiguratorClass::NetworkConfiguratorClass(ConnectionHandler &connection
3333 _state{ NetworkConfiguratorStates::END },
3434 _connectionHandler{ &connectionHandler },
3535 _connectionHandlerIstantiated{ false },
36+ _configInProgress{ false },
3637 _kvstore{ nullptr },
3738 _connectionTimeout{ NC_CONNECTION_TIMEOUT_ms, NC_CONNECTION_TIMEOUT_ms },
3839 _connectionRetryTimer{ NC_CONNECTION_RETRY_TIMER_ms, NC_CONNECTION_RETRY_TIMER_ms },
@@ -547,8 +548,11 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleConnecting() {
547548 _agentsManager->update (); // To keep alive the connection with the configurator
548549 StatusMessage err;
549550 ConnectionResult res = connectToNetwork (&err);
550-
551+ _configInProgress = _agentsManager-> isConfigInProgress ();
551552 if (res == ConnectionResult::SUCCESS) {
553+ if (_configInProgress) {
554+ _ledFeedback->setMode (LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED);
555+ }
552556 return NetworkConfiguratorStates::CONFIGURED;
553557 } else if (res == ConnectionResult::FAILED) {
554558 sendStatus (err);
@@ -560,17 +564,16 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleConnecting() {
560564}
561565
562566NetworkConfiguratorStates NetworkConfiguratorClass::handleConfigured () {
563- bool configInprogress = _agentsManager->isConfigInProgress ();
564-
565- if (configInprogress) {
566- _ledFeedback->setMode (LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED);
567- }
568-
569567 _agentsManager->update ();
568+ const bool updatedConfigInprogress = _agentsManager->isConfigInProgress ();
569+
570570 // If the agent manager changes state, it means that user is trying to configure the network, so the network configurator should change state
571- if (_agentsManager->isConfigInProgress () && !configInprogress) {
572- scanNetworkOptions ();
573- return NetworkConfiguratorStates::UPDATING_CONFIG;
571+ if (_configInProgress != updatedConfigInprogress) {
572+ _configInProgress = updatedConfigInprogress;
573+ if (_configInProgress) {
574+ scanNetworkOptions ();
575+ return NetworkConfiguratorStates::UPDATING_CONFIG;
576+ }
574577 }
575578
576579 return NetworkConfiguratorStates::CONFIGURED;
0 commit comments