Using a bluetooth mouse with FreeBSD

18 Feb 2020 - tsp
Last update 18 Feb 2020

This article is a short summary on the process to use a bluetooth mouse on FreeBSD. Please remember that any wireless connection poses an inherent security risk - so only use if really necessary, you’re already using bluetooth or are using bluetooth at an safe location.

To that target one has to:

First one has to load the kernel module. To do this immediately (as long as the securelevel allows it):

kldload ng_ubt

To load the module during boot edit /boot/loader.conf and add


It’s a good idea to test if one can load the module without any interference on a running system to prevent boot time errors after the next restart.

Now one can determine the name of the local bluetooth device that’s going to be used to connect to the device:

hccontrol read_node_list

# Or for an shellscript:
BTNODE=`hccontrol read_node_list | tail -n 1 | awk '{ print $1; }'`

Then scanning for the device that one wants to connect to is possible:

hccontrol -n ${BTNODE} inquiry

This command should discover the device as long as it’s in discoverable mode. Then one should take note of the device address (in this example it will be called BTADDR from know on). To allow automatic connection one should now query all device information:

bthidcontrol -a ${BDADDR} query

This device descriptor should also be added to the bthidd.conf file:

bthidcontrol -a BDADDR query >> /etc/bluetooth/bthidd.conf

The last thing to be done is to enter credentials for the connection into /etc/bluetooth/hcsecd.conf:

device {
        bdaddr  ${BDADDR};
        name    "Bluetooth mouse";
        key     nokey;
        pin     "0000";

After a restart of hcsecd and bthidd and a reboot of the bluetooth mouse everything should work flawlessly from know on:

/etc/rc.d/hcsecd restart
/etc/rc.d/bthidd restart

One can detect the working of the bluetooth HID connection by inspecting the /var/log/messages file for messages like

bthidd[2784]: Accepted control connection from 8c:1a:3c:15:3b:35
bthidd[2784]: Accepted interrupt connection from 8c:1a:3c:15:3b:35

Whenever the mouse goes into standy state it will disconnect with an

bthidd[2784]: Remote device 8c:1a:3c:15:3b:35 has closed control connection

message. In case the mouse awakes it will reconnect as usual.

This article is tagged:

Data protection policy

Dipl.-Ing. Thomas Spielauer, Wien (

This webpage is also available via TOR at http://jugujbrirx3irwyx.onion/

Valid HTML 4.01 Strict Powered by FreeBSD IPv6 support