From cbeac02edc70ec560288725999f1512e34340d72 Mon Sep 17 00:00:00 2001 From: Pablo2048 Date: Tue, 24 Aug 2021 17:09:21 +0200 Subject: [PATCH] Zalohovani stare konfigurace --- src/WiFiConfig.cpp | 4 ++++ src/WiFiConfig.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/WiFiConfig.cpp b/src/WiFiConfig.cpp index d2c78c4..f3c8342 100644 --- a/src/WiFiConfig.cpp +++ b/src/WiFiConfig.cpp @@ -471,6 +471,10 @@ void WiFiConfig::_handleSetAP(AsyncWebServerRequest *request) if (str.length() > 0) { uint8_t mode; + if (USEDFS.exists(F(WIFICFG_OLD_FILE))) { + USEDFS.remove(F(WIFICFG_OLD_FILE)); + } + USEDFS.rename(F(WIFICFG_FILE), F(WIFICFG_OLD_FILE)); strEncode(str); svSetV(F("ssid"), str, F(WIFICFG_FILE)); str = request->arg(F("_p")); diff --git a/src/WiFiConfig.h b/src/WiFiConfig.h index 2c623b6..76fa89f 100644 --- a/src/WiFiConfig.h +++ b/src/WiFiConfig.h @@ -44,6 +44,9 @@ #if not defined(WIFICFG_FILE) # define WIFICFG_FILE "/wifi.json" #endif +#if not defined(WIFICFG_OLD_FILE) +# define WIFICFG_OLD_FILE "/wifi.old" +#endif // Parametr, predany uzivatelske callback funkci, urceny pro aplikacni vizualizaci stavu konfigurace a pripojeni typedef enum {