From 7ded1c16d60f17c5b53e97f7d8c5cb2dcd011dac Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Sun, 19 Nov 2023 02:23:47 +0100 Subject: [PATCH] Small API fix --- src/lib/webserver.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/webserver.cpp b/src/lib/webserver.cpp index 588be10..dd689f1 100644 --- a/src/lib/webserver.cpp +++ b/src/lib/webserver.cpp @@ -162,11 +162,13 @@ void onApiStatus(AsyncWebServerRequest *request) { AsyncResponseStream *response = request->beginResponseStream("application/json"); - StaticJsonDocument<768> root = getStatusObject(); + StaticJsonDocument<1024> root = getStatusObject(); JsonArray data = root.createNestedArray("data"); JsonArray rendered = root.createNestedArray("rendered"); String epdContent[NUM_SCREENS]; + root["leds"] = getLedStatusObject()["data"]; + std::array retEpdContent = getCurrentEpdContent(); std::copy(std::begin(retEpdContent), std::end(retEpdContent), epdContent); @@ -695,6 +697,8 @@ void onApiLightsSetColor(AsyncWebServerRequest *request) { if (request->hasParam("c")) { + AsyncResponseStream *response = request->beginResponseStream("application/json"); + String rgbColor = request->getParam("c")->value(); if (rgbColor.compareTo("off") == 0) @@ -707,7 +711,16 @@ void onApiLightsSetColor(AsyncWebServerRequest *request) sscanf(rgbColor.c_str(), "%02x%02x%02x", &r, &g, &b); setLights(r, g, b); } - request->send(200, "text/plain", rgbColor); + + StaticJsonDocument<48> doc; + doc["result"] = rgbColor; + + + serializeJson(getLedStatusObject()["data"], *response); + + request->send(response); + } else { + request->send(400); } }