Are there any means currently for performing service discovery (mDNS or unicast DND-SD) in nanoframework?

541 Views Asked by At

I'm just wondering if there are any means of service discovery built into the nanoframework?

I am mainly interested in mDNS or unicast DNS service discovery. Think Apple Bonjour/Avahi.

I noticed Espressif has some arduino examples around mDNS.

https://github.com/espressif/arduino-esp32/blob/a59eafbc9dfa3ce818c110f996eebf68d755be24/libraries/ESPmDNS/examples/mDNS-SD_Extended/mDNS-SD_Extended.ino

It would make sense as a separate deployment use case when you don't want to connect to a hub in the cloud but instead have the hub (MQTT server) running on the local network and need to discover it.

Many thanks!

3

There are 3 best solutions below

1
Benvorth On

Welcome Cristian!

On an ESP32 you can include multicast DNS and DNS-Service Discovery like that:

#include <ESPmDNS.h>
...
if (MDNS.begin("esp32")) { // access this ESP32 via http://esp32 (eg in browser)
    Serial.println("mDNS responder started");
}
...
// register a http-service in DNS-SD
if (mdns_service_add("esp32_website", "_http", "_tcp", 80, NULL, 0)) {
    Serial.println("DNS-SD responder started");
}
mdns_service_txt_item_set("esp32_website", "_http._tcp", "version", "1.0");

In order to actually discover the ESP32 and it's services you need to make sure that the machine you are working on supports mDNS and DNS-SD.

Note: mDNS just "resolves" the name of the ESP to it's IP. You need to set-up a webserver on it to actually DO something (like provide the DNS-SD-promised website or such)

0
José Simões On

Currently there is no support for mDNS in .NET nanoFramework. But that doesn't seem overcomplicated to add. Please raise an issue with the feature suggestion on our GitHub.

0
hansmbakker On

Update 01-01-2023: Support for mDNS in .NET nanoframework was requested in https://github.com/nanoframework/Home/issues/912. In that discussion, https://github.com/karlredgate/mDNS-sharp was recommended as an alternative to having it built-in into .NET nanoframework. It is not clear whether people succeeded with that, though.