Page MenuHomeFreeBSD

ng_hci, hccontrol, hcsecd: Add Bluetooth SSP support
Needs ReviewPublic

Authored by nsonack_outlook.com on Aug 5 2023, 4:49 PM.
Referenced Files
Unknown Object (File)
Sun, Apr 21, 1:27 AM
Unknown Object (File)
Fri, Apr 5, 8:32 AM
Unknown Object (File)
Mar 23 2024, 8:27 PM
Unknown Object (File)
Dec 23 2023, 2:08 AM
Unknown Object (File)
Dec 7 2023, 3:02 AM
Unknown Object (File)
Oct 21 2023, 11:21 AM
Unknown Object (File)
Sep 18 2023, 2:26 PM
Unknown Object (File)
Aug 9 2023, 11:32 AM

Details

Reviewers
emax
Summary

This is merely a initial hack/WIP to make my new bluetooth headphones work on FreeBSD. I am pretty sure that lots of my changes aren't ideal and need some work.

The patch is mostly derived from looking at the hcidump traces on a Linux box and then digging through the Bluetooth specs.

Regarding the change in ng_hci.h: I had difficulties reading the event mask macros and comparing them with the Spec.
Some of them e.g. NG_HCI_EVMSK_KEYPRESS_NOTIFICATION were also wrong.

How to:

  • Scan for new Bluetooth devices (bluetooth-config scan, PIN code is most likely 0000 or 1234 if not set otherwise)
  • Stop the hcsecd service
  • Edit /etc/bluetooth/hcsecd.conf and add autoaccept; to the entry for the new device
  • Start hcsecd again
  • Ensure that sdpd is running.
  • Now create the connection:
    • hccontrol create_connection <bthostname>
    • hccontrol request_authentication <conn-id>
    • hccontrol write_connection_encryption <conn-id> 1
  • Run (my patched version of) virtual_oss to open the audio connection:
    • See https://github.com/herrhotzenplotz/virtual_oss/tree/fix/reverse-sdp-discovery
    • Build with: make HAVE_BLUETOOTH=1
    • virtual_oss -S -C 2 -c 2 -r 48000 -b 16 -s 1024 -R /dev/null -P /dev/bluetooth/<bthostname> -T /dev/sndstat -d dsp -t vdsp.ctl
    • Note: I also have a branch that adds support for the aptX codecs. You'll have to set -b24 instead of -b16 to make it work with these codecs.
  • After you paired the devices, remove the autoaccept entry in hcsecd.conf again and restart the daemon.

PS: I now noticed that there is already a patch for SSP, however it seems to not implement the needed commands in hccontrol and hcsecd in order to allow pairing through SSP.

Test Plan

Have at least other people confirm that this works.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped