From cb6482921036e71f453fa789050875e171b3afef Mon Sep 17 00:00:00 2001 From: Martijn Scheepers Date: Mon, 21 Nov 2016 10:05:41 +0100 Subject: [PATCH] HTTP update server can handle flash and spiffs files (spiffs size limited by free space) --- .../src/ESP8266HTTPUpdateServer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp index 6ef4f93ae7..799fdd19fc 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp @@ -8,12 +8,19 @@ const char* ESP8266HTTPUpdateServer::_serverIndex = R"(
+ - + +
+
+ + +
)"; const char* ESP8266HTTPUpdateServer::_failedResponse = R"(Update Failed!)"; const char* ESP8266HTTPUpdateServer::_successResponse = "Update Success! Rebooting..."; +int _command; ESP8266HTTPUpdateServer::ESP8266HTTPUpdateServer(bool serial_debug) { @@ -41,6 +48,7 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const char * path, _server->on(path, HTTP_POST, [&](){ if(!_authenticated) return _server->requestAuthentication(); + _command = _server->arg("cmd").toInt(); _server->send(200, "text/html", Update.hasError() ? _failedResponse : _successResponse); ESP.restart(); },[&](){ @@ -62,7 +70,7 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const char * path, 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 + if(!Update.begin(maxSketchSpace, _command)){//start with max available size if (_serial_output) Update.printError(Serial); } } else if(_authenticated && upload.status == UPLOAD_FILE_WRITE){