=== New Bluetooth(R) configuration daemon: blued

Links: +
link:https://git.lysator.liu.se/kempe/blued[blued git] URL: https://git.lysator.liu.se/kempe/blued[https://git.lysator.liu.se/kempe/blued]

Contact: +
Mail: kempe@lysator.liu.se +
IRC: kempe@libera.chat

==== Introduction

The blued utility provides an IPC interface that lets an unprivileged user connect to and use Bluetooth devices in a user-friendly way and supports secure simple pairing (public-key cryptography and if the device allows it man-in-the-middle protection).

==== What is blued?

There are three parts to blued: a library, a daemon and a command line utility.
The library abstracts away bluetooth details, the daemon manages Bluetooth devices and the command line utility lets users list or scan for Bluetooth devices, pair with a device, or unpair from one.
The command line utility communicates with the daemon via a UNIX socket.

Unlike bthidd and hcsecd, blued supports secure simple pairing and
provides an IPC.
To get a HID device to work, bthidd is still needed.
A script is provided to pair a Bluetooth device and appropriately configure bthidd so it just works and reconnects without user intervention.

Once pairing has proven stable and bugs have been ironed out, the plan is to integrate bthidd with/into blued in some way to have HID devices automatically start functioning when paired without the use of an external script.
A long-term goal is to provide a graphical user interface that can list devices and provide a simple one-click setup to connect them.

==== Installing and using blued v0.1

You need the optional `src` component installed in [.filename]#/etc/src#.

First, make sure link:https://docs.freebsd.org/en/books/handbook/advanced-networking/#network-bluetooth[you have working Bluetooth drivers loaded as explained in the FreeBSD handbook].

To test blued, fetch link:https://git.lysator.liu.se/kempe/blued/-/releases/v0.1[the blued v0.1 source code].
Then compile it, patch your FreeBSD kernel with the patches in [.filename]#kernel_patches#, and recompile the `hci` module as explained in [.filename]#README#.

I have primarily tested blued 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 it is possible to run the software straight from the build directory or run "make install" that will install all needed files.
Both blued and bluecontrol use capsicum and blued can be configured to drop its root privileges.

For more information, refer to the `Running blued` section of [.filename]#README#.

==== Helping out

===== Testing

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.

===== Contributing

If you want to get involved with the code and submit patches, you're welcome to link:https://git.lysator.liu.se/kempe/blued[visit the repository] on Lysator's Git.
