Skip to content

Commit

Permalink
Fix MDNS in IRServer and IRMQTTServer (#1499)
Browse files Browse the repository at this point in the history
Fix MDNS service in IRServer and IRMQTTServer examples

In the examples IRServer and IRMQTTServer, Chromium and Firefox running on Ubuntu fail to connect to the ESP8266 using the MDNS hostname. For example, esp8266.local and ir_server.local do not resolve.

Based on the MDNS examples included with the ESP8266 board package, adding calls to mdns.addService() and mdns.update() fixes the problems.

Fixes #1498
  • Loading branch information
touchgadget committed Jun 12, 2021
1 parent 7e8ea94 commit b86aa36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/IRMQTTServer/IRMQTTServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2143,6 +2143,8 @@ void setup(void) {
if (mdns.begin(Hostname)) {
#endif // ESP8266
debug("MDNS responder started");
// Announce http tcp service on kHttpPort
mdns.addService("http", "tcp", kHttpPort);
}
#endif // MDNS_ENABLE

Expand Down Expand Up @@ -2591,6 +2593,9 @@ void sendMQTTDiscovery(const char *topic) {
#endif // MQTT_ENABLE

void loop(void) {
#if MDNS_ENABLE && defined(ESP8266)
mdns.update();
#endif // MDNS_ENABLE and ESP8266
server.handleClient(); // Handle any web activity

#if MQTT_ENABLE
Expand Down
5 changes: 5 additions & 0 deletions examples/IRServer/IRServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ void setup(void) {
if (mdns.begin(HOSTNAME)) {
#endif // ESP8266
Serial.println("MDNS responder started");
// Announce http tcp service on port 80
mdns.addService("http", "tcp", 80);
}

server.on("/", handleRoot);
Expand All @@ -148,5 +150,8 @@ void setup(void) {
}

void loop(void) {
#if defined(ESP8266)
mdns.update();
#endif
server.handleClient();
}

0 comments on commit b86aa36

Please sign in to comment.