Silicon Labs AN1259 User Manual

AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-
Processor Mode
This document is an essential reference for anyone developing a system for the Silicon Labs Wireless Gecko products using the Silicon Labs v3.x Bluetooth Stack in Network Co-Processor (NCP) mode. The document covers the C language application development flow, walks through the examples included in the stack, and shows how to customize them.
KEY POINTS
• Introduces the available tools for NCP system development.
• Walks through the NCP host and target examples.
silabs.com | Building a more connected world. Rev. 0.4
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
Introduction

1. Introduction

The Silicon Labs Bluetooth SDK allows you to develop System-On-Chip (SoC) firmware in C on a single microcontroller. The SDK also supports the Network Co-Processor (NCP) system model.
This document gives you a guide on how to get started with software development of an NCP system. It describes the development tools and example projects, then highlights the most important steps you need to follow when writing your own application.

1.1 SoC vs NCP System Models

On an SoC system the Application code, the Bluetooth Host, and Controller code run on the same Wireless MCU.
On an NCP system the Application runs on a Host MCU and the Host and Controller code run on a Target MCU. The Host and Target MCUs communicate on a serial interface. The communication between the Host and Target is defined in the Silicon Labs Proprietary Protocol called BGAPI. The physical interface is UART. BGLib v3.x is an ANSI C reference implementation of the BGAPI protocol, which can be used in the NCP Host Application.
Figure 1.1. SoC vs NCP System Models
silabs.com | Building a more connected world. Rev. 0.4 | 2
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
NCP Target Development

2. NCP Target Development

This chapter describes the available tools for compiling and flashing the NCP target firmware.
Before proceeding with compiling and flashing C-based firmware, you need to install Simplicity Studio 5 (SSv5). You can download it from the Silicon Labs website: http://www.silabs.com/simplicity
Before installing Simplicity Studio, connect the WSTK and your PC with a USB cable. The white switch located on left side of the WSTK must be in the AEM position. See QSG169: Bluetooth® SDK v3.x Quick Start Guide for details on installing Studio and the Bluetooth SDK.
Note: AN1042: Using the v2.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode describes in detail how the NCP is imple- mented in the Gecko SDK v2. This application note explains extensively the code and tools on both the target and host side.
If you have already installed SSv5 you can download the Bluetooth SDK through the Simplicity Studio Package Manager. To open it, click the Install control on the SSv5 toolbar, then click Manage Installed Packages. Go to the Stacks tab, and click [Install] next to the Bluetooth SDK.
To develop in C you need not only Simplicity Studio 5 but also a supported compiler. UG434: Silicon Labs Bluetooth® C Application Developers Guide for SDK v3.x lists the supported compilers.
silabs.com | Building a more connected world. Rev. 0.4 | 3
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
NCP Target Development
The NCP target firmware comes with the Bluetooth SDK. It is available in a precompiled binary format and as a project file you can build. The following procedures describe how to install the precompiled binary image and how to build and install the example project. Note that Simplicity Studio only shows the relevant examples for the preferred SDK, so you have to select Gecko SDK Suite: Blue- tooth first, as shown in the following figure. (Note: Your SDK version may be different from the one shown in the figure.)
The following procedure describes how to build and load the example code. This procedure assumes you have already loaded a Gecko Bootloader in one of the following ways:
• Loading the Gecko Bootloader precompiled binary from the list of Demos. For an NCP application you should load the BGAPI UART DFU bootloader.
• Building and loading your own Gecko Bootloader combined image called <projectname>-combined.s37, as described in chapter 6 of UG266: Silicon Labs Gecko Bootloader User’s Guide.
1. Click Example Projects & Demos, select Bluetooth - NCP Empty, and click [Create].
silabs.com | Building a more connected world. Rev. 0.4 | 4
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
NCP Target Development
2. Name your project and make sure to select Copy contents. Click [Finish].
3. Now your project is ready to build and flash. Click Debug (bug icon) in the top left menu to do it in one step. Once the flashing is
completed press F8 to start the firmware.
Note: If you get an error when you click Debug, click the project .isc file in the Project Explorer view. It may not be fully selected.
silabs.com | Building a more connected world. Rev. 0.4 | 5
AN1259: Using the v3.x Silicon Labs Bluetooth
®
Stack in Network Co-Processor Mode
NCP Host Development

3. NCP Host Development

This chapter introduces two tools that can be used to send BGAPI commands from a graphical user interface:
• The BGTool Interactive View is a legacy product that will be deprecated and then removed in the near future.
• Bluetooth NCP Commander was introduced with Bluetooth SDK 3.1.0, and is the recommended tool to be used moving forward.
The chapter then walks through the process of building the PC Host example provided by the SDK.

3.1 Host – BGTool Interactive View

You can use the BGTool user interface to issue BGAPI commands.
1. To open BGTool, make sure that the correct board is selected and the preferred SDK is Gecko SDK Suite:Bluetooth. Select the Compatible Tools tab and select BG Tool. Click[ Launch].
2. Set up the correct COM port and baud rate in BGTool. Select JLink CDC UART Port and 115200 for the baud rate, then click [Open].
3. Once the UART connection to the WSTK is established, an Interactive view opens, which you can use to issue BGAPI commands. Check the log for the NCP target response and status messages.
silabs.com | Building a more connected world. Rev. 0.4 | 6
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
4. Click [Create Set] to set up advertising and then click [Start] to start advertising.
NCP Host Development
silabs.com | Building a more connected world. Rev. 0.4 | 7
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
NCP Host Development
5. When advertising, the NCP target example accepts Bluetooth connections. If you connect to your WSTK with another master de­vice (for example with your phone), you can see BGAPI communication in the log.
silabs.com | Building a more connected world. Rev. 0.4 | 8
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
NCP Host Development
6. You can also issue commands manually. For example, you can issue the 'system hello' command at any time to verify that commu­nication between the host and the device is working.
silabs.com | Building a more connected world. Rev. 0.4 | 9
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
NCP Host Development

3.2 Bluetooth NCP Commander

You can use the Bluetooth NCP Commander tool to issue BGAPI commands.
1. To open Bluetooth NCP Commander, make sure that the correct board is selected, and the preferred SDK is Gecko SDK Suite:Bluetooth. Select the Compatible Toolstab and select Bluetooth NCP Commander. Click[ Launch].
2. Select your device and click [Connect].
silabs.com | Building a more connected world. Rev. 0.4 | 10
AN1259: Using the v3.x Silicon Labs Bluetooth® Stack in Network Co-Processor Mode
NCP Host Development
3. Once the UART connection to the WSTK is established, an Interactive view opens, which you can use to issue BGAPI commands. Check the log for the NCP target response and status messages. To start advertising, click the "+" button under the "Advertise – Peripheral" view to create an advertiser set:
4. Select the desired advertising mode, and click [Start].
silabs.com | Building a more connected world. Rev. 0.4 | 11
Loading...
+ 25 hidden pages