By Simon Zambrovski, As more users switch to Linux for their daily computing needs, seamless remote communication has become essential. However, some users encounter challenges when trying to use Bluetooth headsets for conferencing.
Specifically, the current version of PulseAudio faces an issue with supporting Bluetooth headsets in both the A2DP profile (headphone mode with disabled microphone) and the HSP/HFP profile (lower headphone quality but with an enabled microphone). In this article, we explore potential solutions to address this issue and enhance the usability of Bluetooth headsets on Linux systems.
Steps to Enable Hands-Free Mode for Your Headset:
- Install Ofono
- Configure PulseAudio
- Set Up ofono-phonesim
- Configure Services Autostarts
1 Install Ofono : Open your console and run the following command:
sudo apt install ofono
2 Configure PulseAudio:
: In the file /etc/pulse/default.pa, locate the section where module-bluetooth-discover is loaded. Modify it as follows:
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover headset=ofono
.endif
Execute the following command to add the user “pulse” to the “bluetooth” group:
sudo usermod -aG bluetooth pulse
Grant Permissions for ofono: Edit the file /etc/dbus-1/system.d/ofono.conf and add the following block as the last policy:
<policy user=”pulse”>
<allow send_destination=”org.ofono”/>
</policy>
Read: How to manage sounds using PulseAudio on Ubuntu 18.04
3 Set Up ofono-phonesim
Install ofono-phonesim by running the following command:
sudo apt install ofono-phonesim
To create a virtual modem, create a new file named /etc/ofono/phonesim.conf with the following content:
[phonesim]
Driver=phonesim
Address=127.0.0.1
Port=12345
Feel free to choose a different port if you’re unable to use port 12345.
Manual mode
System Setup Completion: Your system setup is now complete for manual usage.
Start ofono-phonesim and Restart Bluetooth Stack: To use it, follow these steps:
Start ofono-phonesim by running the command:
ofono-phonesim -p 12345 /usr/share/phonesim/default.xml &
sudo service ofono restart
sudo service bluetooth restart
Test the Phonesim Modem: As a test, run the command:
/usr/share/ofono/scripts/list-modems
You should see the phonesim modem initialized.
Configure Bluetooth Settings: Open your Bluetooth settings (you can use Blueman or the built-in Ubuntu settings). Connect your Bluetooth device and switch it to the HSP/HFP profile.
Read: How to troubleshoot sound issues in Ubuntu 22.04
Setup automation
System Setup Completion: If your manual mode is functioning correctly, you’re almost there. However, manually executing the steps each time can be tedious. Let’s optimize your system startup to streamline this process.
Creating a systemd Unit File for Phonesim: To automatically start Phonesim when your system boots up, follow these steps:
- Create a new file named phonesim.service in the directory /etc/systemd/system/.
- Add the following content to the phonesim.service file:
Read: How to display your sound card details using the terminal on Ubuntu 22.04
Adjusting Port Settings: If you’ve modified the port in your modem definition, ensure that you update it accordingly.
Also, verify that the line containing ExecStart is correctly formatted.
Configuring ofono Service: To establish a dependency between ofono.service and phonesim.service, follow these steps:
Copy the original unit definition for ofono.service to /etc/systemd/system/ofono.service.
Modify the content of the copied file to:
Create the Unit File for Phonesim Modem:
Create a new unit file named /etc/systemd/system/ofono-modem.service.
Add the following content to the ofono-modem.service file:
[Unit]
Description=Enables Phonesim Modem
After=ofono.service
Requires=ofono.service
[Service]
Type=oneshot
ExecStart=/usr/share/ofono/scripts/enable-modem /phonesim
[Install]
WantedBy=multi-user.target
This service will run just after ofono.service and enable our modem during system boot.
Activate the Services on Boot:
Reload your systemd configuration and enable them by executing:
sudo systemctl daemon-reload
sudo systemctl enable phonesim
sudo systemctl enable ofono
sudo systemctl enable ofono-modem
Finally, reboot your system.
After the reboot, verify if the modem is directly connected by running the command: /usr/share/ofono/scripts/list-modems.
You should observe output similar to the following:
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.