mirror of
https://github.com/btclock/btclock_v3.git
synced 2024-11-19 04:30:02 +01:00
Small API fix
This commit is contained in:
parent
b195368150
commit
7ded1c16d6
@ -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<String, NUM_SCREENS> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user