Bluetooth Support for yocto build and verification - cu-ecen-aeld/yocto-assignments-base GitHub Wiki
Outline:
In this module, we will see the changes needed in the yocto configuration file to setup Bluetooth, pair and connect a smartphone with raspberry pi 3b+. To enable the inbuilt Bluetooth in Rpi 3b+ through Buildroot and implement a GATT server application, refer here
Github Link
The changes can be made in build.sh which can be found here
Implementation
The following lines are added in the local.conf file
- To add the bluetooth support add,
DISTRO_FEATURES:append = bluetooth
- To add the bluez linux blueooth stack(bluez5) and initiate a file transfer(obextftp),
IMAGE_INSTALL:append = bluez5 obexftp
- Now we can run ./build.sh to add the Bluetooth support
Verification
Bluetooth driver setup verification
After booting, the following commands can verify whether the bluetooth is installed properly
- Check Bluetooth boot messages:
dmesg | grep Bluetooth
- To Identify the Bluetooth device specification:
hciconfig -a
- To get the bluetooth MAC address:
hcitool dev
- To scan the nearby devices:
hcitool -i hci0 scan
, you can also scan for the devices from the below commands
Scanning, pairing, connecting, removing a device, info about the pair device
Alternatively, we can scan, pair, connect and remove the Bluetooth devices by the following commands Bluetoothctl is an interactive and easy-to-use tool for controlling Bluetooth devices.
- To enter the Bluetooth interactive mode, enter
bluetoothctl
in the console scan on
- To scan the nearby devicespair <MAC ADDRESS>
- To pair with the device, in Fig 2 I have givenpair 4C:4F:EE:EC:B5:82
connect <MAC ADDRESS>
- To connect with the device, in Fig 3, I have given connect4C:4F:EE:EC:B5:82
. I have verified it with smartphoneremove <MAC ADDRESS>
- To remove a paired a device from the Bluetoothtrust <MAC ADDRESS>
- To trust the paired device to connect easily in the future,info <MAC ADDRESS>
- To get the info of the paired device,info 4C:4F:EE:EC:B5:82
Future Work
After connecting the device, we can use obexftp to send files over the Bluetooth or we can also transmit sensor data over Bluetooth to smartphone or any other device