mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
ESP8266mDNS: support multiple interfaces in query code
Add a loop over all known interfaces to queryService() so that it will find devices attached to all available WiFi networks.
This commit is contained in:
parent
4cf7909df9
commit
2450ec6803
@ -317,6 +317,17 @@ int MDNSResponder::queryService(char *service, char *proto) {
|
|||||||
// Only supports sending one PTR query
|
// Only supports sending one PTR query
|
||||||
uint8_t questionCount = 1;
|
uint8_t questionCount = 1;
|
||||||
|
|
||||||
|
_waitingForAnswers = true;
|
||||||
|
for (int itfn = 0; itfn < 2; itfn++) {
|
||||||
|
struct ip_info ip_info;
|
||||||
|
ip_addr_t ifaddr;
|
||||||
|
|
||||||
|
wifi_get_ip_info((!itfn) ? SOFTAP_IF : STATION_IF, &ip_info);
|
||||||
|
if (!ip_info.ip.addr)
|
||||||
|
continue;
|
||||||
|
ifaddr.addr = ip_info.ip.addr;
|
||||||
|
_conn->setMulticastInterface(ifaddr);
|
||||||
|
|
||||||
// Write the header
|
// Write the header
|
||||||
_conn->flush();
|
_conn->flush();
|
||||||
uint8_t head[12] = {
|
uint8_t head[12] = {
|
||||||
@ -345,8 +356,8 @@ int MDNSResponder::queryService(char *service, char *proto) {
|
|||||||
0x00, 0x01 //Class IN
|
0x00, 0x01 //Class IN
|
||||||
};
|
};
|
||||||
_conn->append(reinterpret_cast<const char*>(ptrAttrs), 4);
|
_conn->append(reinterpret_cast<const char*>(ptrAttrs), 4);
|
||||||
_waitingForAnswers = true;
|
|
||||||
_conn->send();
|
_conn->send();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MDNS_DEBUG_TX
|
#ifdef MDNS_DEBUG_TX
|
||||||
Serial.println("Waiting for answers..");
|
Serial.println("Waiting for answers..");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user