diff --git a/include/mainwebserver.h b/include/mainwebserver.h index 76bbecb..503df35 100644 --- a/include/mainwebserver.h +++ b/include/mainwebserver.h @@ -40,6 +40,15 @@ class MainWebServerClass{ request->send(SPIFFS, "/index.html", String(), false, processor); }); + _server->on("/version", HTTP_GET, [&](AsyncWebServerRequest *request){ + if(_authRequired){ + if(!request->authenticate(_username.c_str(), _password.c_str())){ + return request->requestAuthentication(); + } + } + request->send(200, "application/json", "{\"version\":\"3.1.8\"}"); + }); + _server->onNotFound([&](AsyncWebServerRequest *request){ if(_authRequired){ if(!request->authenticate(_username.c_str(), _password.c_str())){ diff --git a/src/main.cpp b/src/main.cpp index 5c65b0e..7103d45 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -158,7 +158,6 @@ void setup() { #endif #ifdef TINANCE2_BACKEND - tinance2_http.setReuse(true); #endif #ifdef WEBHOOKS @@ -180,9 +179,15 @@ void setup() { return; } - #ifdef WEB_OTA_UPDATE - ElegantOTA.begin(&server, http_username, http_password); - #endif + #ifdef WEB_OTA_UPDATE + ElegantOTA.setAutoReboot(false); + ElegantOTA.onEnd([](bool success) { + if (success) { + ESP.restart(); + } + }); + ElegantOTA.begin(&server, http_username, http_password); + #endif #endif diff --git a/upload_params.ini.dist b/upload_params.ini.dist index f56f4ce..720b874 100644 --- a/upload_params.ini.dist +++ b/upload_params.ini.dist @@ -1,3 +1,6 @@ [env:mcu-esp32s-ota] +extra_scripts = platformio_upload.py upload_protocol = custom -custom_upload_url = http://admin:admin@remotehost/update \ No newline at end of file +custom_username = "admin" +custom_password = "b5JvsPZdTsb@MB66kVR2" +custom_upload_url = "http:/remotehost" \ No newline at end of file