mirror of
https://github.com/Fishwaldo/WLED.git
synced 2025-07-12 16:08:23 +00:00
Autodiscovery improvements
This commit is contained in:
parent
6c997f573a
commit
ea3358ecb2
8 changed files with 165 additions and 162 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue