Bluetooth sound on FreeBSD

01 Feb 2025

Using Bluetooth headphones with Beastie

I enjoy the quality and responsiveness of classic cable connections. And another battery to maintain is a drag. But in some cases (like the top of the mountain or an empty train), security and quality are not important. Or I just want wireless workflow. So being able to use the same devices is somewhat critical. For this test, I will use Skull Candy SCTAW packing Bluetooth version 5.2. The system is FreeBSD 14.2.

#Dependencies

Ensure that cuse is loaded (cuse_load="YES" in /boot/loader.conf).

This is T480, which requires an Intel wireless 8260/8265 driver:

doas pkg install iwmbt-firmware
doas service devd restart

Prepare virtual_oss:

doas pkg install virtual_oss

#Services

Start required Bluetooth services:

doas service hcsecd onestart
doas service bluetooth start ubt0

#Pairing

Let's power up the gear and find it via hccontrol -n ubt0hci inquiry:

Inquiry result, num_responses=1
Inquiry result #0
	BD_ADDR: 8c:0d:d9:0e:f5:92
	Page Scan Rep. Mode: 0x2
	Page Scan Period Mode: 00
	Page Scan Mode: 00
	Class: 24:04:04
	Clock offset: 0x2ca4
Inquiry complete. Status: No error [00]

Right now I have only one device around me with the address 8c:0d:d9:0e:f5:92. Confirm the headphones via hccontrol -n ubt0hci remote_name_request $BD_ADDR:

BD_ADDR: 8c:0d:d9:0e:f5:92
Name: Smokin' Buds

Bingo! Now set the device address alias in /etc/bluetooth/hosts:

# $Id: hosts,v 1.1 2003/05/21 17:48:40 max Exp $
#
# Bluetooth Host Database
#
# This file should contain the Bluetooth addresses and aliases for hosts.
#
# BD_ADDR               Name [ alias0 alias1 ... ]

# 00:11:22:33:44:55	phone

8c:0d:d9:0e:f5:92	ssb

Authenticate the device in /etc/bluetooth/hcsecd.conf.:

device {
        bdaddr  8c:0d:d9:0e:f5:92;
        name    "sSB";
        key     nokey;
        pin     nopin;
}

Restart hcsecd:

doas service hcsecd restart

Connect to headphones:

doas hccontrol -n ubt0hci create_connection ssb

Create a virtual audio sink:

doas virtual_oss -T /dev/sndstat -S -a o,-3 -C 2 -c 2 -r 48000 -b 16 -s 1024 -R /dev/null -P /dev/bluetooth/ssb -d dsp -t vdsp.ctl &

This will create a virtual sink with a 48000 Hz sample rate (16 bit) at the ssb address.



Installing Sevice Worker
Service Worker deployed