Using Bluetooth FTP Profile |
Bluetooth is widely used when it is necessary to provide a wireless access to the devices located in short distances. In this application note we will show how to organize a wireless FTP access to the NXP i.MX RT1060 EVK running Linux using a USB Bluetooth adapter. In practical embedded applications such a wireless channel may be used to retrieve data collected by the i.MX RT1060 via the standard FTP protocol. The most obvious use case scenario for this need is a technician visiting an embedded device residing at a remote site in order to retrieve data collected and stored locally by the i.MX RT1060 board locally (e.g. the i.MX RT1060 may store data on a EXT2 partition in the SD Card or on a connected USB Flash). Being able to access the i.MX RT1060 over Bluetooth from a notebook or a smartphone, with no need to connect to the i.MX RT1060 with any physical cables, comes in very hand, especially for devices with limited physical access.
The hardware platform used in this application note is the NXP i.MX RT1060 EVK board with a USB Bluetooth adapter plugged into the USB OTG 2 J10 connector. The adapter used by Emcraft to perform the tests documented below was based on the LM506 chip. The generic Linux kernel device driver for the USB transport HCI layer (CONFIG_BT_HCIBTUSB) is used in this configuration so other USB Bluetooth adapters should work as described below too.
Support for the Bluetooth FTP server is implemented by the obexftp package: The obexftpd daemon is used to implement the FTP server functionality over Bluetooth. The daemon, once started, waits for connections to the specified port from clients. The obexftp utility is used to implement the FTP client functionality over Bluetooth (this allows to connect to FTP servers running on other Bluetooth devices). The OBEX FTP protocol is used for store and retrieve files. Support for the OBEX protocol is implemented with the openobex package: The functionality described below is available from the rootfs.uImage project provided by Emcraft for the NXP i.MX RT1060 EVK board.
We will use the following terminology below:
Power-on the NXP i.MX RT1060 EVK board and wait for the Linux to boot on the Target. Run the Bluetooth daemons in the background: ... Plug-in the Bluetooth adapter to the USB HS interface of the NXP i.MX RT1060 EVK board. Observe the messages similar to the following in the Target console: usb 1-1: new full-speed USB device number 2 using ci_hdrc Get the <Target address> Bluetooth address of the adapter just plugged-in: / # cat /sys/class/bluetooth/hci0/address Create a test file in the root/ directory, which will be exported over FTP from the Target: / # cd /root/ Run the FTP server daemon specifying the Bluetooth port to listen upon, and the exported root directory. In the example below the channel number is 2, an FTP root directory is /root: / # obexftpd -c /root -b2 & List the names of files exported by the Target over Bluetooth by executing the following command on the Host: [yur@ubuntu rootfs]$ obexftp -b 5c:f3:70:70:fa:d5 -B 2 -l Download the test file from the Target over Bluetooth by executing the following commands on the Host: [yur@ubuntu rootfs]$ obexftp -b 5c:f3:70:70:fa:d5 -B 2 -g busybox Upload the test file to the Target over Bluetooth by executing the following commands on the Host: [yur@ubuntu rootfs]$ dd if=/dev/zero of=512kB.host bs=1024 count=512 Validate the uploaded file: /root # ls -lt /root
The Target may also implement the FTP Client functionality and connect to the FTP servers exported over Bluetooth by other devices. The obexftp utility is integrated into the rootfs project and may be used for this purpose. See the commands executed on the Host above in this application note: similar commands may be run on the Target side if we want it to perform the FTP Client role. |