Skip to content

Commit 53a01da

Browse files
committed
move wifi scan from begin and run it when necessary
1 parent 726e598 commit 53a01da

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

examples/auto-retry/auto-retry.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void setup() {
7171
NetworkConf.resetStoredConfiguration();
7272
}
7373
NetworkConf.startBLEIfConnectionFails(true);
74+
NetworkConf.updateNetworkOptions();
7475
NetworkConf.begin();
7576
ProvisioningSystem.begin();
7677

examples/provisioning/provisioning.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void setup() {
113113
#if defined(ARDUINO_UNOR4_WIFI)
114114
WiFi.end();
115115
#endif
116-
clearStoredCredentials();
116+
117117
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_PORTENTA_H7_M7)
118118
pinMode(RESETCRED_BUTTON, INPUT_PULLDOWN);
119119
#else
@@ -130,6 +130,7 @@ clearStoredCredentials();
130130
}
131131

132132
NetworkConf.setCheckStoredCred(false);
133+
NetworkConf.updateNetworkOptions();
133134
NetworkConf.begin();
134135
ClaimingHandler.begin(&secureElement, &uhwid, clearStoredCredentials);
135136

src/NetworkConfigurator.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ bool NetworkConfigurator::begin() {
5959
DEBUG_ERROR("NetworkConfigurator::%s Error registering \"network settings\" callback to AgentManager", __FUNCTION__);
6060
}
6161

62-
updateNetworkOptions(); //TODO MOVE
6362
if (!_agentManager->begin(SERVICE_ID_FOR_AGENTMANAGER)) {
6463
DEBUG_ERROR("NetworkConfigurator::%s Failed to initialize the AgentsConfiguratorManager", __FUNCTION__);
6564
}
@@ -408,8 +407,12 @@ NetworkConfiguratorStates NetworkConfigurator::handleReadStorage() {
408407
}
409408
_kvstore.end();
410409
#else
411-
nextState = NetworkConfiguratorStates::CONFIGURED; //Fix when implement the check if the provided connectionhandler is already configured
410+
nextState = NetworkConfiguratorStates::CONFIGURED;
412411
#endif
412+
413+
if (nextState == NetworkConfiguratorStates::WAITING_FOR_CONFIG && _lastOptionUpdate == 0) {
414+
updateNetworkOptions();
415+
}
413416
return nextState;
414417
}
415418

@@ -425,6 +428,9 @@ NetworkConfiguratorStates NetworkConfigurator::handleTestStoredConfig() {
425428
if (_startBLEIfConnectionFails) {
426429
_agentManager->enableBLEAgent(true);
427430
}
431+
if(_lastOptionUpdate == 0) {
432+
updateNetworkOptions();
433+
}
428434
nextState = NetworkConfiguratorStates::WAITING_FOR_CONFIG;
429435
}
430436
return nextState;

src/NetworkConfigurator.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class NetworkConfigurator {
3535
};
3636
bool resetStoredConfiguration();
3737
bool end();
38-
38+
bool updateNetworkOptions();
3939
private:
4040
NetworkConfiguratorStates _state = NetworkConfiguratorStates::END;
4141
AgentsConfiguratorManager *_agentManager;
@@ -74,7 +74,6 @@ class NetworkConfigurator {
7474
String decodeConnectionErrorMessage(NetworkConnectionState err, int *errorCode);
7575
ConnectionResult connectToNetwork(StatusMessage *err);
7676
ConnectionResult disconnectFromNetwork();
77-
bool updateNetworkOptions();
7877
bool sendStatus(StatusMessage msg);
7978
void printNetworkSettings();
8079
#ifdef BOARD_HAS_WIFI

0 commit comments

Comments
 (0)