sadanand-singh / reckoning.dev.comments

0 stars 0 forks source link

blog/airpods-pro-ubuntu/ #4

Closed utterances-bot closed 1 year ago

utterances-bot commented 3 years ago

Setting up Airpods Pro on Ubuntu 20.04 | reckoning.dev

If you have apple airpods or airpods pro, and sometimes want to use it with your Ubuntu machines, follow this guide! If you try to pair…

https://reckoning.dev/blog/airpods-pro-ubuntu/

wangliax commented 3 years ago

However, after enabled HFP, you may can't switch back to A2DP again, have you tried? thanks!

kforner commented 3 years ago

There are some typos: in /etc/systemd/system/phonesim-enable-modem.service you typed ofone instead of ofono. Then you have to compile ofono, and for this you need ell: cf https://askubuntu.com/questions/1204810/make-no-rule-to-make-target-ell-util-c-needed-by-ell-util-lo It would be even better to use a specific commit/tag to ensure reproducibility.

Thanks a lot fore your tutorial.

poldpold commented 3 years ago

There are two typos in {{phonesim-enable-modem.service}}, the two paths should say {{/opt/ofono}} instead of {{/opt/ofone}}.

poldpold commented 3 years ago

Oops, looks like the previous poster got this one already, sorry. However, now I'm running into this other problem that does not seem to have a solution online: https://www.reddit.com/r/linux4noobs/comments/mhvcp0/linux_lite_ofono_installation_for_bluetooth/ . Looks like an issue with my python version, but it's hard to say how to fix it.

poldpold commented 3 years ago

Some insight into the python / modem issue, although no solution yet: https://forums.linuxmint.com/viewtopic.php?p=1963473 .

sadanand-singh commented 3 years ago

Thanks for pointing out the typos. I have fixed them now. I have also added particular commit of ofono that I have used.

sadanand-singh commented 3 years ago

Oops, looks like the previous poster got this one already, sorry. However, now I'm running into this other problem that does not seem to have a solution online: https://www.reddit.com/r/linux4noobs/comments/mhvcp0/linux_lite_ofono_installation_for_bluetooth/ . Looks like an issue with my python version, but it's hard to say how to fix it.

May be you should try again with the particular commit that I have pointed to. Also, just to make sure, you are using Ubuntu 20.04, right?

sadanand-singh commented 3 years ago

However, after enabled HFP, you may can't switch back to A2DP again, have you tried? thanks!

No, Its been working fine for me, you might to switch manually in Settings.

poldpold commented 3 years ago

May be you should try again with the particular commit that I have pointed to. Also, just to make sure, you are using Ubuntu 20.04, right?

If by particular commit you mean the repo ppa:smoser/bluetooth it is indeed that one. You're correct, I'm on 20.04. Wish I could be of more help.

efillman commented 3 years ago

So easy a caveman could do it! Thank you!

multiplexcuriosus commented 3 years ago

Hy. I am a total noob and rarely able to resolve errors in the console when I'm just copy pasting random code from the internet. Still I wanted to ask if someone could give me adivce on what to do about the following error message, which I received after doing:

/tmp# git checkout b3682c6bab99cbe301fa9bf4a2416c3f730d8bfd

fatal: not a git repository (or any of the parent directories): .git

I tried a few other commits from https://git.kernel.org/pub/scm/network/ofono/ofono.git/log/, all the while having no idea what i was doing, but all of the commits i tried yielded the error message from above. Thanks for any help!

MGelbana commented 3 years ago

multiplexcuriosus, you need to cd ofono/ after cloning the repo, then you need to cd .. before running sudo mv ofono /opt/.

ghost commented 3 years ago

@poldpold I also just had the issue with b3682c6bab99cbe301fa9bf4a2416c3f730d8bfd so I tried the current head (4adcc7f965495aa321348fd4530f1075fbdee0d0) instead and it works now.

primetimber commented 3 years ago

Hi all. I am using Pop!_OS 21.04. I am guessing I am having a different problem here, am I?

morhook commented 3 years ago

Awesome guide! It worked on Ubuntu 21.04. I only had to add a small sleep 2 on /etc/systemd/system/phonesim-enable-modem.service as my machine randomly failed on that script on startup. (also used this info for a post on SO https://askubuntu.com/a/1350854/170833 )

captainkovalsky commented 3 years ago

Are there some scripts.sh for doing these steps automatically?

gSpikey commented 2 years ago

I just ran through that recipe on Ubuntu 20.04 and I only had to do some small tweaks with the git steps. This first line is to install git

sudo apt install git
cd /tmp
git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
cd ofono/
git checkout    b3682c6bab99cbe301fa9bf4a2416c3f730d8bfd
cd ..
sudo mv ofono /opt/
gSpikey commented 2 years ago

I also appeared to have issues switching to/from HFP/A2DP. In settings it would let me switch between the two - but the left/right speaker test didn't make any sound. I think that turned out to be independent volume controls. It started working after I rebooted and played with the volume controls. It now automatically pauses Spotify and switches to HFP when I answer a call in Teams. It also automatically switches back to A2DP when the call ends and resumes my spotify music.

Thanks @sadanand-singh for putting together this guide!

I also ran into the start up issue. I'm assuming this delay is required because I have a boot up script that auto connects to my bluetooth headphones, maybe there's some sort of race condition there. So here's an updated /etc/systemd/system/phonesim-enable-modem.service

[Unit]
Description=Enable and online phonesim modem
Requires=ofono-phonesim.service

[Service]
ExecStart=sleep 5
ExecStart=/opt/ofono/test/enable-modem /phonesim
ExecStart=/opt/ofono/test/online-modem /phonesim
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
adrien-chinour commented 2 years ago

I needed to run some extras commands after clone ofono :

cd /tmp
git clone https://git.kernel.org/pub/scm/network/ofono/ofono.git
git clone https://git.kernel.org/pub/scm/libs/ell/ell.git

cd ofono
autoreconf -fi && ./configure && make

cd ..
sudo mv ofono /opt/

ofono require ell : https://git.kernel.org/pub/scm/network/ofono/ofono.git/about/

I clone repo on commit 3940a1014631c0a51ddf2ec2e5f1db634e68cee5 on ell and 6ee67e14a69fd90ad6dbb9e06dd2518cba58cfce on ofono

morhook commented 2 years ago

Hey guys! I've switched from using ofono + pulseaudio to use pipewire instead. Now I have 16k of quality on the microphone of my AirPods. https://askubuntu.com/a/1350854

iizno commented 2 years ago

@morhook Could you kindly explain how to "clean" everything we did here with ofono to use pipewire instead please ?

morhook commented 2 years ago

Of course @iizno ! Remove all ofono packages for starting:

 sudo apt remove ofono ofono-phonesim

(If you have installed from git repo instead of apt you might need to run a sudo make uninstall from the source code)

And also disable the startup services with commands like

sudo systemctl disable ofono-phonesim
sudo systemctl disable phonesim-enable-modem

And if you are fan of clean systems, erase also the PPA you added:

sudo add-apt-repository -r ppa:smoser/bluetooth
iizno commented 2 years ago

@morhook Thank you very much for you quick answer !

Do I need to delete /opt/ofono too ? And do i need to revert the file /etc/pulse/default.pa ? in order to remove the headset=ofono addition we did ?

morhook commented 2 years ago

Yes @iizno ! Undo the headset=ofono modification on /etc/pulse/default.pa and also delete /opt/ofono.

iizno commented 2 years ago

@morhook Thank you ! That was really helpfull. It now works with pipewire !

I've got this now in the sound settings :

image

If I select A2DP Sink, the sound quality is good, but i can not select the airpod in tne input device If I select HSP/HFP, the sound quality is really bad, but then i CAN select the airpod in the input device.

Do you have any idea how I can increase the sound quality in hsp mode or switch easily between the two of them when I need the microphone ?

morhook commented 2 years ago

Directly select codec mSBC that is the best one. That's how I do it

morhook commented 2 years ago

When you hear music select A2DP SBC, AAC one gave me some problems.

kevitivity commented 2 years ago

This appears to be a real mess and not easily maintainable for users...

These are packages for improved bluetooth. Specifically I want/need my anker Q20 headset to work in hfp mode.

ofono-phonesim got dropped from debian/ubuntu because it depended on qt4. Shortly after that someone ported to qt5 [1]. I filed a debian #960941 [2] to re-add it.

As far as I can tell, the ofono-phonesim solution described at [3] is still required, so here we are. It seems that a upstream solution is being discussed at [4,5,6] which may include 'hsphfpd' [7]

Note 2021-11-02: Uploaded a no-change backport of pulseaudio from 21.10 to focal which fixes some headsets for me. It now has some built-in hfp support. (LP: #1576559 / pa #84 [8])

[1] https://git.kernel.org/pub/scm/network/ofono/phonesim.git [2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=960941 [3] https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index5h2 [4] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/722 [5] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/94 [6] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/288 [7] https://github.com/pali/hsphfpd-prototype [8] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/84 More info: https://launchpad.net/~smoser/+archive/ubuntu/bluetooth Press [ENTER] to continue or Ctrl-c to cancel adding it. ^C

charltonstanley commented 2 years ago

So i switched to using pipewire as @morhook had suggested. It does indeed work better when using the microphone!

However, it appears that the volume sliders for any of the A2DP profiles don't work (I would prefer to use A2DP when listening to music). Does anybody have any ideas as to why that is, or how to fix that?

Thanks!

preetsindhal commented 2 years ago

after following the above steps did you guys face any drop in the quality of audio like some random cracks or the voice or the difference in bets in general? I think i have, i will test more and see.

Thanks!

charltonstanley commented 2 years ago

@preetsindhal no I haven't experienced any cracks or voice issues, outside of what is to be expected when you are using one of the HSP profiles, which you have to do if you want to use the microphone.

dgbaenar commented 2 years ago

Hi guys, I kindly appreciate your help because my sound is working but not the microphone because my airpods doesn't appear in the list of input devices.

I did all the steps listed by @morhook in the linked post of https://askubuntu.com/questions/922860/pairing-apple-airpods-as-headset/1350854#1350854 using Pipeware and uninstalling ofono as you said, but my airpods doesn't appear in the input devices.

Thank you so much for your help.

morhook commented 2 years ago

hello @dgbaenar ! Have you connected via bluetooth the airpods first? After doing that can you run pactl list cards? On my machine I see something like this:

Card #612                                                                                                                                                                                                  
        Name: bluez_card.60_BE_C4_xx_xx_xx                                                           
        Driver: module-bluez5-device.c                                                               
        Owner Module: n/a                                                                            
        Properties:                                                                                                                                                                                        
                device.api = "bluez5"                                                                                                                                                                      
                device.bus = "bluetooth"                                                             
                media.class = "Audio/Device"                                                                                                                                                               
                device.name = "bluez_card.60_BE_C4_xx_xx_xx"                                                                                                                                               
                device.description = "AirPods de Morhook"                                                                                                                                                  
                device.alias = "AirPods de Morhook"                                                                                                                                                        
                device.vendor.id = "bluetooth:004c"                                                                                                                                                        
                device.product.id = "0x200f"                                                                                                                                                               
                device.form_factor = "headphone"                                                                                                                                                           
                device.string = "60:BE:C4:xx:xx:xx"                                                  
                api.bluez5.icon = "audio-card"                                                                                                                                                             
                api.bluez5.path = "/org/bluez/hci0/dev_60_BE_C4_xx_xx_xx"                                                                                                                                  
                api.bluez5.address = "60:BE:C4:xx:xx:xx"                                             
                api.bluez5.device = ""                                                               
                api.bluez5.class = "0x240418"                                                        
                api.bluez5.connection = "connected"                                                  
                device.icon_name = "audio-headphones-bluetooth"                                                                                                                                            
                bluez5.auto-connect = "[ hfp_hf hsp_hs a2dp_sink ]"                                                                                                                                        
                factory.id = "14"                                                                                                                                                                          
                client.id = "31"                                                                                                                                                                           
                object.id = "102"                                                                    
                object.serial = "612"    
morhook commented 2 years ago

Another thing you can try @dgbaenar to get us more info is to run sudo dmesg -wH. You might need to "know" a little bit what are normal messages in that log (those are messages from the kernel are mostly all hardware). What Linux are you using?

seschu commented 2 years ago

Is any body familair with this error?

~$ sudo service phonesim-enable-modem start
Job for phonesim-enable-modem.service failed because the control process exited with error code.
See "systemctl status phonesim-enable-modem.service" and "journalctl -xe" for details.
ses@ses-nb2-t470p:~$ systemctl status phonesim-enable-modem.service
● phonesim-enable-modem.service - Enable and online phonesim modem
     Loaded: loaded (/etc/systemd/system/phonesim-enable-modem.service; enabled>
     Active: failed (Result: exit-code) since Wed 2022-04-27 11:17:31 CEST; 7s >
    Process: 3399 ExecStart=/opt/ofono/test/enable-modem /phonesim (code=exited>
   Main PID: 3399 (code=exited, status=1/FAILURE)

Apr 27 11:17:30 ses-nb2-t470p enable-modem[3399]:   File "/usr/lib/python3/dist>
Apr 27 11:17:30 ses-nb2-t470p enable-modem[3399]:     self.start_service_by_nam>
Apr 27 11:17:30 ses-nb2-t470p enable-modem[3399]:   File "/usr/lib/python3/dist>
Apr 27 11:17:30 ses-nb2-t470p enable-modem[3399]:     return (True, self.call_b>
Apr 27 11:17:30 ses-nb2-t470p enable-modem[3399]:   File "/usr/lib/python3/dist>
Apr 27 11:17:30 ses-nb2-t470p enable-modem[3399]:     reply_message = self.send>
Apr 27 11:17:30 ses-nb2-t470p enable-modem[3399]: dbus.exceptions.DBusException>
Apr 27 11:17:31 ses-nb2-t470p systemd[1]: phonesim-enable-modem.service: Main p>
Apr 27 11:17:31 ses-nb2-t470p systemd[1]: phonesim-enable-modem.service: Failed>
Apr 27 11:17:31 ses-nb2-t470p systemd[1]: Failed to start Enable and online pho>
ses@ses-nb2-t470p:~$ journalctl -xe
Apr 27 11:17:31 ses-nb2-t470p systemd[1]: phonesim-enable-modem.service: Main p>
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStart= process belonging to unit phonesim-enable-modem.service has ex>
-- 
-- The process' exit code is 'exited' and its exit status is 1.
Apr 27 11:17:31 ses-nb2-t470p systemd[1]: phonesim-enable-modem.service: Failed>
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit phonesim-enable-modem.service has entered the 'failed' state with r>
Apr 27 11:17:31 systemd[1]: Failed to start Enable and online pho>
-- Subject: A start job for unit phonesim-enable-modem.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit phonesim-enable-modem.service has finished with a failu>
-- 
-- The job identifier is 3506 and the job result is failed.
Apr 27 11:17:31  sudo[3388]: pam_unix(sudo:session): session close>
taruantnew commented 2 years ago

Thank you. Thanks to this, I was able to connect the airpods pro. But they still don't work as a microphone... https://i.imgur.com/XJ1K6fF.png