Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c23c786

Browse filesBrowse files
ESPmDNS: Add method for querying discovered service name (#10819)
* Add method for querying service name * Added implementation for getting service name * Update mDNS-SD_Extended example to include service name * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 51ef2a1 commit c23c786
Copy full SHA for c23c786

File tree

Expand file treeCollapse file tree

3 files changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+12
-0
lines changed

‎libraries/ESPmDNS/examples/mDNS-SD_Extended/mDNS-SD_Extended.ino

Copy file name to clipboardExpand all lines: libraries/ESPmDNS/examples/mDNS-SD_Extended/mDNS-SD_Extended.ino
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ void browseService(const char *service, const char *proto) {
6868
Serial.print(" ");
6969
Serial.print(i + 1);
7070
Serial.print(": ");
71+
Serial.print(MDNS.instanceName(i));
72+
Serial.print(" - ");
7173
Serial.print(MDNS.hostname(i));
7274
Serial.print(" (");
7375
Serial.print(MDNS.address(i));

‎libraries/ESPmDNS/src/ESPmDNS.cpp

Copy file name to clipboardExpand all lines: libraries/ESPmDNS/src/ESPmDNS.cpp
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ String MDNSResponder::hostname(int idx) {
299299
return String(result->hostname);
300300
}
301301

302+
String MDNSResponder::instanceName(int idx) {
303+
mdns_result_t *result = _getResult(idx);
304+
if (!result) {
305+
log_e("Result %d not found", idx);
306+
return String();
307+
}
308+
return String(result->instance_name);
309+
}
310+
302311
IPAddress MDNSResponder::address(int idx) {
303312
mdns_result_t *result = _getResult(idx);
304313
if (!result) {

‎libraries/ESPmDNS/src/ESPmDNS.h

Copy file name to clipboardExpand all lines: libraries/ESPmDNS/src/ESPmDNS.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class MDNSResponder {
110110
}
111111

112112
String hostname(int idx);
113+
String instanceName(int idx);
113114
IPAddress address(int idx);
114115
IPAddress addressV6(int idx);
115116
uint16_t port(int idx);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.