Fix firmware download

This commit is contained in:
jpirnay
2026-04-21 17:16:19 +02:00
parent b7928a86e3
commit df171560db
4 changed files with 45 additions and 2 deletions
+8 -1
View File
@@ -52,14 +52,18 @@ esp_err_t event_handler(esp_http_client_event_t* event) {
} /* namespace */
OtaUpdater::OtaUpdaterError OtaUpdater::checkForUpdate() {
// Reset globals so retries start clean regardless of previous outcome
local_buf = nullptr;
output_len = 0;
JsonDocument filter;
esp_err_t esp_err;
JsonDocument doc;
esp_http_client_config_t client_config = {
.url = latestReleaseUrl,
.event_handler = event_handler,
.timeout_ms = 10000,
.event_handler = event_handler,
/* Default HTTP client buffer size 512 byte only */
.buffer_size = 8192,
.buffer_size_tx = 8192,
@@ -282,6 +286,9 @@ OtaUpdater::OtaUpdaterError OtaUpdater::performInstallUpdateStep() {
if (finish_err != ESP_OK) {
LOG_ERR("OTA", "esp_https_ota_finish Failed: %s", esp_err_to_name(finish_err));
cleanupUpdate();
if (finish_err == ESP_ERR_OTA_VALIDATE_FAILED) {
return VALIDATE_FAILED;
}
return INTERNAL_UPDATE_ERROR;
}
+4 -1
View File
@@ -3,7 +3,9 @@
#include <functional>
#include <string>
#include "esp_https_ota.h"
// Avoid pulling in esp_https_ota.h here — it transitively includes lwip/sockets.h
// which defines INADDR_NONE as a numeric macro, conflicting with Arduino's IPAddress.h.
typedef void* esp_https_ota_handle_t;
class OtaUpdater {
bool updateAvailable = false;
@@ -27,6 +29,7 @@ class OtaUpdater {
OOM_ERROR,
UPDATE_CANCELLED,
UPDATE_IN_PROGRESS,
VALIDATE_FAILED,
};
size_t getOtaSize() const { return otaSize; }