1
0
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:
Stephen Warren 2017-04-04 21:34:10 -06:00 committed by Ivan Grokhotkov
parent 4cf7909df9
commit 2450ec6803

View File

@ -317,6 +317,17 @@ int MDNSResponder::queryService(char *service, char *proto) {
// Only supports sending one PTR query
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
_conn->flush();
uint8_t head[12] = {
@ -345,8 +356,8 @@ int MDNSResponder::queryService(char *service, char *proto) {
0x00, 0x01 //Class IN
};
_conn->append(reinterpret_cast<const char*>(ptrAttrs), 4);
_waitingForAnswers = true;
_conn->send();
}
#ifdef MDNS_DEBUG_TX
Serial.println("Waiting for answers..");