OTA
This commit is contained in:
parent
bafb0e8e9d
commit
7d166f3900
3 changed files with 22 additions and 5 deletions
|
@ -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())){
|
||||
|
|
13
src/main.cpp
13
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
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
[env:mcu-esp32s-ota]
|
||||
extra_scripts = platformio_upload.py
|
||||
upload_protocol = custom
|
||||
custom_upload_url = http://admin:admin@remotehost/update
|
||||
custom_username = "admin"
|
||||
custom_password = "b5JvsPZdTsb@MB66kVR2"
|
||||
custom_upload_url = "http:/remotehost"
|
Loading…
Reference in a new issue