Fix: ota not callback on first powerup perform

This commit is contained in:
Phat Nguyen
2024-06-04 18:01:55 +07:00
parent 11ecea1493
commit ef6b041529

View File

@ -219,6 +219,7 @@ void setup() {
#ifdef ESP8266 #ifdef ESP8266
// ota not supported // ota not supported
#else #else
otaHandler.setHandlerCallback(otaHandlerCallback);
otaHandler.updateFirmwareIfOutdated(ag->deviceId()); otaHandler.updateFirmwareIfOutdated(ag->deviceId());
/** Update first OTA */ /** Update first OTA */
@ -485,6 +486,7 @@ static bool sgp41Init(void) {
} }
static void otaHandlerCallback(OtaState state, String mesasge) { static void otaHandlerCallback(OtaState state, String mesasge) {
Serial.println("OTA message: " + mesasge);
switch (state) { switch (state) {
case OtaState::OTA_STATE_BEGIN: case OtaState::OTA_STATE_BEGIN:
displayExecuteOta(state, fwNewVersion, 0); displayExecuteOta(state, fwNewVersion, 0);
@ -562,7 +564,7 @@ static void displayExecuteOta(OtaState state, String msg, int processing) {
while (i != 0) { while (i != 0) {
i = i - 1; i = i - 1;
if (ag->isOne()) { if (ag->isOne()) {
oledDisplay.showFirmwareUpdateSuccess(String(i)); oledDisplay.showFirmwareUpdateSuccess(i);
} else { } else {
Serial.println("Rebooting... " + String(i)); Serial.println("Rebooting... " + String(i));
} }