Basic BLE Project

Table of Contents

Introduction

The Basic BLE project implements a simple Bluetooth low-energy device with multiple simultaneous connection roles, GATT services and demonstrates the TI Simple Profile.
This project can be a framework for developing many different applications with any BLE role.

Hardware Prerequisites

The default Basic BLE 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. In addition, please refer to the User's Guide for information on importing this project into your IDE workspace and build/run.

Device Roles

The Basic BLE project demonstrate a variety of BLE roles:

BLE Role Description
Broadcaster The device is an advertiser that is non-connectable
Observer The device scans for advertisements but cannot initiate connections
Peripheral The device is an advertiser that is connectable and operates as peripheral in a single or multiple link-layer connection
Central The device scans for advertisements and initiates connections and operates as a central in a single or multiple link-layer connections
Central + Broadcaster The device scans for advertisements and initiates connections and operates as a central in a single or multiple link-layer connections. In addition, the device is an advertiser that is non-connectable
Peripheral + Observer The device is an advertiser that is connectable and operates as peripheral in a single or multiple link-layer connection. In addition, the device scans for advertisements but cannot initiate connections
Peripheral + Central The device is an advertiser that is connectable and operates as peripheral in a single or multiple link-layer connection. In addition, the device scans for advertisements and initiates connections and operates as a central in a single or multiple link-layer connections

The default device role for the Basic BLE project is a Peripheral. The device role can be configured using the "Device Role" option in SysConfig located within the BLE stack module.

GATT Profiles

Device Info

The Device Info Service is based on version 1.1 of the Bluetooth Device Information Service specifications. It exposes manufacturer and/or vendor information about a device.

Service Table

Description UUID Format Properties
Device Information Service 180A Service declaration Read
System ID 2A23 8 bytes uint8 Read
Model Number 2A24 21 bytes uint8 Read
Serial Number 2A25 21 bytes uint8 Read
Firmware Revision 2A26 21 bytes uint8 Read
Hardware Revision 2A27 21 bytes uint8 Read
Software Revision 2A28 21 bytes uint8 Read
Manufacturer Name 2A29 21 bytes uint8 Read
IEEE Regulatory Certification 2A2A The length of this characteristic is not fixed Read
PnP ID 2A50 7 bytes uint8 Read

Simple GATT

The Simple GATT profile is an example of a non-Bluetooth registered profile. It demonstrates various types of characteristics, permissions, and properties.

Service Table

Description UUID Format Properties
Simple GATT Service F000FFF0-0451-4000-B000-000000000000 Service declaration Read
Characteristic 1 F000FFF1-0451-4000-B000-000000000000 1 byte uint8 Read / Write
Characteristic 2 F000FFF2-0451-4000-B000-000000000000 1 byte uint8 Read
Characteristic 3 F000FFF3-0451-4000-B000-000000000000 1 byte uint8 Write
Characteristic 4 F000FFF4-0451-4000-B000-000000000000 1 byte uint8 Read / Write / Notify
Characteristic 5 F000FFF5-0451-4000-B000-000000000000 5 bytes uint8 Read (Authentication required)

L2CAP CoC Service

The L2CAP Connection Oriented Channels (L2CAP COC) feature implements "LE Credit Based Flow Control Mode" of operation of the L2CAP layer, over Connection Oriented Channel (COC).
This example echoes the data received over l2cap layer from a peer device while changing the payload upper-case to lower-case and vice versa.

Usage

To interact with the application over Bluetooth, you may use any device that can act as a BLE Central device, such as

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

Central

When the device role is set to "Central", the project implements a Bluetooth low-energy central device. The application can be configured to filter and connect to peripheral devices with the TI Simple Profile UUID, such as devices with the basic_ble project having a peripheral device role configuration. To enable this behavior, set Discover devices by service UUID to TRUE in SysConfig (under Observer Configuration).

Booting

Once the application starts, the output to the terminal will report its address and ready to begin discovery, as shown below:

When using the menu, you can navigate to the next option by pressing the left button (BTN-1), while the right button (BTN-2) allows you to select an item. If you need to go back to the previous screen, long press the left button (BTN-1), and to return to the main menu, long press the right button (BTN-2).

Connecting

The first option on the menu Scanning can be selected to move to the Scanning Menu:

On the Scanning Menu , Scan can be selected to begin discovering devices that are broadcasting BLE advertisements. This will report the number of discovered devices:

Go back to the Main Menu and select Connection to move to the Connection Menu:

Select Connect view the list of devices, and use the left button (BTN-1) to go through the available devices. When you find the device you are trying to connect to, press the right button (BTN-2) to connect to. This will display information such as the number of connections, the address of the connected peripheral device, and the pairing status (if enabled):

Once connected select Work with and select the connected device:

Peripheral

When the device role is set to "Peripheral", the project implements a Bluetooth low-energy peripheral device with GATT services and demonstrates the TI Simple Profile.

Booting

Once the application starts, the output to the terminal will report its address and the fact that it is advertising:

Using mobile application to scan for the device, you should see a device with the name of 'Basic BLE project' (note that the navigation might be slightly different depending on your mobile application):

If there is more than one device called SimplePeripheral, the RSSI on the right can be used to find which device you are trying to connect to. Press the chevron button to connect to the device. Once connected, the terminal window will show the address of the connected device (smartphone):

After a connection is formed, you will also have the option to switch which physical layer (PHY) preference is used. Use the right button (BTN-2) to move to the Connection Menu, another press to select on the right button (BTN-2) Work with and select the connected device.

In the SimpleLink Connect you should be able to see various information about the device:

You should see TI Simple Peripheral service service, can be labeled as "CUSTOM SERVICE" (this may be slightly different for other smartphone applications). It will also provide its UUID. Clicking on this service will display the 5 characteristics that it contains, with information about each characteristic:

Scrolling down should show all 5 characteristics. The following sections detail the functions and operations of each of the characteristics.

Characteristic 1 (UUID: FFF1)

This characteristic demonstrates both read and write properties, and it contains a 1-byte-long value. As shown below, there are 2 circles, one with an "Read" and one with a "Write":

These are the buttons used for read and write operations. The value for this characteristic is set to "01" by default, and it can be changed by pressing the write button. click on write button, and then enter the value that you want to write to the characteristic (in hexadecimal) in the field below. Press ok, and then you will be able to see that the value has changed by looking at the terminal window. The example below shows a write of 0x42 which is decimal for 66:

Note that the terminal window will print the value in decimal. The value will also be updated in the mobile application:

The read button can be used to read a value. If the Simple Peripheral device has changed the value of the characteristic (i.e. by using a button press), then pressing the read button will show the updated value in the mobile application:

Characteristic 2 (UUID: FFF2)

This characteristic has read property only. Its value can be read following the same procedure as is detailed for characteristic 1. It has a default value of 0x02.

Characteristic 3 (UUID: FFF3)

This characteristic has write property only. Its value can be written to following the same procedure as is detailed for characteristic 1. It has a default value of 0x03.

Characteristic 4 (UUID: FFF4)

This characteristic has notify property only. It is a single byte, and it is set to whatever value is contained in characteristic 3 (this value can be changed by writing to characteristic 3). Under Characteristic 4 there is a circle with notification section and enable button. Pressing this button will enable notifications, and this characteristic will be updated and will display the value contained in characteristic 3:

Characteristic 5 (UUID: FFF5)

This characteristic has read property only. It is 5 bytes, and its default value is 0x0102030405. It differs from the other characteristics in that it requires authentication. This is done by pairing the smartphone with the Simple Peripheral device. The process of doing this varies depending on the smartphone application and the operating system that is being used. Please see documentation on the operating system that you are using for more details. Some documentation for iOS can be found here, and some for Android can be found here. If the Simple Peripheral device and the smartphone have not been paired, you will not see anything when you press the read button (this includes reading the characteristic user description).

When prompted for a passcode on the phone to pair, insert the passcode: 123456. Once the devices are paired, pressing the read button will show the characteristic's value as shown below:

Multi Role

When the device role is set to "Peripheral+Central", the project implements a Bluetooth low-energy "multi role" device and demonstrates the capabilities of the Texas Instruments BLE stack to function in multiple simultaneous connection roles.

Specifically, the project is capable of functioning as a central and a peripheral simultaneously, in any combination, while maintaining up to the amount of connections defined by MAX_NUM_BLE_CONNS:

The project is capable of connecting to any central/peripheral device. Any type of legacy pairing/bonding is possible. Parameter updates are supported. Connections can be established in any role.

L2CAP CoC Service

The l2cap_coc_example starts with the green LED. Once a Bluetooth LE connection has been created, the device might initiate the l2cap channel establishment sequence. Whether this device will initiate the l2cap channel establishment sequence is determined by "L2CAP COC initiate connection". Once an l2cap channel established, each time the peer writes data to the device (using the "L2CAP_SendData" API), the device will echo the received data (it also changes upper case to lower case and vice versa) and will send it back to the peer using L2CAP interface. The example will toggle the LEDs (changed from green to red and vice versa) each time the device sends an echo message.

To interact with the application over Bluetooth, you may use any device that can act as a host device, such as HCI_TEST, HOST_TEST or another basic-ble with L2CAP CoC enabled.

Support

Visit TI Developer Zone to find the User's Guide and more training resources (SimpleLink Academy labs). Leverage the E2E forums for technical support.