provide OTA defaults (#77)

(cherry picked from commit 438b2585463e902b6e9710ae26c3aea4fe64928d)
This commit is contained in:
rjwats 2020-01-08 23:02:36 +00:00 committed by GitHub
parent bcfeef8004
commit 59326c6426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -25,14 +25,9 @@ void OTASettingsService::onConfigUpdated() {
}
void OTASettingsService::readFromJsonObject(JsonObject& root) {
_enabled = root["enabled"];
_port = root["port"];
_enabled = root["enabled"] | DEFAULT_OTA_ENABLED;
_port = root["port"] | DEFAULT_OTA_PORT;
_password = root["password"] | DEFAULT_OTA_PASSWORD;
// provide defaults
if (_port < 0) {
_port = DEFAULT_OTA_PORT;
}
}
void OTASettingsService::writeToJsonObject(JsonObject& root) {

View File

@ -15,6 +15,7 @@
// Emergency defaults
#define DEFAULT_OTA_PORT 8266
#define DEFAULT_OTA_PASSWORD "esp-react"
#define DEFAULT_OTA_ENABLED true
#define OTA_SETTINGS_FILE "/config/otaSettings.json"
#define OTA_SETTINGS_SERVICE_PATH "/rest/otaSettings"