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>
This commit is contained in:
parent
51ef2a1d29
commit
c23c786749
3 changed files with 12 additions and 0 deletions
|
|
@ -68,6 +68,8 @@ void browseService(const char *service, const char *proto) {
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
Serial.print(i + 1);
|
Serial.print(i + 1);
|
||||||
Serial.print(": ");
|
Serial.print(": ");
|
||||||
|
Serial.print(MDNS.instanceName(i));
|
||||||
|
Serial.print(" - ");
|
||||||
Serial.print(MDNS.hostname(i));
|
Serial.print(MDNS.hostname(i));
|
||||||
Serial.print(" (");
|
Serial.print(" (");
|
||||||
Serial.print(MDNS.address(i));
|
Serial.print(MDNS.address(i));
|
||||||
|
|
|
||||||
|
|
@ -299,6 +299,15 @@ String MDNSResponder::hostname(int idx) {
|
||||||
return String(result->hostname);
|
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) {
|
IPAddress MDNSResponder::address(int idx) {
|
||||||
mdns_result_t *result = _getResult(idx);
|
mdns_result_t *result = _getResult(idx);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
String hostname(int idx);
|
String hostname(int idx);
|
||||||
|
String instanceName(int idx);
|
||||||
IPAddress address(int idx);
|
IPAddress address(int idx);
|
||||||
IPAddress addressV6(int idx);
|
IPAddress addressV6(int idx);
|
||||||
uint16_t port(int idx);
|
uint16_t port(int idx);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue