BLE Examples build silex buster plus

From Technologic Systems Manuals

At the time of writing this, version 5.61 is the latest BlueZ release. The following examples will download, build, and install BlueZ directly on the target device. Compilation directly on the device will be far slower but does not have the prerequisite of a properly set up cross build system. Cross compilation of BlueZ is possible, but is beyond the scope of this document.

First, since most of our products ship with BlueZ pre-installed from the distribution package manager, this will need to be removed:

apt-mark unhold "blue*" "libblue*"
apt-get purge -y "blue*" "libblue*"

Ensure all build requirements are met (note that some examples use Python 2 while others use Python 3):

apt-get update && apt-get install -y git libglib2.0-dev libglib2.0-0 libdbus-1-dev libdbus-1-3 libudev-dev libudev1 libical-dev libreadline-dev python3-dbus python3-pip python-dbus docutils-common autotools-dev automake libtool

Next, download the sources for BlueZ 5.61:

tar xvf bluez-5.61.tar.xz

Note that the Silex chipset used requires specific patches that have not yet been merged in to upstream BlueZ. Patch, configure, build, and install BlueZ:

cd bluez-5.61

tar xvf silex-bluez5_49-patchset.tar.xz
for I in *.patch ; do patch -p1 < $I; done  # Some of these will have offset notices, but there should be no failures!

autoreconf -fi  # Needed because the patches do affect Makefiles
./configure --enable-library --enable-test --enable-deprecated && make install
systemctl enable bluetooth
systemctl start bluetooth

From here, the example tools will be installed to /usr/local/lib/bluez/test/. We will be using this later.