diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.cpp index afee027..b2e8782 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.cpp @@ -51,6 +51,7 @@ void ESPMegaWebServer::begin() auto bindedOtaRequestHandler = std::bind(&ESPMegaWebServer::otaRequestHandler, this, std::placeholders::_1); auto bindedOtaUploadHandler = std::bind(&ESPMegaWebServer::otaUploadHandler, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6); this->server->on("/ota_update", HTTP_POST, bindedOtaRequestHandler, bindedOtaUploadHandler); + this->server->on("/reboot", HTTP_GET, std::bind(&ESPMegaWebServer::rebootHandler, this, std::placeholders::_1)); } /** @@ -529,4 +530,19 @@ bool ESPMegaWebServer::checkAuthentication(AsyncWebServerRequest *request) { return false; } return true; +} + +/** + * @brief Handle HTTP requests to the reboot (/reboot) page + * + * @param request The AsyncWebServerRequest object + */ +void ESPMegaWebServer::rebootHandler(AsyncWebServerRequest *request) +{ + if (!request->authenticate(this->webUsername, this->webPassword)) + { + return request->requestAuthentication(); + } + request->send(200, "text/plain", "Rebooting ESPMega PRO..."); + esp_restart(); } \ No newline at end of file diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.hpp index 222e504..6559b67 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaWebServer.hpp @@ -56,4 +56,5 @@ class ESPMegaWebServer void otaRequestHandler(AsyncWebServerRequest *request); void otaUploadHandler(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final); void restAPIHandler(AsyncWebServerRequest *request); + void rebootHandler(AsyncWebServerRequest *request); }; \ No newline at end of file diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/html/ota.html b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/html/ota.html index 4cd1b1f..5a6a1f5 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/html/ota.html +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/html/ota.html @@ -42,6 +42,9 @@

+
+

Device Control

+ SIWAT SYSTEM 2023