From cf7ff9b0d14b35b2f9e5ed89c1da14f53b623333 Mon Sep 17 00:00:00 2001 From: Empire Date: Wed, 17 May 2023 18:24:09 +0200 Subject: [PATCH] added ota state debugging --- esp32/include/ControllerConfiguration.h | 2 +- esp32/src/main.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/esp32/include/ControllerConfiguration.h b/esp32/include/ControllerConfiguration.h index 6c68bda..d39d940 100644 --- a/esp32/include/ControllerConfiguration.h +++ b/esp32/include/ControllerConfiguration.h @@ -80,7 +80,7 @@ /** \addtogroup Configuration * @{ */ -#define FIRMWARE_VERSION "2.5 HW0.10b" +#define FIRMWARE_VERSION "2.7 HW0.10b" #define TIMED_LIGHT_PIN CUSTOM1_PIN5 #define FLOWMETER_PIN CUSTOM1_PIN1 diff --git a/esp32/src/main.cpp b/esp32/src/main.cpp index aea2784..7f4aa7a 100644 --- a/esp32/src/main.cpp +++ b/esp32/src/main.cpp @@ -13,6 +13,7 @@ /****************************************************************************** * INCLUDES ******************************************************************************/ +#define CONFIG_APP_ROLLBACK_ENABLE #include "LogDefines.h" #include "FileUtils.h" #include "TimeUtils.h" @@ -36,6 +37,12 @@ #include "driver/pcnt.h" #include "MQTTUtils.h" #include "esp_ota_ops.h" +#include "Arduino.h" + +extern "C" bool verifyRollbackLater(){ + return true; +} + #if defined(TIMED_LIGHT_PIN) #include "ulp-pwm.h" #endif @@ -141,10 +148,23 @@ void finsihedCycleSucessfully() esp_ota_img_states_t ota_state; if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) { - log(LOG_LEVEL_INFO, "Get State Partition was Successfull", LOG_BOOT_ERROR_DETECTION); + log(LOG_LEVEL_INFO, "Get State Partition was Successfull", LOG_BOOT_ERROR_DETECTION); + + if(ota_state == ESP_OTA_IMG_UNDEFINED){ + log(LOG_LEVEL_INFO, "ESP_OTA_IMG_UNDEFINED should not happen with rollback", LOG_BOOT_ERROR_DETECTION); + } + if(ota_state == ESP_OTA_IMG_NEW){ + log(LOG_LEVEL_INFO, "ESP_OTA_IMG_NEW", LOG_BOOT_ERROR_DETECTION); + } + if(ota_state == ESP_OTA_IMG_INVALID){ + log(LOG_LEVEL_INFO, "ESP_OTA_IMG_INVALID", LOG_BOOT_ERROR_DETECTION); + } + if(ota_state == ESP_OTA_IMG_VALID){ + log(LOG_LEVEL_INFO, "ESP_OTA_IMG_VALID", LOG_BOOT_ERROR_DETECTION); + } if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) { - log(LOG_LEVEL_INFO, "Diagnostics completed successfully! Marking as valid", LOG_BOOT_ERROR_DETECTION); + log(LOG_LEVEL_INFO, "ESP_OTA_IMG_PENDING_VERIFY Diagnostics completed successfully! Marking as valid", LOG_BOOT_ERROR_DETECTION); esp_ota_mark_app_valid_cancel_rollback(); } }