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);
|
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){
|
_server->onNotFound([&](AsyncWebServerRequest *request){
|
||||||
if(_authRequired){
|
if(_authRequired){
|
||||||
if(!request->authenticate(_username.c_str(), _password.c_str())){
|
if(!request->authenticate(_username.c_str(), _password.c_str())){
|
||||||
|
|
13
src/main.cpp
13
src/main.cpp
|
@ -158,7 +158,6 @@ void setup() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TINANCE2_BACKEND
|
#ifdef TINANCE2_BACKEND
|
||||||
tinance2_http.setReuse(true);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WEBHOOKS
|
#ifdef WEBHOOKS
|
||||||
|
@ -180,9 +179,15 @@ void setup() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WEB_OTA_UPDATE
|
#ifdef WEB_OTA_UPDATE
|
||||||
ElegantOTA.begin(&server, http_username, http_password);
|
ElegantOTA.setAutoReboot(false);
|
||||||
#endif
|
ElegantOTA.onEnd([](bool success) {
|
||||||
|
if (success) {
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ElegantOTA.begin(&server, http_username, http_password);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
[env:mcu-esp32s-ota]
|
[env:mcu-esp32s-ota]
|
||||||
|
extra_scripts = platformio_upload.py
|
||||||
upload_protocol = custom
|
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