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 FMPM Target Role 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 Find Me profile defines the behavior when a button is pressed on a device to cause an immediate alert on a peer device. This can be used to allow users to find devices that have been misplaced. There are two roles defined in this profile, The Find Me Target - shall be a GATT server and the Find Me Locator - shall be a GATT client.
This application allows the user to use a console to use Bluetooth Low Energy (BLE) to establish connection between two BLE devices, change phone alert status, change ringer status, put in and get out of silent mode.
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 & ./LinuxFMPM_TAR”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxFMPM_TAR [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)FMPRegisterTargetEvents * * 36)FMPUnRegisterTargetEvents * * 37)StartAdvertising * * 38)StopAdvertising * * 39)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.
FMPM Server Role setup on the demo application[edit]
- To verify the FMPM_TAR target role functionality, after running the "LinuxFMPM_TAR" executable, initializing, and powering on the local device if necessary, first register for FMP target events.
- 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
FMPM>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. FMPM> FMPM>SetDevicePower 1 echo 48 > /sys/class/gpio/export sh: line 0: echo: write error: Device or resource busy echo out > /sys/class/gpio/gpio48/direction echo 0 > /sys/class/gpio/gpio48/value echo 1 > /sys/class/gpio/gpio48/value BT COMM PORT (/dev/ttyS3): 1 Changing HCI baud rate to 3000000 Status: Executing BTS Script /lib/firmware/TIInit_11.8.32.bts. Status: BTS Script successfully executed. DEVM_PowerOnDevice() Success: 0. FMPM> Device Powered On. FMPM>
- c) Now register for FMP Server events.
FMPM>FMPRegisterTargetEvents FMPM_Register_Target_Event_Callback() Success: 1. FMPM>
- d) Start Advertising the target device.
Usage: StartAdvertising [Flags] [Duration] [BD ADDR]. where Flags is a bitmask in the following table Bitmask Number - [Bit is set] [Bit is off] 0x00000001 - [Local Public Address] [Local Random Address] 0x00000002 - [Discoverable] [Non Discoverable] 0x00000004 - [Connectable] [Non Connectable] 0x00000010 - [Advertise Name] [Advertise Name off] 0x00000020 - [Advertise Tx Power] [Advertise Tx Power off] 0x00000040 - [Advertise Appearance] [Advertise Appearance off] 0x00000100 - [Peer Public Address] [Peer Random Address] When Connectable bit (0x0004) is set: 0x00000200 - [Direct Connectable] [Undirect Connectable] When Direct Connectable bit (0x0200) is set: 0x00000400 - [Low Duty Cycle] [High Duty Cycle] Note: BD ADDR is needed only when Direct Connectable flags is in use.
FMPM>StartAdvertising 0x3F 10000 Local Device Properties Changed. Device Flags: 0xC0020000 LE Scan Mode: FALSE, 0x00000000 LE Adv Mode: TRUE, 0x00002710 LE Slv Mode: In Slave Mode FMPM> LE Advertising Started. FMPM>DEVM_StartAdvertising() Success: Duration 10000 seconds. FMPM>
- e) Initiate connection from the collector to the target.
Local Device Properties Changed. Device Flags: 0xC0000000 LE Scan Mode: FALSE, 0x00000000 LE Adv Mode: FALSE, 0x00000000 LE Slv Mode: In Slave Mode FMPM> LE Advertising Stopped. FMPM> Remote Device Found. BD_ADDR: 0002723257F7 Address Type: Public Device Name: LE Type: Single Mode Device Flags: 0x40008000 LE RSSI: 0 LE Paired State : FALSE LE Connect State: TRUE LE Encrypt State: FALSE GATT Services Known: FALSE FMPM> Remote Device Properties Changed. BD_ADDR: 0002723257F7 Address Type: Public LE Type: Single Mode Device Flags: 0x40008000 LE Connect State: TRUE FMPM>
- f) The FMP app is now ready to receive alerts. Use the remote FMP locator device to discover the local device's immediate alert service alert level control point and cause a desired level FMP alert.
FMPM> FMPM Alert: Bluetooth Address: 0002723257F7 Connection Type: Target Alert Level: High Alert FMPM>