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 FTPM 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.
FTP 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 FTP defines how folders and files on a server device can be browsed by a client device. Once a file or location is found by the client, a file can be pulled from the server to the client, or pushed from the client to the server using GOEP.
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]
The demo application provides a description on how to use the demo application to connect two devices browsing files and folders by the client device, pulling files from the server, or pushing files from the client to the server over Bluetooth.
File Transfer Profile (FTP)[edit]
FTPM Client Role[edit]
- To verify the FTP client role, after running the "LinuxFTPM_CLT" executable, initializing, and powering on the device if necessary, connect to a FTP server.
Start the Server and the Demo application by typing “./SS1BTPM & ./LinuxFTPM_CLT”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxFTPM_CLT [1] 1789
Now the help screen is displayed
****************************************************************** * Command Options: 1) Initialize * * 2) Cleanup * * 3) QueryDebugZoneMask * * 4) SetDebugZoneMask * * 5) SetDebugZoneMaskPID * * 6) ShutdownService * * 7) RegisterEventCallback, * * 8) UnRegisterEventCallback, * * 9) QueryDevicePower * * 10)SetDevicePower * * 11)QueryLocalDeviceProperties * * 12)SetLocalDeviceName * * 13)SetLocalClassOfDevice * * 14)SetDiscoverable * * 15)SetConnectable * * 16)SetPairable * * 17)StartDeviceDiscovery * * 18)StopDeviceDiscovery * * 19)QueryRemoteDeviceList * * 20)QueryRemoteDeviceProperties * * 21)AddRemoteDevice * * 22)DeleteRemoteDevice * * 23)UpdateRemoteDeviceAppData * * 24)DeleteRemoteDevices * * 25)PairWithRemoteDevice * * 26)CancelPairWithRemoteDevice * * 27)UnPairRemoteDevice * * 28)QueryRemoteDeviceServices * * 29)QueryRemoteDeviceServiceSupported * * 30)QueryRemoteDevicesForService * * 31)QueryRemoteDeviceServiceClasses * * 32)AuthenticateRemoteDevice * * 33)EncryptRemoteDevice * * 34)ConnectWithRemoteDevice * * 35)DisconnectRemoteDevice * * 36)SetRemoteDeviceLinkActive * * 37)CreateSDPRecord * * 38)DeleteSDPRecord * * 39)AddSDPAttribute * * 40)DeleteSDPAttribute * * 41)EnableBluetoothDebug * * 42)RegisterAuthentication * * 43)UnRegisterAuthentication * * 44)PINCodeResponse * * 45)PassKeyResponse * * 46)UserConfirmationResponse * * 47)ChangeSimplePairingParameters * * 48)SendRawHCICommand * * 49)Connect * * 50)Disconnect * * 51)dir * * 52)cd * * 53)mkdir * * 54)rmdir * * 55)del * * 56)put * * 57)get * * 58)mkfile * * 59)abort * * 60)ldir * * Help, Quit. * ******************************************************************
- a) Initialize the profile by typing “1 1” or “Initialize 1”.
- b) Powering up the Bluetooth device by typing “10 1” or "SetDevicePower 1”, if the device is already powered up you’ll receive an error that the device is already powered up
FTPM>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. FTPM>SetDevicePower 1 [267648.322567] (hci_tty): inside hci_tty_open (ecb2e788, ecd6ad80) [267648.328874] (stc): chnl_id list empty :4 [267648.333022] (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 [267648.496453] (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 [267648.510630] (stk) :TIInit_11.8.32.bts uim:begin polling... (stk) :change remote baud rate command in firmware [267648.523581] (stk) :skipping the wait event of change remote baud[267649.273921] (stc): add_channel_to_table: id 4 [267649.278414] (stc): add_channel_to_table: id 2 [267649.282907] (stc): add_channel_to_table: id 3 BT COMM PORT (/dev/hci_tty): 1 DEVM_PowerOnDevice() Success: 0. FTPM> Device Powered On. FTPM>
- c) Register Authentication before creating a connection
FTPM>RegisterAuthentication DEVM_RegisterAuthentication() Success: 5. FTPM>
- d) Connect to the remote FTP server
FTPM>Connect Usage: Open [Remote Device Address] [RFCOMM Server Port] [Open Flags: Bit Mask (1: Authorization, 2: Authentication, 4: Encryption)]. Function Error. FTPM>
FTPM>Connect 001BDC05B5A6 1 0 FTPM_Open_Remote_File_Server() was successful. FTPM> Remote Device Properties Changed. BD_ADDR: 001BDC05B5A6 Device Flags: 0xC0003001 FTPM> Remote Device Properties Changed. BD_ADDR: 001BDC05B5A6 Device Flags: 0xC0003049 Connect State: TRUE FTPM> Remote Device Properties Changed. BD_ADDR: 001BDC05B5A6 Device Name: Bluetooth PTS Radio v4 Device Flags: 0xC0003049 FTPM> etFTPMConnectConfirmation, FTPConnectionID: 0x0001, Status 0x0000 BD_ADDR: 001BDC05B5A6
- e) The dir command will print a list of the current directory contents.
FTPM>dir FTPM_Get_Directory() issued successfully. FTPM> etFTPMDirectoryRequestConfirmation, FTPConnectionID: 0x0001, Request Complete: TRUE, Parent Directory: FALSE (File) 10/21/2010 4:23 PM 5481 Bytes 1.jpg (File) 2/03/2011 8:45 PM 5481 Bytes 2.jpg (File) 4/09/2014 2:59 PM 84 Bytes 2.vcf (File) 5/28/2014 5:04 PM 4 Bytes 20000000010 (File) 12/31/2013 11:05 PM 190 Bytes 200000000A0 (File) 7/20/2010 7:35 PM 596 Bytes 20000100004.bmsg (File) 10/21/2010 4:24 PM 5481 Bytes 3.jpg (File) 10/21/2010 4:24 PM 5481 Bytes 4.jpg (File) 5/29/2014 4:03 PM 52428800 Bytes 50 (File) 10/21/2010 4:31 PM 52428800 Bytes 50MB_org.txt (File) 7/20/2010 6:40 PM 35776 Bytes 915 start.mht (File) 3/13/2014 2:47 PM 229 Bytes AOLMessenger.vcf (File) 5/28/2014 4:11 PM 0 Bytes asdf (File) 4/26/2010 7:25 PM 7680 Bytes AUDIOAPI32.DLL (File) 7/13/2010 6:06 PM 8491 Bytes bigpic.jpg (File) 6/01/2009 7:02 PM 67 Bytes CancelJobRequest.xml (File) 6/01/2009 7:02 PM 118 Bytes CancelJobResponse.xml (File) 4/29/2010 8:09 PM 67 Bytes ChangeLog.txt (File) 6/01/2009 7:02 PM 502 Bytes CreateJobRequest.xml (File) 6/01/2009 7:02 PM 116 Bytes CreateJobResponse.xml (Dir.) DCIM (File) 7/20/2010 8:20 PM 596 Bytes DEADBEEF2.bmsg (Dir.) xml
- f) The mkdir command will create a new directory in the current folder.
FTPM>mkdir New FTPM_Create_Directory() successful. FTPM> etFTPMDirectoryCreateConfirmation, FTPConnectionID: 0x0001, Success: TRUE Created Directory: New Path : /New
- g) We can navigate directories with the cd command. The '..' parameter will navigate up a directory while providing the folder name will navigate to that directory.
FTPM>cd .. FTPM_Set_Directory() successful. FTPM> etFTPMChangeDirectoryConfirmation, FTPConnectionID: 0x0001, Success: TRUE Path : / FTPM>cd New FTPM_Set_Directory() successful. FTPM> etFTPMChangeDirectoryConfirmation, FTPConnectionID: 0x0001, Success: TRUE Path : /New
- h) Now that we've made a directory, we can delete it with the rmdir command.
Note: This command requires the directory to be empty.
FTPM>rmdir New FTPM_Delete_Directory() successful. FTPM> etFTPMDirectoryDeleteConfirmation, FTPConnectionID: 0x0001, Success: TRUE, Directory Not Empty: FALSE Deleted Directory: New
- i) For convenience, the ldir command will print the contents of the current local directory
FTPM>ldir total 100956 drwxrwxr-x 3 root root 4096 Jun 16 11:54 . drwxrwxr-x 10 root root 4096 Mar 25 16:44 .. -rw-rw-r-- 1 root root 29067308 Aug 25 2009 44100.wav -rw-rw-r-- 1 root root 35179944 Apr 12 2011 48000.wav -rw-rw-r-- 1 root root 121 Jun 16 11:00 BTPMCFG.btc -rw-rw-r-- 1 root root 7276 Jun 16 15:51 BTPMDEV.btd -rw-rw-r-- 1 root root 348 Jun 12 12:30 BTPMLECFG.btc -rwxrwxr-x 1 root root 1009842 Mar 25 16:44 LinuxANCM -rwxrwxr-x 1 root root 1001499 Mar 25 16:44 LinuxANPM -rwxrwxr-x 1 root root 1027604 Mar 25 16:44 LinuxANTM -rwxrwxr-x 1 root root 1059628 Mar 25 16:44 LinuxAUDM -rwxrwxr-x 1 root root 1001473 Mar 25 16:44 LinuxBASM -rwxrwxr-x 1 root root 1001530 Mar 25 16:44 LinuxBLPM -rwxrwxr-x 1 root root 1005774 Mar 25 16:44 LinuxDEVM -rwxrwxr-x 1 root root 997188 Mar 25 16:44 LinuxFMPM_TAR -rwxrwxr-x 1 root root 1010272 Mar 25 16:44 LinuxFTPM_CLT -rwxrwxr-x 1 root root 1005912 Mar 25 16:44 LinuxFTPM_SRV -rwxrwxr-x 1 root root 1014364 Mar 25 16:44 LinuxGATM_CLT -rwxrwxr-x 1 root root 1034888 Mar 25 16:44 LinuxGATM_SRV -rwxrwxr-x 1 root root 1014398 Mar 25 16:44 LinuxGLPM_COL -rwxrwxr-x 1 root root 997429 Mar 25 16:44 LinuxHDPM -rwxrwxr-x 1 root root 1006002 Mar 25 16:44 LinuxHIDM -rwxrwxr-x 1 root root 1014301 Mar 25 16:44 LinuxHOGM -rwxrwxr-x 1 root root 1001368 Mar 25 16:44 LinuxHRPM -rwxrwxr-x 1 root root 1001543 Mar 25 16:44 LinuxHTPM_COL -rwxrwxr-x 1 root root 1005947 Mar 25 16:44 LinuxMAPM_MCE -rwxrwxr-x 1 root root 1014404 Mar 25 16:44 LinuxMAPM_MSE -rwxrwxr-x 1 root root 997311 Mar 25 16:44 LinuxOPPM -rwxrwxr-x 1 root root 993014 Mar 25 16:44 LinuxPANM -rwxrwxr-x 1 root root 1001377 Mar 25 16:44 LinuxPASM_SRV -rwxrwxr-x 1 root root 992938 Mar 25 16:44 LinuxPBAM -rwxrwxr-x 1 root root 1001484 Mar 25 16:44 LinuxPXPM_MON -rwxrwxr-x 1 root root 992965 Mar 25 16:44 LinuxSCOM -rwxrwxr-x 1 root root 1019181 Mar 25 16:44 LinuxSPPLE_PM -rwxrwxr-x 1 root root 1001732 Mar 25 16:44 LinuxSPPM -rwxrwxr-x 1 root root 1005840 Mar 25 16:44 LinuxSPPM_MFi -rwxrwxr-x 1 root root 1005917 Mar 25 16:44 LinuxTIPM_CLT -rwxrwxr-x 1 root root 1001459 Mar 25 16:44 LinuxTIPM_SRV drwxrwxr-x 2 root root 4096 Jun 16 11:54 New folder -rwxrwxr-x 1 root root 2797140 Apr 7 13:17 SS1BTPM -rwxrwxr-x 1 root root 958358 Mar 25 16:44 SS1Tool
- j) We can create a new file with the mkfile command.
FTPM>mkfile New FTPM_Create_File() successful. FTPM> etFTPMFileCreateConfirmation, FTPConnectionID: 0x0001, Success: FALSE Created File: New
- k) And we can delete a file with the del command.
FTPM>del New FTPM_Delete_File() successful. FTPM> etFTPMFileDeleteConfirmation, FTPConnectionID: 0x0001, Success: TRUE Deleted File: New
- k) We can get a file with the get command.
FTPM>get 1.jpg FTPM_Get_File() successful. FTPM> etFTPMFileGetConfirmation, FTPConnectionID: 0x00000001, Success: TRUE Transfer Complete: TRUE, Transferred Length: 0x00001569 File: 1.jpg
- l) And we can put a file with the put command.
FTPM>put fts.log FTPM_Put_File() successful. FTPM> etFTPMFilePutConfirmation, FTPConnectionID: 0x0001, Success: TRUE Transfer Complete: FALSE, Total Length: 0x000001D6, Transferred Length: 0x00000000 File: fts.log FTPM> etFTPMFilePutConfirmation, FTPConnectionID: 0x0001, Success: TRUE Transfer Complete: TRUE, Total Length: 0x000001D6, Transferred Length: 0x000001D6 File: fts.log
- m) Finally we can disconnect the clinet with the Disconnect command.
FTPM>Disconnect FTP Client closed successfully. FTPM> Remote Device Properties Changed. BD_ADDR: 001BDC05B5A6 Device Flags: 0xC0003001 Connect State: FALSE
FTPM Server Role[edit]
- To verify the FTP server role, after running the "LinuxFTPM_SRV" executable, initializing, and powering on the device if necessary, first open a local FTP server.
Start the Server and the Demo application by typing “./SS1BTPM & ./LinuxFTPM_SRV”
root@am335x-evm:~/BluetopiaPM/bin# ./SS1BTPM & ./LinuxFTPM_SRV [1] 1789
Now the help screen is displayed
****************************************************************** * Command Options: 1) Initialize * * 2) Cleanup * * 3) QueryDebugZoneMask * * 4) SetDebugZoneMask * * 5) SetDebugZoneMaskPID * * 6) ShutdownService * * 7) RegisterEventCallback, * * 8) UnRegisterEventCallback, * * 9) QueryDevicePower * * 10)SetDevicePower * * 11)QueryLocalDeviceProperties * * 12)SetLocalDeviceName * * 13)SetLocalClassOfDevice * * 14)SetDiscoverable * * 15)SetConnectable * * 16)SetPairable * * 17)StartDeviceDiscovery * * 18)StopDeviceDiscovery * * 19)QueryRemoteDeviceList * * 20)QueryRemoteDeviceProperties * * 21)AddRemoteDevice * * 22)DeleteRemoteDevice * * 23)UpdateRemoteDeviceAppData * * 24)DeleteRemoteDevices * * 25)PairWithRemoteDevice * * 26)CancelPairWithRemoteDevice * * 27)UnPairRemoteDevice * * 28)QueryRemoteDeviceServices * * 29)QueryRemoteDeviceServiceSupported * * 30)QueryRemoteDevicesForService * * 31)QueryRemoteDeviceServiceClasses * * 32)AuthenticateRemoteDevice * * 33)EncryptRemoteDevice * * 34)ConnectWithRemoteDevice * * 35)DisconnectRemoteDevice * * 36)SetRemoteDeviceLinkActive * * 37)CreateSDPRecord * * 38)DeleteSDPRecord * * 39)AddSDPAttribute * * 40)DeleteSDPAttribute * * 41)EnableBluetoothDebug * * 42)RegisterAuthentication * * 43)UnRegisterAuthentication * * 44)PINCodeResponse * * 45)PassKeyResponse * * 46)UserConfirmationResponse * * 47)ChangeSimplePairingParameters * * 48)SendRawHCICommand * * 49)OpenServer * * 50)CloseServer * * 51)OpenServerPortRequestResponse * * Help, Quit. * ******************************************************************
- a) Initialize the profile by typing “1 1” or “Initialize 1”.
- b) Powering up the Bluetooth device by typing “10 1” or "SetDevicePower 1”, if the device is already powered up you’ll receive an error that the device is already powered up
FTPM>Initialize 1 BTPM_Initialize() Success: 0. DEVM_RegisterEventCallback() Success: 5. FTPM>SetDevicePower 1 [268757.493606] (hci_tty): inside hci_tty_open (ecb2e788, eba91b00) [268757.501110] (stc): chnl_id list empty :4 [268757.505166] (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 [268757.668034] (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 [268757.682275] (stk) :TIInit_11.8.32.bts uim:begin polling... (stk) :change remote baud rate command in firmware [268757.695217] (stk) :skipping the wait event of change remote baud[268758.448619] (stc): add_channel_to_table: id 4 [268758.453139] (stc): add_channel_to_table: id 2 [268758.457603] (stc): add_channel_to_table: id 3 BT COMM PORT (/dev/hci_tty): 1 DEVM_PowerOnDevice() Success: 0. FTPM> Device Powered On. FTPM>
- c) Register Authentication before opening a server
FTPM>RegisterAuthentication DEVM_RegisterAuthentication() Success: 5. FTPM>
- d) Open Server
FTPM>OpenServer Usage: OpenServer [RFCOMM Server Port] [Open Flags: Bit Mask (1: Authorization, 2: Authentication, 4: Encryption)] [Root Directory Path (optional)]. Function Error. FTPM>
FTPM>OpenServer 1 0 Local Device Properties Changed. COD: 0x000010 FTPM>FTP Server Opened (Channel = 1, Root Directory = /home/root/BluetopiaPM/bin). FTPM>
This will set up a FTP service that a remote device can discover and connect to. For example, to use the Bluetooth File Transfer app available on the Google Play store, the user would discover the local device and then select it to connect to. It is likely this will require the devices to pair. When the remote device discovers the FTP service,
- e) The FTP server may require the user to respond to the open request depending on the connection settings. An example indication and response follows:
etFTPMIncomingConnectRequestIndication, FTPConnectionID: 0x0002. Call OpenServerPortRequestResponse.
Server>OpenServerPortRequestResponse 2 1 FTPM_Server_Connect_Request_Response(Accept) Success: 0. FTPM> etFTPMConnectIndication, FTPConnectionID: 0x0002 BD_ADDR: 980D2EEFCAC9 FTPM>
- f) To create a folder the user should select the create folder option on the FTP client. An example of a create folder indication should look like the following:
FTPM> etFTPMDirectoryCreateIndication, FTPConnectionID: 0x0001 Created Directory: New folder Current Directory: /home/root/BluetopiaPM/bin
- g) Navigating to a folder on the remote application should be as simple as tapping or clicking on the folder's icon. An example of a change folder indication should look like the following:
etFTPMChangeDirectoryIndication, FTPConnectionID: 0x0001 Directory: /home/root/BluetopiaPM/bin/New folder
- h) When the remote app requests to delete a folder the local device will give the following indication:
etFTPMDirectoryDeleteIndication, FTPConnectionID: 0x0002 Deleted Directory: New folder Current Directory: /home/root/BluetopiaPM/bin FTPM> etFTPMDirectoryRequestIndication, FTPConnectionID: 0x0002 Directory: /home/root/BluetopiaPM/bin
- i) To pull a file from the FTP server should be as simple as tapping or clicking on the file's icon and selecting save. An example of a pull file request should look like the following:
FTPM> etFTPMFileGetIndication, FTPConnectionID: 0x00000001 Transfer Complete: TRUE, Total Length: 0x0000028F, Transferred Length: 0x0000028F File: Notification.txt Current Directory: /home/root/BluetopiaPM/bin
- j) To push a file from the local file system to the FTP server the user should tap or click on the file's icon and select upload. An example of a push file request should look like the following:
FTPM> etFTPMFilePutIndication, FTPConnectionID: 0x0001 Transfer Complete: TRUE, Total Length: 0x0000028F, Transferred Length: 0x0000028F File: Notification.txt Current Directory: /home/root/BluetopiaPM/bin
- k) To delete a file from the FTP server should be as simple as tapping or clicking on the file's icon and selecting delete. An example of a delete file request should look like the following:
FTPM> etFTPMFileDeleteIndication, FTPConnectionID: 0x0001 Deleted File: Notification.txt Current Directory: /home/root/BluetopiaPM/bin
- l) To close and remove the FTP server enter the following command:
FTPM>CloseServer FTP Server Closed.