diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h index b543073f44..6761177a0a 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h @@ -3,6 +3,9 @@ #include #include #include +#include +#include +#include #include "StreamString.h" #include "ESP8266HTTPUpdateServer.h" @@ -10,11 +13,25 @@ namespace esp8266httpupdateserver { using namespace esp8266webserver; static const char serverIndex[] PROGMEM = - R"(
- - -
- )"; + R"( + + + + + + +
+ Firmware:
+ + +
+
+ FileSystem:
+ + +
+ + )"; static const char successResponse[] PROGMEM = "Update Success! Rebooting..."; @@ -75,9 +92,18 @@ void ESP8266HTTPUpdateServerTemplate::setup(ESP8266WebServerTemplate WiFiUDP::stopAll(); if (_serial_output) Serial.printf("Update: %s\n", upload.filename.c_str()); - uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; - if(!Update.begin(maxSketchSpace)){//start with max available size - _setUpdaterError(); + if (upload.name == "filesystem") { + size_t fsSize = ((size_t) &_FS_end - (size_t) &_FS_start); + SPIFFS.end(); + LittleFS.end(); + if (!Update.begin(fsSize, U_FS)){//start with max available size + if (_serial_output) Update.printError(Serial); + } + } else { + uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; + if (!Update.begin(maxSketchSpace, U_FLASH)){//start with max available size + _setUpdaterError(); + } } } else if(_authenticated && upload.status == UPLOAD_FILE_WRITE && !_updaterError.length()){ if (_serial_output) Serial.printf(".");