Save config.json with default values on initial boot (#2854)
* Save config.json with default values on first boot * Init Ethernet on first boot
This commit is contained in:
parent
22d7d2c1f6
commit
e1d7d9511f
@ -555,11 +555,21 @@ void deserializeConfigFromFS() {
|
||||
DEBUG_PRINTLN(F("Reading settings from /cfg.json..."));
|
||||
|
||||
success = readObjectFromFile("/cfg.json", nullptr, &doc);
|
||||
if (!success) { //if file does not exist, try reading from EEPROM
|
||||
if (!success) { // if file does not exist, optionally try reading from EEPROM and then save defaults to FS
|
||||
releaseJSONBufferLock();
|
||||
#ifdef WLED_ADD_EEPROM_SUPPORT
|
||||
deEEPSettings();
|
||||
#endif
|
||||
releaseJSONBufferLock();
|
||||
|
||||
// save default values to /cfg.json
|
||||
// call readFromConfig() with an empty object so that usermods can initialize to defaults prior to saving
|
||||
JsonObject empty = JsonObject();
|
||||
usermods.readFromConfig(empty);
|
||||
serializeConfig();
|
||||
// init Ethernet (in case default type is set at compile time)
|
||||
#ifdef WLED_USE_ETHERNET
|
||||
WLED::instance().initEthernet();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -568,7 +578,7 @@ void deserializeConfigFromFS() {
|
||||
bool needsSave = deserializeConfig(doc.as<JsonObject>(), true);
|
||||
releaseJSONBufferLock();
|
||||
|
||||
if (needsSave) serializeConfig(); // usermods required new prameters
|
||||
if (needsSave) serializeConfig(); // usermods required new parameters
|
||||
}
|
||||
|
||||
void serializeConfig() {
|
||||
|
@ -467,11 +467,5 @@ void deEEPSettings() {
|
||||
EEPROM.begin(EEPSIZE);
|
||||
loadSettingsFromEEPROM();
|
||||
EEPROM.end();
|
||||
|
||||
//call readFromConfig() with an empty object so that usermods can initialize to defaults prior to saving
|
||||
JsonObject empty = JsonObject();
|
||||
usermods.readFromConfig(empty);
|
||||
|
||||
serializeConfig();
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user