Manjaro Linux

How to Troubleshoot Bluetooth in Manjaro

Bluetooth implementation in Manjaro Linux can occur via two different sets of packages. First is Bluez, which offers Bluetooth stack implementation in all Linux distributions. Bluez provides drivers and various command-line utilities to administer Bluetooth. Whereas the second method is via desktop tools or GUI packages to manage these devices. Similarly, to use audio equipment, users need to install an additional pulseaudio-bluetooth package.

In other words, Bluetooth functionality in Manjaro or any Linux distributions results due to various interacting modules that include hardware drivers, client applications, kernel, bluez, and pulseaudio. Hence, troubleshooting Bluetooth problems in Manjaro is a daunting task.

In this article, we discuss some of the most common Bluetooth connection problems and present effective solutions.

Getting Started

Before beginning to troubleshoot Bluetooth device connection problems, confirm Bluetooth connection and adapter settings.

Verify that the Bluetooth adapter/device is not blocked via the following command:

[manjaro@manjaro:~]$ sudo rfkill list
: ideapad_bluetooth: Bluetooth
       Soft blocked: no
       Hard blocked: no

The above output illustrates that the adapter is unblocked. On the contrary, scenario, use the following command to unblock the adapter.

[manjaro@manjaro:~]$ sudo rfkill unblock bluetooth

Lastly, verify if the Bluetooth service is enabled and active.

[manjaro@manjaro:~]$ sudo systemctl status bluetooth

Bluetooth not available after Sleep/Startup

Bluetooth gets disable after the restart, sleep or hibernate. This process causes the user to re-enable every time from the taskbar or CLI. As soon as the system resumes (before manually enabling Bluetooth), use the above-mentioned command rfkill to verify adapter settings. If the command output is similar to the above, it confirms that the issue is not with the driver.

One of the root causes can be a bug in the old versions of bluez 4.49, 4.50, etc. It also causes unusual behavior during Bluetooth connection, disconnection, and pairing processes.

Use the following command in the terminal to check the current version details of bluez:

[manjaro@manjaro:~]$ sudo pacman -Qi bluez| grep "^Version:"

Update the Manjaro repository and update the bluez to its latest version.

[manjaro@manjaro:~]$ sudo pacman -Sy bluez

The version update resolves the Bluetooth access problem after suspension. It also improves system behavior during Bluetooth pairing, connection, and other settings.

Bluetooth Headset Playing HSP/HFP Not A2DF

Another common Bluetooth problem is that the headsets only play low-quality audio for phone calls instead of high-quality audio playback (music). To troubleshoot this problem, make sure the system identifies the right Bluetooth device in the configuration file.

Before that, verify all the required dependencies are available in the system.

[manjaro@manjaro:~]$ sudo pacman -Sy pulseaudio pulseaudio-utils pavucontrol pulseaudio-module-bluetooth

After verification, edit or create the audio configuration file in the /etc/bluetooth directory, to include the following lines:

[manjaro@manjaro:~]$ sudo vim /etc/bluetooth/main.conf
 #This section contains general options
    [General]
    Enable=Source,Sink,Media,Socket

Save the above file and restart the Bluetooth service.

[manjaro@manjaro:~]$ sudo service bluetooth restart

A2DP not compatible with PulseAudio

Sometimes PulseAudio fails to switch from low-quality audio to A2DP. That occurs due to the socket interface problem. The problem happens with the PulseAudio and bluez versions that are above 3.0 and 4.1.

To troubleshoot, disable the Socket option in the main.conf file in the /etc/bluetooth directory.

#This section contains general options
    [General]
    Enable=Source,Sink,Media
    Disable=Socket

Bluetooth Device Connects and Disconnect

Another problem that Manjaro Bluetooth users face is that the device fails to connect or disconnect after a few moments of connection. Use the journalctl command to check the error logs:

The above error occurs in dual boot systems, not in standalone Manjaro installation. That means the device has already paired with another operating system via a Bluetooth adapter.

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

Whenever the Bluetooth device pairs, the service generates pairing keys. The system stores the device MAC address and the keys. Similarly, the device also stores the system’s MAC address and the matching key.

However, the MAC addresses for both OSs in the system are the same. When the Bluetooth device re-pairs, it overwrites the previous key with the new one. Hence, some devices can not handle pairing twice with the same MAC address or adapter.

Use the following step-by-step instructions to troubleshoot this problem:

Boot into the Windows OS and pair all the devices

Now reboot into the Manjaro Linux and pair all the devices.

Now extract to the Windows pairing keys, switch off the Bluetooth devices to avoid connection attempts.

Go to the command-line terminal to install the chntpw utility

[manjaro@manjaro:~]$ sudo pacman -Sy chntpw

Use the following command to mount Windows system drive

[manjaro@manjaro:~]$ cd /[path_to_windows_system]/Windows/System32/config

Now chntpw -e SYSTEM to get inside the chntpw environment to run

> cd ControlSet001\Services\BTHPORT\Parameters\Keys

Now ls to get Bluetooth adapter MAC address

>ls
Node has 1 subkeys and 0 values
  key name

Now cd into the [bluetooth-adapter-mac-address] folder to list existing MAC address devices.

    Node has 0 subkeys and 1 values
  size     type            value name      [value if type DWORD]
    16  REG_BINARY

Use hex to get the device keys.

> hex xxxxxxxxxxxx
:00000 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX

The XX’s in the above output is the pairing keys. Now note which device maps to with which key.

Add the pairing key to the Manjaro configuration entries:

Change user to root: su

cd into the Bluetooth configuration folder /var/lib/bluetooth/[bluetooth_MAC_Add], such that each paired device has a separate configuration file. To pair each device with both OSs, add Windows Manjaro and Windows, open the configuration file for each device, and add the Windows pairing key under the [LinkKey] option.

[LinkKey]
Key=XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX

Save the files and restart the services:

[manjaro@manjaro:~]$ sudo systemctl restart bluetooth.service
[manjaro@manjaro:~]$ pulseaudio -k

Conclusion

In this tutorial, we demonstrate troubleshooting various Bluetooth connection problems in Manjaro Linux. The issues discussed are the most commonly faced problems by new Manjaro users. The article also resolves the most commonly occurring Bluetooth connection problem in a dual boot system.

About the author

Usama Azad

A security enthusiast who loves Terminal and Open Source. My area of expertise is Python, Linux (Debian), Bash, Penetration testing, and Firewalls. I’m born and raised in Wazirabad, Pakistan and currently doing Undergraduation from National University of Science and Technology (NUST). On Twitter i go by @UsamaAzad14