Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions sld131-bluetooth-getting-started-demos-examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,31 @@ See [Dynamic Multiprotocol Development with Bluetooth and Proprietary Protocols

### NCP Host Examples

NCP host examples are located in \<GSDK-install-location>\app\bluetooth\example_host.
NCP host examples are located in \<SiSDK-install-location>\bluetooth_le_app\example_host.

- **bt\_host\_empty:** Minimal host-side project structure, used as a starting point for NCP host applications. Use it with the **Bluetooth – NCP** target application flashed to the radio board.
- **bt\_aoa\_host\_locator:** A locator host sample app that works together with a **Bluetooth AoA – NCP Locator** target app. It receives IQ samples from the target and estimates the Angle of Arrival (AoA). For more information see [Application Development with Silicon Labs’ RTL Library](https://docs.silabs.com/rtl-lib/latest/direction-finding-solution-guide/).

- **bt\_host\_ota\_dfu:** Demonstrates how to perform an OTA DFU on a Silicon Labs Bluetooth Device. It requires a WSTK with a radio board flashed with NCP firmware to be used as the GATT client that performs the OTA.
- **bt\_cs\_host:** This is the host application for the Channel Sounding (CS) NCP target application.

- **bt\_host\_uart\_dfu:** Demonstrates how to perform a UART DFU on a Silicon Labs Bluetooth Device running NCP firmware.
- **bt\_host\_cpc\_hci\_bridge:** A background application to be run when HCI interface is exposed via CPC. This application retrieves the HCI commands/events from the CPC messages and forwards them toward the Bluetooth host running on the PC. Similarly, it forwards the HCI commands from the host toward the target over CPC.

- **bt\_host\_voice:** On a WSTK programmed with NCP firmware, it to connects to the **Bluetooth – SoC Voice** example, sets the correct configuration on it, receives audio via Bluetooth, and stores audio data into a file.
- **bt\_host\_empty:** Minimal host-side project structure, used as a starting point for NCP host applications. Use it with the **Bluetooth – NCP** target application flashed to the radio board.

- **bt\_aoa\_host\_locator:** A locator host sample app that works together with a **Bluetooth AoA – NCP Locator** target app. It receives IQ samples from the target and estimates the Angle of Arrival (AoA). For more information see [Application Development with Silicon Labs’ RTL Library](https://docs.silabs.com/rtl-lib/latest/direction-finding-solution-guide/).
- **bt\_host\_esl\_ap:** This Python example implements the functionality of an Access Point as specified by the Bluetooth Electronic Shelf Label Profile specification using an NCP ESL AP target.

- **bt\_host\_positioning:** Connects to multiple **bt\_aoa\_host\_locator** sample apps (via MQTT) and estimates a position from Angles of Arrival (AoA). For more information, see *QS175: Application Development with Silicon Labs’ RTL Library.*
- **bt\_host\_ncp\_test:** This Network Co-Processor (NCP) host application serves 2 purposes. It demonstrates (1) how to use user NCP commands and (2) how to implement a simple application to test NCP performance using the default user commands.

- **bt\_host\_positioning\_gui:** Connects to the **bt\_host\_positioning** sample app (via MQTT), reads out the position estimations and displays the tags and locators on a 3D GUI. This sample app is python based. For more information, see [Application Development with Silicon Labs’ RTL Library](https://docs.silabs.com/rtl-lib/latest/direction-finding-solution-guide/).
- **bt\_host\_ota\_dfu:** Demonstrates how to perform an OTA DFU on a Silicon Labs Bluetooth Device. It requires a WSTK with a radio board flashed with NCP firmware to be used as the GATT client that performs the OTA.

- **bt\_host\_positioning:** Connects to multiple **bt\_aoa\_host\_locator** sample apps (via MQTT) and estimates a position from Angles of Arrival (AoA). For more information, see *QS175: Application Development with Silicon Labs’ RTL Library.*

- **bt\_host\_throughput:** Tests the throughput capabilities of the device in NCP mode and can be used to measure throughput between two devices as well as between a device and a smartphone.

- **bt\_host\_cpc\_hci\_bridge:** A background application to be run when HCI interface is exposed via CPC. This application retrieves the HCI commands/events from the CPC messages and forwards them toward the Bluetooth host running on the PC. Similarly, it forwards the HCI commands from the host toward the target over CPC.
- **bt\_host\_uart\_dfu:** Demonstrates how to perform a UART DFU on a Silicon Labs Bluetooth Device running NCP firmware.

- **bt\_host\_voice:** On a WSTK programmed with NCP firmware, it to connects to the **Bluetooth – SoC Voice** example, sets the correct configuration on it, receives audio via Bluetooth, and stores audio data into a file.

- **bt\_host\_positioning\_gui:** Connects to the **bt\_host\_positioning** sample app (via MQTT), reads out the position estimations and displays the tags and locators on a 3D GUI. This sample app is python based. For more information, see [Application Development with Silicon Labs’ RTL Library](https://docs.silabs.com/rtl-lib/latest/direction-finding-solution-guide/).

## Code Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ Bluetooth NCP Commander is an easy-to-use tool that can be used for testing diff

### Built-in Version

1. To open the built-in Bluetooth NCP Commander, select the target board in the **Debug Adapters** view, and check that the preferred SDK is set to **Gecko SDK Suite vn.n.n**. Select the **Compatible Tools** tab, and click **Launch** next to Bluetooth NCP Commander.
1. To open the built-in Bluetooth NCP Commander, select **Tools** tab on the left side, browse **Bluetooth NCP Commander** and click **Open Tool**.

![Compatible Tools](resources/an1259-v14-tools-tab.png)

Alternatively, you can open the built-in Bluetooth NCP Commander from the **Tools** menu.

![Tools dialog](resources/an1259-v14-tools-menu.png)
![Compatible Tools](resources/an1259-launch-Bluetooth-NCP-Commander.png)

2. Select the target device, and click **Connect**.

![Connection Manager](resources/an1259-v14-connection-manager.png)

### Standalone Version

1. To open the standalone tool, navigate to *C:\SiliconLabs\SimplicityStudio\v5\developer\adapter_packs\ncp_commander*, and start NcpCommander.exe.
1. To open the standalone tool, navigate to *C:\Users\\\<user>\\.silabs\slt\installs\archive\ncpcommander-vx.y.z*, and start NcpCommander.exe.

2. In the standalone tool, provide the UART interface settings, and then select the COM port on which the device can be accessed.

Expand Down Expand Up @@ -166,7 +162,7 @@ In **Settings**, if the **Reset Mesh Node before Initializing as Provisioner** o

## Building the NCP Host Examples on Windows

The Silicon Labs v3.x Bluetooth SDK contains a generic NCP Host example project for the PC. This example can be compiled on Windows or any POSIX OS. This section goes through the build process on Windows.
Simplicity Studio SDK contains NCP Host example projects for PC. These examples can be compiled on Windows or any POSIX OS. This section goes through the build process on Windows.

>**Note**: The host example projects in the SDK use the dynamic GATT database feature. They are to be used with the **Bluetooth – NCP** target application.

Expand All @@ -184,39 +180,36 @@ The Silicon Labs v3.x Bluetooth SDK contains a generic NCP Host example project

![msys2 mingw 64-bit](resources/an1259-msys2-mingw-64-bit.png)

5. Change to the NCP Host example folder, where \<version> varies by SDK version:

```C
cd c:\SiliconLabs\SimplicityStudio\v5\developer\sdks\gecko_sdk_suite\v3.x\app\bluetooth\example_host\bt_host_empty\
```

or

```C
cd c:\Users\<username>\SimplicityStudio\SDKs\gecko_sdk\app
```

6. Create an export of the example with the command `make export`. After the project files are exported, the export directory will be a working directory that is completely detached from the SDK but has the same folder structure inside. The benefit of using an export is that changes in the (config) files during development will not affect the SDK content, and multiple instances can coexist, for example for testing different variants. You can also use `make export EXPORT_DIR=/my/custom/export/path` to export the example to a custom directory.

7. Within the export folder navigate to the */app/bluetooth/example_host/bt_host_empty* folder.

8. If you want to add any service/characteristic to the GATT database, edit the */config/btconf/gatt_configuration.btconf* file. Edit it either with a text editor or drag-and-drop the file onto Simplicity Studio to edit it with the GATT Configurator. Do not forget to save the file after editing.
5. Create a new **Bluetooth - Host Empty** project in Simplicity Studio 6

9. Generate GATT database source files from the .*btconf* file by running `make gattdb` (in the */bt_host_empty* folder). Note: The generator script requires installing Python 3 and the Jinja2 package by calling `pip install jinja2`.
![studio6 host app generation](resources/an1259-studio6-host-app-generation.png)

6. At the Target Device select the option **Part** and **WIN32**
![studio6 select os](resources/an1259-studio6-select-os.png)

10. Build the exported project with the command: `make`. (Run it in the */bt_host_empty* folder, where you can find the makefile).

11. The build output is created in a new *exe* folder. Go to this folder with `cd exe`, and then run`bt_host_empty.exe`. The COM port and the IP address of the target are passed as command line parameters. The COM port should be the same as the one used by the JLink CDC UART Port, as shown in [NCP Host Development](./03-ncp-host-development). To see how to pass the different parameters, first run the exe with the `-h` (help) switch.
7. Navigate to the project folder in MSYS2 MinGW 64-bit.

8. Build the project in MSYS2 MinGW 64-bit
```C
.\bt_host_empty.exe -h
make -f bt_host_empty.Makefile
```

12. Once the UART connection with the device is established, you should see the following:

![started advertising message](resources/an1259-figure-3-6.png)

13. Now you can connect to the device over Bluetooth.
9. The build output is created in a new *build/debug/* folder. Navigate to this folder, and then run`bt_host_empty.exe` with the interface as an argument.

10. Once the UART connection with the device is established, the following should appear:

```
MINGW64 ~/SimplicityStudio/v6_workspace_2226/bt_host_empty
$ ./build/debug/bt_host_empty.exe -u COM30
[D] Timer function intialized
[I] NCP host initialised.
[I] Press Crtl+C to quit

[I] Rebooting NCP target (0)...
[I] Bluetooth stack booted: v11.0.1+0e13429e
[I] Bluetooth public device address: 04:87:27:E7:07:5D
[I] Started advertising.
```
10. The device advertises and ready for Bluetooth connection.

## Using Python for Host Side Development

Expand Down
36 changes: 22 additions & 14 deletions sld596-bluetooth-network-coprocessor-mode/04-secure-ncp.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,42 @@ By default, the NCP target boots without using this encryption. It will be reque

## Host Side

To build the NCP Host project with secure mode, use the following command:
1. Create a new **Bluetooth - Host Empty** project in Simplicity Studio 6

```C
make SECURITY=1
```
![studio6 host app generation](resources/an1259-studio6-host-app-generation.png)

This requires the openssl package to be installed. Install it to your MSYS2 environment with:
2. At the *Target Device* select the option *Part* and the desired OS
![studio6 select os](resources/an1259-studio6-select-os.png)

3. Add `Secure NCP communication layer for host projects` component to the project
4. Secure mode requires the openssl package to be installed. It can be installed to the MSYS2 environment if necessary with:

```C
pacman -S mingw-w64-x86_64-openssl
```

After the project is built, the encryption can be enabled by calling the .exe file with the command line parameter `-s`:
5. Build the project in MSYS2 MinGW 64-bit
```C
make -f bt_host_empty.Makefile
```
6. The build output is created in a new *build/debug/* folder. After the project is built, the encryption can be enabled by calling the .exe file with the command line parameter `-s`:

```C
.\empty.exe -s
.\bt_host_empty.exe -s
```

```C
$ ./empty.exe -u COM21 -s
$ ./build/debug/bt_host_empty.exe -u COM<*> -s
[D] Timer function intialized
[I] NCP host initialised.
[I] Resetting NCP target...
[I] Press Ctrl+C to quit
[I] Start encryption
[I] Press Crtl+C to quit

[I] Rebooting NCP target (0)...
[I] Start encryption using OpenSSL 3.0
[I] Communication encrypted
[I] Bluetooth stack booted: v3.2.1-b216
[I] Bluetooth public device address: 00:0B:57:A7:84:15
[I] Bluetooth stack booted: v11.0.1+0e13429e
[I] Bluetooth public device address: 04:87:27:E7:07:5D
[I] Started advertising.
```

Running the exe file without this option will start a normal NCP Host application without encryption.
Running the exe file without `-s` parameter will start a normal NCP Host application without encryption.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

The purpose of the Co-Processor Communication (CPC) Protocol is to act as a serial link multiplexer that allows data sent from multiple applications to be transported over a secure shared physical link. In CPC, data transfers between processors are segmented in sequential packets over endpoints. Transfers are guaranteed to be error-free and sent in order.

Find more information about the CPC at [https://docs.silabs.com/gecko-platform/4.1/service/cpc/overview](https://docs.silabs.com/gecko-platform/4.1/service/cpc/overview).
Find more information about the CPC at [https://docs.silabs.com/gecko-platform/latest/platform-cpc-overview/](https://docs.silabs.com/gecko-platform/latest/platform-cpc-overview/).

## Usage

The CPC daemon acts as a bridge between the host and the target application. It was designed to make a reliable connection between two ends through UART or SPI. Reliability is achieved by an HDLC-like header and CPC. It offers multi-channel communication, and security is turned on by default. It is a connection-based protocol, so that if a message arrives incorrectly, it notifies the other end, which then can re-send that message.

![CPC daemon](resources/an1259-cpc-daemon.png)

The NCP host by default does not contain usage of CPC. You need to build the application with the command line option `CPC=1`.
The NCP host by default does not contain usage of CPC. You need to build the application with **Host NCP CPC adapter (Linux only)** component.

>**Note**: The Host NCP CPC adapter (Linux only) component is Experimental currently.

## Use Cases

Expand All @@ -24,7 +26,13 @@ Adding the CPC functionality is recommended for the following use cases, as they

## Building the Target

To make the target use CPC communication, replace the USART component in the **bt_ncp** sample application with **CPC Secondary - UART (USART)** or **CPC Secondary – SPI (USART)**. This adds all the necessary components to enable CPC communication on the target. Set the pins of the selected communication interface according to the hardware design of the project.
To make the target use CPC communication, replace the USART component in the **bt_ncp** sample application with **CPC Secondary - UART (USART)** or **CPC Secondary – SPI (USART)**. This adds the necessary components to enable CPC communication on the target. Set the pins of the selected communication interface according to the hardware design of the project.

In NCP setup **Bluetooth NCP Transport over CPC** component is required.

>**Note**: The Bluetooth NCP Transport over CPC component is Experimental currently.

![Add Target NCP CPC](resources/Studio6-target-app-CPC.png)

The encryption of the communication is enabled by default. For developing and debugging, Silicon Labs recommends adding the **CPC SECURITY NONE** component so that the packet traces can be easier analyzed.

Expand All @@ -44,9 +52,20 @@ If the **CPC SECURITY NONE** component was added to the target, set **disable_en

### Step 2: Build the host application

Find the *ncp_host_bt.mk* file in the \<SDK folder>/app/Bluetooth/component_host/ folder, and set `CPC_DIR` to the path of the CPC daemon folder on your machine.
1. Create a new **Bluetooth - Host empty** project in Simplicity Studio 6
![studio6 host app generation](resources/an1259-studio6-host-app-generation.png)

2. At the *Target Device* select the option *Part* and *Linux*
![studio6 select os](resources/an1259-studio6-select-os.png)

Next, go to the **bt_host_empty** sample application in \<SDK folder>/app/Bluetooth/example_host/bt_host_empty, and build it with this command line option to enable CPC: `make CPC=1`.
3. Add *Host NCP CPC adapter (Linux only)* component
![Add Host NCP CPC](resources/Studio6-host-app-CPC.png)
>**Note**: The Host NCP CPC adapter (Linux only) component is Experimental currently.
4. Build the project
```C
make -f bt_host_empty.Makefile
```
5. The build output is created in a new *build/debug/* folder.

### Step 3: Run the application

Expand Down
Loading
Loading