Skip to content

Commit 441cf65

Browse files
committed
fixes for the reset command of provisioning
1 parent 32a7248 commit 441cf65

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

examples/provisioning/provisioning.ino

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ DeviceState handleFirstConfig() {
163163
}
164164

165165
DeviceState handleCSR() {
166-
DeviceState nextState = _state;
167166
ClaimingHandler.poll();
167+
DeviceState nextState = _state;
168168
if (CSRHandler->poll() == CSRHandlerClass::CSRHandlerStates::COMPLETED) {
169169

170170

@@ -173,6 +173,9 @@ DeviceState handleCSR() {
173173
Serial.println("CSR done");
174174
display_freeram();
175175
nextState = DeviceState::BEGIN_CLOUD;
176+
}else if(nextState == DeviceState::FIRST_CONFIG){
177+
CSRHandler->end();
178+
delete CSRHandler;
176179
}
177180
return nextState;
178181
}
@@ -192,14 +195,17 @@ DeviceState handleBeginCloud() {
192195
}
193196

194197
DeviceState handleRun() {
198+
ClaimingHandler.poll();
195199
DeviceState nextState = _state;
200+
if(nextState == DeviceState::FIRST_CONFIG){
201+
return nextState;
202+
}
196203
ArduinoCloud.update();
197204

198-
ClaimingHandler.poll();
199205
if (NetworkConfigurator.poll() == NetworkConfiguratorStates::UPDATING_CONFIG) {
200206
nextState = DeviceState::FIRST_CONFIG;
201207
}
202-
208+
203209
// Your code here
204210
if (millis() - lastUpdate > 10000) {
205211
Serial.println("alive");

src/ConfiguratorAgents/AgentsManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void AgentsManagerClass::handleGetBleMacAddressCommand() {
379379

380380
void AgentsManagerClass::handleResetCommand() {
381381
if (_statusRequest.pending) {
382-
DEBUG_DEBUG("AgentsManagerClass::%s received a GetUnique request while executing another request", __FUNCTION__);
382+
DEBUG_DEBUG("AgentsManagerClass::%s received a Reset request while executing another request", __FUNCTION__);
383383
sendStatus(StatusMessage::OTHER_REQUEST_IN_EXECUTION);
384384
return;
385385
}

src/NetworkConfigurator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ bool NetworkConfiguratorClass::resetStoredConfiguration() {
134134
memset(&_networkSetting, 0x00, sizeof(models::NetworkSetting));
135135
if(_connectionHandlerIstantiated) {
136136
disconnectFromNetwork();
137+
_connectionHandlerIstantiated = false;
137138
}
138139

140+
_state = NetworkConfiguratorStates::WAITING_FOR_CONFIG;
141+
139142
return true;
140143
}
141144

0 commit comments

Comments
 (0)