mirror of
https://github.com/espressif/openthread.git
synced 2026-10-11 10:17:35 +00:00
[thci] retrieve BA port from mDNS response (#7130)
Modify `mdns_query` to accept a list of reference devices link local addresses in order to discard their mDNS responses. Also accept a service string to be used for the Thread 1.3 Certification program. Return the DUT's Border Agent address and port.
This commit is contained in:
@@ -2322,10 +2322,6 @@ class OpenThreadTHCI(object):
|
|||||||
print(cmd)
|
print(cmd)
|
||||||
return self.__executeCommand(cmd)[-1] == 'Done'
|
return self.__executeCommand(cmd)[-1] == 'Done'
|
||||||
|
|
||||||
@API
|
|
||||||
def getBorderAgentPort(self):
|
|
||||||
return int(self.__executeCommand('ba port')[0])
|
|
||||||
|
|
||||||
@API
|
@API
|
||||||
def startExternalCommissioner(self, baAddr, baPort):
|
def startExternalCommissioner(self, baAddr, baPort):
|
||||||
"""Start external commissioner
|
"""Start external commissioner
|
||||||
|
|||||||
@@ -608,9 +608,31 @@ EOF"
|
|||||||
self.log('%s', line)
|
self.log('%s', line)
|
||||||
|
|
||||||
@API
|
@API
|
||||||
def mdns_query(self):
|
def mdns_query(self, dst='ff02::fb', service='_meshcop._udp.local', addrs_blacklist=[]):
|
||||||
print('mdns_query')
|
print('mdns_query %s %s %s' % (dst, service, addrs_blacklist))
|
||||||
self.bash('dig -p 5353 @ff02::fb _meshcop._udp.local ptr')
|
|
||||||
|
result = self.bash('dig -p 5353 @%s %s ptr +time=2 +retry=2' % (dst, service))
|
||||||
|
responses = ' '.join(result).split(';; ANSWER SECTION:')
|
||||||
|
|
||||||
|
# Remove responses from unwanted devices
|
||||||
|
for response in responses:
|
||||||
|
if not set(response.split()).isdisjoint(set(addrs_blacklist)):
|
||||||
|
break
|
||||||
|
|
||||||
|
# Records patterns:
|
||||||
|
# raspberrypi-2.local. 10 IN AAAA fe80::81:46ff:fe0d:bfe.43684
|
||||||
|
# OpenThread_BorderRouter._meshcop._udp.local. 10\tIN SRV 0 0 49153 raspberrypi.local.
|
||||||
|
try:
|
||||||
|
addr = response.split('AAAA\tfe80')[1].split(' ')[0]
|
||||||
|
addr = 'fe80%s%%eth0' % addr
|
||||||
|
except Exception:
|
||||||
|
raise Exception('Unable to find the DUT address in the mDNS response')
|
||||||
|
try:
|
||||||
|
port = int(response.split('IN SRV')[1].split(' ')[3])
|
||||||
|
except Exception:
|
||||||
|
raise Exception('Unable to find the DUT port in the mDNS response')
|
||||||
|
|
||||||
|
return (addr, port)
|
||||||
|
|
||||||
# Override powerDown
|
# Override powerDown
|
||||||
@API
|
@API
|
||||||
|
|||||||
Reference in New Issue
Block a user