Skip to content

Commit

Permalink
[tcat] feat: add dataset clear command (openthread#10812)
Browse files Browse the repository at this point in the history
Added 'clear' command to the 'dataset' command tree. This allows to
remove all entries in the 'ThreadDataset' object used by the script to
store the dataset values.

The reason behind this feature is that in the current implementation
of the script, the 'ThreadDataset' object entries are always
initialized by 'initial_dataset' when running the script.

No command allows to clear/remove the particular entry, which makes
this script unable to send an active dataset to the target device
without specific dataset values(custom dataset).

To make this possible, the 'clear' command has been added to the
'dataset' command tree, which removes all entries from the
'ThreadDataset' object and, by using existing commands, sets the
desired entries in the 'ThreadDataset' object from scratch.

This enables the script to send custom active dataset values to the
target device.
  • Loading branch information
jaul-nsc authored Oct 11, 2024
1 parent 19b2d6b commit ed14eb1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/tcat_ble_client/cli/dataset_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ def handle_dataset_entry_command(type: MeshcopTlvType, args, context):
return CommandResultNone()


class DatasetClearCommand(Command):

def get_help_string(self) -> str:
return 'Clear dataset.'

async def execute_default(self, args, context):
ds: ThreadDataset = context['dataset']
ds.clear()
return CommandResultNone()


class DatasetHelpCommand(Command):

def get_help_string(self) -> str:
Expand Down Expand Up @@ -194,6 +205,7 @@ class DatasetCommand(Command):

def __init__(self):
self._subcommands = {
'clear': DatasetClearCommand(),
'help': DatasetHelpCommand(),
'hex': PrintDatasetHexCommand(),
'reload': ReloadDatasetCommand(),
Expand Down
3 changes: 3 additions & 0 deletions tools/tcat_ble_client/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ def set_entry(self, type: MeshcopTlvType, args: List[str]):
self.entries[type].set(args)
return
raise KeyError(f'Key {type} not available in the dataset.')

def clear(self):
self.entries.clear()

0 comments on commit ed14eb1

Please sign in to comment.