Skip to content

Commit

Permalink
Add MDNS discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
fvanroie committed Feb 25, 2024
1 parent 510565c commit 11f695a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
13 changes: 7 additions & 6 deletions src/hasp/hasp_dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
15 changes: 5 additions & 10 deletions src/sys/svc/hasp_mdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down

0 comments on commit 11f695a

Please sign in to comment.