diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp index b53f0fa749..c2a1919083 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.cpp @@ -8,9 +8,15 @@ static const char serverIndex[] PROGMEM = - R"(<html><body><form method='POST' action='' enctype='multipart/form-data'> + R"(<html><body><form method='POST' action='?cmd=0' enctype='multipart/form-data'> + <input type='hidden' name='cmd' value='0'> <input type='file' name='update'> - <input type='submit' value='Update'> + <input type='submit' value='Update Flash'> + </form> + <form method='POST' action='?cmd=100' enctype='multipart/form-data'> + <input type='hidden' name='cmd' value='100'> + <input type='file' name='update'> + <input type='submit' value='Update Spiffs'> </form> </body></html>)"; static const char successResponse[] PROGMEM = @@ -44,7 +50,8 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const String& path return _server->requestAuthentication(); if (Update.hasError()) { _server->send(200, F("text/html"), String(F("Update error: ")) + _updaterError); - } else { + } else { + _command = _server->arg("cmd").toInt(); _server->client().setNoDelay(true); _server->send_P(200, PSTR("text/html"), successResponse); delay(100); @@ -71,8 +78,9 @@ void ESP8266HTTPUpdateServer::setup(ESP8266WebServer *server, const String& path 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 + uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; + _command = _server->arg("cmd").toInt(); + if(!Update.begin(maxSketchSpace, _command)){//start with max available size _setUpdaterError(); } } else if(_authenticated && upload.status == UPLOAD_FILE_WRITE && !_updaterError.length()){ diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.h index a0faa46758..aa75385b1d 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.h @@ -41,6 +41,7 @@ class ESP8266HTTPUpdateServer String _password; bool _authenticated; String _updaterError; + int _command; };