Skip to content

Commit b86aa36

Browse files
authored
Fix MDNS in IRServer and IRMQTTServer (crankyoldgit#1499)
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 crankyoldgit#1498
1 parent 7e8ea94 commit b86aa36

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: examples/IRMQTTServer/IRMQTTServer.ino

+5
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,8 @@ void setup(void) {
21432143
if (mdns.begin(Hostname)) {
21442144
#endif // ESP8266
21452145
debug("MDNS responder started");
2146+
// Announce http tcp service on kHttpPort
2147+
mdns.addService("http", "tcp", kHttpPort);
21462148
}
21472149
#endif // MDNS_ENABLE
21482150

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

25932595
void loop(void) {
2596+
#if MDNS_ENABLE && defined(ESP8266)
2597+
mdns.update();
2598+
#endif // MDNS_ENABLE and ESP8266
25942599
server.handleClient(); // Handle any web activity
25952600

25962601
#if MQTT_ENABLE

Diff for: examples/IRServer/IRServer.ino

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ void setup(void) {
132132
if (mdns.begin(HOSTNAME)) {
133133
#endif // ESP8266
134134
Serial.println("MDNS responder started");
135+
// Announce http tcp service on port 80
136+
mdns.addService("http", "tcp", 80);
135137
}
136138

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

150152
void loop(void) {
153+
#if defined(ESP8266)
154+
mdns.update();
155+
#endif
151156
server.handleClient();
152157
}

0 commit comments

Comments
 (0)