Using mDNS library <ESP8266mDNS>
Posted: Tue Feb 21, 2023 2:23 am
Can you somehow announce a service with a different "Name" and "Hostname" using standart mDNS library <ESP8266mDNS> fo ESP? In my case I want to announce a service on my home network, but the api server for that service is running on a remote VPS.
It's still possible with javascript Node library "bonjour" or standard "dns-sd" command in macOS terminal, but the thing is, I want to make a standalone mDNS announcer on ESP8266 Wemos D1 module.
But when I do as follows I get the same hostname and name of service:
name: "Homebridge-1234"
hostname: homebridge-12324.local
It's still possible with javascript Node library "bonjour" or standard "dns-sd" command in macOS terminal, but the thing is, I want to make a standalone mDNS announcer on ESP8266 Wemos D1 module.
But when I do as follows I get the same hostname and name of service:
Code: Select all
#include <ESP8266mDNS.h>
void setup() {
if (!MDNS.begin("Homebridge-1234")) {
Serial.println("Error setting up MDNS announcer!");
while (1) {
delay(1000);
}
}
Serial.println("mDNS announcer is started");
MDNS.addService("hap", "tcp", 51226);
MDNS.addServiceTxt("hap", "tcp", "pv", "1.1");
MDNS.addServiceTxt("hap", "tcp", "ff", "0");
MDNS.addServiceTxt("hap", "tcp", "s#", "1");
MDNS.addServiceTxt("hap", "tcp", "c#", "2");
...
}
void loop() {
MDNS.update();
}
name: "Homebridge-1234"
hostname: homebridge-12324.local