Nixos Blutooth cant enable after disable

On my a Lenovo Z13 Gen1 with Nixos / KDE Plasma 6.0.5 after the laptop goes into power saving mode the bluetooth adapter enters some kind of degraded state where it does not work properly, for example random disconnects or intermittent lag on bluetooth mouse or the device disappears all together.

After disabling and re-enabling the bluetooth adapter it usually fixes all those issues. Sometimes after clicking disable in the bluetooth task manager widget menu I loose the button to turn bluetooth back on. This does not always happen.

To fix this use rfkill to unblock it, you will then see the toggle button to enable it again in the task manager widget:

~ ❯ rfkill list all
0: tpacpi_bluetooth_sw: Bluetooth
    Soft blocked: yes
    Hard blocked: no
2: phy0: Wireless LAN
    Soft blocked: no
    Hard blocked: no
~ ❯ rfkill unblock 0

Some other commands to troubleshoot:

List BT devices, when blocked above hci0 will not show up:

~ ❯ hcitool dev
Devices:
    hci0    04:7B:CB:B3:48:A5
~ ❯ hciconfig -a
hci0:    Type: Primary  Bus: USB
    BD Address: 04:7B:CB:B3:48:A5  ACL MTU: 1024:7  SCO MTU: 240:8
    UP RUNNING PSCAN
    RX bytes:34838 acl:1757 sco:0 events:208 errors:0
    TX bytes:2676 acl:54 sco:0 commands:135 errors:0
    Features: 0xff 0xfe 0x8f 0xfe 0xd8 0x3f 0x7b 0x87
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
    Link policy: RSWITCH HOLD SNIFF
    Link mode: PERIPHERAL ACCEPT
    Name: 'z13'
    Class: 0x7c010c
    Service Classes: Rendering, Capturing, Object Transfer, Audio, Telephony
    Device Class: Computer, Laptop
    HCI Version: 5.3 (0xc)  Revision: 0x0
    LMP Version: 5.3 (0xc)  Subversion: 0x65e2
    Manufacturer: Qualcomm (29)

Also the bluetooth service:

~ ❯ systemctl status bluetooth
● bluetooth.service - Bluetooth service
     Loaded: loaded (/etc/systemd/system/bluetooth.service; enabled; preset: enabled)
    Drop-In: /nix/store/8gpdvw5qraa56fhhb6z7j6cmbc3f5iwf-system-units/bluetooth.service.d
             └─overrides.conf
     Active: active (running) since Thu 2024-06-13 10:41:23 +08; 11min ago
       Docs: man:bluetoothd(8)
   Main PID: 19637 (bluetoothd)
     Status: "Running"
         IP: 0B in, 0B out
         IO: 0B read, 40.0K written
      Tasks: 1 (limit: 37574)
     Memory: 1.6M (peak: 2.6M)
        CPU: 626ms
     CGroup: /system.slice/bluetooth.service
             └─19637 /nix/store/7anyh20kwbivvpnbypch8mggf54df165-bluez-5.75/libexec/bluetooth/bluetoothd -f /etc/bluetooth/main.conf

Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSink/sbc_xq_453
Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSource/sbc_xq_453
Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSink/sbc_xq_512
Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSource/sbc_xq_512
Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSink/sbc_xq_552
Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSource/sbc_xq_552
Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSink/faststream
Jun 13 10:47:27 z13 bluetoothd[19637]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSource/faststream
Jun 13 10:47:27 z13 bluetoothd[19637]: Path / reserved for Adv Monitor app :1.268
Jun 13 10:47:28 z13 bluetoothd[19637]: Failed to set mode: Failed (0x03)

Comments

comments powered by Disqus