Skip to content

Commit

Permalink
[otci] add backward compability (openthread#6780)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonlingoogle authored Jul 6, 2021
1 parent 48b129e commit 478fb1e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tools/otci/otci/otci.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,14 @@ def get_network_name(self):
return self.__parse_str(self.execute_command('networkname'))

def get_network_key(self) -> str:
"""Get the network network key."""
return self.__parse_network_key(self.execute_command('networkkey'))
"""Get the network key."""
return self.__parse_network_key(self.execute_command(self.__detect_networkkey_cmd()))

def set_network_key(self, networkkey: str):
"""Set the network network key."""
"""Set the network key."""
self.__validate_network_key(networkkey)
self.execute_command(f'networkkey {networkkey}')
cmd = self.__detect_networkkey_cmd()
self.execute_command(f'{cmd} {networkkey}')

def get_key_sequence_counter(self) -> int:
"""Get the Thread Key Sequence Counter."""
Expand Down Expand Up @@ -1674,7 +1675,7 @@ def __parse_dataset(self, output: List[str]) -> Dict[str, Any]:
dataset['extpanid'] = val
elif key == 'Mesh Local Prefix':
dataset['mesh_local_prefix'] = val
elif key == 'Network Key':
elif key in ('Network Key', 'Master Key'):
dataset['networkkey'] = val
elif key == 'Network Name':
dataset['network_name'] = val
Expand Down Expand Up @@ -1728,7 +1729,8 @@ def dataset_set_buffer(self,
self.execute_command(f'dataset meshlocalprefix {mesh_local_prefix}')

if network_key is not None:
self.execute_command(f'dataset networkkey {network_key}')
nwk_cmd = self.__detect_networkkey_cmd()
self.execute_command(f'dataset {nwk_cmd} {network_key}')

if network_name is not None:
self.execute_command(f'dataset networkname {self.__escape_escapable(network_name)}')
Expand Down Expand Up @@ -1801,6 +1803,9 @@ def __detect_allowlist_cmd(self):
else:
return '\x77\x68\x69\x74\x65\x6c\x69\x73\x74'

def __detect_networkkey_cmd(self) -> str:
return 'networkkey' if self.api_version >= 126 else 'masterkey'

#
# Unicast Addresses management
#
Expand Down

0 comments on commit 478fb1e

Please sign in to comment.