1*cfb92d14SAndroid Build Coastguard Worker# BBTC Client 2*cfb92d14SAndroid Build Coastguard Worker 3*cfb92d14SAndroid Build Coastguard Worker## Overview 4*cfb92d14SAndroid Build Coastguard Worker 5*cfb92d14SAndroid Build Coastguard WorkerThis is a Python implementation of Bluetooth-Based Thread Commissioning (BBTC) client, based on Thread's TCAT (Thread Commissioning over Authenticated TLS) functionality. 6*cfb92d14SAndroid Build Coastguard Worker 7*cfb92d14SAndroid Build Coastguard Worker## Installation 8*cfb92d14SAndroid Build Coastguard Worker 9*cfb92d14SAndroid Build Coastguard WorkerIf you don't have the poetry module installed (check with `poetry --version`), install it first using: 10*cfb92d14SAndroid Build Coastguard Worker 11*cfb92d14SAndroid Build Coastguard Worker```bash 12*cfb92d14SAndroid Build Coastguard Workerpython3 -m pip install poetry 13*cfb92d14SAndroid Build Coastguard Worker``` 14*cfb92d14SAndroid Build Coastguard Worker 15*cfb92d14SAndroid Build Coastguard Worker``` 16*cfb92d14SAndroid Build Coastguard Workerpoetry install 17*cfb92d14SAndroid Build Coastguard Worker``` 18*cfb92d14SAndroid Build Coastguard Worker 19*cfb92d14SAndroid Build Coastguard WorkerThis will install all the required modules to a virtual environment, which can be used by calling `poetry run <COMMAND>` from the project directory. 20*cfb92d14SAndroid Build Coastguard Worker 21*cfb92d14SAndroid Build Coastguard Worker## Usage 22*cfb92d14SAndroid Build Coastguard Worker 23*cfb92d14SAndroid Build Coastguard WorkerTo see the supported commandline arguments of BBTC client, use: 24*cfb92d14SAndroid Build Coastguard Worker 25*cfb92d14SAndroid Build Coastguard Worker``` 26*cfb92d14SAndroid Build Coastguard Workerpoetry run python3 bbtc.py --help 27*cfb92d14SAndroid Build Coastguard Worker``` 28*cfb92d14SAndroid Build Coastguard Worker 29*cfb92d14SAndroid Build Coastguard WorkerIn order to connect to a TCAT device, enter the project directory and run: 30*cfb92d14SAndroid Build Coastguard Worker 31*cfb92d14SAndroid Build Coastguard Worker```bash 32*cfb92d14SAndroid Build Coastguard Workerpoetry run python3 bbtc.py {<device specifier> | --scan} 33*cfb92d14SAndroid Build Coastguard Worker``` 34*cfb92d14SAndroid Build Coastguard Worker 35*cfb92d14SAndroid Build Coastguard Workerwhere `<device specifier>` can be: 36*cfb92d14SAndroid Build Coastguard Worker 37*cfb92d14SAndroid Build Coastguard Worker- `--name <NAME>` - name advertised by the device 38*cfb92d14SAndroid Build Coastguard Worker- `--mac <ADDRESS>` - physical address of the device's Bluetooth interface 39*cfb92d14SAndroid Build Coastguard Worker 40*cfb92d14SAndroid Build Coastguard WorkerUsing the `--scan` option will scan for every TCAT device and display them in a list, to allow selection of the target. 41*cfb92d14SAndroid Build Coastguard Worker 42*cfb92d14SAndroid Build Coastguard WorkerFor example: 43*cfb92d14SAndroid Build Coastguard Worker 44*cfb92d14SAndroid Build Coastguard Worker``` 45*cfb92d14SAndroid Build Coastguard Workerpoetry run python3 bbtc.py --name 'Thread BLE' 46*cfb92d14SAndroid Build Coastguard Worker``` 47*cfb92d14SAndroid Build Coastguard Worker 48*cfb92d14SAndroid Build Coastguard WorkerThe application will connect to the first matching device discovered and set up a secure TLS channel. The user is then presented with the CLI. 49*cfb92d14SAndroid Build Coastguard Worker 50*cfb92d14SAndroid Build Coastguard Worker## Usage with a specific TCAT Commissioner identity 51*cfb92d14SAndroid Build Coastguard Worker 52*cfb92d14SAndroid Build Coastguard WorkerThe TCAT Commissioner's certificate specifies what permissions it has obtained for specific features of managing a TCAT Device. By default, the identity in the `auth` directory is used. In order to use a different TCAT Commissioner certificate (identity), use the `--cert_path` argument, as follows: 53*cfb92d14SAndroid Build Coastguard Worker 54*cfb92d14SAndroid Build Coastguard Worker```bash 55*cfb92d14SAndroid Build Coastguard Workerpoetry run python3 bbtc.py --cert_path <certs-path> {<device specifier> | --scan} 56*cfb92d14SAndroid Build Coastguard Worker``` 57*cfb92d14SAndroid Build Coastguard Worker 58*cfb92d14SAndroid Build Coastguard Workerwhere `<certs-path>` is the directory where the private key, certificate, and CA certificate of the TCAT Commissioner are stored. 59*cfb92d14SAndroid Build Coastguard Worker 60*cfb92d14SAndroid Build Coastguard WorkerFor example to use a pre-configured identity `CommCert2` (related to Thread certification tests): 61*cfb92d14SAndroid Build Coastguard Worker 62*cfb92d14SAndroid Build Coastguard Worker``` 63*cfb92d14SAndroid Build Coastguard Workerpoetry run python3 bbtc.py --cert_path ./auth-cert/CommCert2 --name 'Thread BLE' 64*cfb92d14SAndroid Build Coastguard Worker``` 65*cfb92d14SAndroid Build Coastguard Worker 66*cfb92d14SAndroid Build Coastguard WorkerThe `auth-cert` directory contains some other identities too, for testing purposes. Refer to Thread TCAT test plan documents for details. 67*cfb92d14SAndroid Build Coastguard Worker 68*cfb92d14SAndroid Build Coastguard WorkerSee [GENERATING_CERTIFICATES.md](GENERATING_CERTIFICATES.md) for details on generating own certificates. 69*cfb92d14SAndroid Build Coastguard Worker 70*cfb92d14SAndroid Build Coastguard Worker## TCAT Commissioner CLI Commands 71*cfb92d14SAndroid Build Coastguard Worker 72*cfb92d14SAndroid Build Coastguard WorkerThe application supports the following interactive CLI commands: 73*cfb92d14SAndroid Build Coastguard Worker 74*cfb92d14SAndroid Build Coastguard Worker- `help` - Display available commands. 75*cfb92d14SAndroid Build Coastguard Worker- `commission` - Commission the device with current dataset. 76*cfb92d14SAndroid Build Coastguard Worker- `thread start` - Enable Thread interface. 77*cfb92d14SAndroid Build Coastguard Worker- `thread stop` - Disable Thread interface. 78*cfb92d14SAndroid Build Coastguard Worker- `hello` - Send "hello world" application data and read the response. 79*cfb92d14SAndroid Build Coastguard Worker- `exit` - Close the connection and exit. 80*cfb92d14SAndroid Build Coastguard Worker- `dataset` - View and manipulate current dataset. Use `dataset help` for more information. 81