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?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityI 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?
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.
Install ofono
:
sudo apt install ofono
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>
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.
ofono-phonesim-autostart
which will start the phonesim as a service.References:
ofono-phonesim-autostart
is not really working for me. How do I set it up?
Oct 10, 2020 at 23:58
./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?
./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.
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:
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
To update the PPA packages in your system do:
sudo apt update
Install the package:
sudo apt install pipewire
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
Now, to install the client libraries:
sudo apt install pipewire-audio-client-libraries
Reload the daemon:
systemctl --user daemon-reload
Disable PulseAudio:
systemctl --user --now disable pulseaudio.service pulseaudio.socket
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.
After a new update of Pipewire, you also need to enable pipewire-media-session-service
:
systemctl --user --now enable pipewire-media-session.service
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
systemctl
commands, e.g. it looks like systemctl — user daemon-reload
instead of systemctl --user daemon-reload
Jun 1, 2021 at 10:17
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?
Jul 14, 2021 at 9:33
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
.
sudo service phonesim-enable-modem.service start
as Failed to start phonesim-enable-modem.service.service: Unit phonesim-enable-modem.service.service not found.
Dec 20, 2020 at 12:15
sudo service phonesim-enable-modem.service start
Dec 24, 2020 at 9:58
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 :)
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.