Skip to content

Commit a6c869c

Browse files
authored
Merge branch 'wled:0_15_x' into 0_15_x
2 parents 9aa3c68 + a25fc6e commit a6c869c

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

wled00/cfg.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -639,16 +639,16 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
639639

640640
static const char s_cfg_json[] PROGMEM = "/cfg.json";
641641

642-
void deserializeConfigFromFS() {
643-
bool success = deserializeConfigSec();
642+
bool deserializeConfigFromFS() {
643+
[[maybe_unused]] bool success = deserializeConfigSec();
644644
#ifdef WLED_ADD_EEPROM_SUPPORT
645645
if (!success) { //if file does not exist, try reading from EEPROM
646646
deEEPSettings();
647-
return;
647+
return true;
648648
}
649649
#endif
650650

651-
if (!requestJSONBufferLock(1)) return;
651+
if (!requestJSONBufferLock(1)) return false;
652652

653653
DEBUG_PRINTLN(F("Reading settings from /cfg.json..."));
654654

@@ -658,17 +658,11 @@ void deserializeConfigFromFS() {
658658
#ifdef WLED_ADD_EEPROM_SUPPORT
659659
deEEPSettings();
660660
#endif
661-
662-
// save default values to /cfg.json
663-
// call readFromConfig() with an empty object so that usermods can initialize to defaults prior to saving
664-
JsonObject empty = JsonObject();
665-
UsermodManager::readFromConfig(empty);
666-
serializeConfig();
667661
// init Ethernet (in case default type is set at compile time)
668662
#ifdef WLED_USE_ETHERNET
669663
WLED::instance().initEthernet();
670664
#endif
671-
return;
665+
return true; // config does not exist (we will need to save it once strip is initialised)
672666
}
673667

674668
// NOTE: This routine deserializes *and* applies the configuration
@@ -677,7 +671,7 @@ void deserializeConfigFromFS() {
677671
bool needsSave = deserializeConfig(root, true);
678672
releaseJSONBufferLock();
679673

680-
if (needsSave) serializeConfig(); // usermods required new parameters
674+
return needsSave;
681675
}
682676

683677
void serializeConfig() {

wled00/fcn_declare.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void IRAM_ATTR touchButtonISR();
2525

2626
//cfg.cpp
2727
bool deserializeConfig(JsonObject doc, bool fromFS = false);
28-
void deserializeConfigFromFS();
28+
bool deserializeConfigFromFS();
2929
bool deserializeConfigSec();
3030
void serializeConfig();
3131
void serializeConfigSec();

wled00/wled.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ void WLED::setup()
419419
multiWiFi.push_back(WiFiConfig(CLIENT_SSID,CLIENT_PASS)); // initialise vector with default WiFi
420420

421421
DEBUG_PRINTLN(F("Reading config"));
422-
deserializeConfigFromFS();
422+
bool needsCfgSave = deserializeConfigFromFS();
423423
DEBUG_PRINTF_P(PSTR("heap %u\n"), ESP.getFreeHeap());
424424

425425
#if defined(STATUSLED) && STATUSLED>=0
@@ -439,6 +439,8 @@ void WLED::setup()
439439
UsermodManager::setup();
440440
DEBUG_PRINTF_P(PSTR("heap %u\n"), ESP.getFreeHeap());
441441

442+
if (needsCfgSave) serializeConfig(); // usermods required new parameters; need to wait for strip to be initialised #4752
443+
442444
if (strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) == 0)
443445
showWelcomePage = true;
444446
WiFi.persistent(false);

0 commit comments

Comments
 (0)