Data Stream
Table of Contents
Introduction
The data_stream_example
project is based on the Basic BLE example and implements a simple Bluetooth low-energy peripheral device with GATT services.
This project can be a framework for developing many different peripheral-role applications.
The purpose of the data stream example is to echo received data from a peer device using GATT notifications.
Hardware Prerequisites
The default Data Stream board configuration uses the device's LaunchPad development kit.
Software Prerequisites
For information on what versions of Code Composer Studio and IAR Embedded Workbench to use, see the Release Notes file provided in the SDK. In addition, please refer to the User's Guide for information on importing this project into your IDE workspace and build/run.
Data Stream Service
This project contains the data stream service in addition to Device Information.
Service Table
This service exposes a long (longer than legacy MTU size) characteristic, Write Data
, and another characteristic to exemplify streaming Server Data
.
If notifications are enabled on the Server Data
characteristics the data received data from the Write Data
characteristic will be sent out as notifications.
The MTU of the connection limits the size of each notification. If a message size is larger than the MTU, the example will split the echo message into multiple GATT notifications.
Description | UUID | Format | Properties |
---|---|---|---|
Data Stream Service | F000C0C0-0451-4000-B000-000000000000 | Service declaration | Read |
Write Data | F000C0C1-0451-4000-B000-000000000000 | Up to DATASTREAM_MAX_DATA_IN_LEN byte uint8_t | Write |
Server Data | F000C0C2-0451-4000-B000-000000000000 | 1 byte uint8_t | Write/Notify |
Usage
The data_stream_example
starts with the green LED. Once a BLE connection has been created, the client discovered the Data Stream service. Next, the client shall allow notifications from the server (using the "Server Data" characteristic).
Each time the client writes data to the server (using the "Write Data" characteristic), the server will echo the received data (it also changes upper case to lower case and vice versa) and send it back to the client using GATT notifications. The example will toggle the LEDs (changed from green to red and vice versa) each time the server sends an echo message.
The DATASTREAM_MAX_DATA_IN_LEN is defined as 128 bytes for the incoming data and can be changed by the user.
If the incoming data exceeds the DATASTREAM_MAX_DATA_IN_LEN length, the server will not echo the incoming message and send an error message ("Data size is too long") using GATT notifications
To interact with the application over Bluetooth, you may use any device that can act as a BLE Central device, such as
iOS with the apps SimpleLink Connect or other BLE application
Android with the apps SimpleLink Connect or other BLE application
A CC26xx/CC13xx/CC23xx LaunchPad running the sample app HostTest from a compatible SDK with the PC tool BTool from the same SDK.
UART
This application uses the UART peripheral to provide an interface for the application. The UART is only used for display messages.
We recommend using a terminal program that can parse ANSI/VT100 color codes, such as Tera Term, PuTTY, Code Composer Studio Terminal, etc., to monitor the LaunchPad UART output.
The following default parameters are used for the UART peripheral for display:
UART Param | Default Values |
---|---|
Baud Rate | 115200 |
Data length | 8 bits |
Parity | None |
Stop bits | 1 bit |
Flow Control | None |
Booting
Once the Data Stream sample application starts, the output to the terminal will report its address and the fact that it is advertising, as shown below:
Connecting
When a device connects, the address of the device will be shown in the console. After a while, you will see the automatic parameter update request sent from the device being applied.
Flow
Step 1: Connect to the "Data Stream" device.
Step 2: Find the Data Stream service.
Step 3: Verify UTF-8 format and enable notifications.
Step 4: Select "write" and write new data.
Step 5: Recive echo from the server.
Teminal output: