Bug 395990

Summary: Bluetooth controller unavailable most of the time
Product: [Frameworks and Libraries] frameworks-bluez-qt Reporter: tobias.kuendig
Component: generalAssignee: David Rosca <nowrep>
Status: RESOLVED FIXED    
Severity: normal CC: i
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description tobias.kuendig 2018-06-29 07:37:23 UTC
I run KDE Neon 5.13.2 and have problems with my bluetooth adapter.

The adapter is detected only sometimes. I cannot make out any pattern. It sometimes works after a cold boot, sometimes doesn't. It is unavailable most of the time after waking from suspend. 

`bluetoothctl list` shows nothing. If the adapter *is* detected, it shows obviously shows up. In the KDE bluetooth adapter settings window the message "no adapter has been found" is displayed.


```
rfkill list                            
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
```

```
systemctl status bluetooth -l                           
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
   Active: active (running) since Fre 2018-06-29 08:48:37 CEST; 28min ago
     Docs: man:bluetoothd(8)
 Main PID: 16554 (bluetoothd)
   Status: "Running"
    Tasks: 1
   Memory: 704.0K
      CPU: 7ms
   CGroup: /system.slice/bluetooth.service
           └─16554 /usr/lib/bluetooth/bluetoothd

Jun 29 08:48:37 dell systemd[1]: Stopped Bluetooth service.
Jun 29 08:48:37 dell systemd[1]: Starting Bluetooth service...
Jun 29 08:48:37 dell bluetoothd[16554]: Bluetooth daemon 5.37
Jun 29 08:48:37 dell bluetoothd[16554]: Unknown key AutoEnable in main.conf
Jun 29 08:48:37 dell systemd[1]: Started Bluetooth service.
Jun 29 08:48:37 dell bluetoothd[16554]: Starting SDP server
Jun 29 08:48:37 dell bluetoothd[16554]: Bluetooth management interface 1.14 initialized
```


```
lsmod | grep bluetooth              
bluetooth             548864  16 btrtl,hci_uart,btintel,btqca,bnep,btbcm,rfcomm,btusb
ecdh_generic           24576  1 bluetooth
```
Comment 1 Guo Yunhe 2018-11-08 09:05:01 UTC
I have exactly the same issue and systemd output with:

openSUSE Tumbleweed
KDE 5.14.2
KDE Frameworks 5.51.0
Qt 5.11.2
Comment 2 tobias.kuendig 2018-11-08 09:23:29 UTC
I was able to figure out a possible cause for this bug:

The bluetooth adapter was missing after waking the laptop up from standby while the power cord was connected. 

If I put the laptop to sleep, remove the power cord and wake the laptop up again the bluetooth adapter is available. The power cord can now be attached again.
Comment 3 David Rosca 2018-11-08 09:24:02 UTC
If it doesn't show in bluetoothctl list, then this is not issue in bluez-qt.

So is the issue that bluetoothctl list shows adapter, but KDE Bluetooth settings doesn't see it, or there is nothing in both bluetoothctl list and KDE Bluetooth settings?
Comment 4 Guo Yunhe 2018-11-08 09:40:41 UTC
(In reply to David Rosca from comment #3)
> If it doesn't show in bluetoothctl list, then this is not issue in bluez-qt.
> 
> So is the issue that bluetoothctl list shows adapter, but KDE Bluetooth
> settings doesn't see it, or there is nothing in both bluetoothctl list and
> KDE Bluetooth settings?

In my computer, bluetoothctl list show nothing and KDE bluetooth applet show nothing. It is an iMac, something between laptop and desktop.
Comment 5 Guo Yunhe 2018-11-08 09:46:27 UTC
(In reply to tobias.kuendig from comment #2)
> If I put the laptop to sleep, remove the power cord and wake the laptop up
> again the bluetooth adapter is available. The power cord can now be attached
> again.

I just tried your solution. I make the PC sleep and then resume it. Then bluetoothctl list shows my device! And then I restart plasmashell and bluetooth is activited in system tray.

So I agree this is an issue in the bluetooth driver/controller, not Qt or KDE. And it is likely related to power management.
Comment 6 Guo Yunhe 2018-11-08 14:26:12 UTC
Sadly, I didn't found any bug tracking system of BlueZ. Should we send the bug report to their mail list?
Comment 7 Guo Yunhe 2018-12-20 07:51:12 UTC
I don't have this issue anymore after a couple of system updates. Bluetooth works fine for two weeks. Maybe some kernel or driver updates have fixed this.

openSUSE Tumbleweed 20181214
KDE Plasma 5.14.4
KDE Frameworks 5.52.0
Qt 5.12.0
Kernel 4.19.7
Comment 8 Christoph Feck 2019-01-17 03:28:06 UTC
Tobias, can you confirm it is fixed with newer system software?
Comment 9 David Rosca 2019-03-18 11:17:00 UTC
Closing as fixed then.