Failed to change profile to headset_head_unit

Solution 1:

I had the similar problem on Ubuntu 18.04 with Galaxy Earbuds+ and here is how I solved it:

My earbuds profiles were A2DP, AVRCP and HFP and no support for HSP. Pulseaudio only supports HSP out-of-the-box. That's why I couldn't switch to HSP/HFP. In order to make HSP/HFP work, you have to enable HFP on pulseaudio which needs ofono.

  1. Install ofono:

    sudo apt install ofono
    
  2. Config pulseaudio to use ofono:

  • Goto /etc/pulse/default.pa find the line load-module module-bluetooth-discover and change it in load-module module-bluetooth-discover headset=ofono.

  • Add the user pulse to group bluetooth to grant the permission: sudo usermod -aG bluetooth pulse (probably it's already correct)

  • VERY IMPORTANT: To grant the permission, add this to /etc/dbus-1/system.d/ofono.conf (before </busconfig>):

      <policy user="pulse">
        <allow send_destination="org.ofono"/>
      </policy>
    
  1. Provide phonesim to ofono. In order to make ofono work, you have to provide a modem to it! You can install a modem emulator called phonesim (implemented by ofono) to make it work:
  • install ofono-phonesim (in some distros it is called phonesim). in Ubuntu 18.04 (for Ubuntu 20.04 follow this link):

     sudo apt install ofono-phonesim
    
  • Configure phonesim by adding the following lines to /etc/ofono/phonesim.conf:

      [phonesim]
      Driver=phonesim
      Address=127.0.0.1
      Port=12345
    
  • Restart ofono:

     sudo systemctl restart ofono.service
    
  • Start phonesim:

     ofono-phonesim -p 12345 /usr/share/phonesim/default.xml
    

Note that the command can be phonesim. To make sure phonesim is started correctly you can clone the ofono repo and use their test scripts:

cd /tmp
git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
cd ofono/test
./list-modems

You should see the modem in the result. You might have to first enable the modem by executing enable-modem and online-modem scripts in the same directory.

  • Once the modem is enabled, you should be able to enable HFP profile.
  1. Autostart phonesim. Since you have executed phonesim manually, after every restart you should execute it again. Instead you can install ofono-phonesim-autostart which will start the phonesim as a service.

References:

  • https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/
  • https://stackoverflow.com/a/51697709/692422
  • https://docs.plasma-mobile.org/Ofono.html

Solution 2:

I was facing the same issue with Oneplus Wireless Z Bass edition. My headset microphone was not detected by PulseAudio and the problem is that my headphones don't have HSP profile, only HFP profile. After trying for 2 days, I came to the solution of replacing PulseAudio with Pipewire sound server, which supports HSP, HFP and A2DP by itself. So there will be no need to install any other utility like ofono, phonesim. Also, to be noted that my problem wasn't resolved even after following all the steps to configure ofono in PulseAudio. So I came up with the steps to replace PulseAudio with PipeWire.

Here is the detailed article I have written to resolve this problem, the steps of which I'm also adding here. You can follow it and most probably be able to solve your problem.

Bluetooth headset microphone not detected

Open your terminal and follow these steps:

  1. We will use a PPA for adding Pipewire to Ubuntu 20.04, which is maintained regularly:

    sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
    
  2. To update the PPA packages in your system do:

    sudo apt update
    
  3. Install the package:

    sudo apt install pipewire
    
  4. There is also a dependency needed to be installed with Pipewire, otherwise you will face the issue of “Bluetooth headset won’t connect after installing pipewire”. Install the dependency by:

    sudo apt install libspa-0.2-bluetooth
    
  5. Now, to install the client libraries:

    sudo apt install pipewire-audio-client-libraries
    
  6. Reload the daemon:

    systemctl --user daemon-reload
    
  7. Disable PulseAudio:

    systemctl --user --now disable pulseaudio.service pulseaudio.socket
    
  8. If you are on Ubuntu 20.04, you also need to “mask” the PulseAudio by:

    systemctl --user mask pulseaudio
    

I am not sure but, if possible, you can try to run this on other versions too.
9. After a new update of Pipewire, you also need to enable pipewire-media-session-service:

   systemctl --user --now enable pipewire-media-session.service
  1. You can ensure that Pipewire is now running through:

    pactl info
    

    This command will give the following output, in Server Name you can see:

    PulseAudio (on PipeWire 0.3.28)
    

    Things should be working by now and you can see your microphone.

If it doesn’t show up, then try restarting Pipewire by this command:

systemctl --user restart pipewire

Also, you need to uninstall ofono and ofono-phonesim if you have them installed.

sudo apt remove ofono
sudo apt remove ofono-phonesim

If it’s still not showing your microphone, you can try rebooting once and remove and pair your Bluetooth device again to check if it works now.

I hope I have helped you solve your problem.

If you want to rollback all the changes we did, you can do it by using:

systemctl --user unmask pulseaudio
systemctl --user --now enable pulseaudio.service pulseaudio.socket