Skip to content

Commit 59326c6

Browse files
authored
provide OTA defaults (#77)
(cherry picked from commit 438b258)
1 parent bcfeef8 commit 59326c6

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

lib/framework/OTASettingsService.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,9 @@ void OTASettingsService::onConfigUpdated() {
2525
}
2626

2727
void OTASettingsService::readFromJsonObject(JsonObject& root) {
28-
_enabled = root["enabled"];
29-
_port = root["port"];
28+
_enabled = root["enabled"] | DEFAULT_OTA_ENABLED;
29+
_port = root["port"] | DEFAULT_OTA_PORT;
3030
_password = root["password"] | DEFAULT_OTA_PASSWORD;
31-
32-
// provide defaults
33-
if (_port < 0) {
34-
_port = DEFAULT_OTA_PORT;
35-
}
3631
}
3732

3833
void OTASettingsService::writeToJsonObject(JsonObject& root) {

lib/framework/OTASettingsService.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// Emergency defaults
1616
#define DEFAULT_OTA_PORT 8266
1717
#define DEFAULT_OTA_PASSWORD "esp-react"
18+
#define DEFAULT_OTA_ENABLED true
1819

1920
#define OTA_SETTINGS_FILE "/config/otaSettings.json"
2021
#define OTA_SETTINGS_SERVICE_PATH "/rest/otaSettings"

0 commit comments

Comments
 (0)