Bluetooth headset: Difference between revisions

From ArchWiki
m (→‎Gnome with GDM: link to existing section)
(→‎Disable PipeWire HSP/HFP profile: update configuration syntax for wireplumber 0.5)
 
(395 intermediate revisions by more than 100 users not shown)
Line 3: Line 3:
[[ja:Bluetooth ヘッドセット]]
[[ja:Bluetooth ヘッドセット]]
[[ru:Bluetooth headset]]
[[ru:Bluetooth headset]]
[[zh-hans:Bluetooth headset]]
{{Related articles start}}
{{Related articles start}}
{{Related|Bluetooth}}
{{Related|Bluetooth}}
{{Related|Bluez4}}
{{Related articles end}}
{{Related articles end}}


Currently, Arch Linux supports the A2DP profile (Audio Sink) for remote audio playback with the default installation.  
There are three Bluetooth audio systems:
* A2DP (advanced audio distribution) provides music-grade stereo output (sink), typically without input (source).
** A2DP can use a variety of codecs. The standard SBC has a poor quality-bitrate tradeoff, but much better, open-source alternatives (LDAC, AptX) have become widespread.
** AVRCP is used on top of A2DP to provide playback control.
* HFP/HSP (hands-free/headset) provides voice-grade mono output and input. HFP builds on top of HSP.
* LE Audio is a low-energy audio standard announced in 2020. The standard codec is LC3.


{{Note|1=<nowiki></nowiki>
The kernel, BlueZ 5, and PipeWire support all three profiles. Older sound servers such as PulseAudio and ALSA only support A2DP and HFP/HSP. Although Bluetooth is infamous for being unreliable[https://xkcd.com/2055/], many implementations have seen massive improvements, making it a somewhat less excruciating experience on well-established hardware like Intel Bluetooth chips.
* The most recent version of [[Bluez]] does not support the Headset/Handsfree profiles (see [https://bugs.freedesktop.org/show_bug.cgi?id=73325 this bug report] for example). This means that microphone input will not work, and also no sound output on headsets that do not support the A2DP profile. For using a headset with the Headset/Handsfree profiles, you will need to jump down to the legacy methods which require using [[AUR]] to fetch alternative packages.
 
* Bluez5 is only supported by [[PulseAudio]] and not by [[ALSA]]. If you do not want to use PulseAudio, you need to install an older Bluez version from the AUR.
== Headset via PipeWire ==
}}
 
[[PipeWire]] acts as a drop-in replacement for [[PulseAudio]] and offers an easy way to set up Bluetooth headsets. It includes out-of-the-box support for A2DP sink profiles using SBC/SBC-XQ, AptX, LDAC or AAC codecs, and HFP/HSP.
 
[[Install]] {{Pkg|pipewire-pulse}} (which replaces {{Pkg|pulseaudio}} and {{Pkg|pulseaudio-bluetooth}}).
 
The daemon will be started automatically as a [[systemd/User|user service]]. Use {{Pkg|pavucontrol}} or your desktop environment's settings for configuration. For more information, see [[PipeWire#Bluetooth devices]].
 
=== Troubleshooting ===
 
{{Merge|PipeWire#Troubleshooting|The section on this page just links to [[Pipewire]] which has its own troubleshooting section.}}
 
==== High audio volume due to synchronization between headphones and PipeWire ====
 
Since [https://gitlab.freedesktop.org/pipewire/pipewire/-/releases/0.3.26 version 0.3.26], PipeWire uses "hardware volume" to link the volume of the headphones with the system, making it impossible to change one without the other. On some devices, this may result in the lowest possible volume being uncomfortably loud, and volume controls becoming too coarse. Hardware volume can be disabled using either WirePlumber or Pipewire Media Session.
 
===== Using WirePlumber =====
 
If it doesn't exist, create the directory {{ic|/etc/wireplumber/bluetooth.lua.d/}} to disable hardware volume system-wide, or {{ic|~/.config/wireplumber/bluetooth.lua.d}} to disable it only for your user. Then, copy {{ic|/usr/share/wireplumber/bluetooth.lua.d/50-bluez-config.lua}} to the directory you created. Edit the file, and change the line
--["bluez5.enable-hw-volume"] = true
to
["bluez5.enable-hw-volume"] = false
 
Restart the system or the PipeWire services for the changes to take effect.
 
===== Using Pipewire Media Session =====
 
If it doesn't exist, create the directory {{ic|/etc/pipewire/media-session.d/}} to disable hardware volume system-wide, or {{ic|~/.config/pipewire/media-session.d/}} to disable it only for your user. Then, copy {{ic|/usr/share/pipewire/media-session.d/bluez-monitor.conf}} to the directory you created. Edit the file, and add the line
bluez5.enable-hw-volume = false
 
Restart the system or the PipeWire services for the changes to take effect.


== Headset via Bluez5/PulseAudio ==
== Headset via Bluez5/PulseAudio ==


PulseAudio 5.x supports A2DP per default.
{{Merge|Bluetooth|Significant redundancy with general setup on Bluetooth page. Should be merged there. Headset-specific info would stay on this page.|Talk:Bluetooth#Merging general setup from Keyboard, Mouse, Headset pages}}
Make sure the following packages are [[install]]ed: {{Pkg|pulseaudio-alsa}}, {{Pkg|pulseaudio-bluetooth}}, {{Pkg|bluez}}, {{Pkg|bluez-libs}}, {{Pkg|bluez-utils}}, {{Pkg|bluez-firmware}}. Without {{Pkg|pulseaudio-bluetooth}} you won't be able to connect after the next pairing and you won't get any usable error messages.


Start the Bluetooth system:
[[Install]] the {{Pkg|pulseaudio-alsa}}, {{Pkg|pulseaudio-bluetooth}} and {{Pkg|bluez-utils}} packages, the last of which provides the {{ic|bluetoothctl}} utility.


# systemctl start bluetooth
{{Note|Before continuing, ensure that the bluetooth device is not blocked by [[rfkill]].}}
 
=== Configuration via CLI ===
 
[[Start]] {{ic|bluetooth.service}}.


Now we can use the ''bluetoothctl'' command line utility to pair and connect. For troubleshooting and more detailed explanations of ''bluetoothctl'' see the [[Bluetooth]] article. Run
Now we can use the ''bluetoothctl'' command line utility to pair and connect. For troubleshooting and more detailed explanations of ''bluetoothctl'' see the [[Bluetooth]] article. Run


  # bluetoothctl
  $ bluetoothctl


to be greeted by its internal command prompt. Then enter:
to be greeted by its internal command prompt. Then enter:


  # power on
  [bluetooth]# power on
  # agent on
  [bluetooth]# agent on
  # default-agent
  [bluetooth]# default-agent
  # scan on
  [bluetooth]# scan on


Now make sure that your headset is in pairing mode. It should be discovered shortly. For example,
Now make sure that your headset is in pairing mode. It should be discovered shortly. For example,
  [NEW] Device 00:1D:43:6D:03:26 Lasmex LBT10
  [NEW] Device 00:1D:43:6D:03:26 Lasmex LBT10
shows a device that calls itself "Lasmex LBT10" and has MAC address ''00:1D:43:6D:03:26''. We will now use that MAC address to initiate the pairing:


  # pair 00:1D:43:6D:03:26
shows a device that calls itself ''"Lasmex LBT10"'' and has MAC address ''"00:1D:43:6D:03:26"''. We will now use that MAC address to initiate the pairing:
 
  [bluetooth]# pair 00:1D:43:6D:03:26
 
After pairing, you also need to explicitly connect the device (if this does not work, try the {{ic|trust}} command below ''before'' attempting to connect):
 
[bluetooth]# connect 00:1D:43:6D:03:26
 
If you are getting a connection error {{ic|org.bluez.Error.Failed}} retry by killing existing PulseAudio daemon first:
 
$ pulseaudio -k
[bluetooth]# connect 00:1D:43:6D:03:26


After pairing, you also need to explicitly connect the device (every time?):
Finally, if you want to automatically connect to this device in the future:


  # connect 00:1D:43:6D:03:26
  [bluetooth]# trust 00:1D:43:6D:03:26


If everything works correctly, you now have a separate output device in [[PulseAudio]].
If everything works correctly, you now have a separate output device in [[PulseAudio]].
{{Note|The device may be off by default. Select it's audio profile (''OFF'', A2DP, HFP) in the "Configuration" tab of {{Pkg|pavucontrol}}.}}
 
{{Note|The device may be off by default. Select its audio profile ({{ic|OFF}}, {{ic|A2DP}}, {{ic|HFP}}) in the "Configuration" tab of {{Pkg|pavucontrol}}.}}
 
You can now redirect any audio through that device using the "Playback" and "Recording" tabs of {{Pkg|pavucontrol}}.
You can now redirect any audio through that device using the "Playback" and "Recording" tabs of {{Pkg|pavucontrol}}.


You can now disable scanning again and exit the program:
You can now disable scanning again and exit the program:
  # scan off
 
  # exit
  [bluetooth]# scan off
  [bluetooth]# exit
 
==== Setting up auto connection ====
 
To make your headset auto connect you need to enable PulseAudio's switch-on-connect module. Do this by adding the following lines to {{ic|/etc/pulse/default.pa}}:
 
{{hc|/etc/pulse/default.pa|
### Automatically switch to newly-connected devices
load-module module-switch-on-connect
}}
 
{{Note|Make sure that your bluetooth audio device is ''trusted'', otherwise repeated pairing will fail. See [[Bluetooth#Pairing]] for details.}}
 
=== Configuration via GNOME Bluetooth ===
 
{{Note| The A2DP profile will not activate using this method with pulseaudio 9/10 due to an ongoing bug, leading to possible low quality mono sound. See [[#A2DP not working with PulseAudio]] for a possible solution.}}
 
You can use [[Bluetooth#Graphical|GNOME Bluetooth]] graphical front-end to easily configure your bluetooth headset.
 
First, you need to be sure that {{ic|bluetooth.service}} systemd unit is running.
 
Open GNOME Bluetooth and activate the bluetooth. After scanning for devices, you can connect to your headset selecting it on the device list. You can directly access to sound configuration panel from the device menu. On the sound panel, a new sink should appear when your device is connected.
 
=== LDAC/aptX ===
 
[[Wikipedia:LDAC_(codec)|LDAC]]/[[Wikipedia:aptX|aptX]] codecs are supported as of [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/15.0/#supportforldacandaptxbluetoothcodecsplussbcxqsbcwithhigher-qualityparameters PulseAudio 15.0]. You can verify the codec you are using for connection as follows:
 
$ pactl list | grep a2dp_codec


=== Troubleshooting ===
=== Troubleshooting ===


Many users report frustration with getting A2DP/Bluetooth Headsets to work.  
{{Note|Many users report frustration with getting A2DP/Bluetooth Headsets to work. see [[#Switch between HSP/HFP and A2DP setting]] for additional information.}}
 
==== Bad sound / Static noise / "Muddy" sound ====
 
If you experience bad sound quality with your headset, it could in all likelihood be because your headset is not set to the correct profile.
See [[#Switch between HSP/HFP and A2DP setting]] to solve the problem.
 
If you suspect the bad sound quality is due to a poor bluetooth connection, you might compensate for it by switching to a lower bit-rate and lower audio quality codec such as SBC or aptX using {{ic|pactl}}:
 
$ pactl send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec '"sbc"'
 
where a list of available codecs can be obtained by:
 
$ pactl send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez list-codecs


==== Selected audio profile, but headset inactive and audio cannot be redirected ====
==== Selected audio profile, but headset inactive and audio cannot be redirected ====
Line 61: Line 152:
Deceptively, this menu is available before the device has been connected; annoyingly it will have no effect. The menu seems to be created as soon as the receiver recognizes the device.
Deceptively, this menu is available before the device has been connected; annoyingly it will have no effect. The menu seems to be created as soon as the receiver recognizes the device.


Make sure to run bluetoothctl (with sudo/as root) and connect the device manually. There may be configuration options to remove the need to do this each time, but neither pairing nor trusting induce automatic connecting for me.
Make sure to run {{ic|bluetoothctl}} as root and connect the device manually. There may be configuration options to remove the need to do this each time, but neither pairing nor trusting induce automatic connecting for me.


==== Pairing fails with AuthenticationFailed ====
==== Pairing fails with AuthenticationFailed ====


If pairing fails, you can try [https://stackoverflow.com/questions/12888589/linux-command-line-howto-accept-pairing-for-bluetooth-device-without-pin disabling SSPMode] with:
If pairing fails, you can try enabling or [https://stackoverflow.com/questions/12888589/linux-command-line-howto-accept-pairing-for-bluetooth-device-without-pin disabling SSPMode] with:
  # hciconfig hci0 sspmode 0
 
  # btmgmt ssp off
 
or
 
# btmgmt ssp on
 
You may need to turn off BlueTooth while you run this command.


==== Pairing works, but connecting does not ====
==== Pairing works, but connecting does not ====
Line 76: Line 174:
  Failed to connect: org.bluez.Error.Failed
  Failed to connect: org.bluez.Error.Failed


To further investigate, have a look at the log via one of the following commands:
To further investigate, check the [[unit status]] of {{ic|bluetooth.service}} or have a look at the log as follows:


# systemctl status bluetooth
  # journalctl -n 20
  # journalctl -n 20


Line 86: Line 183:


This may be due to the {{Pkg|pulseaudio-bluetooth}} package not being installed. Install it if it missing, then restart pulseaudio.
This may be due to the {{Pkg|pulseaudio-bluetooth}} package not being installed. Install it if it missing, then restart pulseaudio.
It can also be due to permission, especially if starting pulseaudio as root allows you to connect. Add your user to the ''lp'' group, then restart pulseaudio.
See {{ic|/etc/dbus-1/system.d/bluetooth.conf}} for reference.


If the issue is not due to the missing package, the problem in this case is that PulseAudio is not catching up. A common solution to this problem is to restart PulseAudio. Note that it is perfectly fine to run ''bluetoothctl'' as root while PulseAudio runs as user. After restarting PulseAudio, retry to connect. It is not necessary to repeat the pairing.
If the issue is not due to the missing package, the problem in this case is that PulseAudio is not catching up. A common solution to this problem is to restart PulseAudio. Note that it is perfectly fine to run ''bluetoothctl'' as root while PulseAudio runs as user. After restarting PulseAudio, retry to connect. It is not necessary to repeat the pairing.
Line 95: Line 195:
The same load-module command can be added to {{ic|/etc/pulse/default.pa}}.
The same load-module command can be added to {{ic|/etc/pulse/default.pa}}.


If that still does not work, or you are using PulseAudio's system-wide mode, also load the following PulseAudio modules (again these can be loaded via your default.pa or system.pa):
If that still does not work, or you are using PulseAudio's system-wide mode, also load the following PulseAudio modules (again these can be loaded via your {{ic|default.pa}} or {{ic|system.pa}}):


  module-bluetooth-policy
  module-bluetooth-policy
Line 101: Line 201:
  module-bluez5-discover
  module-bluez5-discover


To have your headset auto connect you need to enable PulseAudio's switch-on-connect module. Add the following:
It is also possible there are no write [[permissions]] for the owner of {{ic|/var/lib/bluetooth/}}. If this is the case, you may get the device to work by removing and re-pairing it, but the issue will return after rebooting. Restoring write permissions fixes this issue:
{{hc|/etc/pulse/default.pa|
 
# automatically switch to newly-connected devices
# chmod -R u+w /var/lib/bluetooth
load-module module-switch-on-connect
 
}}
==== Connecting works, but there are sound glitches all the time ====
 
This is very likely to occur when the Bluetooth and the WiFi share the same chip as they share the same physical antenna and possibly band range (2.4GHz). Although this works seamlessly on Windows, this is not the case on Linux.
 
A possible solution is to move your WiFi network to 5GHz so that there will be no interference. If your card/router does not support this, you can upgrade your WiFi drivers/firmware.  
 
If nothing of the previous is possible, a less effective mitigation is to tweak the fragment size and the latency on PulseAudio output port, trying to compensate interference. Reasonable values must be chosen, because these settings can make the audio out of sync (e.g. when playing videos). To change the latency of the bluetooth headset's port (e.g. to 125000 microseconds in the following example):
 
$ pactl set-port-latency-offset <bluez_card> headset-output '''125000'''
 
where the identifier of the card can be found with
 
$ pacmd list-sinks | grep -Eo 'bluez_card[^>]*'


You then need to tell ''bluetoothctl'' to trust your Bluetooth headset, or you will see errors like this:
The fragment size can be set in {{ic|/etc/pulse/daemon.conf}} and takes effect after a restart of PulseAudio (for more details please see [[PulseAudio/Troubleshooting#Setting the default fragment number and buffer size in PulseAudio]]).
bluetoothd[487]: Authentication attempt without agent
bluetoothd[487]: Access denied: org.bluez.Error.Rejected


[bluetooth]# trust 00:1D:43:6D:03:26
Perhaps it will help to add {{ic|1=options ath9k btcoex_enable=1}} to the {{ic|/etc/modprobe.d/ath9k.conf}} (with the appropriate bluetooth adapter):


After a reboot, your Bluetooth adapter will not power on by default. You need to add a udev rule to power it on:
{{hc|1=/etc/modprobe.d/ath9k.conf|2=
{{hc|/etc/udev/rules.d/10-local.rules|2=
# possibly fix for sound glitches
# Set bluetooth power up
options ath9k btcoex_enable=1
ACTION=="add", SUBSYSTEM=="bluetooth", KERNEL=="hci[0-9]*", RUN+="/usr/bin/hciconfig %k up"
}}
}}


==== Connecting works, but I cannot play sound ====
Then restart.
 
==== Connecting works, but there is no sound ====


Make sure that you see the following messages in your system log:
Make sure that you see the following messages in your system log:
Line 128: Line 239:
If you see a message similar to this, you can go on and investigate your PulseAudio configuration. Otherwise, go back and ensure the connection is successful.
If you see a message similar to this, you can go on and investigate your PulseAudio configuration. Otherwise, go back and ensure the connection is successful.


When using [[GDM]], another instance of PulseAudio is started, which "captures" your bluetooth device connection. This can be prevented by creating or updating a configuration file:
{{Merge|PulseAudio/Troubleshooting|2=The following seems to be general issue: [https://wiki.archlinux.org/index.php?title=PulseAudio/Troubleshooting&diff=next&oldid=421986]}}


{{hc|/var/lib/gdm/.pulse/client.conf|2=
When using [[GDM]], another instance of PulseAudio is started, which "captures" your bluetooth device connection. This can be prevented by [[mask]]ing the pulseaudio socket for the GDM user by doing the following:
autospawn = no
 
daemon-binary = /bin/true
# mkdir -p  /var/lib/gdm/.config/systemd/user
# ln -s /dev/null  /var/lib/gdm/.config/systemd/user/pulseaudio.socket
 
On next reboot the second instance of PulseAudio will not be started.
 
It may happen that bluez wrongly considers an headset as not a2dp capable. In this case, search the index of the bluetooth device with
 
$ pacmd ls
 
Among the output there should be a section related to the bluetooth headset, containing something similar to
 
{{hc|1=$ pacmd ls|2=
index: 2
        name: <bluez_card.XX_XX_XX_XX_XX_XX>
        driver: <module-bluez5-device.c>
        owner module: 27
        properties:
                device.description = "SONY MDR-100ABN"
                device.string = "XX:XX:XX:XX:XX:XX"
                device.api = "bluez"
                device.class = "sound"
                ...
}}
 
To manually set the profile, run
 
$ pacmd set-card-profile 2 a2dp_sink
 
where 2 is the index of the device retrieved through {{ic|pacmd ls}}.
 
==== Connecting works, but the device does not show up in PulseAudio sinks ====
 
If the headphones connect successfully (which can be [[Bluetooth#Pairing|confirmed]] via {{ic|bluetoothctl}}) but do not show up as an output/input sink in {{ic|pavucontrol}}, you can try adding the following policy to your Bluetooth configuration file {{ic|/etc/bluetooth/main.conf}}:
 
{{hc|/etc/bluetooth/main.conf|2=
[General]
Enable=Control,Gateway,Headset,Media,Sink,Socket,Source
}}
 
Some users [https://bbs.archlinux.org/viewtopic.php?id=234790 report] that this has solved their problem.
 
==== Connecting works, sound plays fine until headphones become idle, then stutters ====
 
If the headphones play sound correctly until they become idle and then stutter on resume (e.g. because the sound is paused, or because no sound is played for a while), try disabling PulseAudio's automatic sink/source suspension on idle.
 
Some user [https://bbs.archlinux.org/viewtopic.php?id=117420 reports] huge delays or even no sound when the Bluetooth connection does not send any data. This is due to the {{ic|module-suspend-on-idle}} module, which automatically suspends sinks/sources on idle. As this can cause problems with headset, the responsible module can be deactivated.
 
To disable loading of the {{ic|module-suspend-on-idle}} module, comment out the following line in the configuration file in use ({{ic|~/.config/pulse/default.pa}} or {{ic|/etc/pulse/default.pa}}):
 
{{hc|~/.config/pulse/default.pa|
### Automatically suspend sinks/sources that become idle for too long
#load-module module-suspend-on-idle
}}
}}


Make sure the file is created with {{ic|gdm:gdm}} permissions, use [[chown]] if necessary. The problem will be fixed at the next reboot.
Finally restart PulseAudio to apply the changes.


==== UUIDs has unsupported type ====
==== UUIDs has unsupported type ====
Line 145: Line 307:
This message is a very common one and can be ignored.
This message is a very common one and can be ignored.


== Legacy method: ALSA-BTSCO ==
==== PC shows device as paired, but is not recognized by device ====
 
This might be due to the device not supporting bluetooth LE for pairing.
 
Try setting {{ic|1=ControllerMode = bredr}} in {{ic|/etc/bluetooth/main.conf}}. See [https://unix.stackexchange.com/questions/292189/pairing-bose-qc-35-over-bluetooth-on-fedora].
 
==== Device connects, then disconnects after a few moments ====
 
If you see messages like the following in the [[journal]], and your device fails to connect or disconnects shortly after connecting:
 
bluetoothd: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
bluetoothd: connect error: Connection refused (111)
 
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 adapter).  You can fix this by re-pairing the device.  Start by removing the device:


{{Out of date|Instructions rely on [[bluez4]].}}
$ bluetoothctl
[bluetooth]# devices
Device XX:XX:XX:XX:XX:XX My Device
[bluetooth]# remove XX:XX:XX:XX:XX:XX


It is much easier to set up your bluetooth headset today, with bluez >= 3.16. You may want to try the out-of-box python script in [http://fosswire.com/2008/01/11/a2dp-stereo-linux/ this blog] (you need edit the script to work with gconftool-2). There is also a piece of equivalent bash script [http://lymanrb.blogspot.com/2008/05/linux.html here].
Then [[restart]] {{ic|bluetooth.service}}, turn on your bluetooth adapter, make your device discoverable, re-scan for devices, and re-pair your device. Depending on your bluetooth manager, you may need to perform a full reboot in order to re-discover the device.


You need your headset's bdaddr. It is of the form ''12:34:56:78:9A:BC''. Either find it in the documentation of your headset, on the headset itself or with the '''hcitool scan''' command.
==== Apple AirPods have low volume ====


Install {{AUR|btsco}}{{Broken package link|{{aur-mirror|btsco}}}}.
Create a [[drop-in file]] for {{ic|bluetooth.service}} with the following contents:


To load the kernel module, type:
{{hc|/etc/systemd/system/bluetooth.service.d/noplugin-avrc.conf|2=
# modprobe snd-bt-sco
[Service]
There will now be an extra audio device. Use {{ic|alsamixer -cN}} (where N is most likely 1) to set the volume. You can access the device with any alsa-capable application by choosing the device ''BT headset'', or with any OSS application by using {{ic|/dev/dspN}} as the audio device.
ExecStart=
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=avrcp
}}


But to actually get any sound, you have to connect your headset to the computer first.
Then, [[restart]] {{ic|bluetooth.service}}, [[reload]] its configuration, and reconnect your headset.


=== Connecting the headset ===
Additionally, for AirPods Pro, disable the spatial audio and enable Mono in the settings of your iPhone.


If you connect your headset for the first time, read the section about pairing first. To connect to your headset to the computer, use the command
This can also solve issues with some devices that are unable to be controlled through AVRCP.
$ btsco -f <bdaddr>
for example
$ btsco -f 12:34:56:78:9A:BC


==== Pairing the headset with your computer ====
==== Apple AirPods Pro working with PulseAudio as A2DP Sink but not with HSP/HFP ====


The first time you connect the headset, you have to pair it with the computer. To do this, you need your headset's PIN. Depending on your headset you may have to reset the headset and repeat the pairing everytime you used the headset with another bluetooth device.
If you find that AirPods Pro are working with PulseAudio, but are incapable of using the HSP/HFP configurations (in ''pavucontrol''<nowiki/>'s ''Configurations'' tab, usually listed as unavailable), try switching to {{Pkg|pipewire-pulse}}.


There are two ways to pair your headset with the computer:
Note that switching to ''pipewire-pulse'' (and restarting your computer or the appropriate user-level ''systemd'' services) should enable HSP/HFP, but may also disable A2DP. (When selecting ''A2DP Sink'' in the ''Configurations'' tab, the option is instantly deselected and becomes ''Off''.) If you encounter this issue, try removing/renaming the {{ic|/var/lib/bluetooth}} folder like so:


===== Using ''bluez-gnome'' =====
# mv /var/lib/bluetooth /var/lib/bluetooth.bak


{{Out of date|Package does no longer exist in the repositories.}}
Re-pair your AirPods Pro (and other devices) afterwards. This should make all configurations (HSP/HFP and A2DP) available again and easily accessible from ''pavucontrol'' and ''pacmd''.


Install the ''bluez-gnome'' package from the community repository. Then start the '''bt-applet''' program. Once you try to connect to the headset, a window will open and ask for the PIN.
==== HSP problem: the bluetooth sink and source are created, but no audio is being transmitted ====


===== Using ''passkey-agent'' =====
You may be missing firmware or the SCO (audio protocol of HSP and HFP) routing might be wrong. See [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index10h3] - the firmware for BCM20702 can be installed via {{AUR|bcm20702a1-firmware}} or {{AUR|bcm20702b0-firmware}}.


Before connecting to the headset, enter the command
==== Error: Failed to start discovery org.bluez.Error.InProgress ====
$ passkey-agent --default <pin>
where ''<pin>'' is your headset's PIN. Then try to connect to the headset.


=== Headset and ALSA Devices ===
If your headset is discovered, but fails to connect with the error "Failed to start discovery org.bluez.Error.InProgress", install {{AUR|bluez-hciconfig}}{{Broken package link|package not found}} and run


1. First if you have not already, [[pacman|install]] {{Pkg|bluez}} from the [[official repositories]].
$ hciconfig hci''X'' up
$ hciconfig hci''X'' reset


2. Scan for your device
where ''X'' is the identifier of your computer's bluetooth device (typically 0).
$ hcitool (-i <optional hci#>***) scan


3. Pair your headset with your device:
You should then be able to connect following the steps in [[#Configuration via CLI]].
$ bluez-simple-agent (optional hci# ***) XX:XX:XX:XX:XX:XX
and put in your pin (0000 or 1234, etc)


4. Make sure your {{ic|/etc/bluetooth/audio.conf}} allows A2DP Audio Sinks. Place this line just bellow the [General] heading:
==== High audio volume due to synchronization between headphones and PulseAudio ====
Enable=Source,Sink,Media,Socket


5. Add this to your {{ic|/etc/asound.conf}} file:
As of [https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/15.0/#supportforbluetootha2dpavrcpabsolutevolume PulseAudio 15], "Absolute Volume" interlocks the audio volume of your headphones with PulseAudio, making it impossible to change one without the other. On some headphones, e.g. on the Hoco W25, this may result in irritating loudness. To disable "Absolute Volume", edit {{ic|/etc/pulse/default.pa}} and change the line
#/etc/asound.conf
  load-module module-bluetooth-discover
to
pcm.btheadset {
   load-module module-bluetooth-discover avrcp_absolute_volume=false
    type plug
    slave {
        pcm {
            type bluetooth
            device XX:XX:XX:XX:XX:XX
            profile "auto"
        } 
    }    
    hint {
        show on
        description "BT Headset"
    } 
}
ctl.btheadset {
  type bluetooth


6. Check to see if it has been added to alsa devices
== Switch between HSP/HFP and A2DP setting ==
$ aplay -L


7. Now play with aplay:
This can easily be achieved by the following command where the {{ic|''card_number''}} can be obtained by running {{ic|pacmd list-cards}}.
$ aplay -D btheadset /path/to/audio/file


or Mplayer:
  $ pacmd set-card-profile ''card_number'' a2dp_sink
  $ mplayer -ao alsa:device=btheadset /path/to/audio/or/video/file


{{Tip|To find hci# for a usb dongle, type in
For enabling automatic profile switching from A2DP to HSP when a recording stream appears without any role set, you can append {{ic|1=auto_switch=2}} to {{ic|load-module module-bluetooth-policy}} in {{ic|/etc/pulse/default.pa}}.
  $ hcitool dev
 
}}
For more information about PulseAudio profiles, see [https://freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index1h2 PulseAudio Documentation].
 
=== A2DP not working with PulseAudio ===
 
==== Socket interface problem ====
 
If PulseAudio fails when changing the profile to A2DP with bluez 4.1+ and PulseAudio 3.0+, you can try disabling the Socket interface from {{ic|/etc/bluetooth/main.conf}} by removing the line {{ic|1=Enable=Socket}} and adding line {{ic|1=Disable=Socket}}.
 
==== A2DP sink profile is unavailable ====
 
When the A2DP sink profile is unavailable it will not be possible to switch to the A2DP sink (output) with a PulseAudio front-end and the A2DP sink will not even be listed. This can be confirmed with {{ic|pactl}}.
 
  $ pactl list | grep -C2 A2DP
      Profiles:
              headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
              a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: no)
              off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: headset_head_unit


=== Headset's multimedia buttons ===
Trying to manually set the card profile with {{ic|pacmd}} will fail.


In order to get your bluetooth headset's multimedia buttons (play, pause, next, previous) working you need to create {{ic|/etc/modules-load.d/uinput.conf}} containing {{ic|uinput}}.
$ pacmd set-card-profile bluez_card.C4_45_67_09_12_00 a2dp_sink
Failed to set card profile to 'a2dp_sink'.


== Legacy method: PulseAudio ==
This is known to happen from version 10.0 of PulseAudio when connecting to Bluetooth headphones via Bluedevil or another BlueZ front-end. See [https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/525 related bug report.]


{{Out of date|Instructions rely on [[bluez4]] (references to {{ic|/etc/bluetooth/audio.conf}} and ''bluez-simple-agent'').}}
This issue also appears after initial pairing of Headphones with some Bluetooth controllers (e.g. {{ic|0a12:0001, Cambridge Silicon Radio}}) which might default to the {{ic|Handsfree}} or {{ic|Headset - HS}} service and will not allow switching to the A2DP PulseAudio sink that requires the {{ic|AudioSink}} service.


This one is much easier and more elegant. PulseAudio will seamlessly switch between output devices when the headset is turned on. If you have ALSA as the sound server, you need the following packages installed:
Possible solutions:
{{Pkg|pulseaudio}} and {{Pkg|pulseaudio-alsa}}.


Now, to configure the audio output to use bluetooth, just install {{Pkg|pavucontrol}} and run it to configure the audio output:
* For some headsets, using the headset's volume or play/pause controls while connected can trigger the A2DP profile to become available.
$ pavucontrol
* It is possible that connecting to a headset via {{ic|bluetoothctl}} from {{pkg|bluez-utils}} will make the A2DP sink profile available. There is an automation for this every time a bluetooth device is connected: {{AUR|fix-bt-a2dp}} ([https://github.com/pastleo/fix-bt-a2dp#usage detailed usage])
Make sure to take a look at the [[PulseAudio]] wiki entry for setting up PulseAudio, especially if you are running KDE.


=== Troubleshooting ===
[bluetooth]# connect ''headset_MAC_address''


==== Audio sink fails ====
* Manually switching to Bluetooth's {{ic|AudioSink}} service which would make the A2DP profile and its A2DP PulseAudio sink available. This can be done with blueman-manager which included in {{pkg|blueman}} or by registering the UUID of the AudioSink service with {{ic|bluetoothctl}}.


Bluetooth headset is connected, but ALSA/PulseAudio fails to pick up the connected device. You will get "Audio sink fails".
$ bluetoothctl
According to [http://wiki.gentoo.org/wiki/Bluetooth_Headset gentoo wiki], you have to verify than in {{ic|/etc/bluetooth/audio.conf}} there is {{ic|<nowiki>Enable=Socket</nowiki>}} under the {{ic|[General]}} section heading.
[bluetooth]# menu gatt
[bluetooth]# register-service 0000110b-0000-1000-8000-00805f9b34fb
[bluetooth]# quit


Just do a {{ic|# systemctl restart bluetooth}} to apply it.
* Disable the headset profile


==== Page timeout issue ====
{{hc|/etc/bluetooth/main.conf|2=
[General]
Disable=Headset
}}


If you receive this error whilst trying to pair your headset with your system using bluez-simple-agent, then you can try to restart your system and use the graphical bluez applet of your desktop environment.
* Enable MultiProfile support. This may help with headsets that support A2DP as well as Headset audio.


== Legacy documentation: ALSA, bluez5 and PulseAudio method ==
{{hc|/etc/bluetooth/main.conf|2=
[General]
MultiProfile=multiple
}}


{{Accuracy|Describes two different methods, see the [[Talk:Bluetooth_Headset#bluez5_method:_overcomplicated_instructions|talk page]] for details.|Talk:Bluetooth_Headset#bluez5_method:_overcomplicated_instructions}}
* Sometimes, none of the steps above will work. You may have tried rebooting and powering bluetooth off and on to no avail. In this case, try [[restart]]ing the {{ic|bluetooth.service}}.
* For some headphone models with audio control panel, the A2DP profile must be enabled by pressing the ''Play/Pause'' button on the panel.


[[ALSA]], [[bluez|bluez5]], and [[PulseAudio]] work together to allow a wireless [[Bluetooth]] headset to play audio. The following method works with a Lenovo T61p laptop and SoundBot SB220 wireless bluetooth headset. The required software stack is extensive and failure to include all components can produce errors which are difficult to understand. The following list of software packages might not be the minimum required set and needs to be examined more closely.
==== Gnome with GDM ====


Bluez5 has a regression causing HSP/HFP Telephone profile to not be available. This regression is documented in the [http://www.freedesktop.org/wiki/Software/PulseAudio/Notes/5.0/ draft release notes for Pulseaudio 5.0] which say (in "Notes for packagers"): "PulseAudio now supports BlueZ 5, but only the A2DP profile. BlueZ 4 is still the only way to make HSP/HFP work." ([https://fedoraproject.org/wiki/Common_F20_bugs#bluez5-profile from here])
{{Merge|#Connecting works, but I cannot play sound|duplicate instructions}}


=== Install Software Packages ===
The instructions below were tested on Gnome 3.24.2 and PulseAudio 10.0 however they may still be applicable and useful for other versions.


The core software components are [[ALSA]], Bluez5, [[PulseAudio]]. However there are additional libraries which are required. As well as a player which can play audio files. The following section lists the software packages installed in order to connect the headset and play audio over the headset.
If PulseAudio fails when changing the profile to A2DP while using GNOME with GDM, you need to prevent GDM from starting its own instance of PulseAudio:


==== Install ALSA and associated libraries ====
* Prevent PulseAudio clients from automatically starting a server if one is not running by adding the following:


[[ALSA]] works with the linux kernel to provide audio services to user mode software. The following packages are used with the [[Bluetooth]] headset: {{Pkg|alsa-utils}}, {{Pkg|alsa-plugins}}, {{Pkg|alsa-tools}}.
{{hc|/var/lib/gdm/.config/pulse/client.conf|2=
autospawn = no
daemon-binary = /bin/true
}}


==== Install Bluez5 ====
* Prevent systemd from starting PulseAudio anyway with socket activation:


Bluez5 is the latest [[Bluetooth]] stack. It is required for [[PulseAudio]] to interface with wireless headsets. Required packages: {{Pkg|bluez}}, {{Pkg|bluez-utils}}, {{Pkg|bluez-libs}}.
$ sudo -ugdm mkdir -p /var/lib/gdm/.config/systemd/user
$ sudo -ugdm ln -s /dev/null /var/lib/gdm/.config/systemd/user/pulseaudio.socket


==== Install Audacious ====
* Restart, and check that there is no PulseAudio process for the {{ic|gdm}} user using:


[[Audacious]] is a program which plays audio files. It can work directly with [[ALSA]] or with [[PulseAudio]]. Required packages: {{Pkg|audacious}}, {{Pkg|audacious-plugins}}.
$ pgrep -u gdm pulseaudio


=== Procedure ===
Further discussion about this problem and alternative fixes can be found at [https://bbs.archlinux.org/viewtopic.php?id=194006] and [https://bbs.archlinux.org/viewtopic.php?id=196689]. Alternatively, one may try and install {{AUR|fix-bt-a2dp}}.


Once the required packages are installed, use this procedure to play audio with a bluetooth headset. The high level overview of the procedure is to pair the headset, connect the headset, configure the player and pulse audio controller and then play audio.
=== HFP not working with PulseAudio ===


Start the bluetooth service as root:
{{Note|Some users have reported success in enabling HFP support by replacing PulseAudio with PipeWire for Bluetooth support. [https://www.reddit.com/r/archlinux/comments/w69mij/hfp_audio_is_no_longer_available_stuck_on/] See [[#Headset via PipeWire]] for installation instructions.}}
# systemctl start bluetooth


Verify Bluetooth is started
HFP-only bluetooth headsets may not be usable in the standard configuration of PulseAudio. The respective profiles occur, but they are not available:
# systemctl status bluetooth
bluetooth.service - Bluetooth service
  Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; disabled)
  Active: active (running) since Sat 2013-12-07 12:31:14 PST; 12s ago
    Docs: man:bluetoothd(8)
Main PID: 3136 (bluetoothd)
  Status: "Running"
  CGroup: /system.slice/bluetooth.service
          └─3136 /usr/lib/bluetooth/bluetoothd
Dec 07 12:31:14 t61p systemd[1]: Starting Bluetooth service...
Dec 07 12:31:14 t61p bluetoothd[3136]: Bluetooth daemon 5.11
Dec 07 12:31:14 t61p systemd[1]: Started Bluetooth service.
Dec 07 12:31:14 t61p bluetoothd[3136]: Starting SDP server
Dec 07 12:31:14 t61p bluetoothd[3136]: Bluetooth management interface 1.3 i...ed
Hint: Some lines were ellipsized, use -l to show in full.


Start the PulseAudio daemon.  This must be done after X windows is started and as a normal user.
{{hc|bluetoothctl info|
$ pulseaudio -D
UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Handsfree                (0000111e-0000-1000-8000-00805f9b34fb)
}}


Verify the PulseAudio daemon is running.
{{hc|pactl list|
$ pulseaudio --check -v
...
I: [pulseaudio] main.c: Daemon running as PID 3186
Profiles:
      ...
      headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: no)
}}


Start up bluetoothctl as root and pair and connect your headset. As a regular user, bluetoothctl will pair but not connect. Perhaps this is related to the config file (shown below) which is setup for what appears to be the root user.
To solve the respective issue, update PulseAudio and BlueZ to latest versions. Then [[install]] {{AUR|ofono}} and {{AUR|phonesim}} then create / activate a fake modem as described here [https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index1h3]:
Note: the procedure shown below is for an initial pair and connect of the headphone. If the headset is already paired, then the procedure below can be shortened to: power on, agent on, default-agent, connect <mac address>. The mac address can be seen from the devices command output.


  $ bluetoothctl
{{Note|The steps following the creation of {{ic|phonesim.conf}} should be done ''every time'' you want to connect the headset.}}
  [NEW] Controller 00:1E:4C:F4:98:5B t61p-0 [default]
  [NEW] Device 00:1A:7D:12:36:B9 SoundBot SB220
  [bluetooth]# show
  Controller 00:1E:4C:F4:98:5B
        Name: t61p
        Alias: t61p-0
        Class: 0x000000
        Powered: no
        Discoverable: no
        Pairable: yes
        UUID: PnP Information          (00001200-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        Modalias: usb:v1D6Bp0246d050B
        Discovering: no
  [bluetooth]# power on
  [CHG] Controller 00:1E:4C:F4:98:5B Class: 0x0c010c
  Changing power on succeeded
  [CHG] Controller 00:1E:4C:F4:98:5B Powered: yes
  [bluetooth]# agent on
  Agent registered
  [bluetooth]# default-agent
  Default agent request successful


<power on your headset in pairing mode. Eventually you will see what appears to be a mac address.>
* Create {{ic|/etc/ofono/phonesim.conf}} with:
  [bluetooth]# scan on
  Discovery started
  [CHG] Controller 00:1E:4C:F4:98:5B Discovering: yes
  [CHG] Device 00:1A:7D:12:36:B9 RSSI: -61
  [bluetooth]# pair 00:1A:7D:12:36:B9
  Attempting to pair with 00:1A:7D:12:36:B9
  [CHG] Device 00:1A:7D:12:36:B9 Connected: yes
  [CHG] Device 00:1A:7D:12:36:B9 UUIDs has unsupported type
  [CHG] Device 00:1A:7D:12:36:B9 Paired: yes
  Pairing successful
  [bluetooth]# connect 00:1A:7D:12:36:B9
  [CHG] Device 00:1A:7D:12:36:B9 Connected: yes
  Connection successful
  [bluetooth]# info 00:1A:7D:12:36:B9
  Device 00:1A:7D:12:36:B9
        Name: SoundBot SB220
        Alias: SoundBot SB220
        Class: 0x240404
        Icon: audio-card
        Paired: yes
        Trusted: no
        Blocked: no
        Connected: yes
        LegacyPairing: yes
        UUID: Headset                  (00001108-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: Handsfree                (0000111e-0000-1000-8000-00805f9b34fb)


Start up alsamixer, for simplicity un-mute all your outputs. Oddly enough some can be muted though. The ones I had muted during playback were:
[phonesim]
* Headphones
Address=127.0.0.1
* SPIDF
Driver=phonesim
Port=12345


Start up audacious. Use the menu to select PulseAudio as your output. Somewhere I read that bluez5 requires pulseaudio-git and this jives with my experience.
* Start as user:


Start up pavucontrol in a terminal. In the Outputs tab select the bluetooth headset.
$ phonesim -p 12345 /usr/share/phonesim/default.xml &


[http://netskink.blogspot.com/2013/12/pulseaudio-pavucontrol-and-audacious.html screenshot of application settings]
* [[Enable/start]] the {{ic|ofono.service}}.
* Power modem:


==== Miscellaneous configuration files ====
$ dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Powered" variant:boolean:true


For reference, these settings were also done.
* Activate modem:


===== ALSA /etc/asound.conf =====
$ dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Online" variant:boolean:true


The settings shown at the top of this page was used, but the additional modification for Intel laptop sound cards.
* To check the results, use the test commands from {{AUR|ofono}} installed in {{ic|/usr/lib/ofono/test/}}. To power, activate, and test the modem you can use:


{{bc|<nowiki>
$ /usr/lib/ofono/test/enable-modem /phonesim
pcm.btheadset {
$ /usr/lib/ofono/test/online-modem /phonesim
  type plug
$ /usr/lib/ofono/test/list-modems
  slave {
    pcm {
      type bluetooth
      device 00:1A:7D:12:36:B9
      profile "auto"
    }
  }
  hint {
    show on
    description "BT Headset"
  }
}
ctl.btheadset {
  type bluetooth
}
options snd-hda-intel model=laptop
</nowiki>}}


===== /etc/dbus-1/system.d/bluetooth.conf =====
The output of the respective modem section should read like this:


The settings here seem to be enabled for root onlySee the policy user="root" section. However, if a regular user is specified here, the system fails to start. Someone with more knowledge could explain why.
...
  [ /phonesim ]
  Online = 1
  Powered = 1
  Lockdown = 0
  Emergency = 0
  Manufacturer = MeeGo
  ...


{{hc|/etc/dbus-1/system.d/bluetooth.conf|<nowiki>
* Finally, restart PulseAudio and reconnect headset. Now, HFP should be available:
<!-- This configuration file specifies the required security policies for Bluetooth core daemon to work. -->


<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>


  <!-- ../system.conf have denied everything, so we just punch some holes -->
{{Note|HFP support is not stable and may cause glitches with switching to A2DP; try reconnecting, if the needed mode is not available.}}


  <policy user="root">
=== Disable PulseAudio auto switching headset to HSP/HFP ===
    <allow own="org.bluez"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent1"/>
    <allow send_interface="org.bluez.MediaEndpoint1"/>
    <allow send_interface="org.bluez.MediaPlayer1"/>
    <allow send_interface="org.bluez.ThermometerWatcher1"/>
    <allow send_interface="org.bluez.AlertAgent1"/>
    <allow send_interface="org.bluez.Profile1"/>
    <allow send_interface="org.bluez.HeartRateWatcher1"/>
    <allow send_interface="org.bluez.CyclingSpeedWatcher1"/>
  </policy>


  <policy at_console="true">
When using a bluetooth headset that supports multiple profiles, some applications switch to HSP/HFP profile automatically. If this behaviour is undesired you can disable this by appending the auto_switch=false parameter to the bluetooth-policy module:
    <allow send_destination="org.bluez"/>
  </policy>


  <!-- allow users of lp group (printing subsystem) to communicate with bluetoothd -->
{{hc|/etc/pulse/default.pa|2=
  <policy group="lp">
load-module module-bluetooth-policy auto_switch=false
    <allow send_destination="org.bluez"/>
}}
  </policy>


  <policy context="default">
=== Disable PipeWire HSP/HFP profile ===
    <deny send_destination="org.bluez"/>
  </policy>


</busconfig>
Unlike PulseAudio, [[PipeWire#Automatic profile selection|PipeWire does not automatically switch between A2DP and HSP/HFP]] in response to input events. However, rather than to enable automatically switching to the (lower audio quality) HSP/HFP profile if A2DP fails, you may prefer to disable the former altogether. To do so, create or edit a bluez configuration as shown below.
</nowiki>}}


===== Tested applications =====
{{Note|HSP mode is required for built-in microphones to work [https://www.reddit.com/r/pop_os/comments/otofgt/bluetooth_headphone_switches_to_hsphfp_when/].}}


As noted above this will work easily with audacious. YouTube videos with Chromium and Flash Player will work on some videos. If the video has ads it will not work, but if the video does not have ads it will work. Just make sure that after audacious is working with Bluetooth headset, start Chromium, and navigate to YouTube. Find a video without leading ads, and it should play the audio. If the settings icon has the a menu with two drop-down combo boxes for Speed and Quality it will play.
{{hc|/etc/wireplumber/wireplumber.conf.d/50-bluez.conf (or ~/.config/wireplumber/wireplumber.conf.d/50-bluez.conf)|2=
monitor.bluez.rules = [
  {
    matches = [
      {
        ## This matches all bluetooth devices.
        device.name = "~bluez_card.*"
      }
    ]
    actions = {
      update-props = {
        bluez5.auto-connect = [ a2dp_sink ]
        bluez5.hw-volume = [ a2dp_sink ]
      }
    }
  }
]


== Switch between HSV and A2DP setting ==
monitor.bluez.properties = {
  bluez5.roles = [ a2dp_sink ]
  bluez5.hfphsp-backend = "none"
}
}}


This can easily be achieved by the following command where 2 needs to be changed with the correct device number.
=== Alternative: A2DP duplex channel ===


pacmd set-card-profile 2 a2dp_sink
FastStream, AptX LL, and "Opus 05 Pro" ([https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/1322 a pipewire invention]) have a "duplex" channel that allows for sending microphone audio back without needing to go into HSP/HFP and tolerate the sound quality degradation. PipeWire, but not PulseAudio, has support for this feature. Support is automatic upon feature detection. Interaction with existing profile switcher (WirePlumber) is unknown.


=== A2DP not working with PulseAudio ===
== Tips and tricks ==


==== Socket interface problem ====
The following applies to both PipeWire and PulseAudio.


If PulseAudio fails when changing the profile to A2DP with bluez 4.1+ and PulseAudio 3.0+, you can try disabling the Socket interface from {{ic|/etc/bluetooth/audio.conf}} by removing the line {{ic|1=Enable=Socket}} and adding line {{ic|1=Disable=Socket}}.
=== Battery level reporting ===


==== Gnome with GDM ====
{{Note|This is an experimental feature. Enabling it may prevent some Bluetooth mice from connecting automatically (see [https://github.com/bluez/bluez/issues/236 GitHub issue]).}}
{{Note|Below was tested with Gnome 3.16.2 and PulseAudio 6.0}}


If PulseAudio fails when changing the profile to A2DP while using GNOME with GDM, you need to prevent GDM from starting its own instance of PulseAudio. Apply the same fix as shown in [[#Connecting works, but I cannot play sound]].
To get the current battery level of your headset reported to {{Pkg|upower}}, you must enable bluez' D-Bus experimental features as described in [[Bluetooth#Enabling experimental features]].


{{Note|1=Discussion about this problem can be found [https://bbs.archlinux.org/viewtopic.php?id=194006 here] and [https://bbs.archlinux.org/viewtopic.php?id=196689 here]}}
=== Media controls ===


== Tested headsets ==
To use the media controls they may be forwarded to MPRIS, where they can be picked up by media players that support MPRIS for external control. See [[MPRIS#Bluetooth]] for details.


{| class="wikitable"
=== AVRCP Media controls ===
! Model
! Version
! Comments
! Compatible
|-
| '''Philips SHB9150'''
| bluez5, pulseaudio 5
| Pause and resume does not work. With at least mpv and Banshee hitting the pause button stops audio output but does not pause the player.
| {{R|Limited}}
|-
| '''Philips SHB9100'''
|
| Pause and resume is flaky. See [https://bbs.archlinux.org/viewtopic.php?pid=1315428#p1315428] for the underlying issue and a temporary solution to improve audio quality.
| {{R|Limited}}
|-
| '''Philips SHB7000'''
|
| Pause and resume is flaky.
| {{R|Limited}}
|-
| '''Philips SHB7100'''
| bluez 5.32, pulseaudio 6.0
| Next/previous buttons work. Pause and resume is flaky (sometimes works in VLC, not at all in Audacious). Tested only A2DP and Handsfree audio out, built-in mic was broken.
| {{R|Limited}}
|-
| '''Philips SHB7150'''
| bluez 5.32, pulseaudio 6.0
| Next/previous buttons work. Pause and resume work in VLC. Tested only A2DP profile.
| {{Yes}}
|-
| '''Philips SHB5500BK/00'''
| bluez 5.28, PulseAudio 6.0
| Pause and resume is not working.
| {{R|Limited}}
|-
| '''Parrot Zik'''
|
| Firmware 1.04. The microphone is detected, but does not work. Sometimes it lags (but does not stutter); usually this is not noticeable unless playing games, in which case you may switch to a wired connection.
| {{R|Limited}}
|-
| '''Sony DR-BT50'''
| bluez{4,5}
| Works for a2dp, see [http://vlsd.blogspot.com/2013/11/bluetooth-headphones-and-arch-linux.html]). Adapter: D-Link DBT-120 USB dongle.
| {{Yes}}
|-
| '''Sony SBH50'''
| bluez5
| Works for a2dp, Adapter: Broadcom Bluetooth 2.1 Device (Vendor=0a5c ProdID=219b Rev=03.43). Requires the {{ic|btusb}} [[modprobe|module]].
| {{Yes}}
|-
| '''Sony MDR-XB950BT'''
| pulseaudio
| Tested a2dp. Adapter: Grand-X BT40G. Doesn't auto-connect, need to connect manually. Other functionality works fine.
| {{R|Limited}}
|-
| '''Sony MUC-M1BT1'''
| bluez5, {{AUR|pulseaudio-git}}
| Both A2DP & HSP/HFP work fine.
| {{Yes}}
|-
| '''SoundBot SB220'''
| bluez5, {{AUR|pulseaudio-git}}
|
| {{Yes}}
|-
| '''Auna Air 300'''
| bluez5, pulseaudio-git
| For some reason, a few restarts were required, and eventually it just started working.
| {{R|Limited}}
|-
| '''Sennheiser MM 400-X'''
| bluez5, pulseaudio 4.0-6
|
| {{Yes}}
|-
| '''Sennheiser MM 550-X Travel'''
| bluez 5.27-1, pulseaudio 5.0-1
| Next/Previous buttons work out-of-the-box, Play/Pause does not
| {{Yes}}
|-
| '''Audionic BlueBeats (B-777)'''
| bluez5, pulseaudio 4.0-6
|
| {{Yes}}
|-
| '''Logitech Wireless Headset'''
| bluez 5.14, pulseaudio-git
| part number PN 981-000381, advertised for use with iPad
| {{Yes}}
|-
| '''HMDX Jam Classic Bluetooth'''
| bluez, pulseaudio-git
|
| {{Yes}}
|-
| '''PT-810'''
| bluez 5.14, pulseaudio-git
| Generic USB-Powered Bluetooth Audio Receiver with 3.5mm headset jack and a2dp profile. Widely available as "USB Bluetooth Receiver." IDs as PT-810.
| {{Yes}}
|-
| '''Philips SHB4000WT'''
| bluez5
| A2DP works, HDP distorted.
| {{Yes}}
|-
| '''Philips AEA2000/12'''
| bluez5
|
| {{Yes}}
|-
| '''Nokia BH-104'''
| bluez4
|
| {{Yes}}
|-
| '''Creative AirwaveHD'''
| bluez 5.23
| Bluetooth adapter Atheros Communications usb: 0cf3:0036
| {{Yes}}
|-
| '''Creative HITZ WP380'''
| bluez 5.27, pulseaudio 5.0-1
| A2DP Profile only. Buttons work (Play, Pause, Prev, Next). Volume buttons are hardware-only. Auto-connect works but you should include the bluetooth module in "pulseaudio" to switch to it automatically. Clear HD Music Audio (This device support APTx codec but it isn't supported in linux yet). You may have some latency problems which needs pulseaudio restart.
| {{Yes}}
|-
| '''deleyCON Bluetooth Headset'''
| bluez 5.23
| Adapter: CSL - USB nano Bluetooth-Adapter V4.0. Tested a2dp profile. Untested microphone. Does not auto-connect (even when paired and trusted), must connect manually. Play/pause button mutes/unmutes the headphones, not the playback. Playback fwd/bwd buttons do not work (nothing visible with ''xev'').
| {{R|Limited}}
|-
| '''UE BOOM'''
| bluez 5.27, pulseaudio-git 5.99
| Update to latest UE BOOM fw 1.3.58. Sound latency in video solved by configuring pavucontrol. Works with UE BOOM x2.
| {{Yes}}
|-
| '''LG HBS-730'''
| bluez 5.30, pulseaudio 6.0
| Works out of box with A2DP profile.
| {{Yes}}
|-
| '''LG HBS-750'''
| bluez 5.30, pulseaudio-git 6.0
| Works out of box with A2DP profile.
| {{Yes}}
|-
| '''Beats Studio Wireless'''
| bluez 5.28, pulseaudio 6.0
| Works out of box. Not tested multimedia buttons.
| {{Yes}}
|-
| '''AKG Y45BT'''
| bluez 5.30, pulseaudio 6.0
| Pause and resume does not work. Needs {{ic|1=Enable=Socket}} in {{ic|/etc/bluetooth/audio.conf}} and {{ic|load-module module-bluetooth-discover}} in {{ic|/etc/pulse/default.pa}}.
| {{Yes}}
|-
| '''Bluedio Turbine'''
| bluez5, pulseaudio 6.0
| HSP/HFP work fine, A2DP not tested
| {{Yes}}
|-
| '''Sony SBH20'''
| bluez 5.30, pulseaudio 6.0
| Works out of box with A2DP profile.
| {{Yes}}
|-
| '''Nokia BH-111'''
| bluez 5.30, pulseaudio 6.0
| Works with both HSP/HFP and A2DP. Buttons work in certain apps.
| {{Yes}}
|-
| '''Sony MDR-ZX330BT'''
| bluez 5.31, pulseaudio 6.0
| Works out of box (HSP/HFP and A2DP). Buttons work in certain apps.
| {{Yes}}
|-
| '''Samsung Level Link'''
| bluez 5.33, pulseaudio 6.0
| Works out of box (HSP/HFP and A2DP). Buttons work in certain apps.
| {{Yes}}
|}


== See also ==
This may be desired for bluetooth headsets with overly sensitive touch controls, and AVRCP playback controls can be disabled through the {{ic|inhibited}} sysfs file corresponding to the virtual AVRCP input device, for example {{ic|/sys/devices/virtual/input/input877/inhibited}}. The correct virtual input can be identified via the {{ic|name}} attribute, {{ic|/sys/devices/virtual/input/input877/name}}, which may for example be "Soundcore Life P3 (AVRCP)". Echoing {{ic|1}} to this file inhibits/disables AVRCP, and echoing {{ic|0}} re-enables it. This can be changed dynamically at runtime without restarting bluetoothd or disconnecting your device.


This will be reset on device disconnect and reconnect, so it is likely desired to automatically set it via a [[udev]] rule such as:


Using the same device on Windows and Linux without pairing the device over and over again
SUBSYSTEM=="input" ATTR{name}=="Soundcore Life P3 (AVRCP)" ATTR{inhibited}="1"


* [http://ubuntuforums.org/showthread.php?p=9363229#post9363229 Dual booting with a Bluetooth keyboard]
If you want to be able to change this attribute as a regular user, see [[udev#Allowing regular users to use devices]]

Latest revision as of 05:27, 26 March 2024

There are three Bluetooth audio systems:

  • A2DP (advanced audio distribution) provides music-grade stereo output (sink), typically without input (source).
    • A2DP can use a variety of codecs. The standard SBC has a poor quality-bitrate tradeoff, but much better, open-source alternatives (LDAC, AptX) have become widespread.
    • AVRCP is used on top of A2DP to provide playback control.
  • HFP/HSP (hands-free/headset) provides voice-grade mono output and input. HFP builds on top of HSP.
  • LE Audio is a low-energy audio standard announced in 2020. The standard codec is LC3.

The kernel, BlueZ 5, and PipeWire support all three profiles. Older sound servers such as PulseAudio and ALSA only support A2DP and HFP/HSP. Although Bluetooth is infamous for being unreliable[1], many implementations have seen massive improvements, making it a somewhat less excruciating experience on well-established hardware like Intel Bluetooth chips.

Headset via PipeWire

PipeWire acts as a drop-in replacement for PulseAudio and offers an easy way to set up Bluetooth headsets. It includes out-of-the-box support for A2DP sink profiles using SBC/SBC-XQ, AptX, LDAC or AAC codecs, and HFP/HSP.

Install pipewire-pulse (which replaces pulseaudio and pulseaudio-bluetooth).

The daemon will be started automatically as a user service. Use pavucontrol or your desktop environment's settings for configuration. For more information, see PipeWire#Bluetooth devices.

Troubleshooting

This article or section is a candidate for merging with PipeWire#Troubleshooting.

Notes: The section on this page just links to Pipewire which has its own troubleshooting section. (Discuss in Talk:Bluetooth headset)

High audio volume due to synchronization between headphones and PipeWire

Since version 0.3.26, PipeWire uses "hardware volume" to link the volume of the headphones with the system, making it impossible to change one without the other. On some devices, this may result in the lowest possible volume being uncomfortably loud, and volume controls becoming too coarse. Hardware volume can be disabled using either WirePlumber or Pipewire Media Session.

Using WirePlumber

If it doesn't exist, create the directory /etc/wireplumber/bluetooth.lua.d/ to disable hardware volume system-wide, or ~/.config/wireplumber/bluetooth.lua.d to disable it only for your user. Then, copy /usr/share/wireplumber/bluetooth.lua.d/50-bluez-config.lua to the directory you created. Edit the file, and change the line

--["bluez5.enable-hw-volume"] = true

to

["bluez5.enable-hw-volume"] = false

Restart the system or the PipeWire services for the changes to take effect.

Using Pipewire Media Session

If it doesn't exist, create the directory /etc/pipewire/media-session.d/ to disable hardware volume system-wide, or ~/.config/pipewire/media-session.d/ to disable it only for your user. Then, copy /usr/share/pipewire/media-session.d/bluez-monitor.conf to the directory you created. Edit the file, and add the line

bluez5.enable-hw-volume = false

Restart the system or the PipeWire services for the changes to take effect.

Headset via Bluez5/PulseAudio

This article or section is a candidate for merging with Bluetooth.

Notes: Significant redundancy with general setup on Bluetooth page. Should be merged there. Headset-specific info would stay on this page. (Discuss in Talk:Bluetooth#Merging general setup from Keyboard, Mouse, Headset pages)

Install the pulseaudio-alsa, pulseaudio-bluetooth and bluez-utils packages, the last of which provides the bluetoothctl utility.

Note: Before continuing, ensure that the bluetooth device is not blocked by rfkill.

Configuration via CLI

Start bluetooth.service.

Now we can use the bluetoothctl command line utility to pair and connect. For troubleshooting and more detailed explanations of bluetoothctl see the Bluetooth article. Run

$ bluetoothctl

to be greeted by its internal command prompt. Then enter:

[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# scan on

Now make sure that your headset is in pairing mode. It should be discovered shortly. For example,

[NEW] Device 00:1D:43:6D:03:26 Lasmex LBT10

shows a device that calls itself "Lasmex LBT10" and has MAC address "00:1D:43:6D:03:26". We will now use that MAC address to initiate the pairing:

[bluetooth]# pair 00:1D:43:6D:03:26

After pairing, you also need to explicitly connect the device (if this does not work, try the trust command below before attempting to connect):

[bluetooth]# connect 00:1D:43:6D:03:26

If you are getting a connection error org.bluez.Error.Failed retry by killing existing PulseAudio daemon first:

$ pulseaudio -k
[bluetooth]# connect 00:1D:43:6D:03:26

Finally, if you want to automatically connect to this device in the future:

[bluetooth]# trust 00:1D:43:6D:03:26

If everything works correctly, you now have a separate output device in PulseAudio.

Note: The device may be off by default. Select its audio profile (OFF, A2DP, HFP) in the "Configuration" tab of pavucontrol.

You can now redirect any audio through that device using the "Playback" and "Recording" tabs of pavucontrol.

You can now disable scanning again and exit the program:

[bluetooth]# scan off
[bluetooth]# exit

Setting up auto connection

To make your headset auto connect you need to enable PulseAudio's switch-on-connect module. Do this by adding the following lines to /etc/pulse/default.pa:

/etc/pulse/default.pa
### Automatically switch to newly-connected devices
load-module module-switch-on-connect
Note: Make sure that your bluetooth audio device is trusted, otherwise repeated pairing will fail. See Bluetooth#Pairing for details.

Configuration via GNOME Bluetooth

Note: The A2DP profile will not activate using this method with pulseaudio 9/10 due to an ongoing bug, leading to possible low quality mono sound. See #A2DP not working with PulseAudio for a possible solution.

You can use GNOME Bluetooth graphical front-end to easily configure your bluetooth headset.

First, you need to be sure that bluetooth.service systemd unit is running.

Open GNOME Bluetooth and activate the bluetooth. After scanning for devices, you can connect to your headset selecting it on the device list. You can directly access to sound configuration panel from the device menu. On the sound panel, a new sink should appear when your device is connected.

LDAC/aptX

LDAC/aptX codecs are supported as of PulseAudio 15.0. You can verify the codec you are using for connection as follows:

$ pactl list | grep a2dp_codec

Troubleshooting

Note: Many users report frustration with getting A2DP/Bluetooth Headsets to work. see #Switch between HSP/HFP and A2DP setting for additional information.

Bad sound / Static noise / "Muddy" sound

If you experience bad sound quality with your headset, it could in all likelihood be because your headset is not set to the correct profile. See #Switch between HSP/HFP and A2DP setting to solve the problem.

If you suspect the bad sound quality is due to a poor bluetooth connection, you might compensate for it by switching to a lower bit-rate and lower audio quality codec such as SBC or aptX using pactl:

$ pactl send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez switch-codec '"sbc"'

where a list of available codecs can be obtained by:

$ pactl send-message /card/bluez_card.XX_XX_XX_XX_XX_XX/bluez list-codecs

Selected audio profile, but headset inactive and audio cannot be redirected

Deceptively, this menu is available before the device has been connected; annoyingly it will have no effect. The menu seems to be created as soon as the receiver recognizes the device.

Make sure to run bluetoothctl as root and connect the device manually. There may be configuration options to remove the need to do this each time, but neither pairing nor trusting induce automatic connecting for me.

Pairing fails with AuthenticationFailed

If pairing fails, you can try enabling or disabling SSPMode with:

# btmgmt ssp off

or

# btmgmt ssp on

You may need to turn off BlueTooth while you run this command.

Pairing works, but connecting does not

You might see the following error in bluetoothctl:

[bluetooth]# connect 00:1D:43:6D:03:26
Attempting to connect to 00:1D:43:6D:03:26
Failed to connect: org.bluez.Error.Failed

To further investigate, check the unit status of bluetooth.service or have a look at the log as follows:

# journalctl -n 20

You might see a message like this:

bluetoothd[5556]: a2dp-sink profile connect failed for 00:1D:43:6D:03:26: Protocol not available

This may be due to the pulseaudio-bluetooth package not being installed. Install it if it missing, then restart pulseaudio.

It can also be due to permission, especially if starting pulseaudio as root allows you to connect. Add your user to the lp group, then restart pulseaudio. See /etc/dbus-1/system.d/bluetooth.conf for reference.

If the issue is not due to the missing package, the problem in this case is that PulseAudio is not catching up. A common solution to this problem is to restart PulseAudio. Note that it is perfectly fine to run bluetoothctl as root while PulseAudio runs as user. After restarting PulseAudio, retry to connect. It is not necessary to repeat the pairing.

If restarting PulseAudio does not work, you need to load module-bluetooth-discover.

# pactl load-module module-bluetooth-discover

The same load-module command can be added to /etc/pulse/default.pa.

If that still does not work, or you are using PulseAudio's system-wide mode, also load the following PulseAudio modules (again these can be loaded via your default.pa or system.pa):

module-bluetooth-policy
module-bluez5-device
module-bluez5-discover

It is also possible there are no write permissions for the owner of /var/lib/bluetooth/. If this is the case, you may get the device to work by removing and re-pairing it, but the issue will return after rebooting. Restoring write permissions fixes this issue:

# chmod -R u+w /var/lib/bluetooth

Connecting works, but there are sound glitches all the time

This is very likely to occur when the Bluetooth and the WiFi share the same chip as they share the same physical antenna and possibly band range (2.4GHz). Although this works seamlessly on Windows, this is not the case on Linux.

A possible solution is to move your WiFi network to 5GHz so that there will be no interference. If your card/router does not support this, you can upgrade your WiFi drivers/firmware.

If nothing of the previous is possible, a less effective mitigation is to tweak the fragment size and the latency on PulseAudio output port, trying to compensate interference. Reasonable values must be chosen, because these settings can make the audio out of sync (e.g. when playing videos). To change the latency of the bluetooth headset's port (e.g. to 125000 microseconds in the following example):

$ pactl set-port-latency-offset <bluez_card> headset-output 125000

where the identifier of the card can be found with

$ pacmd list-sinks | grep -Eo 'bluez_card[^>]*'

The fragment size can be set in /etc/pulse/daemon.conf and takes effect after a restart of PulseAudio (for more details please see PulseAudio/Troubleshooting#Setting the default fragment number and buffer size in PulseAudio).

Perhaps it will help to add options ath9k btcoex_enable=1 to the /etc/modprobe.d/ath9k.conf (with the appropriate bluetooth adapter):

/etc/modprobe.d/ath9k.conf
# possibly fix for sound glitches
options ath9k btcoex_enable=1

Then restart.

Connecting works, but there is no sound

Make sure that you see the following messages in your system log:

bluetoothd[5556]: Endpoint registered: sender=:1.83 path=/MediaEndpoint/A2DPSource
bluetoothd[5556]: Endpoint registered: sender=:1.83 path=/MediaEndpoint/A2DPSink

If you see a message similar to this, you can go on and investigate your PulseAudio configuration. Otherwise, go back and ensure the connection is successful.

This article or section is a candidate for merging with PulseAudio/Troubleshooting.

Notes: The following seems to be general issue: [2] (Discuss in Talk:Bluetooth headset)

When using GDM, another instance of PulseAudio is started, which "captures" your bluetooth device connection. This can be prevented by masking the pulseaudio socket for the GDM user by doing the following:

# mkdir -p  /var/lib/gdm/.config/systemd/user
# ln -s /dev/null  /var/lib/gdm/.config/systemd/user/pulseaudio.socket

On next reboot the second instance of PulseAudio will not be started.

It may happen that bluez wrongly considers an headset as not a2dp capable. In this case, search the index of the bluetooth device with

$ pacmd ls

Among the output there should be a section related to the bluetooth headset, containing something similar to

$ pacmd ls
index: 2
        name: <bluez_card.XX_XX_XX_XX_XX_XX>
        driver: <module-bluez5-device.c>
        owner module: 27
        properties:
                device.description = "SONY MDR-100ABN"
                device.string = "XX:XX:XX:XX:XX:XX"
                device.api = "bluez"
                device.class = "sound"
                ...

To manually set the profile, run

$ pacmd set-card-profile 2 a2dp_sink

where 2 is the index of the device retrieved through pacmd ls.

Connecting works, but the device does not show up in PulseAudio sinks

If the headphones connect successfully (which can be confirmed via bluetoothctl) but do not show up as an output/input sink in pavucontrol, you can try adding the following policy to your Bluetooth configuration file /etc/bluetooth/main.conf:

/etc/bluetooth/main.conf
[General]
Enable=Control,Gateway,Headset,Media,Sink,Socket,Source

Some users report that this has solved their problem.

Connecting works, sound plays fine until headphones become idle, then stutters

If the headphones play sound correctly until they become idle and then stutter on resume (e.g. because the sound is paused, or because no sound is played for a while), try disabling PulseAudio's automatic sink/source suspension on idle.

Some user reports huge delays or even no sound when the Bluetooth connection does not send any data. This is due to the module-suspend-on-idle module, which automatically suspends sinks/sources on idle. As this can cause problems with headset, the responsible module can be deactivated.

To disable loading of the module-suspend-on-idle module, comment out the following line in the configuration file in use (~/.config/pulse/default.pa or /etc/pulse/default.pa):

~/.config/pulse/default.pa
### Automatically suspend sinks/sources that become idle for too long
#load-module module-suspend-on-idle

Finally restart PulseAudio to apply the changes.

UUIDs has unsupported type

During pairing you might see this output in bluetoothctl:

[CHG] Device 00:1D:43:6D:03:26 UUIDs has unsupported type

This message is a very common one and can be ignored.

PC shows device as paired, but is not recognized by device

This might be due to the device not supporting bluetooth LE for pairing.

Try setting ControllerMode = bredr in /etc/bluetooth/main.conf. See [3].

Device connects, then disconnects after a few moments

If you see messages like the following in the journal, and your device fails to connect or disconnects shortly after connecting:

bluetoothd: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
bluetoothd: connect error: Connection refused (111)

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 adapter). You can fix this by re-pairing the device. Start by removing the device:

$ bluetoothctl
[bluetooth]# devices
Device XX:XX:XX:XX:XX:XX My Device
[bluetooth]# remove XX:XX:XX:XX:XX:XX

Then restart bluetooth.service, turn on your bluetooth adapter, make your device discoverable, re-scan for devices, and re-pair your device. Depending on your bluetooth manager, you may need to perform a full reboot in order to re-discover the device.

Apple AirPods have low volume

Create a drop-in file for bluetooth.service with the following contents:

/etc/systemd/system/bluetooth.service.d/noplugin-avrc.conf
[Service]
ExecStart=
ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=avrcp

Then, restart bluetooth.service, reload its configuration, and reconnect your headset.

Additionally, for AirPods Pro, disable the spatial audio and enable Mono in the settings of your iPhone.

This can also solve issues with some devices that are unable to be controlled through AVRCP.

Apple AirPods Pro working with PulseAudio as A2DP Sink but not with HSP/HFP

If you find that AirPods Pro are working with PulseAudio, but are incapable of using the HSP/HFP configurations (in pavucontrol's Configurations tab, usually listed as unavailable), try switching to pipewire-pulse.

Note that switching to pipewire-pulse (and restarting your computer or the appropriate user-level systemd services) should enable HSP/HFP, but may also disable A2DP. (When selecting A2DP Sink in the Configurations tab, the option is instantly deselected and becomes Off.) If you encounter this issue, try removing/renaming the /var/lib/bluetooth folder like so:

# mv /var/lib/bluetooth /var/lib/bluetooth.bak

Re-pair your AirPods Pro (and other devices) afterwards. This should make all configurations (HSP/HFP and A2DP) available again and easily accessible from pavucontrol and pacmd.

HSP problem: the bluetooth sink and source are created, but no audio is being transmitted

You may be missing firmware or the SCO (audio protocol of HSP and HFP) routing might be wrong. See [4] - the firmware for BCM20702 can be installed via bcm20702a1-firmwareAUR or bcm20702b0-firmwareAUR.

Error: Failed to start discovery org.bluez.Error.InProgress

If your headset is discovered, but fails to connect with the error "Failed to start discovery org.bluez.Error.InProgress", install bluez-hciconfigAUR[broken link: package not found] and run

$ hciconfig hciX up
$ hciconfig hciX reset

where X is the identifier of your computer's bluetooth device (typically 0).

You should then be able to connect following the steps in #Configuration via CLI.

High audio volume due to synchronization between headphones and PulseAudio

As of PulseAudio 15, "Absolute Volume" interlocks the audio volume of your headphones with PulseAudio, making it impossible to change one without the other. On some headphones, e.g. on the Hoco W25, this may result in irritating loudness. To disable "Absolute Volume", edit /etc/pulse/default.pa and change the line

 load-module module-bluetooth-discover

to

 load-module module-bluetooth-discover avrcp_absolute_volume=false

Switch between HSP/HFP and A2DP setting

This can easily be achieved by the following command where the card_number can be obtained by running pacmd list-cards.

$ pacmd set-card-profile card_number a2dp_sink

For enabling automatic profile switching from A2DP to HSP when a recording stream appears without any role set, you can append auto_switch=2 to load-module module-bluetooth-policy in /etc/pulse/default.pa.

For more information about PulseAudio profiles, see PulseAudio Documentation.

A2DP not working with PulseAudio

Socket interface problem

If PulseAudio fails when changing the profile to A2DP with bluez 4.1+ and PulseAudio 3.0+, you can try disabling the Socket interface from /etc/bluetooth/main.conf by removing the line Enable=Socket and adding line Disable=Socket.

A2DP sink profile is unavailable

When the A2DP sink profile is unavailable it will not be possible to switch to the A2DP sink (output) with a PulseAudio front-end and the A2DP sink will not even be listed. This can be confirmed with pactl.

$ pactl list | grep -C2 A2DP
     Profiles:
             headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
             a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: no)
             off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: headset_head_unit

Trying to manually set the card profile with pacmd will fail.

$ pacmd set-card-profile bluez_card.C4_45_67_09_12_00 a2dp_sink
Failed to set card profile to 'a2dp_sink'.

This is known to happen from version 10.0 of PulseAudio when connecting to Bluetooth headphones via Bluedevil or another BlueZ front-end. See related bug report.

This issue also appears after initial pairing of Headphones with some Bluetooth controllers (e.g. 0a12:0001, Cambridge Silicon Radio) which might default to the Handsfree or Headset - HS service and will not allow switching to the A2DP PulseAudio sink that requires the AudioSink service.

Possible solutions:

  • For some headsets, using the headset's volume or play/pause controls while connected can trigger the A2DP profile to become available.
  • It is possible that connecting to a headset via bluetoothctl from bluez-utils will make the A2DP sink profile available. There is an automation for this every time a bluetooth device is connected: fix-bt-a2dpAUR (detailed usage)
[bluetooth]# connect headset_MAC_address
  • Manually switching to Bluetooth's AudioSink service which would make the A2DP profile and its A2DP PulseAudio sink available. This can be done with blueman-manager which included in blueman or by registering the UUID of the AudioSink service with bluetoothctl.
$ bluetoothctl
[bluetooth]# menu gatt
[bluetooth]# register-service 0000110b-0000-1000-8000-00805f9b34fb
[bluetooth]# quit
  • Disable the headset profile
/etc/bluetooth/main.conf
[General]
Disable=Headset
  • Enable MultiProfile support. This may help with headsets that support A2DP as well as Headset audio.
/etc/bluetooth/main.conf
[General]
MultiProfile=multiple
  • Sometimes, none of the steps above will work. You may have tried rebooting and powering bluetooth off and on to no avail. In this case, try restarting the bluetooth.service.
  • For some headphone models with audio control panel, the A2DP profile must be enabled by pressing the Play/Pause button on the panel.

Gnome with GDM

This article or section is a candidate for merging with #Connecting works, but I cannot play sound.

Notes: duplicate instructions (Discuss in Talk:Bluetooth headset)

The instructions below were tested on Gnome 3.24.2 and PulseAudio 10.0 however they may still be applicable and useful for other versions.

If PulseAudio fails when changing the profile to A2DP while using GNOME with GDM, you need to prevent GDM from starting its own instance of PulseAudio:

  • Prevent PulseAudio clients from automatically starting a server if one is not running by adding the following:
/var/lib/gdm/.config/pulse/client.conf
autospawn = no
daemon-binary = /bin/true
  • Prevent systemd from starting PulseAudio anyway with socket activation:
$ sudo -ugdm mkdir -p /var/lib/gdm/.config/systemd/user
$ sudo -ugdm ln -s /dev/null /var/lib/gdm/.config/systemd/user/pulseaudio.socket
  • Restart, and check that there is no PulseAudio process for the gdm user using:
$ pgrep -u gdm pulseaudio

Further discussion about this problem and alternative fixes can be found at [5] and [6]. Alternatively, one may try and install fix-bt-a2dpAUR.

HFP not working with PulseAudio

Note: Some users have reported success in enabling HFP support by replacing PulseAudio with PipeWire for Bluetooth support. [7] See #Headset via PipeWire for installation instructions.

HFP-only bluetooth headsets may not be usable in the standard configuration of PulseAudio. The respective profiles occur, but they are not available:

bluetoothctl info
UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
pactl list
...
Profiles:
      ...
      headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: no)

To solve the respective issue, update PulseAudio and BlueZ to latest versions. Then install ofonoAUR and phonesimAUR then create / activate a fake modem as described here [8]:

Note: The steps following the creation of phonesim.conf should be done every time you want to connect the headset.
  • Create /etc/ofono/phonesim.conf with:
[phonesim]
Address=127.0.0.1
Driver=phonesim
Port=12345
  • Start as user:
$ phonesim -p 12345 /usr/share/phonesim/default.xml &
$ dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Powered" variant:boolean:true
  • Activate modem:
$ dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Online" variant:boolean:true
  • To check the results, use the test commands from ofonoAUR installed in /usr/lib/ofono/test/. To power, activate, and test the modem you can use:
$ /usr/lib/ofono/test/enable-modem /phonesim
$ /usr/lib/ofono/test/online-modem /phonesim
$ /usr/lib/ofono/test/list-modems

The output of the respective modem section should read like this:

...
[ /phonesim ]
  Online = 1
  Powered = 1
  Lockdown = 0
  Emergency = 0
  Manufacturer = MeeGo
  ...
  • Finally, restart PulseAudio and reconnect headset. Now, HFP should be available:
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
Note: HFP support is not stable and may cause glitches with switching to A2DP; try reconnecting, if the needed mode is not available.

Disable PulseAudio auto switching headset to HSP/HFP

When using a bluetooth headset that supports multiple profiles, some applications switch to HSP/HFP profile automatically. If this behaviour is undesired you can disable this by appending the auto_switch=false parameter to the bluetooth-policy module:

/etc/pulse/default.pa
load-module module-bluetooth-policy auto_switch=false

Disable PipeWire HSP/HFP profile

Unlike PulseAudio, PipeWire does not automatically switch between A2DP and HSP/HFP in response to input events. However, rather than to enable automatically switching to the (lower audio quality) HSP/HFP profile if A2DP fails, you may prefer to disable the former altogether. To do so, create or edit a bluez configuration as shown below.

Note: HSP mode is required for built-in microphones to work [9].
/etc/wireplumber/wireplumber.conf.d/50-bluez.conf (or ~/.config/wireplumber/wireplumber.conf.d/50-bluez.conf)
monitor.bluez.rules = [
  {
    matches = [
      {
        ## This matches all bluetooth devices.
        device.name = "~bluez_card.*"
      }
    ]
    actions = {
      update-props = {
        bluez5.auto-connect = [ a2dp_sink ]
        bluez5.hw-volume = [ a2dp_sink ]
      }
    }
  }
]

monitor.bluez.properties = {
  bluez5.roles = [ a2dp_sink ]
  bluez5.hfphsp-backend = "none"
}

Alternative: A2DP duplex channel

FastStream, AptX LL, and "Opus 05 Pro" (a pipewire invention) have a "duplex" channel that allows for sending microphone audio back without needing to go into HSP/HFP and tolerate the sound quality degradation. PipeWire, but not PulseAudio, has support for this feature. Support is automatic upon feature detection. Interaction with existing profile switcher (WirePlumber) is unknown.

Tips and tricks

The following applies to both PipeWire and PulseAudio.

Battery level reporting

Note: This is an experimental feature. Enabling it may prevent some Bluetooth mice from connecting automatically (see GitHub issue).

To get the current battery level of your headset reported to upower, you must enable bluez' D-Bus experimental features as described in Bluetooth#Enabling experimental features.

Media controls

To use the media controls they may be forwarded to MPRIS, where they can be picked up by media players that support MPRIS for external control. See MPRIS#Bluetooth for details.

AVRCP Media controls

This may be desired for bluetooth headsets with overly sensitive touch controls, and AVRCP playback controls can be disabled through the inhibited sysfs file corresponding to the virtual AVRCP input device, for example /sys/devices/virtual/input/input877/inhibited. The correct virtual input can be identified via the name attribute, /sys/devices/virtual/input/input877/name, which may for example be "Soundcore Life P3 (AVRCP)". Echoing 1 to this file inhibits/disables AVRCP, and echoing 0 re-enables it. This can be changed dynamically at runtime without restarting bluetoothd or disconnecting your device.

This will be reset on device disconnect and reconnect, so it is likely desired to automatically set it via a udev rule such as:

SUBSYSTEM=="input" ATTR{name}=="Soundcore Life P3 (AVRCP)" ATTR{inhibited}="1"

If you want to be able to change this attribute as a regular user, see udev#Allowing regular users to use devices