diff --git a/data/igate_conf.json b/data/igate_conf.json index 98766f4..46cb1b3 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -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 - } + } } \ No newline at end of file diff --git a/src/configuration.cpp b/src/configuration.cpp index 2d90496..66abfab 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -64,6 +64,9 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { syslog.port = data["syslog"]["port"].as(); bme.active = data["bme"]["active"].as(); + + ota.username = data["ota"]["username"].as(); + ota.password = data["ota"]["password"].as(); configFile.close(); } diff --git a/src/configuration.h b/src/configuration.h index 6d439de..0bb90cd 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -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(); diff --git a/src/utils.cpp b/src/utils.cpp index 0c50e7a..adf60b5 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -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!"); }