Silicon Labs AN1269, UG305 User Manual

AN1269: Dynamic Multiprotocol Development with Bluetooth® and
Proprietary Protocols on RAIL in GSDK v3.x
This application note provides details on how to develop a multi­protocol application running Bluetooth and a proprietary protocol at the same time, using SDKs from Gecko SDK Suite v3.x. First the criteria for the coexistence of Bluetooth and a proprietary pro­tocol are discussed. Then the application note guides you through how to create a new DMP application, how to configure Bluetooth and your proprietary protocol, and how to transmit and receive proprietary packets while Bluetooth is running. Finally a Light/Switch DMP example is introduced in more details. For background on Dynamic Multiprotocol Application development in general and about Bluetooth task priorities and scheduling, see UG305: Dynamic Multiprotocol User’s Guide.
KEY POINTS
• Generic guidelines for protocol coexistence
• Generating and configuring a new Bluetooth/Proprietary DMP project
• Sending and receiving proprietary packets
• Using RAIL priorities
• Building and understanding the Light/ Switch DMP example
silabs.com | Building a more connected world. Rev. 0.1
AN1269: Dynamic Multiprotocol Development with Bluetooth® and Proprietary Protocols on RAIL in GSDK v3.x
Introduction

1. Introduction

UG305: Dynamic Multiprotocol User’s Guide provides information about the Dynamic Multiprotocol solution, where two protocols are running on the same device in parallel, and includes general background as well as information on Bluetooth task priorities and sched­uling. This application note introduces the Bluetooth / Proprietary multiprotocol solution. It assumes that the reader is familiar with the principles of Dynamic Multiprotocol and with all the terms related to it.

1.1 Requirements

To be able to use all the features discussed in this document, you will need the followings installed on your computer:
• Bluetooth SDK version 3.0.0 or higher
• Micrium OS-5 kernel
To be able to run the Light/Switch example, you will need the following installed on your computer:
• Bluetooth SDK version 3.0.0 or higher
• Flex SDK version 3.0.0 or higher
• Micrium OS-5 kernel
• An EFR32 chip with at least 512 kB of flash (required to run all the necessary software components)
• IAR Embedded Workbench for ARM (IAR-EWARM) (required for the RAIL Switch application). See the release notes for the Blue­tooth SDK for the required IAR-EWARM version.
silabs.com | Building a more connected world. Rev. 0.1 | 2
AN1269: Dynamic Multiprotocol Development with Bluetooth® and Proprietary Protocols on RAIL in GSDK v3.x
Guidelines for Bluetooth and Proprietary Coexistence

2. Guidelines for Bluetooth and Proprietary Coexistence

When you start implementing a Bluetooth / Proprietary DMP application the first thing to consider is if your proprietary protocol is com­patible with Bluetooth. Here are some guidelines that you should always take into account:
Bluetooth is deterministic. The huge advantage of the Bluetooth protocol in a DMP scenario is that it does not send and receive packets at random times, but at predefined time instances – always at the start of a connection interval. This means, among other things, that Bluetooth does not need a background receive, and your proprietary protocol can receive in the background, of course with some interruptions.
Bluetooth needs accuracy. The consequence of predefined time instances is that Bluetooth packets cannot be late – their timing needs 500 ppm accuracy. If you delay a Bluetooth packet, it will not be received on the other side. So in case of collision with a proprietary packet, either the proprietary packet has to be delayed, or one of the packets has to be dropped.
Bluetooth connection is active. Once a Bluetooth connection is established, the connection is kept alive by sending and receiving at least an empty packet every connection interval. Consequently your proprietary protocol need to be prepared to be interrupted every connection interval. You can, however, set the connection interval to a long period if you do not need low Bluetooth latency. You can also use the slave latency parameter to make Bluetooth communication less frequent on the slave side.
Bluetooth uses short packets. If there is no data to be sent, the Bluetooth connection is kept alive by empty packets. An empty packet takes 80.µs to be sent out on 1 meg PHY, and 40 µs on 2 meg PHY. Empty packets sending + inter frame space + empty packet receiving takes 80 + 150 + 80 = 310 µs or 40 + 150 + 40 = 230 µs. This is the usual time needed by Bluetooth in every connection interval. The largest Bluetooth packet has 257 byte payload which takes 2120 µs to be sent on 1 meg PHY and 1060 µs on 2 meg PHY. Along with receiving an empty response packet this takes 2120 + 150 + 80 = 2350 µs on 1 meg PHY and 1060 + 150 + 40 = 1250 µs on 2 meg PHY.
Bluetooth uses packet chains. If the data to be sent does not fit into one packet, Bluetooth communication can be extended within a connection interval, that is you can expect that more than one packet is sent and received in an interval, but this is rare.
Bluetooth is robust. If a Bluetooth packet cannot be sent, then it will be retransmitted in the next connection interval. If a Blue­tooth packet is received with a CRC error, it is always signaled by the other side by not sending a response packet. Again, the packet will be retransmitted in the next connection interval. The only limit is the supervision timeout. If there is no successful trans­mission within the supervision timeout, then the connection is dropped. In other words, Bluetooth communication can be subdued by higher priority radio tasks for a time interval shorter that the supervision timeout.
Summary: When implementing your DMP protocol, you have to take into account that Bluetooth will need the radio every connection interval for a short time (230 µs – 2350 µs). Bluetooth needs accurate timing, so Bluetooth packets cannot be delayed. The Bluetooth packets can interrupt both your packet sending and packet receiving, hence the proprietary protocol should implement acknowledge­ment and retransmission mechanisms, or a deterministic timing that is interleaved with the Bluetooth communication. Bluetooth commu­nication can be subdued by a higher priority radio task for a time interval shorter than the supervision timeout.
silabs.com | Building a more connected world. Rev. 0.1 | 3
AN1269: Dynamic Multiprotocol Development with Bluetooth® and Proprietary Protocols on RAIL in GSDK v3.x
Software Architecture of a Bluetooth / Proprietary DMP application

3. Software Architecture of a Bluetooth / Proprietary DMP application

DMP applications are based on Micrium RTOS. The RTOS helps run the Bluetooth and Proprietary protocols in parallel and independ­ently.
Since the Bluetooth stack itself is just a collection of functions, Bluetooth needs separate tasks to run the stack. The BluetoothTask() and the LinkLayerTask() are responsible for this, and they can be used as they are. The functions of the Bluetooth stack can be ac­cessed through these tasks using BGAPI, as in the case of an RTOS-less or an NCP application. The Bluetooth application (handling Bluetooth events and calling Bluetooth commands) has to be implemented by the developer in sl_bt_on_event() , which is (indirect­ly) called from the sl_bt_event_handler_task(). For details please refer to AN1260: Integrating Silicon Labs Bluetooth® Applications with the Micrium RTOS.
The proprietary protocol is implemented in the proprietaryAppTask(). Unlike Bluetooth, the proprietary protocol can access the radio directly through the RAIL API. RAIL events need a callback function – sl_rail_app_on_event() – to be defined. This function is called every time a new RAIL event is generated, and can notify the application about the event. Note: sl_rail_app_on_event() is called from interrupt context, so only time-critical functions should be implemented in it. Everything else should be done in the application.
Although the Bluetooth and Proprietary applications are independent, they can communicate using inter-process communication (IPC).
silabs.com | Building a more connected world. Rev. 0.1 | 4
AN1269: Dynamic Multiprotocol Development with
Bluetooth® and Proprietary Protocols on RAIL in GSDK v3.x
Developing a Bluetooth / Proprietary DMP Project

4. Developing a Bluetooth / Proprietary DMP Project

4.1 Create a New Project

Silicon Labs Bluetooth SDK (v2.9 or later) includes the “Soc Empty Rail Dmp” software sample that should be used as a starting point for every Bluetooth / Proprietary application. This sample project:
• Includes the multiprotocol RAIL library
• Includes the Bluetooth library
• Includes the Micrium RTOS
• Has a default Bluetooth GATT database configuration
• Has a default RAIL configuration
• Has a default RTOS configuration
• Implements Bluetooth initialization
• Implements RAIL initialization
• Implements RTOS initialization
The only thing you have to do is to modify the configurations according to your needs and implement the Bluetooth application task and the Proprietary application task. As default the proprietaryAppTask() is defined and implemented in the files proprietary_app.c and proprietary_app.h.
For the Bluetooth part, the default implementation contains the Bluetooth event handler, the sl_bt_on_event() function, defined in the bluetooth_app.c file.
The GATT database can be configured with the visual GATT Configurator in Simplicity Studio 5, while the RAIL configuration can be generated with the Radio Configurator tool. You may also need to add some emlib and emdrv files to your project to support peripheral configuration. The general workflow to create a DMP project looks like this:
To create a new project.
1. Open Simplicity Studio 5.
2. Select a connected device in the Debug Adapters view, or select a part in the My Products view.
3. Click File > New > Silicon Labs Project Wizard.
4. Review your SDK and toolchain. If you have more than one GSDK version installed, verify that Gecko SDK Suite v3.x is shown. If you wish to use IAR instead of GCC, be sure to change it here. Once you have created a project it is difficult to change toolchains. Click NEXT.
5. On the Example Project Selection dialog, filter on Bluetooth and select SOC – Empty – RAIL – DMP. Click NEXT.
6. Name your project. Click [FINISH].
silabs.com | Building a more connected world. Rev. 0.1 | 5
AN1269: Dynamic Multiprotocol Development with
Bluetooth® and Proprietary Protocols on RAIL in GSDK v3.x
Developing a Bluetooth / Proprietary DMP Project

4.2 Configure Bluetooth

Configuring Bluetooth consists of two steps:
• Configuring the local GATT database
• Configuring the Bluetooth stack
To configure the local GATT database, use Simplicity Studio 5's GATT Configurator.
1. Open the .slcp file in the project (if it is not already open).
2. Click the Software Components tab.
3. Under the Advanced Configurators group, select the Bluetooth GATT Configurator and click Open.
4. Add your custom services and characteristics as described in QSG169: Bluetooth® SDK v3.x Quick Start Guide (or use the default GATT database).
5. Your changes are automatically saved and project files are generated.
To configure the Bluetooth stack:
1. Go to the Software Components tab
silabs.com | Building a more connected world. Rev. 0.1 | 6
Loading...
+ 12 hidden pages