mirror of
https://github.com/espressif/openthread.git
synced 2026-07-22 12:04:06 +00:00
[link-metrics] add blocking CLI query command and enhance tests (#8108)
This commit updates CLI `linkmetrics query` command to allow it to be used in blocking mode (wait for response to query). This is then used in different tests to validate the `LinkMetrics` module behavior. In particular, `v1_2_test_single_probe` and `v1_2_LowPower_7_2_01_ForwardTrackingSeries` are updated to validate that the received query report message is correctly parsed.
This commit is contained in:
committed by
GitHub
parent
c3dd3ba8fb
commit
6dca78e757
@@ -2861,15 +2861,38 @@ class NodeImpl:
|
||||
|
||||
return router_table
|
||||
|
||||
def link_metrics_query_single_probe(self, dst_addr: str, linkmetrics_flags: str):
|
||||
cmd = 'linkmetrics query %s single %s' % (dst_addr, linkmetrics_flags)
|
||||
def link_metrics_query_single_probe(self, dst_addr: str, linkmetrics_flags: str, block: str = ""):
|
||||
cmd = 'linkmetrics query %s single %s %s' % (dst_addr, linkmetrics_flags, block)
|
||||
self.send_command(cmd)
|
||||
self._expect_done()
|
||||
self.simulator.go(5)
|
||||
return self._parse_linkmetrics_query_result(self._expect_command_output())
|
||||
|
||||
def link_metrics_query_forward_tracking_series(self, dst_addr: str, series_id: int):
|
||||
cmd = 'linkmetrics query %s forward %d' % (dst_addr, series_id)
|
||||
def link_metrics_query_forward_tracking_series(self, dst_addr: str, series_id: int, block: str = ""):
|
||||
cmd = 'linkmetrics query %s forward %d %s' % (dst_addr, series_id, block)
|
||||
self.send_command(cmd)
|
||||
self._expect_done()
|
||||
self.simulator.go(5)
|
||||
return self._parse_linkmetrics_query_result(self._expect_command_output())
|
||||
|
||||
def _parse_linkmetrics_query_result(self, lines):
|
||||
"""Parse link metrics query result"""
|
||||
|
||||
# Exmaple of command output:
|
||||
# ['Received Link Metrics Report from: fe80:0:0:0:146e:a00:0:1',
|
||||
# '- PDU Counter: 1 (Count/Summation)',
|
||||
# '- LQI: 0 (Exponential Moving Average)',
|
||||
# '- Margin: 80 (dB) (Exponential Moving Average)',
|
||||
# '- RSSI: -20 (dBm) (Exponential Moving Average)']
|
||||
#
|
||||
# Or 'Link Metrics Report, status: {status}'
|
||||
|
||||
result = {}
|
||||
for line in lines:
|
||||
if line.startswith('- '):
|
||||
k, v = line[2:].split(': ')
|
||||
result[k] = v.split(' ')[0]
|
||||
elif line.startswith('Link Metrics Report, status: '):
|
||||
result['Status'] = line[29:]
|
||||
return result
|
||||
|
||||
def link_metrics_mgmt_req_enhanced_ack_based_probing(self,
|
||||
dst_addr: str,
|
||||
|
||||
Reference in New Issue
Block a user