chimeraos icon indicating copy to clipboard operation
chimeraos copied to clipboard

Bluetooth auto reconnect service

Open RowlaxX opened this issue 1 year ago • 10 comments

Motivation

Hi, after installing ChimeraOS, I was unable to connect my Xbox Series controller until I navigated to the bluetooth settings. It was very similar to this issue

Investigation

After searching the cause of this problem, it seems that a Bluetooth scan was triggered while navigating to the Gnome Bluetooth Settings, and disabled when leaving that page.

Later, I was able to reconnect my controller by using the command bluetoothctl -t -1 scan on without navigating to the bluetooth settings

Solution

This PR add a simple systemd service that periodically scan for previously connected Bluetooth devices

I am now able to automatically reconnect my controller in the following cases :

  • On startup even before the session is loaded
  • When I unplug & replug my bluetooth dongle
  • When my controller is disconnected due to idle or battery and I press the guide button

Mention

It seems that Bluez allow for periodic scans in the config via ScanIntervalAutoConnect & ScanWindowAutoConnect parameters (link).

This could be a way cleaner solution, but I was unable to make them work.

Hardware & Software

  • Xbox Series Official Wireless Controller
  • my bluetooth dongle (https://www.amazon.fr/dp/B09TT7SXHY?ref=ppx_yo2ov_dt_b_fed_asin_title)
  • NVidia Geforce 1080TI
  • ChimeraOS 47 (b88d2bf) [UNSTABLE]

Note

This is my first PR for Chimera so I may not have respected some design & architectural choice

RowlaxX avatar Oct 09 '24 09:10 RowlaxX

Thanks for the work, but I am a bit confused as to why this is necessary.

If the controller is paired, it should be able to autoconnect without this service.

alkazar avatar Oct 16 '24 12:10 alkazar

It appears that Bluez don't support autoconnect for some bluetooth controller unless there is a bluetooth scan occuring. It was the case with the bluetooth dongle mentioned above.

However, I tried to run a fresh chimeraos with another bluetooth dongle (this one) and didn't got any issue

This service is a fix for controllers that need a scan for connecting devices

RowlaxX avatar Oct 17 '24 14:10 RowlaxX

I see, so it is hardware dependent. Thank you.

I am not sure if it is a good idea to be scanning constantly like that. I will have to do some research and think about it.

alkazar avatar Oct 17 '24 17:10 alkazar

@alkazar Have you had a chance to consider this further? I've had to implement it myself locally to resolve the same issue as there seems to be no other viable solution for me (having to use a keyboard to manually disable/re-enable bluetooth to reconnect the controller everytime quickly fails family UAT). I'm surprised this hasn't been an issue for more people to be honest. I'm using the built-in bluetooth on the ASRock B550M-ITX/ac motherboard.

I implemented the following;

[Unit]
Description=A service that periodicaly scan & connect for previously connected bluetooth devices
After=bluetooth.service

[Service]
ExecStart=/usr/bin/bluetoothctl -t 3 scan on
Restart=always
RestartSec=15

kharenis avatar Dec 31 '24 01:12 kharenis

I bought a pci bluetooth/wifi card and this problem has been resolved for me. It is hardware dependent as far as I can tell.

Maybe a nice compromise could be to add this service for the next release and keeping it disabled by default. We can also add an option to the web UI to enable/disable this service in case some user have this problem.

I can start working on that if needed @alkazar

RowlaxX avatar Dec 31 '24 19:12 RowlaxX

@RowlaxX can you share which card you bought? Im having bt troubles also (with a fenvi card)

jossmusix avatar Mar 23 '25 12:03 jossmusix

@RowlaxX Bonne soirée et passe un excellent dimanche soir!

jossmusix avatar Mar 23 '25 20:03 jossmusix

As a compromise, I was thinking what if we run this service only for the first few minutes after startup?

alkazar avatar Apr 07 '25 11:04 alkazar

That sounds like a good compromise to me. Sadly a PCIe card is out of the question for me as I don't have enough slots.

kharenis avatar Apr 29 '25 14:04 kharenis