mirror of
https://github.com/esphome/esphome.git
synced 2025-08-09 11:57:46 +00:00
make sure ota still works without ota loaded
This commit is contained in:
parent
b49fe146ad
commit
7f2f9636f5
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#if defined(USE_ESP_IDF) && defined(USE_WEBSERVER_OTA)
|
#if defined(USE_ESP_IDF) && defined(USE_WEBSERVER_OTA)
|
||||||
#include <esp_ota_ops.h>
|
#include <esp_ota_ops.h>
|
||||||
#include <esp_task_wdt.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
@ -36,37 +35,7 @@ class IDFWebServerOTABackend {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_ESP_TASK_WDT_TIMEOUT_S < 15
|
|
||||||
// The following function takes longer than the 5 seconds timeout of WDT
|
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
esp_task_wdt_config_t wdtc;
|
|
||||||
wdtc.idle_core_mask = 0;
|
|
||||||
#if CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0
|
|
||||||
wdtc.idle_core_mask |= (1 << 0);
|
|
||||||
#endif
|
|
||||||
#if CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1
|
|
||||||
wdtc.idle_core_mask |= (1 << 1);
|
|
||||||
#endif
|
|
||||||
wdtc.timeout_ms = 15000;
|
|
||||||
wdtc.trigger_panic = false;
|
|
||||||
esp_task_wdt_reconfigure(&wdtc);
|
|
||||||
#else
|
|
||||||
esp_task_wdt_init(15, false);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
esp_err_t err = esp_ota_begin(this->partition_, 0, &this->update_handle_);
|
esp_err_t err = esp_ota_begin(this->partition_, 0, &this->update_handle_);
|
||||||
|
|
||||||
#if CONFIG_ESP_TASK_WDT_TIMEOUT_S < 15
|
|
||||||
// Set the WDT back to the configured timeout
|
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
wdtc.timeout_ms = CONFIG_ESP_TASK_WDT_TIMEOUT_S * 1000;
|
|
||||||
esp_task_wdt_reconfigure(&wdtc);
|
|
||||||
#else
|
|
||||||
esp_task_wdt_init(CONFIG_ESP_TASK_WDT_TIMEOUT_S, false);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
esp_ota_abort(this->update_handle_);
|
esp_ota_abort(this->update_handle_);
|
||||||
this->update_handle_ = 0;
|
this->update_handle_ = 0;
|
||||||
@ -102,6 +71,13 @@ class IDFWebServerOTABackend {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void abort() {
|
||||||
|
if (this->update_handle_ != 0) {
|
||||||
|
esp_ota_abort(this->update_handle_);
|
||||||
|
this->update_handle_ = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
esp_ota_handle_t update_handle_{0};
|
esp_ota_handle_t update_handle_{0};
|
||||||
const esp_partition_t *partition_{nullptr};
|
const esp_partition_t *partition_{nullptr};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user