OTA security added

This commit is contained in:
richonguzman 2023-08-28 22:08:00 -04:00
parent 310b3afe59
commit a396c3a9bf
4 changed files with 25 additions and 5 deletions

View file

@ -46,12 +46,16 @@
"server": "192.168.0.100",
"port": 514
},
"bme": {
"active": false
},
"ota": {
"username":"richon",
"password": "totoro"
},
"other": {
"beaconInterval": 15,
"rememberStationTime": 30,
"sendBatteryVoltage": false
},
"bme": {
"active": false
}
}
}

View file

@ -64,6 +64,9 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
syslog.port = data["syslog"]["port"].as<int>();
bme.active = data["bme"]["active"].as<bool>();
ota.username = data["ota"]["username"].as<String>();
ota.password = data["ota"]["password"].as<String>();
configFile.close();
}

View file

@ -58,6 +58,14 @@ public:
bool active;
};
class OTA {
public:
String username;
String password;
};
class Configuration {
public:
@ -74,6 +82,7 @@ public:
Display display;
SYSLOG syslog;
BME bme;
OTA ota;
Configuration();

View file

@ -276,7 +276,11 @@ void startOTAServer() {
request->send(SPIFFS, "/index2.html", "text/html");
});
AsyncElegantOTA.begin(&server);
if (Config.ota.username != "" && Config.ota.password != "") {
AsyncElegantOTA.begin(&server, Config.ota.username.c_str(), Config.ota.password.c_str());
} else {
AsyncElegantOTA.begin(&server);
}
server.begin();
Serial.println("init : OTA Server ... done!");
}