[tcat] implement decommissioning in tcat_agent (#10415)

Commits adds handling of TCAT TLV 0x60 `kTlvDecommission`.
This commit is contained in:
Przemysław Bida
2024-07-01 19:14:53 -07:00
committed by GitHub
parent 99b3ed4ca8
commit 6aa6f45606
6 changed files with 110 additions and 3 deletions
+2 -1
View File
@@ -125,7 +125,8 @@ async def get_device_by_args(args):
elif args.scan:
tcat_devices = await ble_scanner.scan_tcat_devices()
device = select_device_by_user_input(tcat_devices)
device = await BleStream.create(device.address, BBTC_SERVICE_UUID, BBTC_TX_CHAR_UUID, BBTC_RX_CHAR_UUID)
if device:
device = await BleStream.create(device.address, BBTC_SERVICE_UUID, BBTC_TX_CHAR_UUID, BBTC_RX_CHAR_UUID)
elif args.simulation:
device = UdpStream("127.0.0.1", int(args.simulation))
@@ -87,6 +87,22 @@ class CommissionCommand(Command):
return CommandResultTLV(tlv_response)
class DecommissionCommand(Command):
def get_help_string(self) -> str:
return 'Stop Thread interface and decommission device from current network.'
async def execute_default(self, args, context):
bless: BleStreamSecure = context['ble_sstream']
print('Disabling Thread and decommissioning device...')
data = (TLV(TcatTLVType.DECOMMISSION.value, bytes()).to_bytes())
response = await bless.send_with_resp(data)
if not response:
return
tlv_response = TLV.from_bytes(response)
return CommandResultTLV(tlv_response)
class ThreadStartCommand(Command):
def get_help_string(self) -> str:
+3 -1
View File
@@ -29,7 +29,8 @@
import readline
import shlex
from ble.ble_stream_secure import BleStreamSecure
from cli.base_commands import (HelpCommand, HelloCommand, CommissionCommand, ThreadStateCommand, ScanCommand)
from cli.base_commands import (HelpCommand, HelloCommand, CommissionCommand, DecommissionCommand, ThreadStateCommand,
ScanCommand)
from cli.dataset_commands import (DatasetCommand)
from dataset.dataset import ThreadDataset
from typing import Optional
@@ -42,6 +43,7 @@ class CLI:
'help': HelpCommand(),
'hello': HelloCommand(),
'commission': CommissionCommand(),
'decommission': DecommissionCommand(),
'dataset': DatasetCommand(),
'thread': ThreadStateCommand(),
'scan': ScanCommand(),