From 22e2b6f3c517233eaca2e0972790e10d38db20b5 Mon Sep 17 00:00:00 2001 From: Will Miles Date: Sun, 23 Mar 2025 15:18:08 -0400 Subject: [PATCH] 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. --- wled00/json.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index 0a307594a..c09b543f1 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -1028,7 +1028,7 @@ class LockedJsonResponse: public AsyncJsonResponse { void serveJson(AsyncWebServerRequest* request) { enum class json_target { - all, state, info, state_info, nodes, effects, palettes, fxdata, networks + all, state, info, state_info, nodes, effects, palettes, fxdata, networks, config }; json_target subJson = json_target::all; @@ -1041,6 +1041,7 @@ void serveJson(AsyncWebServerRequest* request) else if (url.indexOf(F("palx")) > 0) subJson = json_target::palettes; else if (url.indexOf(F("fxda")) > 0) subJson = json_target::fxdata; else if (url.indexOf(F("net")) > 0) subJson = json_target::networks; + else if (url.indexOf(F("cfg")) > 0) subJson = json_target::config; #ifdef WLED_ENABLE_JSONLIVE else if (url.indexOf("live") > 0) { serveLiveLeds(request); @@ -1051,9 +1052,6 @@ void serveJson(AsyncWebServerRequest* request) request->send_P(200, FPSTR(CONTENT_TYPE_JSON), JSON_palette_names); return; } - else if (url.indexOf(F("cfg")) > 0 && handleFileRead(request, F("/cfg.json"))) { - return; - } else if (url.length() > 6) { //not just /json serveJsonError(request, 501, ERR_NOT_IMPL); return; @@ -1085,6 +1083,8 @@ void serveJson(AsyncWebServerRequest* request) serializeModeData(lDoc); break; case json_target::networks: serializeNetworks(lDoc); break; + case json_target::config: + serializeConfig(lDoc); break; case json_target::state_info: case json_target::all: JsonObject state = lDoc.createNestedObject("state");