Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

CC256x TI Bluetooth Stack SPPLEDemo Lite App

From Texas Instruments Wiki
Jump to: navigation, search

Return to CC256x MSP430 TI’s Bluetooth stack Basic Demo APPS

Demo Overview

The Serial Port Profile Low-Energy Lite (SPPLE Lite) version is a version of SPPLE where an SPP Server is initialized and the device is ready to accept connections. An SPP Server is registered on port 1. We can connect to the device from both SPP and SPPLE devices.

For more information about SPPLE and SPP profiles please refer to their respective wiki pages:

It is recommended that the user visits the kit setup Getting Started Guide page before trying the application described on this page.

Running the Bluetooth Code

Once the code is flashed, connect the board to a PC using a miniUSB to USB cable. Once connected, wait for the driver to install. It will show up as MXP-EXP430F5438 USB - Serial Port(COM x) under Ports (COM & LPT) in the Device manager. Attach a Terminal program like Tera Term to the serial port x for the board. The serial parameters to use are 9600 Baud, 8,n,1 and no flow control.

NoteNote: The MSP430F5529 does not have the Terminal Output as shown below because the debug UART is shared with BT UART.

Initialize the SPP Server

a) Perform the above setup to initialize the SPP Lite Server.

NoteNote: There is no command prompt for input after initializing unlike the other demos. If you reset the device you should see a startup screen like this one.


Connecting from a SPP Client

b) Initialize the SPP Client using the steps above and On the "Choose mode>" prompt, enter Client.

c) You will see a list of all possible commands at this time for a Client. You can see this list at any time by entering Help at the Client> prompt.

d) At the "Client>" prompt, enter Inquiry. This will initiate the Inquiry process. Once it is complete, you will get a list of all discovered devices.

e) You can access this list any time by typing DisplayInquiryList at the Client prompt.


Initiating connection from the Client

f) Note the index number of the first board that was configured as a Server. [If the list is not on the screen, issue the DisplayInquiryList command on the Client to display the list of discovered devices again. ]

g) Issue a Open <index number> <server port number> command at the command prompt.

h) Wait for an SPP Open confirmation.


You should see an Indication on the SPP-Lite side as well


Data Transfer between Client and Server

i) Now we have a SPP connection established and both devices are ready to transmit data to each other.

j) The SPPLEDemo Lite App doesn't have an option for terminal Input. It simply echos or loops-back the data sent to it.

k) On the Client you can send some data to the remote side by issuing a "Write" command. This command sends a hardcoded test string to the other side. The same data is received back by the Client.

l) The user can read the data by issuing a "Read" command.

m) The connection can be closed by issuing the close command. In the example the Client closes the connection and the Server receives a close indication.

Connecting from a SPPLE Client

NoteNote: Steps a and b are optional if you already know the Bluetooth address of the device that you want to connect to

a) The Client LE device can try to find which LE devices are in the vicinity issuing the command: StartScanning.

b) Once you have found the device, you can stop scanning by issuing the command: StopScanning.

c) Once the application on the Client side knows the Bluetooth address of the device that is advertising, it can connect to that device issuing the command: ConnectLE <Bluetooth Address>


After this it we can communicate as we used to for SPPLE.

Demonstrating SPP LE on an iOS Device with the LightBlue App

LightBlue Overview

The LightBlue app is a free iOS app that allows you to test and demonstrate the GATT Profile using Bluetooth Low Energy (BLE). It allows you to create custom services and interact with Servers with custom services. The app supports both the Client and Server roles of GATT. Here we will explain how to use the app with the SPPLEDemo_Lite application.

SPP LE Service Overview

SPP LE is not an official Bluetooth service. It is a custom service that is designed to demonstrate using Bluetooth Low Energy to send and receive data in a similar manner that Classic Bluetooth's SPP profile does. It uses a credit based protocol to send and receive data. In order for a device to send data to a remote device with the SPP LE protocol the remote device must have provided the device with credits. These credits specify how much data the device is allowed to send. When a device has sent its maximum number of credits, it must wait for the remote device to provide it with more credits before it can continue sending. In this application 1 credit is equivalent to 1 byte (octet) of data.


SPP LE implements its credit-based protocol using GATT characteristics. The SPP LE service has 4 characteristics:

Name UUID Purpose
Rx Characteristic 0x8B00ACE7-EB0B-49B0-BBE9-9AEE0A26E1A3 Client sends data to the Server using this characteristic with an ATT Write Request.
Tx Credits Characteristic 0xBA04C4B2-892B-43BE-B69C-5D13F2195392 Client sends its credits to the Server using this characteristic with an ATT Write Request.
Tx Characteristic 0x0734594A-A8E7-4B1A-A6B1-CD5243059A57 Server sends data to the Client using this characteristic with an ATT Handle Value Notification.
Rx Credits Characteristic 0xE06D5EFB-4F4A-45C0-9EB1-371AE5A14AD4 Server sends its credits to the Client using this characteristic with an ATT Handle Value Notification.

The Client and Server use these characteristics to send and receive data and credits. Next we'll demonstrate SPPLEDemo_Lite as the Server and LightBlue as the Client. If you haven't already done so, download the LightBlue app from the App Store and turn on Bluetooth on your iOS device.

NoteNote: For more information about characteristics, ATT Write Requests, and ATT Handle Value Notifications, please refer to the Attribute Protocol (ATT) and Generic Attribute Profile (GATT) specifications in the Bluetooth Core specification, which can be found on the Bluetooth SIG's website.

NoteNote: The following instructions were confirmed in version 2.2.0 of LightBlue running on an iPhone 5 with iOS 8.1.3. SPPLEDemo_Lite from the MSP430 v1.5 R2 SDK was used running on an MSP-EXP430F5438 Experimenter Board.

LightBlue as the Client/SPPLEDemo_Lite as the Server

Connecting the Devices

First we need to establish a connection between the devices. To do this, open the LightBlue app and you'll seen a screen similar to the following:

LightBlue Startup

Now start SPPLEDemo_Lite, you'll see text similar to the following the terminal:

Bluetooth Stack ID: 1.
Device Chipset: 4.1.
BD_ADDR: 0xD03972CD7DF3
Sucessfully registered SPPLE Service.
Server Opened: 1.
GAP_LE_Advertising_Enable success.

Now that SPPLEDemo_Lite is running and advertising you will see the device shown in LightBlue:

SPPLEDemo_Lite Discovered by LightBlue

Next select the SPPLEDemo device in LightBlue, after doing so you should see the following screen:

LightBlue and SPPLEDemo_Lite Connected

In the SPPLEDemo_Lite terminal you will see the following:

etLE_Connection_Complete with size 18.
Status:       0x00.
Role:         Slave.
Address Type: Random.
BD_ADDR:      0x62DB8FBB5659.

etGATT_Connection_Device_Connection with size 12:
Connection ID:   1.
Connection Type: LE.
Remote Device:   0x62DB8FBB5659.
Connection MTU:  23.

The devices are now connected.

Enabling Notifications

Next enable notifications on the Tx Characteristic and Rx Credits Characteristic in LightBlue by doing the following:

  1. Opening the Tx Characteristic (0x0734594A-A8E7-4B1A-A6B1-CD5243059A57).
  2. Choosing Listen for notifications.
  3. Press the back button in the top left corner.
  4. Opening the Rx Credits Characteristic (0xE06D5EFB-4F4A-45C0-9EB1-371AE5A14AD4).
  5. Choosing Listen for notifications.
  6. Pressing the back button in the top left corner.

You will notice that after enabling notifications on the Rx Credits Characteristic (0xE06D5EFB-4F4A-45C0-9EB1-371AE5A14AD4) that SPPLEDemo_Lite sends its initial credits to LightBlue and you will see 0x3200 displayed twice in the app:

Initial Credits Received from SPPLEDemo_Lite

NoteNote: The first instance of 0x3200 is seen because LightBlue read the characteristic automatically when the connection was first established.

NoteNote: The data here is displayed in little-endian byte order, the actual number of credits is 0032 in hexadecimal, 50 in decimal.

Sending and Receiving Data

SPPLEDemo_Lite is configured as loopback device. This means that any data it receives is automatically sent back to the remote device. Therefore, before we can send data to SPPLEDemo_Lite we must first provide it with transmit credits. To provide SPPLEDemo_Lite with transmit credits do the following in LightBlue:

  1. Open the Tx Credits Characteristic (0xBA04C4B2-892B-43BE-B69C-5D13F2195392).
  2. Choose Write new value.
  3. Type 6400. (100 credits = 0x0064 little-endian)
  4. Choose Done.
  5. Press the back button in the top left corner.

We have now given SPPLEDemo_Lite 100 credits. At this point the Client (LightBlue) can send data to the Server (SPPLEDemo_Lite). To send data from LightBlue to SPPLEDemo_Lite do the following:

  1. Open the Rx Characteristic (0x8B00ACE7-EB0B-49B0-BBE9-9AEE0A26E1A3).
  2. Choose Write new value.
  3. Type 414243 ("ABC" in ASCII).
  4. Choose Done.

At this point LightBlue as sent data to SPPLEDemo_Lite, SPPLEDemo_Lite has received the data, has looped it back to LightBlue, and has provided LightBlue with 3 more transmit credits. You can check that LightBlue received the data by:

  1. Opening the Tx Characteristic (0x0734594A-A8E7-4B1A-A6B1-CD5243059A57).
  2. You will see 0x414243 displayed in the list of NOTIFIED VALUES as seen below:

Data Received from SPPLEDemo_Lite

If you open the Rx Credits Characteristic (0xE06D5EFB-4F4A-45C0-9EB1-371AE5A14AD4) you will see that SPPLEDemo_Lite has credited LightBlue with 3 more transmit credits:

Additional Credits Received from SPPLEDemo_Lite

Now that LightBlue has received data from SPPLEDemo_Lite it needs to return the transmit credits. This can be done by repeating the sequence above and re-writing 0x0300 to the Tx Credits Characteristic (0xBA04C4B2-892B-43BE-B69C-5D13F2195392).

See Also