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 BASM 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.
This demo allows users to evaluate TI's WL18xx device by using the AM335x platform. The BAS sample application code is provided to enable a rich out-of-box experience to the user. The application allows the user to use a console to send Bluetooth commands, setup a Bluetooth Device to accept connections, connect to a remote Bluetooth device and communicate over Bluetooth-LE.
This application allows the user to use a console to use Bluetooth Low Energy (BLE) to establish connection between two BLE devices
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 & ./LinuxBASM”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxBASM [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)DeleteRemoteDevices * * 23)PairWithRemoteDevice * * 24)CancelPairWithRemoteDevice * * 25)UnPairRemoteDevice * * 26)QueryRemoteDeviceServices * * 27)RegisterAuthentication * * 28)UnRegisterAuthentication * * 29)PINCodeResponse * * 30)PassKeyResponse * * 31)UserConfirmationResponse * * 32)ChangeSimplePairingParameters * * 33)ConnectWithRemoteDevice * * 34)DisconnectRemoteDevice * * 35)BASRegisterClientEvents * * 36)BASUnRegisterClientEvents * * 37)BASEnableNotifications * * 38)BASDisableNotifications * * 39)BASGetBatteryLevel * * 40)BASGetBatteryIdentification * * 41)BASCancelTransaction * * 42)StartAdvertising * * 43)StopAdvertising * * 44)EnableBluetoothDebug * * 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. The Battery Service exposes the Battery State and Battery Level of a single battery or set of batteries in a device.
BASM setup on the demo application[edit]
- To verify the BASM client role functionality, first run the "LinuxBASM" executable, initialize, and power on the local device if necessary.
- 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
BASM>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. BASM>SetDevicePower 1 [ 9795.454420] (hci_tty): inside hci_tty_open (ecc473c0, eba55ec0) [ 9795.461704] (stc): chnl_id list empty :4 [ 9795.465672] (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 [ 9795.628835] (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 [ 9795.642936] (stk) :TIInit_11.8.32.bts uim:begin polling... (stk) :change remote baud rate command in firmware [ 9795.655838] (stk) :skipping the wait event of change remote baud[ 9796.412598] (stc): add_channel_to_table: id 4 [ 9796.417003] (stc): add_channel_to_table: id 2 [ 9796.421470] (stc): add_channel_to_table: id 3 BT COMM PORT (/dev/hci_tty): 1 DEVM_PowerOnDevice() Success: 0. BASM> Device Powered On. BASM>
- c) Now register for BAS client events.
BASM>BASRegisterClientEvents BASM_Register_Client_Event_Callback() Success: 1. BASM>
- d) Connect to remote BAS device and discover its services
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
BASM>ConnectWithRemoteDevice 001583584D9F 1 Attempting to Connect With (LE) Remote Device: 001583584D9F (Flags = 0x80000000). DEVM_ConnectWithRemoteDevice() Success: 0. BASM> Remote Device Properties Changed. BD_ADDR: 001583584D9F Address Type: Public LE Type: Dual Mode Device Flags: 0xC0000101 BASM> Remote Device Connection Status: 001583584D9F, 0 (SUCCESS) BASM> Remote Device Properties Changed. BD_ADDR: 001583584D9F Address Type: Public LE Type: Dual Mode Device Flags: 0xC0048101 LE Connect State: TRUE
- e) Query Services from remote device
BASM>QueryRemoteDeviceServices 001583584D9F 1 1 Attempting Query Remote Device 001583584D9F For GATT Services. DEVM_QueryRemoteDeviceServices() Success: 0, Total Number Service Bytes: 0. BASM> Remote Device 001583584D9F Services Status: LE, SUCCESS. BASM> Remote Device Properties Changed. BD_ADDR: 001583584D9F Address Type: Public LE Type: Dual Mode Device Flags: 0xC0049101 GATT Services Known: TRUE BASM> betBASConnected with size 20: Event Callback ID: 1 Bluetooth Address: 001583584D9F Connected Flags: 0x00000000 Connection Type: Server Number of Instances: 1 BASM> Remote Device Properties Changed. BD_ADDR: 001583584D9F Address Type: Public LE Type: Dual Mode Device Flags: 0xC004B101 Device Appearance: 128 BASM>
- f) Enable BAS notifications
BASM>BASEnableNotifications Usage: BASEnableNotifications [BD_ADDR] [InstanceID]. Function Error. BASM>BASEnableNotifications 001583584D9F 0
BASM_Enable_Notifications() Success. BASM>
- g) Get the battery level
BASM>BASGetBatteryLevel Usage: BASGetBatteryLevel [BD_ADDR] [InstanceID]. Function Error.
BASM>BASGetBatteryLevel 001583584D9F 0 BASM_Get_Battery_Level() Success. TransactionID = 3. BASM> betBASBatteryLevel with size 24: Event Callback ID: 1 Bluetooth Address: 001583584D9F InstanceID: 0 TransactionID: 3 Status: 0 Battery Level: 100% BASM>
- h) Disconnect the remote device from the local device
BASM>DisconnectRemoteDevice Usage: DisconnectRemoteDevice [BD_ADDR] [LE Device (1= LE, 0 = BR/EDR)] [Force Flag (Optional)]. Function Error.
BASM>DisconnectRemoteDevice 001583584D9F 1 Attempting to Disconnect Remote Device: 001583584D9F. DEVM_DisconnectRemoteDevice() Success: 0. BASM> Remote Device Properties Changed. BD_ADDR: 001583584D9F Address Type: Public LE Type: Dual Mode Device Flags: 0xC0003101 LE Connect State: FALSE BASM> betBASDisconnected with size 16: Event Callback ID: 1 Bluetooth Address: 001583584D9F Disconnected Flags: 0x00000000 Connection Type: Server BASM>