Merge pull request #5012 from DedeHai/improved_welcompage_check

Improvement to "Welcome Page" check
This commit is contained in:
Will Tatam 2025-10-22 20:40:06 +01:00 committed by GitHub
commit b60313e1f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 1 deletions

View File

@ -777,6 +777,10 @@ bool verifyConfig() {
return validateJsonFile(s_cfg_json); return validateJsonFile(s_cfg_json);
} }
bool configBackupExists() {
return checkBackupExists(s_cfg_json);
}
// rename config file and reboot // rename config file and reboot
// if the cfg file doesn't exist, such as after a reset, do nothing // if the cfg file doesn't exist, such as after a reset, do nothing
void resetConfig() { void resetConfig() {

View File

@ -27,6 +27,7 @@ void IRAM_ATTR touchButtonISR();
bool backupConfig(); bool backupConfig();
bool restoreConfig(); bool restoreConfig();
bool verifyConfig(); bool verifyConfig();
bool configBackupExists();
void resetConfig(); void resetConfig();
bool deserializeConfig(JsonObject doc, bool fromFS = false); bool deserializeConfig(JsonObject doc, bool fromFS = false);
bool deserializeConfigFromFS(); bool deserializeConfigFromFS();
@ -103,6 +104,7 @@ inline bool readObjectFromFile(const String &file, const char* key, JsonDocument
bool copyFile(const char* src_path, const char* dst_path); bool copyFile(const char* src_path, const char* dst_path);
bool backupFile(const char* filename); bool backupFile(const char* filename);
bool restoreFile(const char* filename); bool restoreFile(const char* filename);
bool checkBackupExists(const char* filename);
bool validateJsonFile(const char* filename); bool validateJsonFile(const char* filename);
void dumpFilesToSerial(); void dumpFilesToSerial();

View File

@ -557,6 +557,12 @@ bool restoreFile(const char* filename) {
return false; return false;
} }
bool checkBackupExists(const char* filename) {
char backupname[32];
snprintf_P(backupname, sizeof(backupname), s_backup_fmt, filename + 1); // skip leading '/' in filename
return WLED_FS.exists(backupname);
}
bool validateJsonFile(const char* filename) { bool validateJsonFile(const char* filename) {
if (!WLED_FS.exists(filename)) return false; if (!WLED_FS.exists(filename)) return false;
File file = WLED_FS.open(filename, "r"); File file = WLED_FS.open(filename, "r");

View File

@ -474,7 +474,7 @@ void WLED::setup()
if (needsCfgSave) serializeConfigToFS(); // usermods required new parameters; need to wait for strip to be initialised #4752 if (needsCfgSave) serializeConfigToFS(); // usermods required new parameters; need to wait for strip to be initialised #4752
if (strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) == 0) if (strcmp(multiWiFi[0].clientSSID, DEFAULT_CLIENT_SSID) == 0 && !configBackupExists())
showWelcomePage = true; showWelcomePage = true;
WiFi.persistent(false); WiFi.persistent(false);
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);