Skip to content

Commit b60313e

Browse files
authored
Merge pull request #5012 from DedeHai/improved_welcompage_check
Improvement to "Welcome Page" check
2 parents 1fff61b + 43eb2d6 commit b60313e

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

wled00/cfg.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ bool verifyConfig() {
777777
return validateJsonFile(s_cfg_json);
778778
}
779779

780+
bool configBackupExists() {
781+
return checkBackupExists(s_cfg_json);
782+
}
783+
780784
// rename config file and reboot
781785
// if the cfg file doesn't exist, such as after a reset, do nothing
782786
void resetConfig() {

wled00/fcn_declare.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ void IRAM_ATTR touchButtonISR();
2727
bool backupConfig();
2828
bool restoreConfig();
2929
bool verifyConfig();
30+
bool configBackupExists();
3031
void resetConfig();
3132
bool deserializeConfig(JsonObject doc, bool fromFS = false);
3233
bool deserializeConfigFromFS();
@@ -103,6 +104,7 @@ inline bool readObjectFromFile(const String &file, const char* key, JsonDocument
103104
bool copyFile(const char* src_path, const char* dst_path);
104105
bool backupFile(const char* filename);
105106
bool restoreFile(const char* filename);
107+
bool checkBackupExists(const char* filename);
106108
bool validateJsonFile(const char* filename);
107109
void dumpFilesToSerial();
108110

wled00/file.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,12 @@ bool restoreFile(const char* filename) {
557557
return false;
558558
}
559559

560+
bool checkBackupExists(const char* filename) {
561+
char backupname[32];
562+
snprintf_P(backupname, sizeof(backupname), s_backup_fmt, filename + 1); // skip leading '/' in filename
563+
return WLED_FS.exists(backupname);
564+
}
565+
560566
bool validateJsonFile(const char* filename) {
561567
if (!WLED_FS.exists(filename)) return false;
562568
File file = WLED_FS.open(filename, "r");

wled00/wled.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ void WLED::setup()
474474

475475
if (needsCfgSave) serializeConfigToFS(); // usermods required new parameters; need to wait for strip to be initialised #4752
476476

477-
if (strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) == 0)
477+
if (strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) == 0 && !configBackupExists())
478478
showWelcomePage = true;
479479
WiFi.persistent(false);
480480
WiFi.onEvent(WiFiEvent);

0 commit comments

Comments
 (0)