https://wiki.archlinux.org/api.php?action=feedcontributions&user=WinstonHo&feedformat=atomArchWiki - User contributions [en]2024-03-28T12:04:37ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Bluetooth&diff=740403Bluetooth2022-08-07T08:53:07Z<p>WinstonHo: Accurate and specific instructions for dual-boot pairing of the MX Master 3. Wasted 4 hours of my time because of how half-assed the documentation was.</p>
<hr />
<div>[[Category:Bluetooth]]<br />
[[de:Bluetooth]]<br />
[[es:Bluetooth]]<br />
[[fr:Bluetooth]]<br />
[[ja:Bluetooth]]<br />
[[ru:Bluetooth]]<br />
[[zh-hans:Bluetooth]]<br />
{{Related articles start}}<br />
{{Related|Bluetooth mouse}}<br />
{{Related|Bluetooth keyboard}}<br />
{{Related|Bluetooth headset}}<br />
{{Related|Blueman}}<br />
{{Related|ObexFTP}}<br />
{{Related articles end}}<br />
[[Wikipedia:Bluetooth|Bluetooth]] is a standard for the short-range wireless interconnection of cellular phones, computers, and other electronic devices. In Linux, the canonical implementation of the Bluetooth protocol stack is [http://www.bluez.org/ BlueZ].<br />
<br />
== Installation ==<br />
<br />
# [[Install]] the {{Pkg|bluez}} package, providing the Bluetooth protocol stack.<br />
# [[Install]] the {{Pkg|bluez-utils}} package, providing the {{ic|bluetoothctl}} utility. Alternatively install {{AUR|bluez-utils-compat}} to additionally have the [[#Deprecated BlueZ tools|deprecated BlueZ tools]].<br />
# The generic Bluetooth driver is the {{ic|btusb}} kernel module. [[Kernel module#Obtaining information|Check]] whether that module is loaded. If it is not, then [[Kernel_module#Manual module handling|load the module]].<br />
# [[Start/enable]] {{ic|bluetooth.service}}.<br />
<br />
{{Note|<br />
* By default the Bluetooth daemon will only give out bnep0 devices to users that are a member of the {{ic|lp}} [[Users and groups#System groups|group]]. Make sure to add your user to that group if you intend to connect to a Bluetooth tether. You can change the group that is required in the file {{ic|/usr/share/dbus-1/system.d/bluetooth.conf}}.<br />
* Some Bluetooth adapters are bundled with a Wi-Fi card (e.g. [https://www.intel.com/content/www/us/en/wireless-products/centrino-advanced-n-6235.html Intel Centrino]). These require that the Wi-Fi card is firstly enabled (typically a keyboard shortcut on a laptop) in order to make the Bluetooth adapter visible to the kernel.<br />
* Some Bluetooth cards (e.g. Broadcom) conflict with the network adapter. Thus, you need to make sure that your Bluetooth device gets connected before the network service boot.<br />
* Some tools such as hcitool and hciconfig have been deprecated upstream, and are no longer included in {{Pkg|bluez-utils}}. Since these tools will no longer be updated, it is recommended that scripts be updated to avoid using them. If you still desire to use them, install {{AUR|bluez-utils-compat}}. See {{Bug|53110}} and [https://lore.kernel.org/linux-bluetooth/20170104133401.3636-1-luiz.dentz@gmail.com/ the Bluez mailing list] for more information.}}<br />
<br />
=== Front-ends ===<br />
<br />
==== Console ====<br />
<br />
* {{App|bluetoothctl|Pairing a device from the shell is one of the simplest and most reliable options.|http://www.bluez.org/|{{Pkg|bluez-utils}}}}<br />
* {{App|bluetuith|Provides a bluetooth manager via a Terminal User Interface for easier pairing and device/adapter management, with OBEX File Transfer and mouse support.|https://www.github.com/darkhz/bluetuith|{{AUR|bluetuith}}}}<br />
<br />
{{Tip|To automate bluetoothctl commands, use {{ic|echo -e "''command1''\n''command2''\n" {{!}} bluetoothctl}} or {{ic|bluetoothctl -- ''command''}}.}}<br />
<br />
==== Graphical ====<br />
<br />
The following packages allow for a graphical interface to customize Bluetooth.<br />
<br />
* {{App|GNOME Bluetooth|[[GNOME]]'s Bluetooth tool.<br />
** {{Pkg|gnome-bluetooth-3.0}} provides the back-end ({{Pkg|gnome-bluetooth}} is now legacy)<br />
** {{Pkg|gnome-shell}} provides the status monitor applet<br />
** {{Pkg|gnome-control-center}} provides the configuration front-end GUI that can be accessed by typing Bluetooth on the Activities overview, or with the {{ic|gnome-control-center bluetooth}} command. <br />
** You can also launch the {{ic|bluetooth-sendto}} command directly to send files to a remote device.<br />
** {{AUR|nautilus-bluetooth}} adds a "Send via Bluetooth" entry to Nautilus' right-click menu<br />
** To receive files, open the Bluetooth settings panel; you can only receive whilst the Bluetooth panel is open.<br />
** To add a Bluetooth entry to the ''Send To'' menu in Thunar's file properties menu, see instructions [https://docs.xfce.org/xfce/thunar/send-to here]. (The command that needs to be configured is {{ic|bluetooth-sendto %F}}).<br />
|https://wiki.gnome.org/Projects/GnomeBluetooth|}}<br />
* {{App|Bluedevil|[[KDE]]'s Bluetooth tool. If there is no Bluetooth icon visible in Dolphin and in the system tray, enable it in the system tray options or add a widget. You can configure Bluedevil and detect Bluetooth devices by clicking the icon. An interface is also available from the KDE System Settings.|https://invent.kde.org/plasma/bluedevil|{{Pkg|bluedevil}}}}<br />
* {{App|Blueberry|Linux Mint's spin-off of GNOME Bluetooth, which works in all desktop environments. ''Blueberry'' does not support receiving files through Obex Object Push.|https://github.com/linuxmint/blueberry|{{Pkg|blueberry}}}}<br />
* {{App|[[Blueman]]|A full featured Bluetooth manager.|https://github.com/blueman-project/blueman|{{Pkg|blueman}}}}<br />
* {{App|[[ObexFTP]]|A tool for transferring files to/from any OBEX enabled device.|http://dev.zuckschwerdt.org/openobex/wiki/ObexFtp|{{AUR|obexftp}}}}<br />
<br />
== Pairing ==<br />
<br />
{{Note|Before using the Bluetooth device, make sure that it is not blocked by [[rfkill]].}}<br />
<br />
This section describes directly configuring ''bluez5'' via the ''bluetoothctl'' CLI, which might not be necessary if you are using an alternative front-end tool (such as GNOME Bluetooth).<br />
<br />
The exact procedure depends on the devices involved and their input functionality. What follows is a general outline of pairing a device using {{ic|bluetoothctl}}.<br />
<br />
Start the {{ic|bluetoothctl}} interactive command. Input {{ic|help}} to get a list of available commands.<br />
<br />
# (optional) Select a default controller with {{ic|select ''MAC_address''}}.<br />
# Enter {{ic|power on}} to turn the power to the controller on. It is off by default and will turn off again each reboot, see [[#Auto power-on after boot/resume]].<br />
# Enter {{ic|devices}} to get the MAC address of the device with which to pair.<br />
# Enter device discovery mode with {{ic|scan on}} command if device is not yet on the list.<br />
# Turn the agent on with {{ic|agent on}} or choose a specific agent: if you press tab twice after {{ic|agent}} you should see a list of available agents. A bluetooth agent is what manages the Bluetooth 'pairing code'. It can either respond to a 'pairing code' coming in, or can send one out. The {{ic|default-agent}} should be appropriate in most cases.[https://askubuntu.com/questions/763939/bluetoothctl-what-is-a-bluetooth-agent]<br />
# Enter {{ic|pair ''MAC_address''}} to do the pairing (tab completion works).<br />
# If using a device without a PIN, one may need to manually trust the device before it can reconnect successfully. Enter {{ic|trust ''MAC_address''}} to do so.<br />
# Enter {{ic|connect ''MAC_address''}} to establish a connection.<br />
<br />
An example session may look this way:<br />
<br />
{{hc|$ bluetoothctl|<br />
[NEW] Controller 00:10:20:30:40:50 ''hostname'' [default]<br />
[bluetooth]# agent KeyboardOnly<br />
Agent registered<br />
<br />
[bluetooth]# default-agent<br />
Default agent request successful<br />
<br />
[bluetooth]# power on<br />
Changing power on succeeded<br />
[CHG] Controller 00:10:20:30:40:50 Powered: yes<br />
<br />
[bluetooth]# scan on<br />
Discovery started<br />
[CHG] Controller 00:10:20:30:40:50 Discovering: yes<br />
[NEW] Device 00:12:34:56:78:90 ''device name''<br />
[CHG] Device 00:12:34:56:78:90 LegacyPairing: yes<br />
<br />
[bluetooth]# pair 00:12:34:56:78:90<br />
Attempting to pair with 00:12:34:56:78:90<br />
[CHG] Device 00:12:34:56:78:90 Connected: yes<br />
[CHG] Device 00:12:34:56:78:90 Connected: no<br />
[CHG] Device 00:12:34:56:78:90 Connected: yes<br />
Request PIN code<br />
[agent] Enter PIN code: 1234<br />
[CHG] Device 00:12:34:56:78:90 Paired: yes<br />
Pairing successful<br />
[CHG] Device 00:12:34:56:78:90 Connected: no<br />
<br />
[bluetooth]# connect 00:12:34:56:78:90<br />
Attempting to connect to 00:12:34:56:78:90<br />
[CHG] Device 00:12:34:56:78:90 Connected: yes<br />
Connection successful<br />
}}<br />
<br />
=== Dual boot pairing ===<br />
<br />
To pair devices on dual boot setups you need to change the pairing keys manually on your Linux install, so that they match in both systems.<br />
<br />
==== Setup ====<br />
<br />
To do this, first pair your device on your Arch Linux install. Then reboot into the other OS and pair the device. Now you need to extract the pairing keys, but first switch off the Bluetooth devices to prevent any connection attempts.<br />
<br />
{{Note|Some Logitech devices, such as the [[Logitech MX Master|MX Master 3]], increment the MAC address by one every time that the device is paired with a new system. You should determine whether this is the case, so that it can be accounted for at the end of the process.}}<br />
<br />
==== For Windows ====<br />
<br />
===== Extracting on Windows =====<br />
<br />
{{Accuracy|The key structure for a BT5.1 mouse may be different than described here.}}<br />
<br />
The registry key containing the link keys may only be accessed by the [https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/local-accounts#system SYSTEM account], which cannot be logged into. Therefore, you will need Microsoft's [https://docs.microsoft.com/en-us/sysinternals/downloads/psexec PsExec] tool from the official Windows Sysinternals site in order to run {{ic|regedit.exe}} as {{ic|SYSTEM}}.<br />
<br />
Download [https://download.sysinternals.com/files/PSTools.zip PsTools], and extract {{ic|PsExe64.exe}}.<br />
<br />
In an administrator instance of a [https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands#command-shell-overview command shell], from the location of the extracted EXE, launch the registry editor:<br />
.\PsExec64.exe -s -i regedit.exe<br />
<br />
In the registry editor, navigate to the following registry key:<br />
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Keys<br />
<br />
Within this key is a key for each Bluetooth adapter, by MAC address. If there are multiple keys, and you are unsure of which to use, follow [https://www.addictivetips.com/windows-tips/find-bluetooth-mac-address-windows-10/ this guide] to find the MAC address for the desired Bluetooth adapter.<br />
<br />
Within the desired device adapter key, there is a binary value for each paired device, by MAC address in the same way.<br />
<br />
For each paired device that you wish to share between the installations, right click on the whole key and export it as a ''.reg'' file.<br />
<br />
If there are {{ic|LTK}}, {{ic|ERand}}, and {{ic|EDIV}} values present, then this is a Bluetooth 5.1 device and these are the keys that have to be saved. Refer to [[#Preparing Bluetooth 5.1 Keys]] to convert these into the right format.<br />
<br />
Finally, to import the key(s) into your Linux installation, proceed to [[#Finishing up]].<br />
<br />
===== Extracting on Linux =====<br />
<br />
{{Note|If your Windows partition is encrypted with Bitlocker, you will not be able to access it from Linux using chntpw.}}<br />
<br />
Reboot into Arch. Install {{Pkg|chntpw}}. Mount your windows system drive.<br />
<br />
$ cd ''/path/to/windows/system''/Windows/System32/config<br />
$ chntpw -e SYSTEM<br />
{{Note|Instead of CurrentControlSet you may see ControlSet00X, where X is any number. Check using the ls command.}}<br />
Inside the {{ic|chntpw}} environment, run <br />
<br />
> cd CurrentControlSet\Services\BTHPORT\Parameters\Keys<br />
or<br />
> cd ControlSet00X\Services\BTHPORT\Parameters\Keys<br />
<br />
Then get your Bluetooth adapter's MAC address and enter its folder<br />
<br />
> ls<br />
> cd ''your-device's-mac-address''<br />
<br />
Do the same for your paired devices:<br />
<br />
{{hc|> ls|<br />
Node has 0 subkeys and 1 values<br />
size type value name [value if type DWORD]<br />
16 REG_BINARY <123456789876><br />
}}<br />
<br />
Now get your device's key through {{ic|hex}}:<br />
<br />
{{hc|> hex 123456789876|<br />
:00000 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX (some other chars)<br />
}}<br />
<br />
The "XX"s are the pairing key. Make note of which keys map to which MAC addresses.<br />
<br />
In a BT5.1 Mouse, you might see this output:<br />
<br />
{{bc|<br />
Node has 0 subkeys and 8 values<br />
size type value name [value if type DWORD]<br />
16 3 REG_BINARY <LTK><br />
4 4 REG_DWORD <KeyLength> 16 [0x10]<br />
8 b REG_QWORD <ERand><br />
4 4 REG_DWORD <EDIV> 37520 [0x9290]<br />
16 3 REG_BINARY <IRK><br />
8 b REG_QWORD <Address><br />
4 4 REG_DWORD <AddressType> 1 [0x1]<br />
4 4 REG_DWORD <AuthReq> 45 [0x2d]<br />
}}<br />
<br />
Of these values, you must save {{ic|LTK}}, {{ic|ERand}}, and {{ic|EDIV}}. Refer to [[#Preparing Bluetooth 5.1 Keys]] to convert these into the right format.<br />
<br />
{{hc|> hex LTK|<br />
:00000 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX (some other chars)<br />
}}<br />
<br />
{{Note|If you are attempting to pair the MX Master 3, instead of extracting the {{ic|LTK}}, {{ic|ERand}}, and {{ic|EDIV}} keys, you should instead extract {{ic|LTK}} and {{ic|IRK}} only.}}<br />
<br />
Finally, to import the key(s) into your Linux installation, proceed to [[#Finishing up]].<br />
<br />
===== Preparing Bluetooth 5.1 Keys =====<br />
<br />
{{Accuracy|On the Logitech MX Master 3, {{ic|LTK}} maps to '''both''' {{ic|SlaveLongTermKey.Key}} and {{ic|PeripheralLongTermKey.Key}}, while {{ic|IRK}} (previously unsaved) maps to {{ic|IdentityResolvingKey.Key}} There is no conversion required; simply remove the spaces between the hexadecimals (you can use the following [https://www.browserling.com/tools/remove-all-whitespace online tool] to do so quickly). |Talk:Bluetooth#Logitech Bluetooth Devices Mac Address Increment}}<br />
<br />
If there were {{ic|LTK}}, {{ic|ERand}}, and {{ic|EDIV}} values in the registry for the desired device, they must be converted for use with Linux. {{ic|LTK}} corrsponds to {{ic|LongTermKey.Key}}, {{ic|ERand}} to {{ic|Rand}}, {{ic|EDIV}} to {{ic|EDiv}}. The {{ic|ERand}} value shound be reversed and converted to decimal. For example:<br />
* An {{ic|LTK}} of {{ic|48 4D AF CD 0F 92 22 88 0A 52 9A F4 76 DA 8B 94}} makes for a {{ic|LongTermKey.Key}} of {{ic|484DAFCD0F9222880A529AF476DA8B94}}.<br />
* An {{ic|ERand}} of {{ic|63 02 84 B8 5D 40 44 DF}} makes for a {{ic|Rand}} of {{ic|16088054540146049635}}.<br />
* An {{ic|EDIV}} of {{ic|37520}} makes for an {{ic|EDiv}} of {{ic|37520}}.<br />
<br />
{{Note|You can use this [[Python]] code to do the {{ic|ERand}} conversion:<br />
<br />
{{bc|1=<br />
>>> ERand=' 63 02 84 B8 5D 40 44 DF '<br />
>>> ERand=list(reversed(ERand.strip().split()))<br />
>>> int("".join(ERand), 16)<br />
16088054540146049635<br />
}}<br />
}}<br />
<br />
==== For macOS ====<br />
<br />
Boot into macOS, then open a terminal.<br />
<br />
* If you are on Sierra or older, run <br />
<br />
{{bc|# defaults read /private/var/root/Library/Preferences/blued.plist LinkKeys > ~/bt_keys.txt}}<br />
<br />
* If you are on High Sierra or newer, run<br />
<br />
{{bc|# defaults read /private/var/root/Library/Preferences/com.apple.bluetoothd.plist LinkKeys > ~/bt_keys.txt}}<br />
<br />
For older versions of macOS (High Sierra and older) you will have to reverse the keys. For example, {{ic|98 54 2f aa bb cc dd ee ff gg hh ii jj kk ll mm}} becomes {{ic|MM LL KK JJ GG FF EE DD CC BB AA 2F 54 98}}.<br />
<br />
Copy the {{ic|bt_keys.txt}} file to a drive that can be read from Arch Linux. Reboot into Arch Linux.<br />
<br />
==== Finishing up ====<br />
<br />
Now that you have the keys change user to root, then continue with:<br />
<br />
{{bc|# cd /var/lib/bluetooth/''BT-Adapter-MAC-address''}}<br />
<br />
Here you will find folders for each paired Bluetooth device. For each device you want to pair with Arch and your dual boot, do the following:<br />
<br />
{{bc|# cd ''device-MAC-address''}}<br />
<br />
{{Note|At this point, if you are using a device which increments its MAC address on pairing, you must move the MAC address directory to the incremented path. Either copy the MAC address from Windows, or increment it yourself while minding the fact that each octet is a two-digit [[Wikipedia:Hexadecimal|hexadecmial]] number.}}<br />
<br />
If you have a pairing key (i.e. this is not a Bluetooth 5.1 device), then edit the {{ic|info}} file and change the key under {{ic|[LinkKey]}}. E.g.: <br />
<br />
{{hc|1=info|2=<br />
[LinkKey]<br />
Key=XXXXXXXXXXXXXXX<br />
}}<br />
<br />
{{Note|You will have to make sure that all the letters are in capital case. Remove any spaces.}}<br />
<br />
If you have Bluetooth 5.1 keys, then you must instead copy the key files to the MAC address directory.<br />
<br />
Then [[restart]] {{ic|bluetooth.service}} and {{ic|pulseaudio}} (with {{ic|pulseaudio -k && pulseaudio --start}}).<br />
<br />
You should be able to connect to your device now. <br />
<br />
{{Note|Depending on your Bluetooth manager, you may need to perform a full reboot in order to reconnect to the device.}}<br />
<br />
== Configuration ==<br />
<br />
=== Auto power-on after boot/resume ===<br />
<br />
{{Accuracy|Since {{Pkg|bluez}} 5.65, {{ic|AutoEnable}} defaults to {{ic|true}}. [https://github.com/bluez/bluez/commit/180cf09933b2d8eb03972c8638063429fe5fece5]}}<br />
<br />
By default, the Bluetooth adapter does not power on after a reboot or resuming from suspend. If you would like the adapter to be powered on after reboot or resume, set {{ic|1=AutoEnable=true}} in {{ic|/etc/bluetooth/main.conf}} in the {{ic|[Policy]}} section:<br />
<br />
{{hc|1=/etc/bluetooth/main.conf|2=<br />
[Policy]<br />
AutoEnable=true<br />
}}<br />
<br />
=== Discoverable on startup ===<br />
<br />
If the device should always be visible and directly connectable:<br />
<br />
{{hc|1=/etc/bluetooth/main.conf|2=<br />
[General]<br />
DiscoverableTimeout = 0<br />
}}<br />
<br />
=== Wake from suspend ===<br />
<br />
To allow Bluetooth keyboards, mice, etc. to wake the system from suspend. First, check the bios settings and make sure that wake from USB is not disabled. In many cases, Bluetooth from the motherboard is a USB device. <br />
<br />
Find the vendor code and device ID for the Bluetooth adapter.<br />
<br />
{{hc|$ lsusb {{!}} grep bluetooth -i|<br />
Bus 001 Device 002: ID 8087:0039 Intel Corp. AX200 Bluetooth<br />
}}<br />
<br />
Add a new udev rule for the vendor code and device ID to enable wake from suspend.<br />
<br />
{{hc|/etc/udev/rules.d/91-keyboard-mouse-wakeup.rules|2=<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="8087", ATTRS{idProduct}=="0039" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/../power/wakeup;'"<br />
}}<br />
<br />
To automatically re-configure your Bluetooth keyboard after wakeups to e.g. have a different keymap or key press repeat rate (for details, see [[Xorg/Keyboard configuration#Adjusting typematic delay and rate]] and [[xmodmap]]), create an [[executable]] script.<br />
<br />
{{hc|configure_keyboard.sh|2=<br />
#!/bin/sh<br />
export DISPLAY=:0<br />
xset r rate 220 30<br />
xmodmap /''your''/''path''/''to''/.Xmodmap<br />
}}<br />
<br />
Then create an additional udev rule like above.<br />
<br />
{{hc|/etc/udev/rules.d/92-keyboard-reconfiguration-wakeup.rules|2=<br />
SUBSYSTEM=="usb", ATTRS{idVendor}=="8087", ATTRS{idProduct}=="0039" RUN+="/''your''/''path''/''to''/configure_keyboard.sh"<br />
}}<br />
<br />
== Audio ==<br />
<br />
You will typically need to take an additional step to integrate the audio server with Bluetooth. This is detailed in the below sections.<br />
<br />
See the [[Bluetooth headset]] page for more information about Bluetooth audio and Bluetooth headsets.<br />
<br />
=== PulseAudio ===<br />
<br />
In order to be able to use audio equipment like Bluetooth headphones or speakers, you need to install the additional {{Pkg|pulseaudio-bluetooth}} package. Make sure to restart pulseaudio to make the installation take effect: {{ic|pulseaudio -k}}. With a default PulseAudio installation you should immediately be able to stream audio from a Bluetooth device to your speakers.<br />
<br />
If you have a system-wide PulseAudio setup make sure the user running the daemon (usually {{ic|pulse}}) is in the {{ic|lp}} group and you load the Bluetooth modules in your PulseAudio config:<br />
<br />
{{hc|/etc/pulse/system.pa|2=<br />
...<br />
load-module module-bluetooth-policy<br />
load-module module-bluetooth-discover<br />
...<br />
}}<br />
<br />
Optionally, add {{ic|load-module module-switch-on-connect}} if you want to auto-switch all audio to the Bluetooth device.<br />
<br />
=== PipeWire ===<br />
<br />
PipeWire as of v0.3.19 enables its Bluetooth support by default.<br />
<br />
=== ALSA ===<br />
<br />
{{Note|Bluez5 has dropped direct integration for [[ALSA]] and supports [[PulseAudio]] only. Follow the instructions below if you cannot or do not want to use PulseAudio.}}<br />
<br />
First, ensure that your Bluetooth audio device is correctly paired and connected to the system.<br />
<br />
Then, install {{AUR|bluez-alsa-git}}, start (and enable) the {{ic|bluealsa}} service, and add your user to the {{ic|audio}} group.<br />
<br />
Run the following command to check if everything is working as intended (replace {{ic|''XX:XX:XX:XX:XX:XX''}} and {{ic|''FILE.wav''}} below):<br />
<br />
$ aplay -D bluealsa:SRV=org.bluealsa,DEV=''XX:XX:XX:XX:XX:XX'',PROFILE=a2dp ''FILE.wav''<br />
<br />
Finally, add the following lines to your {{ic|~/.asoundrc}}:<br />
<br />
{{hc|~/.asoundrc|<br />
defaults.bluealsa {<br />
service "org.bluealsa"<br />
device "XX:XX:XX:XX:XX:XX"<br />
profile "a2dp"<br />
}<br />
}}<br />
<br />
You can now use the {{ic|bluealsa}} device to reach your Bluetooth audio device. Volume management is conducted normally via {{ic|alsamixer}} with the option {{ic|-D bluealsa}}.<br />
<br />
== Bluetooth serial ==<br />
<br />
To get Bluetooth serial communication working on Bluetooth-to-Serial modules (HC-05, HC-06) do the following steps:<br />
<br />
'''Pair''' your Bluetooth device using {{ic|bluetoothctl}} as described [[#Pairing|above]].<br />
<br />
Install {{AUR|bluez-utils-compat}}, as it provides certain functionality which is missing from newer tools.<br />
<br />
Bind paired device MAC address to tty terminal:<br />
<br />
# rfcomm bind rfcomm0 ''MAC_address_of_Bluetooth_device''<br />
<br />
Now you can open {{ic|/dev/rfcomm0}} for serial communication:<br />
<br />
picocom /dev/rfcomm0 -b 115200<br />
<br />
== Troubleshooting ==<br />
<br />
{{Out of date|Replace hciconfig with newer commands.}}<br />
<br />
=== Debugging ===<br />
<br />
In order to debug, first [[stop]] {{ic|bluetooth.service}}.<br />
<br />
And then start it with the {{ic|-d}} parameter:<br />
<br />
# /usr/lib/bluetooth/bluetoothd -n -d<br />
<br />
Another option is via the {{ic|btmon}} tool.<br />
<br />
=== Deprecated BlueZ tools ===<br />
<br />
Eight BlueZ tools [https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=b1eb2c4cd057624312e0412f6c4be000f7fc3617 were deprecated] and removed from {{Pkg|bluez-utils}}, although not all of them were superseded by newer tools. The {{AUR|bluez-utils-compat}} package provides an alternative version of {{Pkg|bluez-utils}} with the deprecated tools.<br />
<br />
{| class="wikitable"<br />
|-<br />
! Deprecated tool<br />
! Most likely replacement<br />
|-<br />
| [https://manpages.debian.org/stretch/bluez/gatttool.1.en.html gatttool] || btgatt-client, [https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt D-Bus Gatt API]<br />
|-<br />
| [https://manpages.debian.org/stretch/bluez/hciattach.1.en.html hciattach] || btattach<br />
|-<br />
| [https://manpages.debian.org/stretch/bluez/hciconfig.1.en.html hciconfig] || btmgmt (and bluetoothctl?)<br />
|-<br />
| [https://manpages.debian.org/stretch/bluez-hcidump/hcidump.1.en.html hcidump] || btmon (and btsnoop)<br />
|-<br />
| [https://manpages.debian.org/stretch/bluez/hcitool.1.en.html hcitool] || missing, [https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/device-api.txt D-Bus Device API] available<br />
|-<br />
| [https://manpages.debian.org/stretch/bluez/rfcomm.1.en.html rfcomm]<br />
| rowspan="2" | missing, implement with [https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/profile-api.txt D-Bus Profile1 API]?<br />
|-<br />
| [https://manpages.debian.org/stretch/bluez/ciptool.1.en.html ciptool]<br />
|-<br />
|[https://manpages.debian.org/stretch/bluez/sdptool.1.en.html sdptool]<br />
| missing, functionality seems to be scattered over different D-Bus objects: [https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/profile-api.txt Profile], [https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/advertising-api.txt Advertising], and the UUIDs arrays in [https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/device-api.txt device] and [https://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/adapter-api.txt adapter]. <br />
|}<br />
<br />
=== gnome-bluetooth ===<br />
<br />
If you see this when trying to enable receiving files in bluetooth-properties:<br />
<br />
Bluetooth OBEX start failed: Invalid path<br />
Bluetooth FTP start failed: Invalid path<br />
<br />
Then make sure that the [[XDG user directories]] exist.<br />
<br />
=== Bluetooth USB dongle ===<br />
<br />
If you are using a USB dongle, you should check that your Bluetooth dongle is recognized. You can do that by running {{ic|journalctl -f}} as root when you have plugged in the USB dongle (or inspecting {{ic|/var/log/messages.log}}). It should look something like the following (look out for hci):<br />
<br />
{{bc|<br />
Feb 20 15:00:24 hostname kernel: [ 2661.349823] usb 4-1: new full-speed USB device number 3 using uhci_hcd<br />
Feb 20 15:00:24 hostname bluetoothd[4568]: HCI dev 0 registered<br />
Feb 20 15:00:24 hostname bluetoothd[4568]: Listening for HCI events on hci0<br />
Feb 20 15:00:25 hostname bluetoothd[4568]: HCI dev 0 up<br />
Feb 20 15:00:25 hostname bluetoothd[4568]: Adapter /org/bluez/4568/hci0 has been enabled<br />
}}<br />
<br />
If you only get the first two lines, you may see that it found the device but you need to bring it up.<br />
Example:<br />
<br />
# btmgmt<br />
<br />
{{hc|[mgmt]# info|<br />
Index list with 1 item<br />
hci0: Primary controller<br />
addr 00:1A:7D:DA:71:10 version 6 manufacturer 10 class 0x000000<br />
supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr <br />
'''current settings:''' connectable discoverable bondable ssp br/edr le secure-conn <br />
name Mozart<br />
short name <br />
}}<br />
<br />
{{hc|[mgmt]# select hci0|<br />
Selected index 0<br />
}}<br />
<br />
{{hc|[hci0]# power up|<br />
hci0 Set Powered complete, settings: '''powered''' connectable discoverable bondable ssp br/edr le secure-conn<br />
}}<br />
<br />
{{hc|[hci0]# info|<br />
hci0: Primary controller<br />
addr 00:1A:7D:DA:71:10 version 6 manufacturer 10 class 0x1c0104<br />
supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr <br />
'''current settings: powered''' connectable discoverable bondable ssp br/edr le secure-conn<br />
}}<br />
<br />
Or<br />
<br />
# bluetoothctl<br />
<br />
{{hc|[bluetooth]# show|<br />
Controller 00:1A:7D:DA:71:10 (public)<br />
Name: Mozart<br />
Alias: Mozart<br />
Class: 0x0000095c<br />
'''Powered: no'''<br />
Discoverable: yes<br />
Pairable: yes<br />
}}<br />
<br />
{{hc|[bluetooth]# power on'''|<br />
[CHG] Controller 00:1A:7D:DA:71:10 Class: 0x001c0104<br />
Changing power on succeeded<br />
[CHG] Controller 00:1A:7D:DA:71:10 '''Powered: yes'''<br />
}}<br />
<br />
{{hc|[bluetooth]# show|<br />
Controller 00:1A:7D:DA:71:10 (public)<br />
Name: Mozart<br />
Alias: Mozart<br />
Class: 0x001c0104<br />
'''Powered: yes'''<br />
Discoverable: yes<br />
Pairable: yes<br />
}}<br />
<br />
To verify that the device was detected you can use {{ic|btmgmt}} which is part of the {{ic|bluez-utils}}. You can get a list of available devices and their identifiers and their MAC address by issuing:<br />
<br />
{{hc|$ btmgmt info|<br />
Index list with 1 item<br />
hci0: Primary controller<br />
addr 00:1A:7D:DA:71:10 '''version 6''' manufacturer 10 class 0x1c0104<br />
supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr hs le advertising secure-conn debug-keys privacy static-addr <br />
current settings: powered connectable discoverable bondable ssp br/edr le secure-conn<br />
}}<br />
<br />
It is possible to check the Bluetooth version as mapped to the HCI version according to the table in the [https://www.bluetooth.com/specifications/assigned-numbers/host-controller-interface/ official specification]. For example, in the previous output, HCI '''version 6''' is Bluetooth version 4.0.<br />
<br />
More detailed information about the device can be retrieved by using the deprecated {{ic|hciconfig}}. ({{AUR|bluez-utils-compat}})<br />
<br />
{{hc|$ hciconfig -a hci0|<br />
hci0: Type: USB<br />
BD Address: 00:1B:DC:0F:DB:40 ACL MTU: 310:10 SCO MTU: 64:8<br />
UP RUNNING PSCAN ISCAN<br />
RX bytes:1226 acl:0 sco:0 events:27 errors:0<br />
TX bytes:351 acl:0 sco:0 commands:26 errors:0<br />
Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80<br />
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3<br />
Link policy: RSWITCH HOLD SNIFF PARK<br />
Link mode: SLAVE ACCEPT <br />
Name: 'BlueZ (0)'<br />
Class: 0x000100<br />
Service Classes: Unspecified<br />
Device Class: Computer, Uncategorized<br />
HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c<br />
Manufacturer: Cambridge Silicon Radio (10)<br />
}}<br />
<br />
==== Audio devices start to skip at short distance from dongle ====<br />
<br />
If other devices share the same USB host, they can [https://bbs.archlinux.org/viewtopic.php?pid=1440161#p1440161 interrupt communication with audio devices]. Make sure it is the only device attached to its bus. For example:<br />
<br />
{{hc|$ lsusb|<br />
Bus 002 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)<br />
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub<br />
Bus 001 Device 004: ID 048d:1345 Integrated Technology Express, Inc. Multi Cardreader<br />
Bus 001 Device 003: ID 0424:a700 Standard Microsystems Corp. 2 Port Hub<br />
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub<br />
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub<br />
}}<br />
<br />
==== CSR dongle 0a12:0001 ====<br />
<br />
The device {{ic|ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)}} has a regression bug, and currently only works in the kernel version ≤ 3.9.11. There is a patch available for newer versions. For more information, see [https://bugzilla.kernel.org/show_bug.cgi?id=60824 Kernel Bug 60824].<br />
<br />
=== Logitech Bluetooth USB dongle ===<br />
<br />
There are Logitech dongles (ex. Logitech MX5000) that can work in two modes: Embedded and HCI. In embedded mode dongle emulates a USB device so it seems to your PC that you are using a normal USB mouse/keyoard.<br />
<br />
If you hold the little red Button on the USB BT mini-receiver it will enable the other mode. Hold the red button on the BT dongle and plug it into the computer, and after 3-5 seconds of holding the button, the Bluetooth icon will appear in the system tray. [https://ubuntuforums.org/showthread.php?t=1332197 Discussion]<br />
<br />
Alternatively, you can install the {{Pkg|bluez-hid2hci}} package. When you connect your Logitech dongle it will automatically switch.<br />
<br />
=== hcitool scan: Device not found ===<br />
<br />
* On some laptops (e.g. Dell Studio 15, Lenovo Thinkpad X1) you have to switch the Bluetooth mode from HID to HCI. Install the {{Pkg|bluez-hid2hci}} package, then [[udev]] should do this automatically. Alternatively, you can run this command to switch to HCI manually:<br />
<br />
# /usr/lib/udev/hid2hci<br />
<br />
* If the device will not show up and you have a Windows operating system on your machine, try booting it and enable the Bluetooth adapter from windows.<br />
<br />
* Sometimes also this simple command helps:<br />
<br />
# bluetoothctl power on<br />
<br />
=== bluetoothctl: No default controller available ===<br />
<br />
There is a bug with some motherboard bluetooth controllers. To see if this might be the issue, run {{ic|journalctl {{!}} grep hci}}. If there are entries like "command tx timeout" or "Reading Intel version command failed", then power off your pc and physically unplug the power cable for a few seconds. This forces the controller to reload the firmware (while a standard reboot will not). See bug report [https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1859592 here].<br />
<br />
Make sure the device is not being blocked by [[rfkill]].<br />
<br />
It might also happen with some intel cards (such as the 8260) to not be picked up correctly by the Bluetooth service. In some cases, using the deprecated {{AUR|bluez-utils-compat}} in lieu of {{Pkg|bluez-utils}} have reportedly fixed the issue.<br />
<br />
This might also be caused by power saving measures, in which case adding the [[Kernel parameters#Configuration|kernel parameter]] {{ic|1=btusb.enable_autosuspend=n}} is a potential solution. See also [https://bugzilla.redhat.com/show_bug.cgi?id=1573562 Red Hat Bugzilla – Bug 1573562].<br />
<br />
Sometimes unloading and loading {{ic|btusb}} without options helps to get the controller back:<br />
<br />
# modprobe -r btusb<br />
# modprobe btusb<br />
<br />
=== systemd: Condition check resulted in Bluetooth service being skipped ===<br />
<br />
{{ic|bluetooth.service}} only requires the directory {{ic|/sys/class/bluetooth}} to exist, which should be created by kernel module {{ic|bluetooth}}, which is only autoloaded by {{ic|systemd-udev}} if it actually finds a working Bluetooth hardware device. <br />
<br />
If your {{ic|/sys/class/bluetooth}} does not exist, check if your kernel Bluetooth module is loaded by {{ic|lsmod}}. If not, and you believe you have a Bluetooth device, you can try manually starting them by [[Kernel module#Manual module handling|loading the Bluetooth module]] and [[restart]]ing {{ic|bluetooth.service}}.<br />
<br />
You should also load your corresponding kernel Bluetooth driver when loading the {{ic|bluetooth}} module, most likely {{ic|btusb}}, but can also be {{ic|btrtl,btintel,btbcm,bnep,btusb}} etc.<br />
<br />
Check {{ic|bluetooth.service}}'s [[unit status]] to see whether it started.<br />
<br />
See also [https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853207 Debian Bug report logs - #853207].<br />
<br />
If {{ic|bluetooth.service}} started successfully, but there is chance that you still cannot use Bluetooth normally (e.g. {{ic|bluetoothctl}} says something like {{ic|org.Bluez.Error.NotReady}} when you {{ic|scan on}}). If this happens, try rebooting your computer, and double-check: whether directory {{ic|/sys/class/bluetooth}} exists; whether {{ic|lsmod}} includes correct Bluetooth modules; log messages in the [[journal]]; etc. {{ic|systemd-udev}} should pickup your Bluetooth hardware automatically without manual changes again.<br />
<br />
=== rfkill unblock: Do not unblock ===<br />
<br />
If your device still soft blocked and you run [[ConnMan]], try this:<br />
<br />
$ connmanctl enable bluetooth<br />
<br />
=== Computer is not visible ===<br />
<br />
Enable discoverable mode if your computer cannot be discovered from your phone:<br />
<br />
# bluetoothctl discoverable on<br />
<br />
Verify that discoverable mode is on:<br />
<br />
{{hc|# bluetoothctl show|<br />
Powered: yes<br />
Discoverable: yes<br />
Pairable: yes<br />
}}<br />
<br />
{{Note|Check {{ic|DiscoverableTimeout}} and {{ic|PairableTimeout}} in {{ic|/etc/bluetooth/main.conf}}.}}<br />
<br />
If the computer still does not show up, try changing the device class in {{ic|/etc/bluetooth/main.conf}} as follows:<br />
<br />
# Default device class. Only the major and minor device class bits are<br />
# considered.<br />
#Class = 0x000100 # Computer Type (from default config)<br />
Class = 0x100100 # (Object-Transfer Service & Computer Type)<br />
<br />
{{Note|In some cases, {{ic|Class}} in {{ic|main.conf}} gets overridden after device initialization, so set the class directly with {{ic|hciconfig hci0 class 100100}}.}}<br />
<br />
A user reported that this was the only solution to make their computer visible for their phone. LG TVs (and some others) are discoverable from their audio devices, so using {{ic|000414}} (the soundbar class) will make such devices appear.<br />
<br />
See https://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html to generate Bluetooth device/service classes.<br />
<br />
=== Foxconn / Hon Hai / Lite-On Broadcom device ===<br />
<br />
Some of these devices require the firmware to be flashed into the device at boot. The firmware is not provided but can converted from a Microsoft Windows ''.hex'' file into a ''.hcd'' using [https://github.com/jessesung/hex2hcd hex2hcd] (which is installed with {{Pkg|bluez-utils}}).<br />
<br />
In order to get the right ''.hex'' file, try searching the device vendor:product code obtained with ''lsusb'', for example:<br />
<br />
...<br />
Bus 002 Device 004: ID '''04ca:2006''' Lite-On Technology Corp. Broadcom BCM43142A0 Bluetooth Device<br />
...<br />
<br />
or<br />
<br />
Bus 004 Device 004: Id '''0489:e031''' Foxconn / Hon Hai<br />
<br />
Alternatively, boot into Windows (a virtual machine installation will suffice) and get the firmware name from the Device Manager utility. If you want to know the model of your device but cannot see it in ''lsusb'', you might see it in ''lsusb -v'' as {{ic|iProduct}}.<br />
<br />
The ''.hex'' file can be extracted from the downloaded Windows driver without having to run Windows for it. Download the right driver, for example [http://www.fujitsupc.com/downloads/mobile/BLUETOOTH_WIDCOMM_V6.5.0.3100_WIN7-32_FPC46-1771-01.EXE Bluetooth Widcomm] (listed among the drivers for [http://support.fujitsupc.com/CS/Portal/supportsearch.do?srch=DOWNLOADS&Series=P%20Series&Model=P771&ProductType=Notebook%20PC Lifebook P771]), which contains the drivers for many Broadcomm devices. In case of Bluetooth Widcomm, the driver is a self-extracting RAR archive, so it can be extracted using ''{{Pkg|unrar}} x''. To find out which of the many ''.hex'' files is the right one for you, look in the file {{ic|Win32/bcbtums-win7x86-brcm.inf}} and search for {{ic|[RAMUSB'''E031'''.CopyList]}}, where {{ic|E031}} should be replaced with the product code (the second hex number in ''lsusb'') of your device in upper-case. Underneath you should see the file name of the right ''.hex'' file.<br />
<br />
Once you have the ''.hcd'' file, copy it into {{ic|/lib/firmware/brcm/BCM.hcd}} - this filename is suggested by [[dmesg]] and it may change in your case so check your ''dmesg'' output in order to verify. Then reload the ''btusb'' module:<br />
<br />
# rmmod btusb<br />
# modprobe btusb<br />
<br />
The device should now be available. See [https://bbs.archlinux.org/viewtopic.php?id=162688 BBS#162688] for information on making these changes persistent.<br />
<br />
=== Intel combined WiFi and Bluetooth cards ===<br />
<br />
See [[Wireless network configuration#Bluetooth coexistence]].<br />
<br />
=== Device connects, then disconnects after a few moments ===<br />
<br />
If you see messages like the following in the journal, and your device fails to connect or disconnects shortly after connecting:<br />
<br />
bluetoothd: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)<br />
bluetoothd: connect error: Connection refused (111)<br />
<br />
This may be because you have already paired the device with another operating system using the same Bluetooth adapter (e.g., dual-booting). Some devices cannot handle multiple pairings associated with the same MAC address (i.e., Bluetooth adapters). Follow instructions on [[#Dual boot pairing]] for solving this issue.<br />
<br />
=== Device does not show up in scan ===<br />
<br />
Some devices using Bluetooth low energy do not appear when scanning with bluetoothctl, for example the Logitech MX Master. The simplest way I have found to connect them is by installing {{aur|bluez-utils-compat}}, then [[start]] {{ic|bluetooth.service}} and do:<br />
<br />
{{hc|# bluetoothctl|<br />
[NEW] Controller (MAC) myhostname [default]<br />
}}<br />
<br />
{{hc|[bluetooth]# power on|<br />
[CHG] Controller (MAC) Class: 0x0c010c<br />
Changing power on succeeded<br />
[CHG] Controller (MAC) Powered: yes<br />
}}<br />
<br />
{{hc|[bluetooth]# scan on|<br />
Discovery started<br />
[CHG] Controller (MAC) Discovering: yes<br />
}}<br />
<br />
In another terminal:<br />
<br />
# hcitool lescan<br />
<br />
Wait until your device shows up, then {{ic|Ctrl+c}} hcitool. bluetoothctl should now see your device and pair normally.<br />
<br />
=== Cannot receive transferred files due to symlink ===<br />
<br />
If incoming file transfers fail on an an otherwise functional Bluetooth connection, the problem may be due to symlinks in your file transfer path. Logs like this would appear in the journal:<br />
<br />
Jun 18 11:18:13 ember obexd[3338969]: open(/home/me/.cache/obexd/MOC740): Operation not permitted (1)<br />
<br />
If the path shown in the error message contains a symlink, then obexd by default [https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/obexd/plugins/filesystem.c#n90 will not accept it]. The behavior can be overridden on initialization using a [[drop-in file]] for the {{ic|obex.service}} [[systemd/User|user service]]:<br />
<br />
{{hc|~/.config/systemd/user/obex.service.d/10-symlink.conf|2=<br />
[Service]<br />
ExecStart=<br />
ExecStart=/usr/lib/bluetooth/obexd --symlinks<br />
}}<br />
<br />
Then [[reload]] the ''systemd'' manager configuration of the calling user and [[restart]] the {{ic|obex.service}} user unit.<br />
<br />
=== Interference between Headphones and Mouse ===<br />
<br />
If you experience audio stuttering while using a Bluetooth mouse and keyboard simultaneously, you can try the following as referenced in #23 https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/424215<br />
<br />
# hciconfig hci0 lm ACCEPT,MASTER<br />
# hciconfig hci0 lp HOLD,SNIFF,PARK<br />
<br />
=== Bluetooth mouse laggy movements ===<br />
<br />
Try to edit the file {{ic|/var/lib/bluetooth/XX:XX:XX:XX:XX:XX/YY:YY:YY:YY:YY:YY/info}} ({{ic|XX:XX:XX:XX:XX:XX}} - your Bluetooth adapter MAC address, {{ic|YY:YY:YY:YY:YY:YY}} - your mouse MAC address) and add these lines:<br />
<br />
[ConnectionParameters]<br />
MinInterval=6<br />
MaxInterval=9<br />
Latency=44<br />
Timeout=216<br />
<br />
You can see your local adapter MAC address by running the command {{ic|hcitool dev}}. You can see the MAC addresses of currently connected remote devices by running the command {{ic|hcitool con}}.<br />
<br />
=== Adapter disappears after suspend/resume ===<br />
<br />
First, find vendor and product ID of the adapter. For example:<br />
<br />
{{hc|$ lsusb -tv|<nowiki><br />
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M<br />
ID 1d6b:0002 Linux Foundation 2.0 root hub<br />
...<br />
|__ Port 3: Dev 3, If 0, Class=Wireless, Driver=btusb, 12M<br />
ID 8087:0025 Intel Corp. <br />
|__ Port 3: Dev 3, If 1, Class=Wireless, Driver=btusb, 12M<br />
ID 8087:0025 Intel Corp. <br />
...<br />
</nowiki>}}<br />
<br />
In this case, the vendor ID is 8087 and the product ID is 0025.<br />
<br />
Then, use {{pkg|usb_modeswitch}} to reset the adapter:<br />
<br />
# usb_modeswitch -R -v ''vendor_ID'' -p ''product_ID''<br />
<br />
=== Problems with all BLE devices on kernel 5.9+ ===<br />
<br />
Starting with v5.9, the kernel Bluetooth stack tries to use link-layer privacy on BLE connections. If the device works after pairing but does not survive a reboot or suspend, it is probably because of this.<br />
<br />
To workaround [https://lkml.kernel.org/lkml/D577711C-4AF5-4E82-8A17-E766B64E15A9@holtmann.org/] this issue, open {{ic|/var/lib/bluetooth/''adapter_mac''/''device_mac''/info}}, remove the following lines, and restart {{ic|bluetooth.service}}:<br />
<br />
{{bc|1=<br />
[IdentityResolvingKey]<br />
Key=...<br />
}}<br />
<br />
See the relevant [https://bbs.archlinux.org/viewtopic.php?id=259954 discussion] on the Arch forum.<br />
<br />
=== Bluetooth immediately waking up suspend-to-idle devices ===<br />
<br />
On systems capable of [[Power_management/Suspend_and_hibernate|suspend-to-idle/S2idle/S0ix/Modern Standby]], Bluetooth controllers will stay enabled during sleep. This will usually cause the system to [https://bugzilla.kernel.org/show_bug.cgi?id=200039 wake up immediately after going to sleep] if any Bluetooth device is connected.<br />
<br />
To prevent this, you can disable Bluetooth completely before going to sleep - install {{Pkg|bluez-utils}} and create this file:<br />
<br />
{{hc|/etc/systemd/system/bluetooth-disable-before-sleep.service|2=<br />
[Unit]<br />
Description=Disable Bluetooth before going to sleep<br />
Before=sleep.target<br />
Before=suspend.target<br />
Before=hybrid-sleep.target<br />
Before=suspend-then-hibernate.target<br />
StopWhenUnneeded=yes<br />
<br />
[Service]<br />
Type=oneshot<br />
RemainAfterExit=yes<br />
<br />
ExecStart=/usr/bin/bluetoothctl power off<br />
ExecStop=/usr/bin/bluetoothctl power on<br />
<br />
[Install]<br />
WantedBy=sleep.target<br />
WantedBy=suspend.target<br />
WantedBy=hybrid-sleep.target<br />
WantedBy=suspend-then-hibernate.target<br />
}}<br />
<br />
[[Enable]] this service and check if Bluetooth devices disconnect when going to sleep, and whenever Bluetooth goes back up after waking up the system.<br />
<br />
If this workaround is in use, [[#Wake from suspend|waking up the system with a Bluetooth mouse/keyboard]] will not work.<br />
<br />
=== Continually connect/disconnect with tp-link UB400 and xbox controller ===<br />
<br />
Edit {{ic|/etc/bluetooth/main.conf}} and set below settings (uncomment/change value):<br />
<br />
[General<br />
JustWorksRepairing = always<br />
FastConnectable = true<br />
Class = 0x000100<br />
<br />
[GATT]<br />
ReconnectIntervals=1,1,2,3,5,8,13,21,34,55<br />
AutoEnable=true<br />
<br />
Then [[restart]] the {{ic|bluetooth.service}}.<br />
<br />
You can see relevant [https://github.com/atar-axis/xpadneo/issues/166 discussion on xpadneo] but the xpadneo driver is not needed.<br />
<br />
=== Enabling experimental feature ===<br />
<br />
The Bluez stack keeps new, potentially buggy features behind the ''Experimental'' option. The functionality included under this by this vary over time, as experimental features are determined to be stable and no longer require the option. To enable this, uncomment the relevant line in the configuration:<br />
<br />
{{hc|/etc/bluetooth/main.conf|2=<br />
# Enables experimental features and interfaces.<br />
# Defaults to false.<br />
Experimental = true<br />
}}<br />
<br />
Alternatively, you can [[edit]] the {{ic|bluetooth.service}} to add the {{ic|--experimental}} flag, like this [[drop-in file]]:<br />
<br />
{{hc|/etc/systemd/system/bluetooth.service.d/override.conf|2=<br />
[Service]<br />
ExecStart=<br />
ExecStart=/usr/lib/bluetooth/bluetoothd --experimental<br />
}}<br />
<br />
Then [[restart]] the {{ic|bluetooth.service}}.<br />
<br />
== See also ==<br />
<br />
* [https://averylarsen.com/2019/12/20/keeping-bluetooth-devices-paired-between-linux-and-windows/ Keeping Bluetooth devices paired between Linux and Windows]<br />
* [https://nullroute.eu.org/~grawity/bluetooth-key-sharing.html Bluetooth link keys on dual-boot systems]</div>WinstonHo