Skip to content

Commit 1b50d52

Browse files
committed
fix for updating credential
1 parent cab5e7e commit 1b50d52

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/Arduino_NetworkConfigurator.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

562566
NetworkConfiguratorStates NetworkConfiguratorClass::handleConfigured() {
563-
bool configInprogress = _agentsManager->isConfigInProgress();
564-
565-
if (configInprogress) {
566-
_ledFeedback->setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED);
567-
}
568-
569567
_agentsManager->update();
568+
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;

src/Arduino_NetworkConfigurator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class NetworkConfiguratorClass {
162162
ConnectionHandler *_connectionHandler;
163163
static inline models::NetworkSetting _networkSetting;
164164
bool _connectionHandlerIstantiated;
165+
bool _configInProgress;
165166
ResetInput *_resetInput;
166167
LEDFeedbackClass *_ledFeedback;
167168
/* Timeout instances */

0 commit comments

Comments
 (0)