NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
WL18xx TI Bluetooth Stack SPPLE PM Demo App
Return to WL18xx AM335x TI Bluetooth Stack
Contents
Demo Overview[edit]
Note: : This instructions can be used to run this demo on the AM335x Platform.
The SPPLE profile is a custom application that demonstrates using the Bluetooth Low Energy protocol to send raw data, similar to classic Bluetooth’s SPP (Serial Port) profile. It is not a Bluetooth Low Energy profile, and will only be useful if both the local and remote device are using the custom protocol.
This application allows the user to use a console to use Bluetooth Low Energy (BLE) to establish connection between two BLE devices, and send raw data between the service and client.
It is recommended that the user visits the kit setup Getting Started Guide for AM335x pages before trying the application described on this page.
Running the Bluetooth Code[edit]
Once the am335x is initialized on the terminal, follow the instructions;
Note: When using a CC256x controller you will need to change the init script in order to enable BLE.
You can use the following command in the AM335x device terminal
cp -f /lib/firmware/TIInit_6.7.16_ble_on.bts /lib/firmware/TIInit_6.7.16.bts
Enter to the Sample Application folder, for this example “cd BluetopiaPM/bin”
root@am335x-evm:~# cd BluetopiaPM/bin/ root@am335x-evm:~/BluetopiaPM/bin#
Start the Server and the Demo application by typing “./SS1BTPM & ./LinuxSPPLE_PM”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxSPPLE_PM [1] 1789
Now the help screen is displayed
****************************************************************** * Command Options: 1) Initialize * * 2) Cleanup * * 3) QueryDebugZoneMask * * 4) SetDebugZoneMask * * 5) ShutdownService * * 6) RegisterEventCallback, * * 7) UnRegisterEventCallback, * * 8) QueryDevicePower * * 9) SetDevicePower * * 10)QueryLocalDeviceProperties * * 11)SetLocalDeviceName * * 12)SetLocalClassOfDevice * * 13)SetDiscoverable * * 14)SetConnectable * * 15)SetPairable * * 16)StartDeviceDiscovery * * 17)StopDeviceDiscovery * * 18)QueryRemoteDeviceList * * 19)QueryRemoteDeviceProperties * * 20)AddRemoteDevice * * 21)DeleteRemoteDevice * * 22)UpdateRemoteDeviceAppData * * 23)DeleteRemoteDevices * * 24)PairWithRemoteDevice * * 25)CancelPairWithRemoteDevice * * 26)UnPairRemoteDevice * * 27)QueryRemoteDeviceServices * * 28)QueryRemoteDeviceServiceSupported * * 29)QueryRemoteDevicesForService * * 30)QueryRemoteDeviceServiceClasses * * 31)AuthenticateRemoteDevice * * 32)EncryptRemoteDevice * * 33)ConnectWithRemoteDevice * * 34)DisconnectRemoteDevice * * 35)SetRemoteDeviceLinkActive * * 36)CreateSDPRecord * * 37)DeleteSDPRecord * * 38)AddSDPAttribute * * 39)DeleteSDPAttribute * * 40)EnableBluetoothDebug * * 41)RegisterAuthentication * * 42)UnRegisterAuthentication * * 43)PINCodeResponse * * 44)PassKeyResponse * * 45)UserConfirmationResponse * * 46)ChangeSimplePairingParameters * * 47)RegisterGATTCallback * * 48)UnRegisterGATTCallback * * 49)QueryGATTConnections * * 50)SetLocalDeviceAppearance * * 51)ConfigureSPPLE * * 52)Send * * 53)Read * * 54)Loopback * * 55)DisplayRawModeData * * 56)AutomaticReadMode * * 57)StartAdvertising * * 58)StopAdvertising * * Help, Quit. * ******************************************************************
Demo Application[edit]
This section provides a description of how to use the demo application to connect two configured board and communicate over Bluetooth-LE. Bluetooth SPPLE is a simple Client-Server connection process. In this guide we explain how to use LinuxSPPLE_PM to connect to a CC256x board running SPPLEDemo App.
Serial Port Profile Low Energy (SPPLE)[edit]
- To verify the SPPM_LE , after running the "LinuxSPPLE_PM" executable, initializing, and powering on the local device if necessary, first register for GATT Callback events.
Preparing the CC256x device[edit]
- a) Program and download the SPPLEDemo App onto the device.
- b) Select Server or Client (either is fine) and the Help screen will appear
****************************************************************** * Command Options General: Help, GetLocalAddress, SetBaudRate * * Quit, * * Command Options BR/EDR: Inquiry, DisplayInquiryList, Pair, * * EndPairing, PINCodeResponse, * * PassKeyResponse, * * UserConfirmationResponse, * * SetDiscoverabilityMode, * * SetConnectabilityMode, * * SetPairabilityMode, * * ChangeSimplePairingParameters, * * GetLocalName, SetLocalName, * * GetClassOfDevice, SetClassOfDevice, * * GetRemoteName, SniffMode, * * ExitSniffMode, Open, Close, Read, * * Write, GetConfigParams, * * SetConfigParams, GetQueueParams, * * SetQueueParams, Loopback, * * DisplayRawModeData, AutomaticReadMode,* * CBSend * * Command Options GAPLE: SetDiscoverabilityMode, * * SetConnectabilityMode, * * SetPairabilityMode, * * ChangePairingParameters, * * SetRandomAddress, * * ResolveRemoteAddress, * * AdvertiseLE, StartScanning, * * StopScanning, ConnectLE, * * DisconnectLE, CancelConnectLE, * * PairLE, UnPairLE, LEPasskeyResponse, * * QueryEncryptionMode, SetPasskey, * * DiscoverGAPS, GetLocalName, * * SetLocalName, GetLERemoteName, * * LEUserConfirmationResponse, * * EnableSCOnly, * * RegenerateP256LocalKeys, * * SCGenerateOOBLocalParams, * * SetLocalAppearance, * * GetLocalAppearance, * * GetRemoteAppearance, * * Command Options SPPLE: DiscoverSPPLE, RegisterSPPLE, LESend, * * ConfigureSPPLE, LERead, Loopback, * * DisplayRawModeData, AutomaticReadMode * ******************************************************************
- c) Register SPPLE services with the command RegisterSPPLE.
- d) Configure device to automatically display raw data using DisplayRawModeData and AutomaticReadMode.
- e) Set the local address with SetRandomAddress 1.
SetRandomAddress 1 Random Resolvable Private BD_ADDR: 0x471F05974892
- f) Start advertising with the command AdvertiseLE 1 1 [BD_ADDR] where [BD_ADDR] is the random address set above.
AdvertiseLE 1 1 471F05974892 GAP_LE_Advertising_Enable success.
Running the demo on the WL18xx device[edit]
- a) Initialize the profile by typing “1 1” or “Initialize 1”.
- b) Powering up the Bluetooth device by typing “9 1” or "SetDevicePower 1”, if the device is already powered up you’ll receive an error that the device is already powered up
SPPMLE>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. SPPMLE>SetDevicePower 1 [12503.105029] (hci_tty): inside hci_tty_open (ecc4d3c0, eb87fb00) [12503.112408] (stc): chnl_id list empty :4 [12503.116406] (stk) : st_kim_start(stk) :ldisc_install = 1uim:poll broke due to event 10(PRI:2/ERR:8) uim:read 1 from install uim:@ st_uart_config uim: signal received, opening /dev/ttyS1 uim:@ set_baud_rate uim:set_baud_rate() done uim:Setting speed to 3000000 uim:@ read_command_complete uim: Command complete started uim:@ read_hci_event uim: read_hci_event uim:Command complete done [12503.279039] (stc): st_tty_open uim:Speed changing to 3000000, 1 uim:@ set_custom_baud_rate (stk) :line discipline installeduim:Installed N_TI_WL Line displine [12503.293181] (stk) :TIInit_11.8.32.bts uim:begin polling... (stk) :change remote baud rate command in firmware [12503.306045] (stk) :skipping the wait event of change remote baud[12504.061071] (stc): add_channel_to_table: id 4 [12504.065471] (stc): add_channel_to_table: id 2 [12504.069855] (stc): add_channel_to_table: id 3 BT COMM PORT (/dev/hci_tty): 1 DEVM_PowerOnDevice() Success: 0. SPPMLE> Device Powered On. SPPMLE>
- c) Now register for GATT Callback events.
SPPMLE>RegisterGATTCallback GATM_RegisterEventCallback() Success: 1. SPPMLE>
- With the remote device ready and advertising, next on the terminal run the following:
- d) StartDeviceDiscovery 1 10
SPPMLE>StartDeviceDiscovery 1 10 Attempting to Start Discovery (10 Seconds). Local Device Properties Changed. Device Flags: 0x80010000 LE Scan Mode: TRUE, 0x0000000A LE Adv Mode: FALSE, 0x00000000 LE Slv Mode: Not in Slave Mode SPPMLE> LE Device Discovery Started. SPPMLE>DEVM_StartDeviceScan() Success: 0. SPPMLE> Remote Device Found. BD_ADDR: C4BE841D226E Address Type: Public Device Name: 9AAA=mS{>A8sNYgucXfdH?`M5gCIC LE Type: Single Mode Device Flags: 0x40000001 LE RSSI: -73 LE Paired State : FALSE LE Connect State: FALSE LE Encrypt State: FALSE GATT Services Known: FALSE SPPMLE> Remote Device Found. BD_ADDR: 471F05974892 Address Type: Resolvable Random Address. Device Name: LE Type: Dual Mode Device Flags: 0xC0000000 LE RSSI: -60 LE Paired State : FALSE LE Connect State: FALSE LE Encrypt State: FALSE GATT Services Known: FALSE RSSI: 0 Friendly Name: App. Info: : 00000000 Paired State : FALSE Connect State: FALSE Encrypt State: FALSE Sniff State : FALSE COD: 0x000000 SDP Serv. Known : FALSE SPPMLE> Remote Device Properties Changed. BD_ADDR: 471F05974892 Address Type: Resolvable Random Address. Device Name: SPPLEDemo LE Type: Dual Mode SPPMLE> Local Device Properties Changed. Device Flags: 0x80000000 LE Scan Mode: FALSE, 0x00000000 LE Adv Mode: FALSE, 0x00000000 LE Slv Mode: Not in Slave Mode SPPMLE> LE Device Discovery Stopped. SPPMLE>
- Locate your device using the "Device Name" field displayed in the console and note the device address (BD_ADDR) of the device. After you have located your device and noted the BD_ADDR next run the following commands to connect and send data to the device:
- e) Connect to the remote device
Usage: ConnectWithRemoteDevice [BD_ADDR] [Connect LE (1 = LE, 0 = BR/EDR)] [ConnectFlags (Optional)]. where ConnectFlags is a bitmask of 0x00000001 = Authenticate 0x00000002 = Encrypt 0x00000004 = Use Local Random Address 0x00000008 = Use Peer Random Address
SPPMLE>ConnectWithRemoteDevice 471F05974892 1 Attempting to Connect With (LE) Remote Device: 471F05974892 (Flags = 0x80000000). DEVM_ConnectWithRemoteDevice() Success: 0. SPPMLE> Remote Device Connection Status: 471F05974892, 0 (SUCCESS) SPPMLE> Remote Device Properties Changed. BD_ADDR: 471F05974892 Address Type: Resolvable Random Address. LE Type: Dual Mode Device Flags: 0xC0048001 LE Connect State: TRUE SPPMLE> GATT Connection Connection Type: LE Remote Address: 471F05974892 MTU: 23 SPPMLE>
- f) Query Remote Device Services
QueryRemoteDeviceServices 471F05974892 1 1 Attempting Query Remote Device 471F05974892 For GATT Services. DEVM_QueryRemoteDeviceServices() Success: 0, Total Number Service Bytes: 0. SPPMLE> Remote Device 471F05974892 Services Status: LE, SUCCESS. SPPMLE> Remote Device Properties Changed. BD_ADDR: 471F05974892 Address Type: Resolvable Random Address. LE Type: Dual Mode Device Flags: 0xC0049001 GATT Services Known: TRUE SPPMLE> Remote Device Properties Changed. BD_ADDR: 471F05974892 Address Type: Resolvable Random Address. LE Type: Dual Mode Device Flags: 0xC004B001 Device Appearance: 128 SPPMLE>
- g) Configure the SPPLE
SPPMLE>ConfigureSPPLE SPPLE service configured. SupportCredits: TRUE. SPPMLE>
Note: After connecting to the device you only have a few seconds to query its services and to configure SPPLE before the device will issue a disconnect. If the device does disconnect (you will know from the "LE Connect State: FALSE" message), re-issue the commands above to restart the process.
- h) Send 10 bytes to the remote device
SPPMLE>Send 10 Send Complete, Sent 10. SPPMLE>
- In the remote device window, you should see 10 bytes appear.
Next configure LinuxSPPLE_PM to display data it receives:
- i) Displaying the Raw Data
SPPMLE>DisplayRawModeData 1 Current Raw Data Display Mode set to: ACTIVE. SPPMLE>
- j) Automatic Read Mode
SPPMLE>AutomaticReadMode 1 Current Automatic Read Mode set to: ACTIVE. SPPMLE>
- k) On the remote device, get the address of the WL18xx device.
- Now on the remote device send the command LESend 0x84DD2093038C 10'. You should see 10 bytes appear in the console of the WL18xx device.
SPPMLE>0123456789 SPPMLE>
Now that we have demonstrated sending and receiving data to and from the remote device you can now close the connection, perform cleanup, and quit the application
- l) Close the Connection
SPPMLE>DisconnectRemoteDevice 471F05974892 1 Attempting to Disconnect Remote Device: 471F05974892. DEVM_DisconnectRemoteDevice() Success: 0. SPPMLE> GATT Disconnect Connection Type: LE Remote Address: 471F05974892 SPPMLE> Remote Device Properties Changed. BD_ADDR: 471F05974892 Address Type: Resolvable Random Address. LE Type: Dual Mode Device Flags: 0xC0003001 LE Connect State: FALSE SPPMLE>
- m) Performing cleanup
SPPMLE>Cleanup
- n) Quitting the application
SPPMLE>Quit