Skip to content

Bluetooth Support for yocto build and verification

shreyan-collab edited this page May 3, 2022 · 9 revisions

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

  1. To add the bluetooth support add,DISTRO_FEATURES:append = bluetooth
  2. To add the bluez linux blueooth stack(bluez5) and initiate a file transfer(obextftp), IMAGE_INSTALL:append = bluez5 obexftp
  3. 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

  1. Check Bluetooth boot messages: dmesg | grep Bluetooth
  2. To Identify the Bluetooth device specification: hciconfig -a
  3. To get the bluetooth MAC address: hcitool dev
  4. To scan the nearby devices: hcitool -i hci0 scan, you can also scan for the devices from the below commands BluetoothSetup

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.

  1. To enter the Bluetooth interactive mode, enter bluetoothctl in the console
  2. scan on - To scan the nearby devices
  3. pair <MAC ADDRESS> - To pair with the device, in Fig 2 I have given pair 4C:4F:EE:EC:B5:82
  4. connect <MAC ADDRESS> - To connect with the device, in Fig 3, I have given connect 4C:4F:EE:EC:B5:82. I have verified it with smartphone
  5. remove <MAC ADDRESS> - To remove a paired a device from the Bluetooth
  6. trust <MAC ADDRESS> - To trust the paired device to connect easily in the future,
  7. info <MAC ADDRESS> - To get the info of the paired device, info 4C:4F:EE:EC:B5:82

bluetooth_pair_connect BluetoothRemove info trust

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