mirror of
https://github.com/wled/WLED.git
synced 2025-11-13 04:50:51 +00:00
Autodiscovery improvements
This commit is contained in:
@@ -473,6 +473,8 @@ void serializeInfo(JsonObject root)
|
||||
fs_info["u"] = fsBytesUsed / 1000;
|
||||
fs_info["t"] = fsBytesTotal / 1000;
|
||||
fs_info[F("pmt")] = presetsModifiedTime;
|
||||
|
||||
root[F("ndc")] = Nodes.size();
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#ifdef WLED_DEBUG
|
||||
@@ -533,23 +535,22 @@ void serializeInfo(JsonObject root)
|
||||
root[F("brand")] = "WLED";
|
||||
root[F("product")] = F("FOSS");
|
||||
root["mac"] = escapedMac;
|
||||
}
|
||||
|
||||
void serializeNodes(JsonObject root)
|
||||
{
|
||||
JsonArray nodes = root.createNestedArray("nodes");
|
||||
IPAddress ip = WiFi.localIP();
|
||||
for (NodesMap::iterator it = Nodes.begin(); it != Nodes.end(); ++it)
|
||||
{
|
||||
if (it->second.ip[0] != 0)
|
||||
{
|
||||
bool isThisUnit = it->first == ip[3];
|
||||
|
||||
if (isThisUnit) continue;
|
||||
|
||||
JsonObject node = nodes.createNestedObject();
|
||||
node[F("name")] = it->second.nodeName;
|
||||
node[F("type")] = getNodeTypeDisplayString(it->second.nodeType);
|
||||
node[F("type")] = it->second.nodeType;
|
||||
node[F("ip")] = it->second.ip.toString();
|
||||
node[F("age")] = it->second.age;
|
||||
node[F("build")] = it->second.build;
|
||||
node[F("vid")] = it->second.build;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -561,6 +562,7 @@ void serveJson(AsyncWebServerRequest* request)
|
||||
if (url.indexOf("state") > 0) subJson = 1;
|
||||
else if (url.indexOf("info") > 0) subJson = 2;
|
||||
else if (url.indexOf("si") > 0) subJson = 3;
|
||||
else if (url.indexOf("nodes") > 0) subJson = 4;
|
||||
else if (url.indexOf("live") > 0) {
|
||||
serveLiveLeds(request);
|
||||
return;
|
||||
@@ -587,6 +589,8 @@ void serveJson(AsyncWebServerRequest* request)
|
||||
serializeState(doc); break;
|
||||
case 2: //info
|
||||
serializeInfo(doc); break;
|
||||
case 4: //node list
|
||||
serializeNodes(doc); break;
|
||||
default: //all
|
||||
JsonObject state = doc.createNestedObject("state");
|
||||
serializeState(state);
|
||||
|
||||
Reference in New Issue
Block a user