From 68097dcbd294eade90a290ac4e2cf47d3d81929a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Janiszewski?= Date: Wed, 15 May 2024 15:49:34 +0200 Subject: [PATCH 1/2] Add 'dhcp' option per default at file creation. --- src/AsyncFsWebServer.cpp | 2 +- src/SetupConfig.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AsyncFsWebServer.cpp b/src/AsyncFsWebServer.cpp index ff5a7ca8..aaaa5851 100644 --- a/src/AsyncFsWebServer.cpp +++ b/src/AsyncFsWebServer.cpp @@ -13,7 +13,7 @@ bool AsyncFsWebServer::init(AwsEventHandler wsHandle) { file = m_filesystem->open(ESP_FS_WS_CONFIG_FILE, "r"); if (!file) { file = m_filesystem->open(ESP_FS_WS_CONFIG_FILE, "w"); - file.print("{\"wifi-box\": \"\"}"); + file.print("{\"wifi-box\": \"\",\n\t\"dhcp\": false}"); file.close(); } else file.close(); diff --git a/src/SetupConfig.hpp b/src/SetupConfig.hpp index 6271391f..af31430d 100644 --- a/src/SetupConfig.hpp +++ b/src/SetupConfig.hpp @@ -30,7 +30,7 @@ class SetupConfigurator log_error("Error. File %s not created", ESP_FS_WS_CONFIG_FILE); return false; } - file.print("{\"wifi-box\": \"\"}"); + file.print("{\"wifi-box\": \"\",\"dhcp\":false}"); file.close(); } return true; From 19260f4b285f6b014749387ffcd4d556f02ead3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Janiszewski?= Date: Thu, 5 Sep 2024 14:52:35 +0200 Subject: [PATCH 2/2] Fix wrong comparison test in addOption It means the test is mainly false, then the config file is rewritten at each startup ! --- src/SetupConfig.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SetupConfig.hpp b/src/SetupConfig.hpp index af31430d..451f452e 100644 --- a/src/SetupConfig.hpp +++ b/src/SetupConfig.hpp @@ -231,7 +231,7 @@ class SetupConfigurator key += numOptions ; // If key is present and value is the same, we don't need to create/update it. - if (doc.containsKey(key.c_str()) && doc[key] != val) + if (doc.containsKey(key.c_str()) && doc[key] == val) return; // if min, max, step != from default, treat this as object in order to set other properties