Move rebooting process out of OtaHandler

This commit is contained in:
Phat Nguyen
2024-05-08 12:31:54 +07:00
parent 8eb8d4a1ec
commit cca1ab69bb
2 changed files with 22 additions and 13 deletions

View File

@ -487,10 +487,22 @@ static void displayExecuteOta(OtaState state, String msg, int processing) {
break;
}
case OtaState::OTA_STATE_SUCCESS: {
int i = 6;
while(i != 0) {
i = i - 1;
Serial.println("OTA update performed, restarting ...");
int i = 6;
while (i != 0) {
i = i - 1;
if (ag->isOne()) {
oledDisplay.showNewFirmwareSuccess(String(processing));
oledDisplay.showNewFirmwareSuccess(String(i));
} else {
Serial.println("Rebooting... " + String(processing));
Serial.println("Rebooting... " + String(i));
}
delay(1000);
}
esp_restart();
}
break;
}

View File

@ -41,16 +41,13 @@ public:
OtaUpdateOutcome ret = attemptToPerformOta(&config);
Serial.println(ret);
if (ret == OtaUpdateOutcome::UPDATE_PERFORMED) {
Serial.println("OTA update performed, restarting ...");
int i = 6;
while (i != 0) {
i = i - 1;
if (this->callback) {
this->callback(OtaState::OTA_STATE_SUCCESS, String(i));
this->callback(OtaState::OTA_STATE_SUCCESS, "");
}
delay(1000);
} else {
if(this->callback) {
this->callback(OtaState::OTA_STATE_FAIL, "");
}
esp_restart();
}
}