Skip to content

Instantly share code, notes, and snippets.

@larsblumberg
Last active May 28, 2021 16:36
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsblumberg/2335c0ba97f805a2b996f1a7c3ac9571 to your computer and use it in GitHub Desktop.
Save larsblumberg/2335c0ba97f805a2b996f1a7c3ac9571 to your computer and use it in GitHub Desktop.
Flash Raspian Lite and set up latest BlueZ for Raspberry Pi 3
Flashing the memory card and creating /ssh file
===============================================
diskutil unmountDisk /dev/disk4
sudo dd bs=1m if=2017-01-11-raspbian-jessie-lite.img of=/dev/rdisk4
touch /Volumes/boot/ssh
diskutil unmountDisk /dev/disk4
SSH to Raspberry Pi
===================
ssh pi@raspberrypi.local
Stop Legacy BlueZ and Install Dependencies
==========================================
sudo systemctl stop bluetooth
sudo apt-get update
sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libdbus-glib-1-dev unzip
Download, Compile and Install Latest BlueZ
==========================================
cd
mkdir bluez
cd bluez
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.44.tar.xz
tar xf bluez-5.44.tar.xz
cd bluez-5.44
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-library
make
sudo make install
sudo ln -svf /usr/libexec/bluetooth/bluetoothd /usr/sbin/
sudo install -v -dm755 /etc/bluetooth
sudo install -v -m644 src/main.conf /etc/bluetooth/main.conf
sudo systemctl daemon-reload
sudo systemctl start bluetooth
bluetoothd --version # should now print 5.44
Enable bluetoothd on System Start
=================================
sudo systemctl daemon-reload
sudo systemctl enable /lib/systemd/system/bluetooth.service
sudo systemctl start bluetooth
systemctl status bluetooth
Run Ptyhon test scripts that make use of bluetoothd D-Bus
=========================================================
# Install dbus-python
sudo apt-get install -y python-dev libdbus-1-dev libdbus-glib-1-dev python-gi python-pip
sudo python2.7 -m pip install dbus-python
# Run tests (it's inside bluez-5.44 folder)
cd test
sudo python test-discovery
Known issues
============
bluetoothctl sometimes shows "Waiting to connect to bluetoothd..." forever. Rebooting and restarting the bluetooth service seems to sometimes help.
Switch controller to BLE mode only
==================================
vim /etc/bluetooth/main.conf
and add this line:
ControllerMode = le
@larsblumberg
Copy link
Author

I updated the Gist with changed installation instructions – can you check if it's now working for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment