Skip to content

Commit 62b8ac6

Browse files
hreintkedevyte
authored andcommitted
Fix LeamDNS examples (#5563)
* Fix LeamDNS examples * Fix Style check error * Another style fix
1 parent eb5d636 commit 62b8ac6

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock/mDNS_Clock.ino

+8-8
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ bool MDNSProbeResultCallback(MDNSResponder* p_pMDNSResponder,
189189
p_pMDNSResponder->setDynamicServiceTxtCallback(hMDNSService, MDNSDynamicServiceTxtCallback, 0);
190190
}
191191
}
192+
}
193+
} else {
194+
// Change hostname, use '-' as divider between base name and index
195+
if (MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
196+
p_pMDNSResponder->setHostname(pcHostDomain);
192197
} else {
193-
// Change hostname, use '-' as divider between base name and index
194-
if (MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
195-
p_pMDNSResponder->setHostname(pcHostDomain);
196-
} else {
197-
Serial.println("MDNSProbeResultCallback: FAILED to update hostname!");
198-
}
198+
Serial.println("MDNSProbeResultCallback: FAILED to update hostname!");
199199
}
200200
}
201201
}
@@ -241,8 +241,8 @@ void handleHTTPClient(WiFiClient& client) {
241241
if (req == "/") {
242242
IPAddress ip = WiFi.localIP();
243243
String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
244-
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP8266 at ";
245-
s += ipStr;
244+
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ";
245+
s += WiFi.hostname() + " at " + ipStr;
246246
// Simple addition of the current time
247247
s += "\r\nCurrent time is: ";
248248
s += getTimeString();

libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_ServiceMonitor/mDNS_ServiceMonitor.ino

+8-8
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ bool MDNSProbeResultCallback(MDNSResponder* p_pMDNSResponder,
233233
}
234234
}
235235
}
236+
}
237+
} else {
238+
// Change hostname, use '-' as divider between base name and index
239+
if (MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
240+
p_pMDNSResponder->setHostname(pcHostDomain);
236241
} else {
237-
// Change hostname, use '-' as divider between base name and index
238-
if (MDNSResponder::indexDomain(pcHostDomain, "-", 0)) {
239-
p_pMDNSResponder->setHostname(pcHostDomain);
240-
} else {
241-
Serial.println("MDNSProbeResultCallback: FAILED to update hostname!");
242-
}
242+
Serial.println("MDNSProbeResultCallback: FAILED to update hostname!");
243243
}
244244
}
245245
}
@@ -280,8 +280,8 @@ void handleHTTPClient(WiFiClient& client) {
280280
if (req == "/") {
281281
IPAddress ip = WiFi.localIP();
282282
String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
283-
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ESP8266 at ";
284-
s += ipStr;
283+
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>Hello from ";
284+
s += WiFi.hostname() + " at " + ipStr;
285285
// Simple addition of the current time
286286
s += "<br/>Local HTTP services:<br/>";
287287
s += strHTTPServices;

0 commit comments

Comments
 (0)