38

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?

4
  • 1
    Try changing to "off" profile before switching to headset
    – Jeremy31
    Sep 30 '16 at 14:35
  • I confirm that changing profile to "off" and then back to "a2dp" works on Xubuntu 16.04
    – wlk
    Dec 23 '16 at 20:51
  • 1
    How is your comment related to the question? @wlk
    – theV0ID
    Dec 21 '18 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 '20 at 6:56
55

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:

20
  • 2
    This solved it for me with AirPods on Ubuntu 18.04 Thanks! Jun 23 '20 at 16:26
  • 5
    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 '20 at 14:44
  • 4
    ofono-phonesim-autostart is not really working for me. How do I set it up? Oct 10 '20 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 '20 at 21:19
  • 5
    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 at 17:17
17

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
12
  • 1
    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 at 10:17
  • Thanks for your feedback! It really motivates me. Yes, even I saw this problem on Medium but couldn't fix the problem; that's why I posted steps separately.
    – 1nfern0
    Jun 2 at 5:36
  • Should be the accepted answer.
    – Marco M
    Jun 3 at 17:35
  • 1
    For connection fail: systemctl --user restart pipewire-pulse is missing after systemctl --user restart pipewire
    – Bernard
    Aug 9 at 16:31
  • 1
    All works. but profiles HSP, HFP are absent Sep 12 at 11:05
12

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 '20 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 '20 at 12:15
  • 1
    Before last command should be sudo service phonesim-enable-modem.service start Dec 24 '20 at 9:58
  • Thanks @AndriySlobodyanyk, that's correct and I see your edit was already approved.
    – Zoltán
    Dec 26 '20 at 17:01
  • @timekeeper see Andriy's comment, there was an error in my post.
    – Zoltán
    Dec 26 '20 at 17:01
2

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 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 at 7:31
  • @Daniel Oh I see, thanks. Oct 17 at 9:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.