How to get Chrome Web Bluetooth working on Linux

In my previous post I demonstrated how to test and scan for Bluetooth Low Energy:
https://acassis.wordpress.com/2016/06/27/getting-started-with-bluetooth-low-energy-on-linux/

Now I will explain what I did to get Bluetooth Low Energy working on Linux Debian.

First I installed the Chrome Dev version 53 from here:
https://www.google.com/chrome/browser/desktop/index.html?platform=linux&extra=devchannel

But the Bluetooth Scan Page example was not working:
https://googlechrome.github.io/samples/web-bluetooth/device-info.html

Then searching in the forums I discovered these four requirements to get it working:
1) A recente Chrome version 45+ (I’m using version 53);
2) A recente Linux kernel 3.19+ (my kernel was too old: 3.16);
3) BlueZ 5.40+ (my bluez version was 5.36);
4) Bluetooth daemon (bluetoothd) running with experimental interface (/usr/bin/bluetoothd -E).

Then I updated my Linux kernel:

$ sudo apt-get install linux-image-4.6.0-1-amd64

Compiled Bluez 5.40:

// Install the dependecies:
$ sudo apt-get -y install automake autotools-dev bison check clang flex lcov libcap-ng-dev libdbus-glib-1-dev libdw-dev libglib2.0-dev libical-dev libreadline-dev libtool libudev-dev

//Download bluez-5.40:
$ wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.40.tar.xz

//Extract it:
$ tar xvf bluez-5.40.tar.xz

// Configure and compile it:
$ cd bluez-5.40
$ ./configure --prefix=/usr           \
            --mandir=/usr/share/man \
            --sysconfdir=/etc       \
            --localstatedir=/var    \
            --enable-library        \
            --disable-systemd       \
            --disable-android       \
            --enable-experimental
$ make

// Create a debian package with checkinstall:
$ sudo checkinstall

Here checkinstall didn’t create the /usb/bin/bluetoothd link, let us to create it:

# ln -s /usr/libexec/bluetooth/bluetoothd /usr/bin/bluetoothd

We need to stop bluetoothd daemon and call it with -E:

# /etc/init.d/bluetooth stop
# /usr/libexec/bluetooth/bluetoothd -E &

Now let see if Chromium could communicate with the BLE device:

$ ./chrome --enable-web-bluetooth

Then open the sample page to test Discover Services and Characteristics:
https://googlechrome.github.io/samples/web-bluetooth/discover-services-and-characteristics.html

I will test the Nordic Serial Service, then I enter:

6e400001-b5a3-f393-e0a9-e50e24dcca9e

After updating bluez to version 5.40 the Bluetooth Chooser pop-up window stopped to list the nearby Bluetooth LE devices.

This issue was caused because I used “ControllerMode = le” in the /etc/bluetooth/main.conf. This BUG didn’t exist in the bluez 5.36.

Changing “ControllerMode = dual” in the /etc/bluetooth/main.conf fixed the issue (thanks François Beaufort for the help).

And after restarting bluetoothd and clicking on “Discover services and characteristics” and choosing the Nordic_UART device, it returns:

Requesting any Bluetooth Device...
> Name:             Nordic_UART
> Allowed Services: 6e400001-b5a3-f393-e0a9-e50e24dcca9e
Connecting to GATT Server...
Getting Services...
Getting Characteristics...
> Service: 6e400001-b5a3-f393-e0a9-e50e24dcca9e
>> Characteristic: 6e400003-b5a3-f393-e0a9-e50e24dcca9e [NOTIFY]
>> Characteristic: 6e400002-b5a3-f393-e0a9-e50e24dcca9e [WRITEWITHOUTRESPONSE, WRITE]

References:
https://github.com/beaufortfrancois/sandbox/blob/gh-pages/web-bluetooth/Bluez.md
http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html

5 thoughts on “How to get Chrome Web Bluetooth working on Linux

  1. Thanks for you sharing. There is an important detail, you need to enable Experimental Web plataform features on chrome. Going to chrome://flags/

    Cheers

Leave a comment