uniq message for ESP OTA state

This commit is contained in:
Ollo 2024-04-01 11:48:29 +02:00
parent c85f69c545
commit 3764183944
2 changed files with 13 additions and 9 deletions

View File

@ -46,5 +46,10 @@
#define LOG_SLEEP_CYCLE 102
#define LOG_MISSING_PUMP -4
#define LOG_BOOT_ERROR_DETECTION 10000
#define LOG_BOOT_ERROR_IMG_UNDEFINED (LOG_BOOT_ERROR_DETECTION + 1)
#define LOG_BOOT_ERROR_IMG_NEW (LOG_BOOT_ERROR_DETECTION + 2)
#define LOG_BOOT_ERROR_IMG_INVALID (LOG_BOOT_ERROR_DETECTION + 3)
#define LOG_BOOT_ERROR_IMG_VALID (LOG_BOOT_ERROR_DETECTION + 4)
#define LOG_BOOT_ERROR_IMG_PENDING_VERIFY (LOG_BOOT_ERROR_DETECTION + 5)
#define LOG_SOLAR_CHARGER_MISSING 300
#endif

View File

@ -151,23 +151,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_DEBUG, "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);
log(LOG_LEVEL_DEBUG, "ESP_OTA_IMG_UNDEFINED should not happen with rollback", LOG_BOOT_ERROR_IMG_UNDEFINED);
}
if(ota_state == ESP_OTA_IMG_NEW){
log(LOG_LEVEL_INFO, "ESP_OTA_IMG_NEW", LOG_BOOT_ERROR_DETECTION);
log(LOG_LEVEL_DEBUG, "ESP_OTA_IMG_NEW", LOG_BOOT_ERROR_IMG_NEW);
}
if(ota_state == ESP_OTA_IMG_INVALID){
log(LOG_LEVEL_INFO, "ESP_OTA_IMG_INVALID", LOG_BOOT_ERROR_DETECTION);
log(LOG_LEVEL_DEBUG, "ESP_OTA_IMG_INVALID", LOG_BOOT_ERROR_IMG_INVALID);
}
if(ota_state == ESP_OTA_IMG_VALID){
log(LOG_LEVEL_INFO, "ESP_OTA_IMG_VALID", LOG_BOOT_ERROR_DETECTION);
log(LOG_LEVEL_DEBUG, "ESP_OTA_IMG_VALID", LOG_BOOT_ERROR_IMG_VALID);
}
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY)
{
log(LOG_LEVEL_INFO, "ESP_OTA_IMG_PENDING_VERIFY Diagnostics completed successfully! Marking as valid", LOG_BOOT_ERROR_DETECTION);
log(LOG_LEVEL_DEBUG, "ESP_OTA_IMG_PENDING_VERIFY Diagnostics completed successfully! Marking as valid", LOG_BOOT_ERROR_IMG_PENDING_VERIFY);
esp_ota_mark_app_valid_cancel_rollback();
}
}
@ -175,11 +175,11 @@ void finsihedCycleSucessfully()
void espDeepSleep(bool afterPump = false)
{
/* download mode or normal operation should restore device status*/
finsihedCycleSucessfully();
if (mDownloadMode)
{
log(LOG_LEVEL_DEBUG, "abort deepsleep, DownloadMode active", LOG_DEBUG_CODE);
// if we manage to get to the download mode, the device can be restored
finsihedCycleSucessfully();
return;
}
if (aliveWasRead())
@ -239,7 +239,6 @@ void espDeepSleep(bool afterPump = false)
}
}
finsihedCycleSucessfully();
/* sleep always at least one second */
if (secondsToSleep < 0) {
secondsToSleep = 1;