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 MAPM 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 MAP 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.
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;
Enter to the Sample Application folder, for this example “cd BluetopiaPM/bin”
root@am335x-evm:~# cd BluetopiaPM/bin/ root@am335x-evm:~/BluetopiaPM/bin#
Demo Application[edit]
This section provides a description of how to use the demo application to connect two configured board and communicate over Bluetooth. Bluetooth MAP is a simple Client-Server connection process. We will setup one of the boards as a server and the other board as a client. We will then initiate a connection from the client to the server. Once connected, we can transmit data between the two devices over Bluetooth.
Message Access Profile (MAPM)[edit]
MAPM Client Role (MCE)[edit]
- To verify MAPM_MCE client role functionality, first run the "LinuxMAPM_MCE" executable, initialize, and power on the local device if necessary.
Start the Server and the Demo application by typing “./SS1BTPM & ./LinuxMAPM_MCE”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxMAPM_MCE [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)QueryMSEServices * * 34)ConnectMessageAccessServer * * 35)Disconnect * * 36)Abort * * 37)QueryCurrentFolder * * 38)EnableDisableNotifications * * 39)SetFolder * * 40)SetAbsoluteFolder * * 41)GetFolderListing * * 42)GetFolderListingSize * * 43)GetMessageListing * * 44)GetMessageListingSize * * 45)GetMessage * * 46)SetMessageStatus * * 47)PushMessage * * 48)UpdateInbox * * 49)ParseRemoteMASServices * * 50)EnableBluetoothDebug * * Help, Quit. * ******************************************************************
- 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
Message Access>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. Message Access>SetDevicePower 1 echo 117 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio117/direction echo 0 > /sys/class/gpio/gpio117/value echo 1 > /sys/class/gpio/gpio117/value BT COMM PORT (/dev/ttyS1): 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. Message Access> Device Powered On. Message Access>
- c) Discover and identify the remote device services as well as parse the message access services of a remote device that actually has an MSE service; an Android cellular phone with these capabilities was used for the purposes of this demonstration.
Message Access>QueryMSEServices Usage: QueryMSEServices [BD_ADDR] [Force Update]. Function Error. Message Access>
Message Access>QueryMSEServices 34B1F7DF7BB3 1 Attempting Query Remote Device 34B1F7DF7BB3 For Services. Remote Device Found. BD_ADDR: 34B1F7DF7BB3 COD: 0x000000 Device Name: Device Flags: 0x80000000 RSSI: 0 Friendly Name: App. Info: : 00000000 Paired State : FALSE Connect State: FALSE Encrypt State: FALSE Serv. Known : FALSE Message Access>Total Service Size is 0. Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Flags: 0x80000048 Connect State: TRUE Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Name: WL18xx Device Device Flags: 0x80000049 Message Access> Remote Device 34B1F7DF7BB3 Services Status: BR/EDR, SUCCESS. Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Flags: 0x80000149 Serv. Known : TRUE Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Flags: 0x80000101 Connect State: FALSE Message Access>
Message Access>ParseRemoteMASServices 34B1F7DF7BB3 MAPM_Parse_Remote_Message_Access_Services: Function Successful. Instance ID : 1 Server Port : 5 Supported Message Types : 0xaa Service Name : MAP MAS-TestService Message Access>
- d) Register the local device for DEVM authentication events.
Message Access>RegisterAuthentication DEVM_RegisterAuthentication() Success: 5. Message Access> </pre :e) initiate a MAP connection to the remote device, and pair if necessary <pre> Message Access>ConnectMessageAccessServer Usage: ConnectMessageAccessServer [BD_ADDR] [ServerPort] [InstanceID] [ConnectionFlags]. Function Error. Message Access>
Message Access>ConnectMessageAccessServer 34B1F7DF7BB3 5 1 0 MAPM_Connect_Remote_Device: Function Successful. Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Flags: 0x80000149 Connect State: TRUE Message Access> Authentication Request received for 34B1F7DF7BB3. I/O Capability Request. DEVM_AuthenticationResponse() Success. Message Access> Authentication Request received for 34B1F7DF7BB3. I/O Capability Response. Remote I/O Capabilities: Display Yes/No, MITM Protection: TRUE. Message Access> Authentication Request received for 34B1F7DF7BB3. User Confirmation Request. User Confirmation: 281812 Respond with the command: UserConfirmationResponse Message Access>
- f) Respond with the command: UserConfirmationResponse
Message Access>UserConfirmationResponse 1 DEVM_AuthenticationResponse(), User Confirmation Response Success. Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Flags: 0x800001CD Paired State : TRUE Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Flags: 0x800001DD Encrypt State: TRUE Message Access> Connection Status for device 34B1F7DF7BB3. Connection Type: mctMessageAccessClient. Instance ID: 1. Connection Status: 0. Message Access>
- g) Enable notifications about the remote device's MSE for the local device and delete an SMS message on the cellular phone, a notification about this event should appear.
Message Access>EnableDisableNotifications Usage: EnableDisableNotifications [BD_ADDR] [InstanceID] [Enable/Disable (0=Disable, 1=Enable). Function Error. Message Access>
Message Access>EnableDisableNotifications 34B1F7DF7BB3 1 1 MAPM_Enable_Notifications: Function Successful. Message Access>
- When the server send confirmation to the client you will see
Message Access> Enable Notifications Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Message Access>
- h) Move down two folders into "TELECOM/MSG", query the current folder, then get the amount of folders in this directory, and perform a folder listing.
Usage: SetFolder [BD_ADDR] [InstanceID] [Path Option (0 = Root, 1 = Down, 2 = Up)] [Folder (only required for Down option)].
Message Access>SetFolder 34B1F7DF7BB3 1 1 TELECOM MAPM_Set_Folder: Function Successful. Message Access> Set Folder Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Current Path: TELECOM. Message Access>SetFolder 34B1F7DF7BB3 1 1 MSG MAPM_Set_Folder: Function Successful. Message Access> Set Folder Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Current Path: TELECOM/MSG. Message Access>
Usage: QueryCurrentFolder [BD_ADDR] [InstanceID].
Message Access>QueryCurrentFolder 34B1F7DF7BB3 1 MAPM_Query_Current_Folder: Function Successful. Current Folder: TELECOM/MSG. Message Access>
Usage: GetFolderListingSize [BD_ADDR] [InstanceID].
Message Access>GetFolderListingSize 34B1F7DF7BB3 1 MAPM_Get_Folder_Listing_Size: Function Successful. Message Access> Get Folder Listing Size Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Number of Folders: 4. Message Access>
Usage: GetFolderListing [BD_ADDR] [InstanceID] [Max List Count] [Starting List Offset].
Message Access>GetFolderListing 34B1F7DF7BB3 1 1024 0 MAPM_Get_Folder_Listing: Function Successful. Message Access> Get Folder Listing Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Final Event?: YES. Data Length: 352 Data: <?xml version="1.0"?> <!DOCTYPE folder-listing SYSTEM "obex-folder-listing.dtd"> <folder-listing version="1.0"> <folder name="inbox" created="20090526T141500Z"/> <folder name="outbox" created="20090526T141500Z"/> <folder name="sent" created="20090526T141500Z"/> <folder name="deleted" created="20090526T141500Z"/> </folder-listing> 352 bytes written to file :FolderListing.txt Message Access>
- i) If you know where you are going you can also move to any specific folder with an absolute path. Go ahead and move into "TELECOM/MSG/INBOX", get the amount of messages in this directory, and then perform a message listing.
Usage: SetAbsoluteFolder [BD_ADDR] [InstanceID] [Folder].
Message Access>SetAbsoluteFolder 34B1F7DF7BB3 1 TELECOM/MSG/INBOX MAPM_Set_Folder_Absolute: Function Successful. Message Access> Set Folder Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Current Path: TELECOM/MSG/INBOX. Message Access>
Usage: GetMessageListingSize [BD_ADDR] [InstanceID] [Folder (optional)].
Message Access>GetMessageListingSize 34B1F7DF7BB3 1 MAPM_Get_Message_Listing_Size: Function Successful. Message Access> Get Message Listing Size Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. New Messages?: NO. Number of Messages: 3. Time/Date: Date: 8/7/2015. Time: 15:43:52. Message Access>
Usage: GetMessageListing [BD_ADDR] [InstanceID] [Max List Count] [Starting List Offset] [Folder (optional)].
Message Access>GetMessageListing 34B1F7DF7BB3 1 1024 0 MAPM_Get_Message_Listing: Function Successful. Message Access> Get Message Listing Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Final Event?: YES. New Messages?: NO. Number Messages: 3. Data Length: 1108 Time/Date: Date: 8/7/2015. Time: 15:44:3. Data: <MAP-msg-listing version="1.0"> <msg handle="20000100001" subject="Hello" datetime="20100513T130510Z" sender="" sender_name="Jamie" sender_addressing="+1-987-6543210" replyto_addressing="" recipient_name="22+1-0123-456789" recipient_addressing="" type="SMS_GSM" size="401" text="" reception_status="complete" attachment_size="0" priority="no" read="yes" sent="no" protected="no"/> <msg handle="20000100002" subject="Guten Tag" datetime="20100512T092200Z" sender="" sender_name="Dmitri" sender_addressing="dmitry@home.com" replyto_addressing="" recipient_name="22+49-9012-34567" recipient_addressing="" type="EMAIL" size="441" text="" reception_status="complete" attachment_size="3000" priority="no" read="no" sent="no" protected="no"/> <msg handle="20000100003" subject="Help" datetime="20100511T032200Z" sender="" sender_name="Catherine" sender_addressing="2058769032" replyto_addressing="" recipient_name="5555555555" recipient_addressing="" type="MMS" size="380" text="" reception_status="complete" attachmen 1108 bytes written to file :MessageListing.txt Message Access>
- j) Get a message from the remote device.
Message Access>GetMessage Usage: GetMessage [BD_ADDR] [InstanceID] [Message Handle (String)] [Char Set (0 = Native, 1 = UTF8)] [Fractional Type (0 = Unfragmented, 1 = First, 4 = Last)]. Function Error. Message Access>
Message Access>GetMessage 34B1F7DF7BB3 1 20000100001 1 0 MAPM_Get_Message() Successful. Message Access> Get Message Response for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Final Event?: YES. Fractional Type: ftUnfragmented. Data Length: 400 Data: BEGIN:BMSG VERSION:1.0 STATUS:READ TYPE:SMS_GSM FOLDER:TELECOM/MSG/INBOX BEGIN:VCARD VERSION:2.1 N:Jamie TEL;CELL;VOICE:+1-987-654-3210 END:VCARD BEGIN:BENV BEGIN:VCARD VERSION:2.1 N: TEL;WORK;VOICE:22+1-0123-456789 END:VCARD BEGIN:BBODY ENCODING:8BIT CHARSET:UTF-8 LENGTH:71 BEGIN:MSG Date: 13 May 09 Subject: Hello Nothing Really END:MSG END:BBODY END:BENV END:BMSG 400 bytes written to file :Message.txt Message Access>
- k) Set the status of a message on the remote devices's MSE to a delete status and the SMS message will be deleted from the cellular phone.
Message Access>SetMessageStatus Usage: SetMessageStatus [BD_ADDR] [InstanceID] [Message Handle] [Status Indicator (0 = Read Status, 1 = Delete Status)] [Status Value (0 = FALSE, 1 = TRUE)]. Function Error. Message Access>
Message Access>SetMessageStatus 34B1F7DF7BB3 1 20000100001 1 1 MAPM_Set_Message_Status() Successful. Message Access> Set Message Status Confirmation for device 34B1F7DF7BB3. Instance ID: 1. Response Code: 0. Message Access>
- l) Disconnect the Message Access Profile connection.
Usage: Disconnect [BD_ADDR] [InstanceID].
Message Access>Disconnect 34B1F7DF7BB3 0 MAPM_Disconnect: Function Successful. Message Access> Remote Device Properties Changed. BD_ADDR: 34B1F7DF7BB3 Device Flags: 0x80000185 Connect State: FALSE Encrypt State: FALSE Message Access>
MAPM Server Role (MSE)[edit]
- To verify the MAPM server role functionality, first run the "LinuxMAPM_MSE" executable, initialize, and power on the local device if necessary.
Start the Server and the Demo application by typing “./SS1BTPM & ../LinuxMAPM_MSE”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxMAPM_MSE [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)ConnectionRequestResponse * * 34)ConnectMessageNotificationServer * * 35)Disconnect * * 36)Abort * * 37)RegisterServer * * 38)UnRegisterServer * * 39)RegisterServiceRecord * * 40)UnRegisterServiceRecord * * 41)EnableNotificationsConfirmation * * 42)ParseRemoteMNSServices * * 43)SendNotification * * 44)EnableBluetoothDebug * * Help, Quit. * ******************************************************************
- 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
Message Access>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. Message Access>SetDevicePower 1 echo 117 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio117/direction echo 0 > /sys/class/gpio/gpio117/value echo 1 > /sys/class/gpio/gpio117/value BT COMM PORT (/dev/ttyS1): 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. Message Access> Device Powered On. Message Access>
- c) Next register a server port with port number 10 and an instance ID of 0, and register a service record for this instance:.
Usage: RegisterServer [ServerPort] [ServerFlags] [InstanceID] [SupportedMessageTypes].
Message Access>RegisterServer 5 0 1 0xAA MAPM_Register_Server: Function Successful. Message Access>
- d) Register a service record.
Usage: RegisterServiceRecord [InstanceID] [ServiceName].
Message Access>RegisterServiceRecord 1 TestService MAPM_Register_Service_Record: Function Successful: Service Record Handle 65545. Message Access>
- e) Register the local device for DEVM authentication events
Message Access>RegisterAuthentication DEVM_RegisterAuthentication() Success: 5. Message Access>
- f) Connect a remote device to the local device.
Message Access> Remote Device Properties Changed. BD_ADDR: 84DD209C58DD Device Flags: 0x80000009 Connect State: TRUE Message Access> Authentication Request received for 84DD209C58DD. I/O Capability Response. Remote I/O Capabilities: Display Yes/No, MITM Protection: TRUE. Message Access> Authentication Request received for 84DD209C58DD. I/O Capability Request. DEVM_AuthenticationResponse() Success. Message Access> Authentication Request received for 84DD209C58DD. User Confirmation Request. User Confirmation: 281812 Respond with the command: UserConfirmationResponse Message Access>
- g) Respond with the command: UserConfirmationResponse
Message Access>UserConfirmationResponse 1 DEVM_AuthenticationResponse(), User Confirmation Response Success. Message Access> Remote Device Properties Changed. BD_ADDR: 84DD209C58DD Device Flags: 0x8000008D Paired State : TRUE Message Access> Remote Device Properties Changed. BD_ADDR: 84DD209C58DD Device Flags: 0x8000009D Encrypt State: TRUE Message Access> Connection for device 84DD209C58DD. Connection Type: mctMessageAccessServer. Instance ID: 1. Message Access>
- Before following section h, check that the Server received Enable Notification Indication.
Message Access> Enable Notifications Indication for device 84DD209C58DD. Instance ID: 1. Enabled: ENABLED. Message Access>
- h) Now use the MCE device to initiate an MAS connection. Note that you may need to respond with a pairing command, for example PINCodeResponse, PassKeyResponse, or UserConfirmationResponse, if you aren't already paired. When MCE has enables notifications respond with the following.
Message Access>EnableNotificationsConfirmation Usage: EnableNotificationsConfirmation [BD_ADDR] [InstanceID] [ResponseStatusCode]. Function Error. Message Access>
Message Access>EnableNotificationsConfirmation 84DD209C58DD 1 0 MAPM_Enable_Notifications_Confirmation: Function Successful. Message Access>
- i) Next query the services of the remote MNS server
Usage: QueryRemoteDeviceServices [BD_ADDR] [Force Update] [Bytes to Query (specified if Force is 0)].
Message Access>QueryRemoteDeviceServices 84DD209C58DD 1 Attempting Query Remote Device 84DD209C58DD For Services. DEVM_QueryRemoteDeviceServices() Success: 0, Total Number Service Bytes: 0. Message Access> Remote Device 84DD209C58DD Services Status: BR/EDR, SUCCESS. Message Access> Remote Device Properties Changed. BD_ADDR: 84DD209C58DD Device Flags: 0x8000019D Serv. Known : TRUE Message Access>
- j) Parse the remote mns services
Message Access>ParseRemoteMNSServices Usage: ParseRemoteMNSServices [BD_ADDR]. Function Error. Message Access>
Message Access>ParseRemoteMNSServices 84DD209C58DD MAPM_Parse_Remote_Message_Notification_Services: Function Successful. Server Port : 5 Service Name : MAP MNS-MAP Notification Server Message Access>
- k) You will see a message in the terminal showing the port number and service name of the MNS server. Connect to the MNS server using the port number just discovered with the following
Message Access>ConnectMessageNotificationServer Usage: ConnectMessageNotificationServer [BD_ADDR] [ServerPort] [InstanceID] [ConnectionFlags]. Function Error. Message Access>
Message Access>ConnectMessageNotificationServer 84DD209C58DD 5 1 0 MAPM_Connect_Remote_Device: Function Successful. Message Access> Connection Status for device 84DD209C58DD. Connection Type: mctNotificationClient. Instance ID: 1. Connection Status: 0. Message Access>
- l) You will see a "Connection Status: 0" message in the terminal on success. Next send a fake message to the MNS, for example
Message Access>SendNotification Usage: SendEventReport [BD_ADDR] [InstanceID] [Handle] [Folder] [EventType (0 - 7)] [Message Type (0-3)]. Function Error. Message Access>
Message Access>SendNotification 84DD209C58DD 1 20000100001 INBOX 0 0 MAPM_Send_Notification() Successful. Message Access> Notification Confirmation from device 84DD209C58DD . Instance ID: 1. Response Code: 0. Message Access>
- m) Disconnect the Message Notification Service.
Usage: Disconnect [BD_ADDR] [InstanceID].
Message Access>Disconnect 84DD209C58DD 1 MAPM_Disconnect: Function Successful. Message Access>
- n) UnRegister the Server
Usage: UnRegisterServer [InstanceID].
Message Access>UnRegisterServer 1 MAPM_Un_Register_Server: Function Successful. Message Access> Remote Device Properties Changed. BD_ADDR: 84DD209C58DD Device Flags: 0x80000185 Connect State: FALSE Encrypt State: FALSE Message Access>