Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESPmDNS: Add method for querying discovered service name #10819

Merged
merged 5 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ void browseService(const char *service, const char *proto) {
Serial.print(" ");
Serial.print(i + 1);
Serial.print(": ");
Serial.print(MDNS.instanceName(i));
Serial.print(" - ");
Serial.print(MDNS.hostname(i));
Serial.print(" (");
Serial.print(MDNS.address(i));
Expand Down
9 changes: 9 additions & 0 deletions libraries/ESPmDNS/src/ESPmDNS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ String MDNSResponder::hostname(int idx) {
return String(result->hostname);
}

String MDNSResponder::instanceName(int idx) {
mdns_result_t *result = _getResult(idx);
if (!result) {
log_e("Result %d not found", idx);
return String();
}
return String(result->instance_name);
}

IPAddress MDNSResponder::address(int idx) {
mdns_result_t *result = _getResult(idx);
if (!result) {
Expand Down
1 change: 1 addition & 0 deletions libraries/ESPmDNS/src/ESPmDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class MDNSResponder {
}

String hostname(int idx);
String instanceName(int idx);
IPAddress address(int idx);
IPAddress addressV6(int idx);
uint16_t port(int idx);
Expand Down
Loading