@@ -317,36 +317,47 @@ int MDNSResponder::queryService(char *service, char *proto) {
317
317
// Only supports sending one PTR query
318
318
uint8_t questionCount = 1 ;
319
319
320
- // Write the header
321
- _conn->flush ();
322
- uint8_t head[12 ] = {
323
- 0x00 , 0x00 , // ID = 0
324
- 0x00 , 0x00 , // Flags = response + authoritative answer
325
- 0x00 , questionCount, // Question count
326
- 0x00 , 0x00 , // Answer count
327
- 0x00 , 0x00 , // Name server records
328
- 0x00 , 0x00 // Additional records
329
- };
330
- _conn->append (reinterpret_cast <const char *>(head), 12 );
331
-
332
- // Only supports sending one PTR query
333
- // Send the Name field (eg. "_http._tcp.local")
334
- _conn->append (reinterpret_cast <const char *>(&serviceNameLen), 1 ); // lenght of "_" + service
335
- _conn->append (reinterpret_cast <const char *>(serviceName), serviceNameLen); // "_" + service
336
- _conn->append (reinterpret_cast <const char *>(&protoNameLen), 1 ); // lenght of "_" + proto
337
- _conn->append (reinterpret_cast <const char *>(protoName), protoNameLen); // "_" + proto
338
- _conn->append (reinterpret_cast <const char *>(&localNameLen), 1 ); // lenght of "local"
339
- _conn->append (reinterpret_cast <const char *>(localName), localNameLen); // "local"
340
- _conn->append (reinterpret_cast <const char *>(&terminator), 1 ); // terminator
341
-
342
- // Send the type and class
343
- uint8_t ptrAttrs[4 ] = {
344
- 0x00 , 0x0c , // PTR record query
345
- 0x00 , 0x01 // Class IN
346
- };
347
- _conn->append (reinterpret_cast <const char *>(ptrAttrs), 4 );
348
320
_waitingForAnswers = true ;
349
- _conn->send ();
321
+ for (int itfn = 0 ; itfn < 2 ; itfn++) {
322
+ struct ip_info ip_info;
323
+ ip_addr_t ifaddr;
324
+
325
+ wifi_get_ip_info ((!itfn) ? SOFTAP_IF : STATION_IF, &ip_info);
326
+ if (!ip_info.ip .addr )
327
+ continue ;
328
+ ifaddr.addr = ip_info.ip .addr ;
329
+ _conn->setMulticastInterface (ifaddr);
330
+
331
+ // Write the header
332
+ _conn->flush ();
333
+ uint8_t head[12 ] = {
334
+ 0x00 , 0x00 , // ID = 0
335
+ 0x00 , 0x00 , // Flags = response + authoritative answer
336
+ 0x00 , questionCount, // Question count
337
+ 0x00 , 0x00 , // Answer count
338
+ 0x00 , 0x00 , // Name server records
339
+ 0x00 , 0x00 // Additional records
340
+ };
341
+ _conn->append (reinterpret_cast <const char *>(head), 12 );
342
+
343
+ // Only supports sending one PTR query
344
+ // Send the Name field (eg. "_http._tcp.local")
345
+ _conn->append (reinterpret_cast <const char *>(&serviceNameLen), 1 ); // lenght of "_" + service
346
+ _conn->append (reinterpret_cast <const char *>(serviceName), serviceNameLen); // "_" + service
347
+ _conn->append (reinterpret_cast <const char *>(&protoNameLen), 1 ); // lenght of "_" + proto
348
+ _conn->append (reinterpret_cast <const char *>(protoName), protoNameLen); // "_" + proto
349
+ _conn->append (reinterpret_cast <const char *>(&localNameLen), 1 ); // lenght of "local"
350
+ _conn->append (reinterpret_cast <const char *>(localName), localNameLen); // "local"
351
+ _conn->append (reinterpret_cast <const char *>(&terminator), 1 ); // terminator
352
+
353
+ // Send the type and class
354
+ uint8_t ptrAttrs[4 ] = {
355
+ 0x00 , 0x0c , // PTR record query
356
+ 0x00 , 0x01 // Class IN
357
+ };
358
+ _conn->append (reinterpret_cast <const char *>(ptrAttrs), 4 );
359
+ _conn->send ();
360
+ }
350
361
351
362
#ifdef MDNS_DEBUG_TX
352
363
Serial.println (" Waiting for answers.." );
0 commit comments