Common Bluetooth Problems in Ubuntu and How to Fix Them
Tags: bluetooth, ubuntu, problems
Published: 2020-10-05 21:49:15

From time to time when you are using Ubuntu Linux and you want to use your Bluetooth headset to watch Netflix or YouTube videos you may experience some problems with the Bluetooth connection on Linux.

The [Bluetooth in Linux](https://www.zdnet.com/article/hands-on-using-bluetooth-on-linux/) functions thanks to the interaction of different modules like the Linux kernel, the drivers, client apps, pulseaudio and Bluez. To learn more about Bluetooth please refer to [this article](https://www.audioreputation.com/bluetooth-audio-codecs/).

**Problem #1 Bluetooth isn’t available when you wake up the system**

When you put your system to sleep, there are chances Bluetooth won’t be available when you wake it up. In order to make everything work fine as before in most cases you will need to restart the system. 

On the other hand, sometimes you will need to disconnect the device and pair it up again with your system. 

One of the main reasons for such behavior was a bug in the Bluez version 4.48. The bug was responsible for the situation described above and other common actions like connecting, disconnecting and pairing. Luckily. Most bugs including this one were fixed in the next versions of Bluez.

**Quick Fix**

In order to fix this issue, we need to launch the Terminal and check whether we have the 4.48 version of Bluez. You can easily do that with this command:

```dpkg --status bluez | grep '^Version:'```

When you see the results, use the following commands to update to the latest version:

```sudo add-apt-repository ppa:bluetooth/bluez
sudo apt-get update```

After these commands, you will be able to update the Buez using:

```sudo apt upgrade```

A new version of Bluez will provide better behavior during the actions mentioned above and you should still have access to your Bluetooth connection when you wake up the system.

**Problem #2 Bluetooth headset won’t play in A2DP (High Fidelity)**

**Quick Fix**

In order to fix this issue, you will need to make your system detect the right type of Bluetooth device by adding a simple configuration file. 

First, let’s check whether we have all the dependencies installed:

```sudo apt install pulseaudio pulseaudio-utils pavucontrol pulseaudio-module-bluetooth```

When we verify it, we need to create or edit this audio config file:

```sudo gedit /etc/bluetooth/audio.conf```

Include the next lines:

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

Now it’s time to save the file and start the Bluetooth service again.

```sudo service bluetooth restart```

You are good to go. Now you will be able to listen to your Bluetooth audio at a2dp (high fidelity) mode. Enjoy!

Problem #3 After automatic pairing when the system booths Bluetooth won’t play sounds in Bluetooth headset 

In most cases the first thing we do after we boot up our system is turning on the Bluetooth headset. Sometimes the system and the device pair up well but no sound. If you use the command **journalctl -f** you will receive the next message:

```pulseaudio[1148]: [pulseaudio] module-bluez5-device.c: Profile a2dp_sink has no transport
pulseaudio[1148]: [pulseaudio] module-bluez5-device.c: Refused to switch profile to a2dp_sink: Not connected```

Connecting the device again will usually resolve the issue, but this isn’t something we would like to do often. The reason for that is that the Bluetooth device must work immediately after the system boots up.

**Quick Fix**

One of the solutions is to press the Play/Pause button after you pair the system and the device. This will make the gnome sound manager have the A2DP available. With this option on you can easily set the audio output in the menu. Although this solution isn’t ideal, it does the job. 

To make the process easier you can add a shortcut to set this output when the pairing completes and the Play/Pause button is pressed. Here is the command:

```nano .bashrcThen add the following line at the end:
alias soundon = 'pacmd set-card-profile device_name a2dp_sink'```

Please note that you can replace the **“Device_name”**. Once the pairing completes you can identify your device with this command:

```pacmd list-cards```

This will appear as a result:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/z498dq5wvcpexfkz5g2f.png)

As you can see the device is identified as **“bluez_card.00_16_94_0B_5F_DE”**. So, you need to replace the **device_name** with **bluez_card.00_16_94_0B_5F_DE**. This is just an example, replace the device name with the result you receive after you use the command.