Skip to content

Commit 22e2b6f

Browse files
committed
Have json/cfg return live config
Rather than reading the file off disk, have the json/cfg endpoint return the live config from system state data. This can improve UI behaviour as it can never be out of date or include values that do not apply to the current firmware install.
1 parent 9c8f8c6 commit 22e2b6f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

wled00/json.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ class LockedJsonResponse: public AsyncJsonResponse {
10281028
void serveJson(AsyncWebServerRequest* request)
10291029
{
10301030
enum class json_target {
1031-
all, state, info, state_info, nodes, effects, palettes, fxdata, networks
1031+
all, state, info, state_info, nodes, effects, palettes, fxdata, networks, config
10321032
};
10331033
json_target subJson = json_target::all;
10341034

@@ -1041,6 +1041,7 @@ void serveJson(AsyncWebServerRequest* request)
10411041
else if (url.indexOf(F("palx")) > 0) subJson = json_target::palettes;
10421042
else if (url.indexOf(F("fxda")) > 0) subJson = json_target::fxdata;
10431043
else if (url.indexOf(F("net")) > 0) subJson = json_target::networks;
1044+
else if (url.indexOf(F("cfg")) > 0) subJson = json_target::config;
10441045
#ifdef WLED_ENABLE_JSONLIVE
10451046
else if (url.indexOf("live") > 0) {
10461047
serveLiveLeds(request);
@@ -1051,9 +1052,6 @@ void serveJson(AsyncWebServerRequest* request)
10511052
request->send_P(200, FPSTR(CONTENT_TYPE_JSON), JSON_palette_names);
10521053
return;
10531054
}
1054-
else if (url.indexOf(F("cfg")) > 0 && handleFileRead(request, F("/cfg.json"))) {
1055-
return;
1056-
}
10571055
else if (url.length() > 6) { //not just /json
10581056
serveJsonError(request, 501, ERR_NOT_IMPL);
10591057
return;
@@ -1085,6 +1083,8 @@ void serveJson(AsyncWebServerRequest* request)
10851083
serializeModeData(lDoc); break;
10861084
case json_target::networks:
10871085
serializeNetworks(lDoc); break;
1086+
case json_target::config:
1087+
serializeConfig(lDoc); break;
10881088
case json_target::state_info:
10891089
case json_target::all:
10901090
JsonObject state = lDoc.createNestedObject("state");

0 commit comments

Comments
 (0)