mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[otci] support MLE Discovery (#7073)
This commit is contained in:
@@ -86,7 +86,7 @@ class OtCliCommandRunner(OTCommandHandler):
|
||||
r')')
|
||||
"""regex used to filter logs"""
|
||||
|
||||
__ASYNC_COMMANDS = {'scan', 'ping'}
|
||||
__ASYNC_COMMANDS = {'scan', 'ping', 'discover'}
|
||||
|
||||
def __init__(self, otcli: OtCliHandler, is_spinel_cli=False):
|
||||
self.__otcli: OtCliHandler = otcli
|
||||
|
||||
@@ -225,9 +225,15 @@ class OTCI(object):
|
||||
"""Stop sending ICMPv6 Echo Requests."""
|
||||
self.execute_command('ping stop')
|
||||
|
||||
def discover(self, channel: int = None) -> List[Dict[str, Any]]:
|
||||
"""Perform an MLE Discovery operation."""
|
||||
return self.__scan_networks('discover', channel)
|
||||
|
||||
def scan(self, channel: int = None) -> List[Dict[str, Any]]:
|
||||
"""Perform an IEEE 802.15.4 Active Scan."""
|
||||
cmd = 'scan'
|
||||
return self.__scan_networks('scan', channel)
|
||||
|
||||
def __scan_networks(self, cmd: str, channel: int = None) -> List[Dict[str, Any]]:
|
||||
if channel is not None:
|
||||
cmd += f' {channel}'
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@ class TestOTCI(unittest.TestCase):
|
||||
logging.info("Leader router table: %r", leader.get_router_table())
|
||||
self.assertFalse(list(leader.get_router_table().values())[0].is_link_established)
|
||||
|
||||
logging.info('discover: %r', leader.discover())
|
||||
logging.info('scan: %r', leader.scan())
|
||||
logging.info('scan energy: %r', leader.scan_energy())
|
||||
|
||||
@@ -613,6 +614,7 @@ class TestOTCI(unittest.TestCase):
|
||||
|
||||
child1.ifconfig_up()
|
||||
|
||||
logging.info("child1 discover: %r", child1.discover())
|
||||
logging.info("child1 scan: %r", child1.scan())
|
||||
logging.info("child1 scan energy: %r", child1.scan_energy())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user