From 3070d75d07cafe8cbf35d795f036dd23db98bc30 Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Thu, 20 Feb 2025 01:08:48 +0100 Subject: [PATCH] feat: update version to 1.2.59 and enhance OTA upload handling --- platformio.ini | 2 +- src/ota.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 9f28f4a..84bab56 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,7 +9,7 @@ ; https://docs.platformio.org/page/projectconf.html [common] -version = "1.2.58" +version = "1.2.59" [env:esp32dev] platform = espressif32 diff --git a/src/ota.cpp b/src/ota.cpp index bae464e..8f6b9eb 100644 --- a/src/ota.cpp +++ b/src/ota.cpp @@ -16,15 +16,19 @@ void handleOTAUpload(AsyncWebServerRequest *request, String filename, size_t ind return; } - if (!Update.begin(contentLength)) { + // Determine if this is a full image (firmware + SPIFFS) or just firmware + bool isFullImage = (contentLength > 0x3D0000); // SPIFFS starts at 0x3D0000 + + if (!Update.begin(contentLength, isFullImage ? U_FLASH : U_SPIFFS)) { Serial.printf("Not enough space: %u required\n", contentLength); request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"Not enough space available\"}"); return; } - Serial.println("Update started"); + Serial.println(isFullImage ? "Full image update started" : "Firmware update started"); } - + + // Write chunk to flash if (Update.write(data, len) != len) { Update.printError(Serial); request->send(400, "application/json", "{\"status\":\"error\",\"message\":\"Error writing update\"}");