Bug 255542 - Bluetooth Could not connect to HC: 5
Summary: Bluetooth Could not connect to HC: 5
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-wireless (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-02 09:20 UTC by didier.castellacci
Modified: 2023-02-18 10:04 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description didier.castellacci 2021-05-02 09:20:35 UTC
Hello,


The configuration of my bluetooth speaker is recognized.

I don't understand the error message "Could not connect to HC: 5":

hw.snd.basename_clone: 1 -> 0
backend_bt: Could not open SDP
backend_bt: PSM=0xffffffff
backend_bt: PSM not found
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5

​
I am very annoyed if you can help me.

​

​Thank you

Didier
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2021-07-02 07:30:52 UTC
^Triage: reclassify somewhat better.
Comment 2 Nico Sonack 2021-07-30 08:06:59 UTC
Chiming in here, since the reporter doesn't answer the request for more information :

I have two machines :

root@hades:~ #  freebsd-version ; uname -a
13.0-RELEASE-p3
FreeBSD hades.herrhotzenplotz.geek 13.0-RELEASE-p3 FreeBSD 13.0-RELEASE-p3 #0: Tue Jun 29 19:46:20 UTC 2021     root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64


root@triton:~ # freebsd-version ; uname -a
13.0-RELEASE-p3
FreeBSD triton.herrhotzenplotz.geek 13.0-RELEASE-p3 FreeBSD 13.0-RELEASE-p3 #3 releng/13.0-n244752-b368bb75bad: Sun Jul 25 18:53:33 CEST 2021     nico@triton.herrhotzenplotz.geek:/usr/obj/usr/src/amd64.amd64/sys/TRITON13  amd64
root@triton:~ #


Attached to it is a USB Bluetooth dongle :

root@triton:~ # usbconfig -d ugen0.4 dump_device_desc
ugen0.4: <SiW SiW> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (50mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0110
  bDeviceClass = 0x00e0  <Wireless controller>
  bDeviceSubClass = 0x0001
  bDeviceProtocol = 0x0001
  bMaxPacketSize0 = 0x0040
  idVendor = 0x1310
  idProduct = 0x0001
  bcdDevice = 0x1500
  iManufacturer = 0x0001  <SiW>
  iProduct = 0x0002  <SiW>
  iSerialNumber = 0x0003  <C5B1320D0B00>
  bNumConfigurations = 0x0001

I have the following script to setup an audio connection to bluetooth headphones :

root@hades:~ # cat /usr/home/nico/.local/bin/bt
#!/bin/sh

service bluetooth restart ubt0
hccontrol -n ubt0hci create_connection headphones
trap "sysctl hw.snd.basename_clone=1" INT
virtual_oss -S -C 2 -c 2 -r 48000 -b 16 -s 1024 -R /dev/null -P /dev/bluetooth/headphones -T /dev/sndstat -d dsp
root@hades:~ #


On one machine it does the following :

root@hades:~ # /usr/home/nico/.local/bin/bt
BD_ADDR: headphones
Connection handle: 1
Encryption mode: Disabled [0]
hw.snd.basename_clone: 1 -> 0
backend_bt: PSM=0x19
backend_bt: No frequency and mode match
backend_bt: No frequency and mode match

...And I can listen to whatever I want.

On the other machine however :

root@triton:~ # /usr/home/nico/.local/bin/bt
BD_ADDR: headphones
Connection handle: 1
Encryption mode: Disabled [0]
hw.snd.basename_clone: 1 -> 0
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
backend_bt: PSM=0x19
backend_bt: Could not connect to HC: 5
^Chw.snd.basename_clone: 0 -> 1
root@triton:~ #


... And it doesn't work.

I suspect, that the issue is related to virtual_oss.

Let me know, if you need any more information or want me to test
something here.

Please bear in mind that the 'hades' machine runs pretty much only
binary ports and patches from freebsd-update but the 'triton' machine
runs a custom kernel. I don't think that this is a huge difference
though.
Comment 3 Nico Sonack 2023-02-18 10:04:02 UTC
After debugging this for a while, I found out that /var/db/hcsecd.keys is the issue.

A workaround for me is the following:

# service hcsecd stop
# rm /var/db/hcsecd.keys
# service hcsecd start

And then the usual steps of hccontrol create_connection and virtual_oss.

One drawback of this approach is that you have to repair the devices every time you want to connect them. For some reason I have yet to find out, I can keep the headphones paired to two FreeBSD machines - however when I connect it to a third the connection fails with the previously described error.

All of the machines are now running FreeBSD 13.1-RELEASE amd64, though I doubt that matters.