mirror of
https://github.com/espressif/openthread.git
synced 2026-09-10 11:10:08 +00:00
[tests] add test case Cert_9_2_02 (#3589)
1. Add new test case **Cert_9_2_02**. Since the test case contains 2 topologies, added 2 new files: - `Cert_9_2_02A_MGMTCommissionerSet.py`, - `Cert_9_2_02B_MGMTCommissionerSet.py`. 2. Add mesh_cop tlvs parsing. The corresponding file is `mesh_cop.py`. The mesh_cop tlvs are used in many cases. For example, `CommissionerSessionId` is used in both the parsing of **Commissioning Data**(in mle) and the parsing of **CoAP**. Collected all mesh_cop tlvs refered in Thread into this file with some unused tlvs unimplemented. 3. Reuse `SubTlvsFactory` in `network_data.py`. `SubTlvsFactory` are used to choose the corresponding factory of specific tlv and do the parsing of it. The `NetworkLayerTlvsFactory` in `network_layer.py` had exactly the same function with it (almost the same code). Moved the `SubTlvsFactory` into a new file `tlvs_parsing.py` and change the usage in `network_data.py` and `network_layer.py`. This helps us remove some redundant code. 4. Some format issues. Remove some trailing spaces.
This commit is contained in:
@@ -511,6 +511,22 @@ class otCli:
|
||||
|
||||
return None
|
||||
|
||||
def get_addr_rloc(self):
|
||||
addrs = self.get_addrs()
|
||||
for addr in addrs:
|
||||
segs = addr.split(':')
|
||||
if segs[4] == '0' and segs[5] == 'ff' and segs[6] == 'fe00' and segs[7] != 'fc00':
|
||||
return addr
|
||||
return None
|
||||
|
||||
def get_addr_leader_aloc(self):
|
||||
addrs = self.get_addrs()
|
||||
for addr in addrs:
|
||||
segs = addr.split(':')
|
||||
if segs[4] == '0' and segs[5] == 'ff' and segs[6] == 'fe00' and segs[7] == 'fc00':
|
||||
return addr
|
||||
return None
|
||||
|
||||
def get_eidcaches(self):
|
||||
eidcaches = []
|
||||
self.send_command('eidcache')
|
||||
@@ -901,3 +917,18 @@ class otCli:
|
||||
timeout = 5
|
||||
|
||||
self._expect('Received coap secure response', timeout=timeout)
|
||||
|
||||
def commissioner_mgmtset(self, tlvs_binary):
|
||||
cmd = 'commissioner mgmtset binary ' + tlvs_binary
|
||||
self.send_command(cmd)
|
||||
self._expect('Done')
|
||||
|
||||
def bytes_to_hex_str(self, src):
|
||||
return ''.join(format(x, '02x') for x in src)
|
||||
|
||||
def commissioner_mgmtset_with_tlvs(self, tlvs):
|
||||
payload = bytearray()
|
||||
for tlv in tlvs:
|
||||
payload += tlv.to_hex()
|
||||
self.commissioner_mgmtset(self.bytes_to_hex_str(payload))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user