51

I got the Sony MDR-ZN770BN connected to my PC via bluetooth. But I can only use A2DP. When I switch it to HSP, I get message "Failed to change profile to headset_head_unit", so no skype calls possible.

How can I solve that?

5
  • 2
    Try changing to "off" profile before switching to headset
    – Jeremy31
    Sep 30, 2016 at 14:35
  • I confirm that changing profile to "off" and then back to "a2dp" works on Xubuntu 16.04
    – wlk
    Dec 23, 2016 at 20:51
  • 1
    How is your comment related to the question? @wlk
    – kostrykin
    Dec 21, 2018 at 18:26
  • 2
    As of Xubuntu 18.04 LTS (in April 2020) changing profile in Blueman to "off" and then to "Headset" does not work with gen 1 Apple Airpods. Mar 27, 2020 at 6:56
  • Ubuntu is tracking the problem in bugs.launchpad.net/bugs/1576559 Apparently, it's been fixed in release 21.10.
    – leggewie
    Jan 27, 2022 at 8:31

5 Answers 5

61

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:

22
  • 6
    I've never been so clueless when following orders, but it actually got my Huawei Freelace headphones to work! Thanks a lot.
    – iSWORD
    Sep 1, 2020 at 14:44
  • 4
    ofono-phonesim-autostart is not really working for me. How do I set it up? Oct 10, 2020 at 23:58
  • 3
    When I try to run ./enable-modem, I get the following error: File "/usr/lib/python3/dist-packages/dbus/connection.py", line 652, in call_blocking reply_message = self.send_message_with_reply_and_block( dbus.exceptions.DBusException: org.ofono.Error.Failed: Operation failed What does it mean and how do I get around it?
    – Zoltán
    Oct 13, 2020 at 21:19
  • 3
    I had to use ./enable-modem /phonesim and ./online-modem /phonesim in order to earphones mic to work but output quality becomes terrible so I prefer using Internal Microfone Built-in and discard this solution.
    – Eduardo
    Feb 11, 2021 at 21:56
  • 6
    feels like tutorial is incomplete by the end, the "ofono-phonesim -p 12345 /usr/share/phonesim/default.xml" , just hangs. Where to enable modem , which directory left to decide to the poor reader. Found 100 ofono polluted dirs. It is disgraceful to expect ubuntu to support airpods in 2021 out of the box. One day ... we say for last 30 years. Deleting all these voodoo packages and just accepting that i will have to switch to usb headphones to talk.
    – Aubergine
    Mar 9, 2021 at 17:17
49

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
    
  10. 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 --now disable pipewire-media-session.service
systemctl --user unmask pulseaudio
systemctl --user --now enable pulseaudio.service pulseaudio.socket

Copied from comments, in case of the error "Connection failure: Connection refused":

do this step:

systemctl --user restart pipewire-pulse
16
  • 2
    Thank you, this should be the accepted answer!! Just one thing, on your Medium post the hyphen autocorrect/formatting broke the systemctl commands, e.g. it looks like systemctl — user daemon-reload instead of systemctl --user daemon-reload Jun 1, 2021 at 10:17
  • 1
    When running pactl info I get Connection failure: Connection refused. pa_context_connect() failed: Connection refused even after I restarted it. Any clue what this could mean?
    – Karussell
    Jul 14, 2021 at 9:33
  • 6
    For connection fail: systemctl --user restart pipewire-pulse is missing after systemctl --user restart pipewire
    – Bernard
    Aug 9, 2021 at 16:31
  • 3
    All works. but profiles HSP, HFP are absent Sep 12, 2021 at 11:05
  • 2
    This should be the accepted answer, it worked great for me, on the contrary with the first answer... how is it that Ubuntu does not support Bluetooth Hear Phones by default as plug and play in 2021???
    – JVGD
    Nov 10, 2021 at 7:57
16

I originally posted this as an edit to @alisabzevari's post, but the edit was rejected :( I still think the information is very valuable, and I wouldn't like to lose it, so I'm posting it as an answer:

As of 2020-10-17, in Ubuntu 20.04 ofono-phonesim-autostart is not available. What you could do is create the following systemd units to start it as a daemon on startup:

To run ofono-phonesim -p 12345 /usr/share/phonesim/default.xml on startup as a systemd unit, create the file /etc/systemd/system/ofono-phonesim.service (as root) with the following contents:

[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 ofono-phonesim runs, you'll need to also enable and put the phonesim modem online. I (@Zoltán) did this by creating another systemd unit file that depends on the above ofono-phonesim systemd unit. Put the following contents in /etc/systemd/system/phonesim-enable-modem.service:

[Unit]
Description=Enable and online phonesim modem
Requires=ofono-phonesim.service
    
[Service]
ExecStart=/<path-to-cloned-ofono-git-repo>/test/enable-modem /phonesim
ExecStart=/<path-to-cloned-ofono-git-repo>/test/online-modem /phonesim
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Then run the following commands to run both daemons:

sudo systemctl daemon-reload

sudo systemctl enable ofono-phonesim.service
sudo systemctl enable phonesim-enable-modem.service
sudo service phonesim-enable-modem start

Check if the service is running with

sudo service phonesim-enable-modem status

Finally, restart pulseaudio with pulseaudio -k. Now you should be able to switch the profile to headset_head_unit.

7
  • Thanks for writing this. I also don't know why your edit got rejected. StackExchange has some strict rules. Dec 19, 2020 at 19:28
  • 1
    Getting error when executing command sudo service phonesim-enable-modem.service start as Failed to start phonesim-enable-modem.service.service: Unit phonesim-enable-modem.service.service not found.
    – timekeeper
    Dec 20, 2020 at 12:15
  • 1
    Before last command should be sudo service phonesim-enable-modem.service start Dec 24, 2020 at 9:58
  • Thanks @AndriySlobodyanyk, that's correct and I see your edit was already approved.
    – Zoltán
    Dec 26, 2020 at 17:01
  • @timekeeper see Andriy's comment, there was an error in my post.
    – Zoltán
    Dec 26, 2020 at 17:01
4

I tried everything i possibly could, even the above answers. But i couldn't use the microphone of my headset. So i found another way to use a mic.

All you need is an Android phone which has bluetooth.

Firstly, go to google playstore on your phone and download a bluetooth microphone app.

I used this one (Simple Bluetooth Mic): https://play.google.com/store/apps/details?id=com.app.google.chrischan.simplebluetoothmic

Alternatively, you can use this: https://play.google.com/store/apps/details?id=wimlog.com.myandroidtest4.

Connect the phone's bluetooth to your PC.

Now connect your bluetooth headset to the PC. (Both the devices must be connected simultaneously)

Open the Simple Bluetooth Mic App on your phone, click on speak.

Voila, that's it.

Basically you are using your phone's mic, because we can't use the bluetooth headset for both audio input and output.(changing from A2DP to HSP everytime you need to use the headset mic is irritating af)

If this doesn't work, go to your sound settings and choose the input device as your phone's bluetooth.

HOPE THIS HELPS :)

3
  • Many BT headsets cannot be connected to two devices at the same time. Apr 12, 2021 at 19:42
  • @FranMarzoa It's not about connecting BT headset to two different devices but connecting phone and headset to the PC and using headset's headphones along with phone's microphone.
    – Daniel
    Oct 16, 2021 at 7:31
  • @Daniel Oh I see, thanks. Oct 17, 2021 at 9:15
2

Encountered this problem after some decent uptime (260 days or so), pulseaudio -k did not help, neither did switching audio profile to "off".

Restarting bluetooth (systemctl restart bluetooth) did.

2
  • restarting bluetooth service helped for me! thank you :-) I didn't attempt the solutions mentioned in the other answers. Just FYI
    – asgs
    Aug 21, 2023 at 5:45
  • I'm glad I tried this first! This instantly fixed the problem. Thanks!
    – Jeff Lamb
    Sep 6, 2023 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .