Add MDNS discovery

This commit is contained in:
fvanroie 2024-02-25 23:12:49 +01:00
parent 510565ca51
commit 11f695aff7
2 changed files with 12 additions and 16 deletions

View File

@ -1299,12 +1299,13 @@ void dispatch_get_discovery_data(JsonDocument& doc)
{
char buffer[64];
doc[F("node")] = haspDevice.get_hostname();
doc[F("mdl")] = haspDevice.get_model();
doc[F("mf")] = F(D_MANUFACTURER);
doc[F("hwid")] = haspDevice.get_hardware_id();
doc[F("pages")] = haspPages.count();
doc[F("sw")] = haspDevice.get_version();
doc[F("node")] = haspDevice.get_hostname();
doc[F("mdl")] = haspDevice.get_model();
doc[F("mf")] = F(D_MANUFACTURER);
doc[F("hwid")] = haspDevice.get_hardware_id();
doc[F("pages")] = haspPages.count();
doc[F("sw")] = haspDevice.get_version();
doc[F("node_t")] = String("hasp/") + haspDevice.get_hostname() + "/";
#if HASP_USE_HTTP > 0
network_get_ipaddress(buffer, sizeof(buffer));

View File

@ -70,18 +70,13 @@ void mdnsStart()
strcpy_P(service, PSTR("openhasp"));
MDNS.addService(service, proto, 80);
strcpy_P(key, PSTR("version"));
MDNS.addServiceTxt(service, proto, key, haspDevice.get_version());
// strcpy_P(key, PSTR("name"));
// strcpy_P(value, PSTR(D_MANUFACTURER));
// MDNS.addServiceTxt(service, proto, key, value);
strcpy_P(key, PSTR("discovery"));
StaticJsonDocument<1024> doc;
dispatch_get_discovery_data(doc);
size_t len = serializeJson(doc, value);
MDNS.addServiceTxt(service, proto, key, value);
JsonObject data = doc.as<JsonObject>();
for(JsonPair i : data) {
MDNS.addServiceTxt(service, proto, i.key().c_str(), i.value().as<String>());
}
// if(debugTelnetEnabled) {
strcpy_P(service, PSTR("telnet"));