Skip to content

Commit

Permalink
CC26X2X7 Initial support of BLE Rendezvous (project-chip#4865)
Browse files Browse the repository at this point in the history
* CC26X2X7 Initial support of BLE Rendezvous

Migrate to the new Texas Instruments CC26X2X7 LaunchPad. This allows
concurrent Full Thread Device and BLE operation. This Enables BLE
rendezvous on the CC26X2X7.

Thanks to Alexander D'Abreu for work on the DMM integration and CHIPoBLE
profile development for the TI platform.

Co-Authored-by: Alexander D'Abreu <alexander.dabreu@ti.com>

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* fixup doxygen issues

* remove commented out code

* Update return cases

* Removed parens around return values.
* Propagated an error if possible.
* used assert() macro otherwise.

* Restyled by whitespace

* Restyled by clang-format

* remove unneded TI-POSIX conifg

* free correct buffer in error case

Co-authored-by: Alexander D'Abreu <alexander.dabreu@ti.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
3 people authored Feb 17, 2021
1 parent 0708a28 commit e76ed54
Show file tree
Hide file tree
Showing 55 changed files with 3,562 additions and 223 deletions.
123 changes: 0 additions & 123 deletions examples/lock-app/cc13x2_26x2/chip.syscfg

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni")

assert(current_os == "freertos")

project_dir = "${chip_root}/examples/lock-app/cc13x2_26x2"
project_dir = "${chip_root}/examples/lock-app/cc13x2x7_26x2x7"

ti_simplelink_sdk("sdk") {
include_dirs = [ "${project_dir}/main/include" ]
Expand All @@ -45,6 +45,10 @@ ti_sysconfig("sysconfig") {
"ti_radio_config.h",
"ti_drivers_config.c",
"ti_drivers_config.h",
"ti_ble_config.c",
"ti_ble_config.h",
"ti_dmm_application_policy.c",
"ti_dmm_application_policy.h",

# disabled until upstream generation is aligned
#"tiop_config.h",
Expand All @@ -55,6 +59,17 @@ ti_sysconfig("sysconfig") {
#"syscfg_c.rov.xs",
#"ti_utils_runtime_model.gv",
#"ti_utils_runtime_Makefile",
#"ti_ble_app_config.opt",
#"ti_build_config.opt",
]
public_configs = [ ":sdk_dmm_config" ]

cflags = [
"-Wno-comment",
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_ble_app_config.opt",
root_build_dir),
"@" + rebase_path("${target_gen_dir}/sysconfig/ti_build_config.opt",
root_build_dir),
]
}

Expand All @@ -67,14 +82,14 @@ ti_simplelink_executable("lock_app") {
"${project_dir}/main/include",
]
defines = []
output_name = "chip-cc13x2_26x2-lock-example.out"
output_name = "chip-${ti_simplelink_board}-lock-example.out"

public_deps = [
":sdk",
":sysconfig",
"${chip_root}/examples/lock-app/lock-common",
"${chip_root}/src/lib",
"${openthread_root}:libopenthread-cli-mtd",
"${openthread_root}:libopenthread-cli-ftd",
]

sources = [
Expand All @@ -84,17 +99,27 @@ ti_simplelink_executable("lock_app") {
"${project_dir}/main/main.cpp",
]

cflags = [
"-Wno-implicit-fallthrough",
"-Wno-sign-compare",
]

output_dir = root_out_dir

ldscript = "${ti_simplelink_sdk_root}/source/ti/boards/cc13x2_cc26x2/cc13x2_cc26x2_freertos.lds"
ldscript = "${ti_simplelink_sdk_root}/source/ti/dmm/apps/common/freertos/cc13x2x7_cc26x2x7.lds"

ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
ldflags = [
"-L${ti_simplelink_sdk_root}/source",
rebase_path("${target_gen_dir}/sysconfig/ti_utils_build_linker.cmd.genlibs",
root_build_dir),
"-T" + rebase_path(ldscript, root_build_dir),
]
}

group("cc13x2_26x2") {
group("cc13x2x7_26x2x7") {
deps = [ ":lock_app" ]
}

group("default") {
deps = [ ":cc13x2_26x2" ]
deps = [ ":cc13x2x7_26x2x7" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ CC13X2_26X2 family of Wireless MCUs.
- [UniFlash](#uniflash)
- [Code Composer Studio](#code-composer-studio)
- [Viewing Logging Output](#viewing-logging-output)
- [Running the Example](#running-the-example)
- [Provisioning](#provisioning)
- [Bluetooth LE Advertising](#bluetooth-le-advertising)
- [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous)
- [CHIP Remote Commands](#chip-remote-commands)
- [TI Support](#ti-support)

---

Expand All @@ -26,9 +32,10 @@ The CC13X2_26X2 lock example application provides a working demonstration of a
connected door lock device. This uses the open-source CHIP implementation and
the Texas Instruments SimpleLink™ CC13x2 and CC26x2 software development kit.

This example is enabled to build on all members of the `CC13X2_26X2` family of
MCUs [recommended for Thread][ti_thread_dnd]. By default this example targets
the [CC1352R1_LAUNCHXL][cc1352r1_launchxl] LaunchPad.
This example is enabled to build for CC2652R7 devices. This upcoming devices are
currently not yet in full production. For more information on device
availability or early access to an engineering build of our CHIP-enabled SDK,
please reach out [here][ti_cc13x2_26x2_r7_chip_request].

The lock example is intended to serve both as a means to explore the workings of
CHIP, as well as a template for creating real products based on the Texas
Expand All @@ -39,10 +46,16 @@ Instruments devices.
This example application has a simple User Interface to depict the state of the
door lock and to control the state. The user LEDs on the LaunchPad are set on
when the lock is locked, and are set off when unlocked. The LEDs will flash when
in the transition state between locked and unlocked. The user buttons are used
for requesting lock and unlock of the door lock. The left button (`BTN-1`) is
used to request locking. The right button (`BTN-2`) us used to request
unlocking.
in the transition state between locked and unlocked.

Short presses (less than 1000ms) of the user buttons are used for requesting
lock and unlock of the door lock. The left button (`BTN-1`) is used to request
locking. The right button (`BTN-2`) is used to request unlocking.

Long presses (greater than 1000ms) of the user buttons are used for controlling
BLE advertisements. The left button (`BTN-1`) is used to disable advertisements
if they are enabled. The Right button (`BTN-2`) is used to enable
advertisements.

## Building

Expand All @@ -51,8 +64,8 @@ unlocking.
Some initial setup is necessary for preparing the build environment. This
section will need to be done when migrating to new versions of the SDK.

- Download and install the [SimpleLink™ CC13x2 and CC26x2 software development
kit (SDK)][simplelink_sdk] ([4.30.00.54][simplelink_sdk_4.30.00.54])
- An engineering SDK from TI is required. Please request access for it
[here][ti_cc13x2_26x2_r7_chip_request].

- Follow the default installation instructions when executing the
installer.
Expand All @@ -64,7 +77,7 @@ section will need to be done when migrating to new versions of the SDK.
- Download and install [SysConfig][sysconfig]
([sysconfig-1.5.0_1397][sysconfig-1.5.0_1397])

- This may have already been installed with your SimpleLink SDK install
- This may have already been installed with your SimpleLink SDK install.

- If you have installed different versions, the build defaults will need to be
changed to reflect this in
Expand All @@ -82,31 +95,14 @@ section will need to be done when migrating to new versions of the SDK.
- You will have to ensure that the default version of Python 3 is Python
3.8.

- run the bootstrap script to setup the build environment.
- Run the bootstrap script to setup the build environment.

```
$ cd ~/connectedhomeip
$ source ./script/bootstrap.sh
```

#### Changes to the TI SDK

The OpenThread library will set the short address assigned to the device as soon
as it receives the Child ID response. This may happen while the radio driver is
still in transmit mode. This is easilly fixed by removing state check in the
else condition in
`${ti_simplelink_sdk_root}/examples/rtos/${ti_simplelink_board}/thread/cli_mtd/platform/radio.c`
on linke 1791.

```
- else if (sState != platformRadio_phyState_Transmit)
+ else
{
sReceiveCmd.localShortAddr = aAddress;
}
```

### Compilation

It is necessary to activate the environment in every new shell. Then run GN and
Expand All @@ -123,7 +119,7 @@ Ninja to build the executable.
- Run the build to produce a default executable. By default on Linux both the
TI SimpleLink SDK and Sysconfig are located in a `ti` folder in the user's
home directory, and you must provide the absolute path to them. For example
`/home/username/ti/simplelink_cc13x2_26x2_sdk_4_30_00_54` and
`/home/username/ti/simplelink_cc13x2_26x2_sdk_4_40_05_02_eng` and
`/home/username/ti/sysconfig_1.6.0`. On Windows the default directory is
`C:\ti`

Expand Down Expand Up @@ -163,8 +159,66 @@ terminal emulator to that port to see the output with the following options:
| Parity | `None` |
| Flow control | `None` |

## Running the Example

Once a device has been flashed with this example, it can now join and operate in
an existing Thread network. The following sections assume that a Thread network
is already active, and has at least one [OpenThread Border
Router][ot_border_router_setup].

### Provisioning

The first step to bring the CHIP device onto the network is to provision it. Our
example accomplishes this with Bluetooth Low Energy (BLE) and the
[CHIPTool](../../../src/android/CHIPTool/README.md) mobile app.

#### Bluetooth LE Advertising

To provision this example onto a Thread network, the device must be discoverable
over Bluetooth LE. BLE advertising is started by long pressing the right button
(greater than 1000ms), labeled `BTN-2` on the silkscreen. Once the device is
fully provisioned, BLE advertising will stop.

#### Bluetooth LE Rendezvous

In this example, the provisioning procedure (called Rendezvous) is done over
Bluetooth LE between a CHIP device (lock-app) and the CHIP controller
(CHIPTool), where the controller has the commissioner role.

To start the rendezvous, the controller must get the commissioning information
from the CHIP device.

This is done by scanning a QR code. A URL will be displayed on the lock-app's
log ([UART terminal](#viewing-logging-output)). It will look like the following:

```
SetupQRCode: [CH:.81TM -00 0C9SS0]
Copy/paste the below URL in a browser to see the QR Code:
https://dhrishi.github.io/connectedhomeip/qrcode.html?data=CH%3A.81TM%20-00%200C9SS0
```

You can directly navigate to the webpage URL displayed (which has QR payload
pre-loaded). Alternatively, you can navigate to [the QR code
generator][qr_code_generator] and enter in the payload shown in `SetupQRCode`
(in this case `CH:.81TM -00 0C9SS0`).

### CHIP Remote Commands

Once the CHIP device is provisioned and operating on the network, CHIPTool can
be used to control the device. During the provisioning process, the CHIP device
would have sent one of its newly assigned IPv6 addresses to the CHIPTool.

In the app, you should see an On/Off cluster; this corresponds to the lock-app.
You can now control the lock-app CHIP device from the smartphone!

## TI Support

For technical support, please consider creating a post on TI's [E2E forum][e2e].
Additionally, we welcome any feedback.

[chip]: https://github.com/project-chip/connectedhomeip
[cc1352r1_launchxl]: https://www.ti.com/tool/LAUNCHXL-CC1352R1
[e2e]: https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread
[simplelink_sdk]: https://www.ti.com/tool/SIMPLELINK-CC13X2-26X2-SDK
[simplelink_sdk_4.30.00.54]:
https://www.ti.com/tool/download/SIMPLELINK-CC13X2-26X2-SDK/4.30.00.54
Expand All @@ -173,3 +227,7 @@ terminal emulator to that port to see the output with the following options:
http://software-dl.ti.com/ccs/esd/sysconfig/sysconfig-1.5.0_1397-setup.run
[ti_thread_dnd]:
https://www.ti.com/wireless-connectivity/thread/design-development.html
[ti_cc13x2_26x2_r7_chip_request]: https://ti.com/chip_sdk
[ot_border_router_setup]:
https://openthread.io/guides/border-router/beaglebone-black
[qr_code_generator]: https://dhrishi.github.io/connectedhomeip/qrcode.html
Loading

0 comments on commit e76ed54

Please sign in to comment.