Skip to content

Commit 3f27d19

Browse files
committed
for zero-touch enabled boards read the storage before run zero-touch procedure
1 parent ce5bc09 commit 3f27d19

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/Arduino_NetworkConfigurator.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,9 @@ bool NetworkConfiguratorClass::begin() {
4949
if(_state != NetworkConfiguratorStates::END) {
5050
return true;
5151
}
52-
/*
53-
* If the board is zero touch capable, starts with zero touch configuration mode
54-
* In this state the board will try to connect to the network using a set of
55-
* default network settings ex. Ethernet with DHCP
56-
* This mode will fail if the provided ConnectionHandler is not GenericConnectionHandler type
57-
* falling back to read the network settings from the storage
58-
*/
5952

60-
#if ZERO_TOUCH_ENABLED
61-
_state = NetworkConfiguratorStates::ZERO_TOUCH_CONFIG;
62-
#else
6353
_state = NetworkConfiguratorStates::READ_STORED_CONFIG;
64-
#endif
54+
6555
_connectionHandler->enableCheckInternetAvailability(true);
6656

6757
memset(&_networkSetting, 0x00, sizeof(models::NetworkSetting));
@@ -98,10 +88,10 @@ NetworkConfiguratorStates NetworkConfiguratorClass::update() {
9888
_ledFeedback->update();
9989

10090
switch (_state) {
91+
case NetworkConfiguratorStates::READ_STORED_CONFIG: nextState = handleReadStorage (); break;
10192
#if ZERO_TOUCH_ENABLED
10293
case NetworkConfiguratorStates::ZERO_TOUCH_CONFIG: nextState = handleZeroTouchConfig(); break;
10394
#endif
104-
case NetworkConfiguratorStates::READ_STORED_CONFIG: nextState = handleReadStorage (); break;
10595
case NetworkConfiguratorStates::WAITING_FOR_CONFIG: nextState = handleWaitingForConf (); break;
10696
case NetworkConfiguratorStates::CONNECTING: nextState = handleConnecting (); break;
10797
case NetworkConfiguratorStates::CONFIGURED: nextState = handleConfigured (); break;
@@ -475,9 +465,10 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleZeroTouchConfig() {
475465
sendStatus(StatusMessage::ERROR);
476466
}
477467
_connectionHandlerIstantiated = false;
478-
return NetworkConfiguratorStates::READ_STORED_CONFIG;
468+
return NetworkConfiguratorStates::WAITING_FOR_CONFIG;
479469
}
480-
return NetworkConfiguratorStates::ZERO_TOUCH_CONFIG;
470+
471+
return handleWaitingForConf();
481472
}
482473
#endif
483474

@@ -518,7 +509,16 @@ NetworkConfiguratorStates NetworkConfiguratorClass::handleReadStorage() {
518509
if (_optionUpdateTimer.getWaitTime() == 0) {
519510
scanNetworkOptions();
520511
}
512+
/*
513+
* If the board is zero touch capable and without network configuration, it starts the zero touch configuration mode
514+
* In this state the board will try to connect to the network using a set of
515+
* default network settings ex. Ethernet with DHCP
516+
*/
517+
#if ZERO_TOUCH_ENABLED
518+
return NetworkConfiguratorStates::ZERO_TOUCH_CONFIG;
519+
#else
521520
return NetworkConfiguratorStates::WAITING_FOR_CONFIG;
521+
#endif
522522
}
523523

524524
NetworkConfiguratorStates NetworkConfiguratorClass::handleWaitingForConf() {

0 commit comments

Comments
 (0)