diff --git a/components/aes67_ota/aes67_ota.c b/components/aes67_ota/aes67_ota.c index de03cb8..81d6403 100644 --- a/components/aes67_ota/aes67_ota.c +++ b/components/aes67_ota/aes67_ota.c @@ -46,13 +46,16 @@ static esp_err_t ota_get(httpd_req_t *req) cJSON_AddStringToObject(o, "build_date", built); cJSON_AddStringToObject(o, "idf", app->idf_ver); cJSON_AddStringToObject(o, "running", run->label); + // Only a bootable image counts as "previous" (not a half-written upload or a rolled-back + // one). With two slots, rollback is possible exactly when the other slot is bootable. + bool can_rollback = esp_ota_check_rollback_is_possible(); esp_app_desc_t prev; - if (other && esp_ota_get_partition_description(other, &prev) == ESP_OK) { + if (can_rollback && other && esp_ota_get_partition_description(other, &prev) == ESP_OK) { cJSON_AddStringToObject(o, "previous", other->label); cJSON_AddStringToObject(o, "previous_version", prev.version); } cJSON_AddBoolToObject(o, "pending_verify", is_pending()); - cJSON_AddBoolToObject(o, "can_rollback", esp_ota_check_rollback_is_possible()); + cJSON_AddBoolToObject(o, "can_rollback", can_rollback); esp_err_t err = web_send_json(req, o); cJSON_Delete(o); return err;