I am having the most bizarre bluetooth problem in Ubuntu 24.04. I have several bluetooth devices (logitech k585 BT keyboard, Airpods pro 2, generic BT mouse) paired/connected to the computer. After waking from sleep/suspend or after a reboot, the mouse and airpods reconnect to BT just fine however the keyboard will not reconnect unless I turn bluetooth off then on again in the system menu.
I have tried playing around with various settings in /etc/bluetooth/main.conf and it appears that setting:
ControllerMode = le
Will enable the keyboard to properly reconnect after sleep/suspend and on boot, but then the airpods will no longer connect or pair with the computer. If I set ControllerMode = bredr, the airpods work fine but the keyboard will no longer connect at all (let alone after wake or reboot). The only setting that seems to work for all devices is ControllerMode = dual, and in this case I have the undesired behavior that the keyboard will not reconnect on wake or reboot unless the bluetooth adapter is turned off and on again.
I have also tried setting MultiProfile = multiple and FastConnectable = true to no avail.
For reference the driver I'm using is bluez/noble,now 5.72-0ubuntu5 amd64 and the kernel is:
bender:~> uname -a
Linux bender 6.8.0-49-generic #49-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 4 02:06:24 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Any help is appreciated as it's not really feasible to turn BT off/on after wake as my mouse is BT as well, meaning I have to ssh in from another computer to re-enable.
The Only thing I've noticed in dmesg is some cryptic opcode failures:
bender:~> sudo dmesg | grep -i blue
[ 3.617461] Bluetooth: Core ver 2.22
[ 3.617494] NET: Registered PF_BLUETOOTH protocol family
[ 3.617495] Bluetooth: HCI device and connection manager initialized
[ 3.617500] Bluetooth: HCI socket layer initialized
[ 3.617502] Bluetooth: L2CAP socket layer initialized
[ 3.617507] Bluetooth: SCO socket layer initialized
[ 3.678221] Bluetooth: hci0: Legacy ROM 2.x revision 5.0 build 25 week 20 2015
[ 3.679172] Bluetooth: hci0: Intel Bluetooth firmware file: intel/ibt-hw-37.8.10-fw-22.50.19.14.f.bseq
[ 4.068237] Bluetooth: hci0: Intel BT fw patch 0x43 completed & activated
[ 4.755238] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 4.755243] Bluetooth: BNEP filters: protocol multicast
[ 4.755248] Bluetooth: BNEP socket layer initialized
[ 4.761546] Bluetooth: MGMT ver 1.22
[ 4.856327] Bluetooth: hci0: Bad flag given (0x1) vs supported (0x0)
[ 4.856373] Bluetooth: hci0: Bad flag given (0x1) vs supported (0x0)
[ 7.018615] Bluetooth: RFCOMM TTY layer initialized
[ 7.018632] Bluetooth: RFCOMM socket layer initialized
[ 7.018641] Bluetooth: RFCOMM ver 1.11
[ 59.704537] Bluetooth: hci0: Opcode 0x2005 failed: -22
[ 59.705031] Bluetooth: hci0: Opcode 0x200b failed: -22
[ 63.288518] hid-generic 0005:046D:B35A.0003: input,hidraw2: BLUETOOTH HID v0.11 Keyboard [Logi K580/K585] on dc:46:28:46:68:b9
Happy to provide any other info/output that would be helpful.
UPDATE:
It appears the problem is worse than I thought. The keyboard is not able to reconnect any time after the screen locks once it disconnects. I had mistakenly thought the issue was related to sleep/suspend but it's actually merely screen lock.
Per the link provided by Hannu, running:
rfkill block bluetooth
rfkill unblock bluetooth
seems to be the only way to get the keyboard to connect again.