- BluetoothUser a2dp
- Pre-configuration
- Firmware
- PulseAudio
- PipeWire
- ALSA only
- Pairing
- Troubleshooting
- Refused to switch profile to a2dp_sink: Not connected
- Workaround 1: Disable PulseAudio in GDM
- Workaround 2: Disable PulseAudio’s Bluetooth in GDM
- Solution
- Unable to control volume with volumeicon-alsa
- a2dp-sink profile connect failed [. ]: Protocol not available
- AptX, LDAC, and AAC codecs are not available with PulseAudio
- See also
- Настройка bluetooth стерео-наушников в Ubuntu Linux (8.04 & 7.10)
- BluetoothUser
- Introduction
- Preparation
- Pairing
- Pairing using a GUI tool
- Pairing using CLI
- Using bluetooth-agent
- Using bluetoothctl
- Using a Bluetooth mouse
- Troubleshooting
- General pairing issues
- Helpful Commands
- Helpful Configuration Files
- KDE Issues
- GNOME topics
- Can’t reconnect after sleep
- Audio device issues (With pairing, quality, codec selection, etc.)
- See also
- External links
- BluetoothUser
- a2dp
A2DP is the «Advanced Audio Distribution Profile», a standard for how Bluetooth devices can stream high-quality audio to remote devices. This is most commonly used for linking wireless headphones and speakers to your PC. The instructions in this page should apply to any A2DP-compatible device.
Pre-configuration
In short: To connect to a given device, you need Bluetooth hardware on your PC (either built-in, or in the form of a USB dongle), the Bluez daemon, and a compatible audio server (either PulseAudio or PipeWire).
Firmware
If your hardware supports Bluetooth but Debian is unable to find any Bluetooth devices, you may have a dongle based on a Broadcom BCM203x chipset, requiring extra firmware to be installed.
Add a non-free component to your apt sources and install the bluez-firmware package.
PulseAudio
PulseAudio is the default audio server in Debian. Unless you know what you’re doing, you probably want to follow these instructions.
Install the pulseaudio-module-bluetooth package if it’s not already installed. You probably also want pavucontrol (or pavucontrol-qt on LXQt or Plasma desktops) to configure your device after connecting it.
Once you have installed the Bluetooth module, it may be necessary to restart the bluetooth and pulseaudio services:
After connecting your device (see the «Pairing» section), your device will appear in Pavucontrol, where you can set it as your default audio output device, change individual applications to output using it, configure its profile, etc.
PipeWire
These instructions are mutually exclusive to the PulseAudio section, for users that are using the newer PipeWire audio server instead. This is also documented on the PipeWire wiki page in brief. Note that simply having the pipewire package installed does not mean this section is relevant to you, as it needs to have also been specially configured to replace PulseAudio.
In Debian, PipeWire supports more modern codecs than PulseAudio without the need to install any external modules. In particular, PipeWire 0.3.26 supports mSBC, SBC, SBC-XQ, LDAC, AptX, and AptX-HD. It also supports the HSP_HS, HSP_AG, HFP_HF, and HFP_AG headset roles. Support for more codecs is in-progress.
At minimum, you will need to install the libspa-0.2-bluetooth package, remove the pulseaudio-module-bluetooth package (if previously installed), and then either reboot your computer or restart the PipeWire services, otherwise device connections will fail with «Protocol not available».
Note that, if you’re using the GNOME desktop, the gnome-core package has a hard dependency on pulseaudio-module-bluetooth. Attempting to remove it will also prompt to remove your desktop. If you run into issues when attempting to use Bluetooth with this package installed, you may still have to use PulseAudio in order to have functioning Bluetooth audio.
PipeWire will attempt to choose the best possible codec by default. You can override this, and tweak many other related settings, in the /etc/pipewire/media-session.d/bluez-monitor.conf file. You can edit this directly, or store local per-user changes by copying the file to
/.config/pipewire/media-session.d/bluez-monitor.conf and editing that instead. You can check the currently-used codec with pactl list sinks
ALSA only
If you want to completely avoid using a higher-level audio server like PipeWire or PulseAudio, see BlueALSA. Currently only available in Debian Unstable.
Pairing
It is also highly recommended to install a graphical pairing tool. GNOME relies on gnome-bluetooth, after which you can find a «Bluetooth» section of your settings. KDE Plasma relies on bluedevil, which is a module for your system settings, a system tray applet, and a wizard for connecting to your devices. Other desktops can use the agnostic blueman tool.
More information, and instructions on using the CLI bluetoothctl tool, can be found on the main BluetoothUser page.
Troubleshooting
Refused to switch profile to a2dp_sink: Not connected
Your Bluetooth headset is connected, but PulseAudio fails to pick up the connected device, or there’s no device to pick. This happens because GDM captures A2DP sink on session start, as GDM needs PulseAudio in the GDM session for accessibility. For example, the screen reader requires it. See 805414 for some discussion.
Workaround 1: Disable PulseAudio in GDM
In order to prevent GDM from capturing the A2DP sink on session start, edit /var/lib/gdm3/.config/pulse/client.conf (or create it, if it doesn’t exist):
After that you have to grant access to this file to Debian-gdm user:
You may also need to disable PulseAudio startup (however in Debian 10/Buster and newer, this has already been removed in the gdm3 postinst):
In order to auto-connect A2DP for some devices, add this to /etc/pulse/default.pa:
Now your audio device should be accessible through pavucontrol and your desktop’s standard audio settings.
Workaround 2: Disable PulseAudio’s Bluetooth in GDM
The actual solution package maintainers are looking into next is to simply disable the Bluetooth sink in the GDM PulseAudio daemon so that it doesn’t take over the device. Add this to /var/lib/gdm3/.config/pulse/default.pa:
This was first discovered in the Arch wiki.
Solution
The actual solution is for PulseAudio to release the Bluetooth device when it is not in use. This is discussed in the PulseAudio 845938 which has a few upstream bugs pending as well that are related.
Unable to control volume with volumeicon-alsa
The volumeicon tray icon may not automatically recognize a Bluetooth A2DP device when a connection is established. See issue #73, «volumeicon does not work to adjust bluetooth volume» and issue #49, «change of the default device not automatically detected» for discussion and possible workarounds / fix. You might also try simply restarting Volumeicon, or adjusting your PulseAudio configuration to switch on connect.
a2dp-sink profile connect failed [. ]: Protocol not available
This error can appear when using PipeWire as your audio server and attempting to pair a device via Bluetooth, without first uninstalling the pulseaudio-module-bluetooth package.
If you’re using PulseAudio, PulseAudio may not be properly connecting to the device. It might be because it was already playing. Stopping anything playing on PulseAudio, restarting PulseAudio, and reconnecting to the device may fix the problem.
In addition, you need the following settings in /etc/pulse/default.pa or /etc/pulse/default.pa.d/bluez5.pa:
Then restart pulseaudio.
AptX, LDAC, and AAC codecs are not available with PulseAudio
While newer audio codecs such as AptX and LDAC are available in PipeWire, they’re still unavailable for PulseAudio users in Debian. AAC is unavailable outright because the library is non-free. However, PulseAudio has recently gained support for all of these codecs via GStreamer. Unfortunately, GStreamer is only supporting these codecs from v1.20 onwards. This means that support for modern codecs with PulseAudio is not available in Debian 10 or Debian 11. It is expected to land in Debian 12.
A third-party project adds support for these additional codecs as well. It is deprecated and the creator recommends users either avoid it entirely, or switch to PipeWire. Nonetheless, it’s still a fully functional option in Debian 10: https://github.com/EHfive/pulseaudio-modules-bt
Additionally, a third-party script for Debian 10 is available which will automatically configure and install the additional codecs via the deprecated pulseaudio-modules-bt project: https://github.com/lagerimsi-ds/debian-buster_bluetooth_aptX-LDAC
If the PulseAudio sink adjusts automatically to SBC-sink (not A2DP-sink with aptX or LDAC), just reconnect your device.
See also
BluetoothUser — Main page for Bluetooth in Debian
BlueDevil — Bluetooth with KDE Plasma
BlueALSA — Bluetooth over ALSA alone
Источник
Настройка bluetooth стерео-наушников в Ubuntu Linux (8.04 & 7.10)
Привет!
Решил написать небольшую инструкцию, чтобы помочь нуждающимся в настройке bluetooth-наушников под Linux. Описанный способ гарантированно работает в Ubuntu 7.10 и 8.04. В других системах не должно возникнуть особых проблем, если имеются все необходимые компоненты (bluez, alsa, python).
В прошлом году я купил себе bluetooth стерео-наушники (+гарнитура) Plantronics 590A. Отличные наушники — хорошее качество звука и полная свобода от проводов. После перехода с Windows XP на Ubuntu возник вопрос использования наушников, как в качестве обычных наушников для вывода звука, так и полноценной гарнитуры для общения в играх и в Skype.
Хотя стандартный bluetooth-менеджер Ubuntu, вроде как, подразумевает использование Audio Service для соответствующих bt-устройств, но я не смог быстро найти внятную инструкцию, как же организовать вывод звука на наушники.
Вскоре мне на глаза попалась замечательная программа BlueMan bluetooth manager (screenshots). Эта программа достойна отдельной статьи, так как у неё очень много возможностей и она очень облегчает жизнь любому, кому потребуется работа с различными устройствами через протокол bluetooth. Программа работает «поверх» стандартного Ubuntu-овского bt-стека bluez и практически не тянет за собой зависимостей (программа написана на python`e).
Перечислять все возможности программы я не стану, ограничусь только тем, что программа поддерживает bt-устройства с профилем A2DP
Всё что необходимо сделать в BlueMan — «спарить» ваши bt-наушники с программой. После «спаринга» я дополнительно активировал в параметрах программы использование службы звука.
В настройках службы звука я активировал использовал служб Headset, Sink, Control для своих наушников. Для обычного вывода звука вполне достаточно службы Headset. Остальные службы присутствуют, я так думаю, для поддержки работы bt-профиля AVRCP. Я не проверял работу профиля ни в одной программе в Ubuntu, так что о его работоспособности сказать ничего не могу.
Последним шагом необходимо подправить файлик
/.asoundrc. Я не большой коппенгаген в конфигурационном файле ALSA, все правки были подсмотрены из статей:
- http://alfa2linux.blogspot.com/2008/03/my-jabra-finally-working-with-bluez.html
- http://wiki.bluez.org/wiki/HOWTO/AudioDevices
Я не ставил никаких дополнительных пакетов, которые были упомянуты в статьях — bluetooth-alsa, btsco и др.
В файл .asoundrc я добавил такие строки:
Источник
- BluetoothUser
Using Bluetooth in a Debian system
Bluetooth is a standard providing short-range wireless communication between devices, generally for linking an audio device, mouse, keyboard, phone, etc. to your PC. This article documents how to configure a Bluetooth adapter with Debian and pair it with a device. Bluetooth audio is separately documented on the BluetoothUser/a2dp page.
Information for developers, related to the internal packaging of Bluetooth within Debian, can be found on the Bluetooth page.
Introduction
We assume you have a Bluetooth adapter in your computer and a Bluetooth device (such as a mobile phone or PDA). This documents describes what you need to do to use Bluetooth to communicate with other Bluetooth devices.
The steps described below are required before you can use the services Bluetooth offers. Once you have setup Bluetooth, you can for example
- exchange data with devices, such as sending music or videos to/from your phone
- use a mobile phone to give your computer mobile internet access
- use Bluetooth peripherals with your computer, such as a Bluetooth wireless mouse
See the links below for details.
Preparation
Install Bluetooth support (package bluetooth) :
Read /usr/share/doc/bluez/README.Debian.gz to get some understanding of what’s going on.
Make sure the Bluetooth daemon is running. If it’s not running, start it.
Pairing
For security reasons, Bluetooth devices will only talk to each other if they have been «introduced» first (a bit like in real life :-)). This is referred to as Pairing.
Note that pairing is usually only required the first time two devices interact. Afterwards, they will remember each other, and no exchange of PINs is necessary. This will however depend on the devices involved (on some devices this may be configurable).
To pair devices, you need a passkey-agent. Options are:
Pairing using a GUI tool
Install one of the following packages:
Log out of your desktop session and log back in — this is required for the pairing pop-up in the next step to appear correctly.
On your Bluetooth device you can now try to pair. On the device you need to choose something like the «setup», «connect» or «Bluetooth» menu and then search for Bluetooth devices. You should find your Debian system, called something like debian-0, where debian is the hostname of your Debian system. On your device, select the Debian system. The device will then ask for a PIN, you can make one up, (choose four digits, say 2309 ).
On your computer you will get a pop-up information balloon asking for the PIN, something like Pairing request from Phone (xx:xx:xx:xx:xx:xx) where Phone is the name of your phone and xx:xx:xx:xx:xx:xx is its MAC address.
Click on the information balloon.
Another window will pop-up. It asks for the PIN, enter the one you just made up. (e.g. 2309 ) and press [Enter].
Your phone sees that the PIN matches and shows it on its display.
Both devices are now paired.
Pairing using CLI
If you do not want to or cannot use Gnome or KDE, you can also use bluetooth-agent or bluetoothctl for the pairing.
Using bluetooth-agent
Bluetooth-agent is a part of package bluez, so it should already be available if Bluetooth has been configured on your system.
Just start bluetooth-agent (as root), giving an arbitrary PIN, such as 4835:
Then, as described above, choose something like the «setup», «connect» or «Bluetooth» menu on the device to be paired, and search for Bluetooth devices. Select your computer once found; the device should prompt you for a PIN. Now enter the PIN you gave to bluetooth-agent, and pairing is completed.
Note: Instead of initiating the pairing process from the phone, you can also initiate it from the computer. Start bluetoogh-agent as explained above, then run a command that will try to connect to the phone, e.g.
is your phone’s bluetooth address, as shown by hcitool scan (note that this will only work if the phone is discoverable, though the computer need not be). This will force a connection from computer to phone, which should cause the phone to ask you to confirm the connection attempt by prompting for a PIN. Enter the pin you used with bluetooth-agent.
Using bluetoothctl
If bluetooth-agent is not available, try bluetoothctl:
Start the bluetoothctl interactive command. Enter «help» to get a list of available commands.
- Turn the power to the controller on by entering «power on». It is off by default.
- Enter «devices» to get the MAC Address of the device with which to pair.
- Enter device discovery mode with «scan on» command if device is not yet on the list.
- Turn the agent on with «agent on».
Enter «pair MAC Address» to do the pairing (tab completion works).
If using a device without a PIN, one may need to manually trust the device before it can reconnect successfully. Enter «trust MAC Address» to do so.
Finally, use «connect MAC address» to establish a connection.
Using a Bluetooth mouse
To use a Bluetooth mouse, first the support for Bluetooth must be installed on the system. See above.
If your machine has a graphical environment with a GUI for pairing Bluetooth devices, chances are you can discover and pair your device easily from there. See above how to pair using a GUI tool.
If that does not succeed or you need to use the command line you can try running
to get the bluetooth MAC address of the mouse.
An initial connection can be done with
where is the MAC address obtained with the previous command.
To enable further automatic reconnections (e.g. on reboot), you need to run
to mark the device as trusted.
Troubleshooting
General pairing issues
In order for the pairing to work as described above, your computer’s bluetooth interfaces must be discoverable. A bluetooth dongle may start off in hidden mode (bug report here)
To fix this you can run:
Or using hciconfig:
Then hciconfig should show the flags ISCAN PSCAN, indicating bluetooth is discoverable (i.e. can be scanned). After you finished pairing, it’s best to make your computer hidden again:
Or using hciconfig:
Helpful Commands
Display your Bluetooth device (for proof that it was installed properly)
Search for remote Bluetooth devices
Restart the Bluetooth services
Force connection to device
Helpful Configuration Files
/etc/default/bluetooth — Default HID bluez setting — enable for mice and keyboards
/etc/bluetooth/hcid.conf — HCI bluez settings — configure static device information
KDE Issues
This section is very outdated and needs a full rewrite.
KDE now uses BlueDevil instead of KDEBluetooth. The programs listed below no longer exist. Devices can be paired with BlueDevil by running bluedevil-wizard in your terminal.
Since the PIN should be implemented on a user level, we need to make some changes to /etc/bluetooth/hcid.conf
comment out the line
and add the following line directly below it (Note: kdebluetooth includes the program kbluepin):
KDE also expects a file /etc/bluetooth/link_key to be present.
In KDE, run kbluetoothd. Click on the Bluetooth icon in the system tray, this loads Konqueror with the Bluetooth:// URL. You should be able to see your device and do some simple file transfers by clicking on the device and choosing the proper transfer protocol.
Scanning for the PC from your device should bring up a window in KDE that asks you for a PIN. Now you can send files to your PC (KDE should bring up a program to handle this).
GNOME topics
In DebianWheezy with GnomeShell the settings for Bluetooth can be found at
System Settings > Bluetooth: Lists paired devices, allows sending of data
/public folder: When opening this folder, you find a notification bar to define the sharing of data. This includes the sharing via WebDAV, but also via Bluetooth. Furthermore, one can enable receiving files via Bluetooth. These files are stored in
/downloads.
- Receive Files over Bluetooth / Receive files in Downloads folder over Bluetooth
- Receive Files over Bluetooth / Notify about received files
Can’t reconnect after sleep
You may notice that you can’t automatically reconnect to a device after it goes to sleep. You would for example notice the following errors in your logs:
This could be because the device is not marked as «trusted». To fix this, try the following command in a bluetoothctl shell:
. where 00:1D:43:6D:03:26 is the device identifier for the speaker.
You may also want to have Pulseaudio automatically connect to the newly discovered output, by adding this to
Note: this fix was found in the Arch Linux wiki.
Audio device issues (With pairing, quality, codec selection, etc.)
See the BluetoothUser/a2dp page for full documentation on Bluetooth audio in Debian.
See also
A2DP — Using a high quality audio device (like bluetooth headphones)
External links
BlueZ — Official Linux Bluetooth protocol stack
Источник