Introduction
Following up on my post about how I pair my bluetooth headphones on FreeBSD, I decided to test drive the new blued project by Andreas Kempe on my Lenovo T480 laptop running FreeBSD 13.1.
I first saw mention of blued configuration daemon on the FreeBSD Quarterly Report and decided to take a look.
The blued build is straightforward. The ng_hci
kernel driver needs to be patched, recompiled, and reloaded to handle several HCI commands that aren’t supported by the current driver. This is probably the hardest part of installing the blued software if you’re unfamiliar with compiling custom FreeBSD drivers / kernels.
I highly recommend using Andreas’ build documentation to build blued since the software still quite new and the build process will likely change during development. Andreas explains how to properly build blued here.
The FreeBSD handbook also has useful information to help you understand how custom kernels are built here.
Config
After building and installing, you can either run the blued daemon as a service or by hand. If you run it as a service, you’ll have to remember to re-patch the ng_hci
driver each time you update your kernel.
First copy the example config into /usr/local/etc/
. The blued daemon will fail to start if the config file is missing. The defaults worked fine for me.
|
|
I chose to start the blued daemon with the service script.
|
|
You can also run the daemon by hand. General messages are sent to /var/log/messages
and debug output is sent to /var/log/debug.log
.
Connecting and Using Bluetooth Devices
Once the blued daemon is running, it was easy to pair my headphones.
Put your device in pairing mode and scan for it:
|
|
|
|
You can ask the name of the returned BDADDR to check if it’s your device:
|
|
|
|
Now ask blued if it knows your device:
|
|
|
|
Finally attempt to pair the device:
|
|
|
|
Success!
Virtual OSS
If you’re pairing an audio device like headphones, Virtual OSS is still required to create a dsp device which applications on the system use to output audio.
You can run it by hand but in my experience it also works well as a service.
By hand:
|
|
As a service, you’ll need to create a custom virtual_oss config and specify virtual_oss to use it in rc.conf. The following works well on my system:
|
|
Once I started virtual_oss
, my headphones told me they’re paired with the laptop and audio seems to function well.
I’d recommend using the blued
service in conjunction with the virtual_oss
service if you’re pairing headphones. The services appear to work well enough for me that I don’t have to think much about bluetooth anymore. I just start up my laptop, turn on my headphones, wait for them to connect, and start working. No more embarrassing script! :)
blued is definitely a step in the right direction for managing bluetooth devices on FreeBSD!
Notes
rc.conf configuration
|
|
unix socket for rpc
Make sure your user has access /var/run/blued/rpc or you won’t be able to communicate with the blued daemon.
|
|
Installed Files
|
|