blued: bluetooth daemon - looking for testers

From: Andreas Kempe <kempe_at_lysator.liu.se>
Date: Mon, 27 Jun 2022 18:51:07 UTC
Hello everyone,

After having issues with my bluetooth mouse, I figured out that the
problem was a lack of support for secure simple pairing and I reported
on this a while back to freebsd-bluetooth and freebsd-hackers. This
sent me down the rabbit hole of working on my own bluetooth daemon
with the goal of providing a user friendly way of pairing and using
bluetooth devices.

At long last, I think I have something worth sharing!


blued - what is it
==================

blued is made up of three parts: a library, a daemon and a command
line client. In its current state, it should allow you to pair a
bluetooth mouse and, most likely, keyboard, but I have no keyboard to
test with.

With the current version of blued, bthidd is still needed for the
mouse to work and a script is provided to automatically pair a mouse
and configure bthidd appropriately. In the future, my aim is to either
make blued work with bthidd directly or integrate its code into blued.
This for a more seamless experience.

If the supplied script works as expected, your mouse will get
connected, paired and simply start working. If the mouse is turned off
and on again, the daemon should let it reconnect without user
intervention.


What is needed to use blued v0.1?
=================================

First you need to make sure you have working bluetooth drivers loaded,
reading the bluetooth chapter of the FreeBSD handbook is recommended
for this [0].

To test blued, you will need to compile the release found at the link
below [1], and you will also have to patch your FreeBSD kernel with
the patches in the kernel_patches directory of the release. The kernel
patches are pretty small and you will only need to recompile the hci
module. Instruction on how to build blued and apply the patches are
provided in the README file.

blued has primarily been tested on FreeBSD 12.3, but my patches
applied cleanly on 13.1 when I tested.

I am not supplying a port at the moment, but "make install" works and
will install all needed files. The daemon binary is called blued,
while the command line utility is called bluecontrol. Man pages for
blued and bluecontrol should also have been installed.

An example configuration file for blued is installed in
/usr/local/share/examples/blued/blued.conf.example and can be
copied to /usr/local/etc/blued.conf which is the default path blued
checks for its configuration.

blued outputs diagnostic data to syslog and on a default FreeBSD
system, it can be found in /var/log/{debug.log,messages}.

To start blued in the background after installing it, execute "blued
&" as root. blued and bluecontrol both use capsicum and blued can be
configured to drop its root privileges.


Feedback!
=========

I have only tried this software with my own mouse and realise that a
sample size of one single bluetooth device is pretty small. I'm
expecting issues and am greatly looking forward to feedback from
others!

In case of trouble, output from /var/log/debug.log and
/var/log/messages as well as a traffic dump from "hcidump -x" while
trying to pair will help with troubleshooting.

If you want to get involved with the code and submit patches, you're
welcome to do so and can find the code on Lysator's Git [2]!

Thank you for you attention!
Cordially,
Andreas Kempe

[0]: https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-bluetooth
[1]: https://git.lysator.liu.se/kempe/blued/-/releases/v0.1
[2]: https://git.lysator.liu.se/kempe/blued