mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 20:56:37 +00:00
Add Firmware Upgrade From URL #300
This commit is contained in:
parent
666c7d10b6
commit
e3d90d9579
@ -1,7 +1,6 @@
|
||||
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
//#include "webServer.h"
|
||||
#include "hasplib.h"
|
||||
#include "ArduinoLog.h"
|
||||
|
||||
@ -2021,7 +2020,26 @@ static void webHandleFirmware()
|
||||
{
|
||||
if(!httpIsAuthenticated(F("firmware"))) return;
|
||||
|
||||
{ // Send Content
|
||||
if(webServer.method() == HTTP_POST && webServer.hasArg(PSTR("url"))) {
|
||||
String url = webServer.arg(PSTR("url"));
|
||||
{
|
||||
String httpMessage((char*)0);
|
||||
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||
httpMessage += F("<h1>");
|
||||
httpMessage += haspDevice.get_hostname();
|
||||
httpMessage += F("</h1><hr>");
|
||||
|
||||
httpMessage += F("<p><b>ESP update</b></p>Updating ESP firmware from: ");
|
||||
httpMessage += url;
|
||||
|
||||
webSendHeader(haspDevice.get_hostname(), httpMessage.length(), true);
|
||||
webServer.sendContent(httpMessage);
|
||||
}
|
||||
|
||||
LOG_TRACE(TAG_HTTP, F("Updating ESP firmware from: %s"), url.c_str());
|
||||
dispatch_web_update(NULL, url.c_str(), TAG_HTTP);
|
||||
} else {
|
||||
// Send Firmware page
|
||||
String httpMessage((char*)0);
|
||||
httpMessage.reserve(HTTP_PAGE_SIZE);
|
||||
httpMessage += F("<h1>");
|
||||
@ -2047,9 +2065,9 @@ static void webHandleFirmware()
|
||||
httpMessage += F("<button type='submit' name='save' value='debug'>" D_HTTP_UPDATE_FIRMWARE "</button>");
|
||||
httpMessage += F("</form></div>");
|
||||
|
||||
/* Update from URL
|
||||
// Update from URL
|
||||
// Form
|
||||
httpMessage += F("<div class='container'><form method='POST' action='/espfirmware'>");
|
||||
httpMessage += F("<div class='container'><form method='POST' action='/firmware'>");
|
||||
|
||||
// URL
|
||||
httpMessage +=
|
||||
@ -2059,7 +2077,6 @@ static void webHandleFirmware()
|
||||
// Submit & End Form
|
||||
httpMessage += F("<button type='submit' name='save' value='debug'>Update from URL</button>");
|
||||
httpMessage += F("</form></div>");
|
||||
*/
|
||||
|
||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user