From 0ec4488dd17a9c9adb43ec17eb17859cbe9c5025 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Sun, 19 Oct 2025 07:08:18 +0200 Subject: [PATCH 1/2] adding function to check if a backup exists --- wled00/cfg.cpp | 4 ++++ wled00/fcn_declare.h | 2 ++ wled00/file.cpp | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 840afb51ba..b5a0574403 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -777,6 +777,10 @@ bool verifyConfig() { return validateJsonFile(s_cfg_json); } +bool configBackupExists() { + return checkBackupExists(s_cfg_json); +} + // rename config file and reboot // if the cfg file doesn't exist, such as after a reset, do nothing void resetConfig() { diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 1d81655d6d..78e97c7075 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -27,6 +27,7 @@ void IRAM_ATTR touchButtonISR(); bool backupConfig(); bool restoreConfig(); bool verifyConfig(); +bool configBackupExists(); void resetConfig(); bool deserializeConfig(JsonObject doc, bool fromFS = false); 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 backupFile(const char* filename); bool restoreFile(const char* filename); +bool checkBackupExists(const char* filename); bool validateJsonFile(const char* filename); void dumpFilesToSerial(); diff --git a/wled00/file.cpp b/wled00/file.cpp index 9f1dd62256..ba406ba3b5 100644 --- a/wled00/file.cpp +++ b/wled00/file.cpp @@ -557,6 +557,12 @@ bool restoreFile(const char* filename) { 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) { if (!WLED_FS.exists(filename)) return false; File file = WLED_FS.open(filename, "r"); From 43eb2d6f471fd896462fc5e53a04f821cc885b08 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Sun, 19 Oct 2025 07:10:05 +0200 Subject: [PATCH 2/2] check config backup as welcome page gate --- wled00/wled.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 923688106d..cd21d8d84e 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -474,7 +474,7 @@ void WLED::setup() 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; WiFi.persistent(false); WiFi.onEvent(WiFiEvent);