File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,33 @@ void Config::taskRunner(void *p) {
2727 }
2828
2929 t->current .clear ();
30- t->current = t->newCfg ;
30+ Config::merge ( t->current , t->newCfg ) ;
3131 t->newCfg .clear ();
3232 t->save ();
3333
3434 vTaskDelete (NULL );
3535};
3636
37+ void Config::merge (JsonVariant dst, JsonVariantConst src) {
38+ if (src.is <JsonObjectConst>()) {
39+ for (JsonPairConst kvp : src.as <JsonObjectConst>()) {
40+ if (dst[kvp.key ()]) {
41+ Config::merge (dst[kvp.key ()], kvp.value ());
42+
43+ return ;
44+ }
45+
46+ dst[kvp.key ()] = kvp.value ();
47+ }
48+
49+ return ;
50+ }
51+
52+ if (!src.isNull () && strcmp (src.as <const char *>(), " " ) != 0 ) {
53+ dst.set (src);
54+ }
55+ };
56+
3757void Config::initServer (AsyncWebServer *server) {
3858 server->on (" /config" , HTTP_GET, [&](AsyncWebServerRequest *request) {
3959 Log::instance ()->info (" Sending current configuration\n " );
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class Config {
1313 private:
1414 JsonDocument newCfg;
1515 ConfigChangeHandler configChangeHandler;
16+ static void merge (JsonVariant, JsonVariantConst);
1617 static void taskRunner (void *);
1718
1819 public:
You can’t perform that action at this time.
0 commit comments