If you use or have just migrated to the linux environment, especially in Ubuntu or Mint distros derived from Debian, you may encounter problems with the microphone of your bluetooth headset.

Especially now during the pandemic, the famous calls (video conferencing) are increasingly part of our daily lives. So you decided to buy that nice bluetooth headset to use and when you connected your microphone it didn't work? Don't worry, there is a way to get your bluetooth headset microphone working on linux.

This tutorial has been tested with JBL headphones and Air Pods, but it should work for most cases.

Activating the bluetooth headset microphone

In order for the headset to work properly with the microphone, you will need to enable the HSP/HFP audio profile. However, by default, the pulseaudio (sound server embedded in these linux distributions) only supports HSP. To make HSP/HFP work, we need to enable HFP in pulseaudio and for that we will use the service phone .

1. Install the phone

$ sudo apt install ofono

two. Configure the pulseaudio to use the phone
edit the file /etc/pulse/default.pa , find the line load-module module-bluetooth-discover and change to load-module module-bluetooth-discover headset=ofono

3. add user pulse to the group bluetooth so that it has the necessary permissions

$ sudo usermod -aG bluetooth pulse

4. Edit and add permissions on the file /etc/dbus-1/system.d/ofono.conf add the code below right before closing </busconfig>

<policy user="pulse"> <allow send_destination="org.ofono"/> </policy>

5. To make ofono work it is necessary to provide a modem for it. And for that we are going to install a modem emulator called phonesim that will be implemented by ofono to work. Install the phone sim :

$ sudo add-apt-repository ppa:smoser/bluetooth $ sudo apt-get update $ sudo apt-get install ofono-phonesim

6. Configure the phonesim adding the following lines to the file /etc/ofono/phonesim.conf

[phonesim]
Driver=phonesim Address=127.0.0.1 Port=12345

Now restart the ofono service:

$ sudo systemctl restart ofono.service

7. Now we need to define and enable some services to start ofono-phonesim as a service.

To execute ofono-phonesim -p 12345 /usr/share/phonesim/default.xml at system startup, create the file as root /etc/systemd/system/ofono-phonesim.service with the following content:

[Unit]
Description=Run ofono-phonesim in the background[Service] ExecStart=ofono-phonesim -p 12345 /usr/share/phonesim/default.xml Type=simple RemainAfterExit=yes[Install] WantedBy=multi-user.target

After the phone sim runs, you will also need to enable and bring the phonessim modem online.

For this we will use the code of a repository git:

$ cd /tmp $ git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git $ sudo mv ofono /opt/

Now you can enable and make the phonessim modem online by creating another service that depends on the ofono-phonesim service.Again, create a new service file as root the file at /etc/systemd/system/phonesim-enable-modem.service and put the following content:

[Unit]
Description=Enable and online phonessim modem Requires=ofono-phonesim.service[Service] ExecStart=/opt/ofono/test/enable-modem /phonesim ExecStart=/opt/ofono/test/online-modem /phonesim Type=oneshot RemainAfterExit=yes[Install] WantedBy=multi-user.target

Then run the following commands to enable and run the two daemons:

$ sudo systemctl daemon-reload $ sudo systemctl enable ofono-phonesim.service $ sudo systemctl enable phonessim-enable-modem.service $ sudo service phonessim-enable-modem start

Check that everything went as expected and that the service is running:

$ sudo service phonesim-enable-modem status

8. Finally, restart the pulseudio :

$ pulseaudio -k.

By now you should be able to see your headset as an input device in the sound setup part. There is a certain instability in this setup, from time to time it may be that your phone is misconfigured or the change of audio profile does not work, when this happens, restart the services as described above and also pulseaudio.

5 1 voto
Nota do Artigo
Subscribe
Notify of
guest

5 Comentários
newest
oldest most voted
Inline Feedbacks
View all comments
Stef
Stef
2 anos atrás

Unfortunately, there are some errors in the instructions.

On the one hand, several line breaks are missing in the lines and another error is that phonessim was accidentally written instead of phonesim. The tutorial at least works when that is corrected.

Nabawy
2 anos atrás

when trying to start phonesim-enable-modem.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

Alberto
Alberto
2 anos atrás

It does not work!

The unit files have no installation config (WantedBy=, RequiredBy=, Also=, Alias= settings in the [Install] section, and DefaultInstance= for template units). This means they are not meant to be enabled using systemctl.

Qqq
Qqq
2 anos atrás

The unit files have no installation config 

5
0
Would love your thoughts, please comment.x