mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
[telemetry] add API for TREL telemetry (#9710)
Create OT API to support trel telemetry which is supported through platform API and also add cli support to get/reset trel counters. Metrics we are adding are: - trel_frames_tx - trel_bytes_tx - trel_frames_rx - trel_bytes_rx - trel_frames_tx_failed - num_trel_peers Metrics already supported through API: - trel_enabled
This commit is contained in:
@@ -1390,6 +1390,30 @@ class NodeImpl:
|
||||
|
||||
raise
|
||||
|
||||
def get_trel_counters(self):
|
||||
cmd = 'trel counters'
|
||||
self.send_command(cmd)
|
||||
result = self._expect_command_output()
|
||||
|
||||
counters = {}
|
||||
for line in result:
|
||||
m = re.match(r'(\w+)\:[^\d]+(\d+)[^\d]+(\d+)(?:[^\d]+(\d+))?', line)
|
||||
if m:
|
||||
groups = m.groups()
|
||||
sub_counters = {
|
||||
'packets': int(groups[1]),
|
||||
'bytes': int(groups[2]),
|
||||
}
|
||||
if groups[3]:
|
||||
sub_counters['failures'] = int(groups[3])
|
||||
counters[groups[0]] = sub_counters
|
||||
return counters
|
||||
|
||||
def reset_trel_counters(self):
|
||||
cmd = 'trel counters reset'
|
||||
self.send_command(cmd)
|
||||
self._expect_done()
|
||||
|
||||
def _encode_txt_entry(self, entry):
|
||||
"""Encodes the TXT entry to the DNS-SD TXT record format as a HEX string.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user