HFP profile with linux and iphone 5

progo picture progo · Jul 30, 2014 · Viewed 7.2k times · Source

how can I use hfp on my ubuntu linux with iphone 5s? I have bluetoooth, all bluez packages and ofono installed.

For ofono I need a modem. From what I understood from bluetooth core, protocoll and profile specification, rfcomm and spp of bluetooth can be used to emulate a modem. How does this work with bluez? Do the bluetoothd and ofonod dbus-services already handle incoming connections to hfp oder do I have to write my own listener?

EDIT:

The program is running. I implemented it according to the test-scripts. But I am experiencing audio issues, as I don't have any sound when performing calls. The sound is not muted.

pa log (translated):

Sep 26 13:57:47 ubu2 pulseaudio[2524]: [alsa-sink-Intel ICH] alsa-sink.c: ALSA woke us up to write new Data on the Device but there was nothing to write!
Sep 26 13:57:47 ubu2 pulseaudio[2524]: [alsa-sink-Intel ICH] alsa-sink.c: This is most probably an Error of the ALSA-Driver 'snd_intel8x0'. Please send this error to the ALSA-Developers.
Sep 26 13:57:47 ubu2 pulseaudio[2524]: [alsa-sink-Intel ICH] alsa-sink.c: We have been woken up by the POLLOUT-Set, but a following call of snd_pcm_avail() returned the value 0 or another value smaller than min_avail.

How can I see if ALSA has encountered some errors? I found no log.

When connecting the a2dp-Profile so that my computer are the speakers of the iPhone I also have no sound.

EDIT 2:

To solve this error, this is recommended:
File: /etc/pulse/default.pa
Add tsched=0 to the following line:
load-module module-detect
from post #21 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/374002

But it does not solve my issue. I try force-loading the also modules too.

Answer

Prathyush picture Prathyush · Aug 3, 2014

Having ofono and bluez should be enough.

However, latest version of bluez/ofono and pulseaudio don't support HSP and HFP profiles. Pulseaudio release notes say that only A2DP is supported with bluez5.x. If you are using bluez4.x, ofono and pulseaudio 4.x/5.x you might still get this working without a problem.

http://www.freedesktop.org/wiki/Software/PulseAudio/Notes/5.0/

ofono will treat your iPhone 5s as your modem. Once you get the iPhone paired and connected through bluetoothctl or any alternative GUI, you could run the following ofono tests to see if ofono picked it up right. Try running ofonod using ofonod -n -d on a terminal to monitor the debug log and probably run pulseaudio in verbose too (pulseaudio -k && pulseaudio -v)

bash$ cd */ofono-1.x/test

This directory contains sample dbus scripts to test the ofono functionalities.

bash$ ./list-modems

[ /hfp/org/bluez/hci0/dev_94_94_26_88_XX_XX ]
    Type = hfp
    Interfaces = org.ofono.Siri org.ofono.VoiceCallManager org.ofono.CallVolume org.ofono.Handsfree org.ofono.NetworkRegistration 
    Features = net 
    Serial = 94:94:26:88:XX:XX
    Online = 1
    Powered = 1
    Lockdown = 0
    Emergency = 0
    Name = XXXXXX’s iPhone
    [ org.ofono.Siri ]
        EyesFreeMode = disabled
        Enabled = 1
    [ org.ofono.VoiceCallManager ]
        EmergencyNumbers = 08 000 999 110 112 911 118 119 
    [ org.ofono.CallVolume ]
        Muted = 0
        SpeakerVolume = 50
        MicrophoneVolume = 50
    [ org.ofono.Handsfree ]
        VoiceRecognition = 0
        InbandRinging = 1
        Features = three-way-calling echo-canceling-and-noise-reduction voice-recognition release-all-held release-specified-active-call private-chat create-multiparty 
        BatteryChargeLevel = 4
        SubscriberNumbers = +XXXXXXXXXXXX
        EchoCancelingNoiseReduction = 1
    [ org.ofono.NetworkRegistration ]
        Status = registered
        Name = XXX XXXXXX
        Mode = auto-only
        Strength = 60

If you see output similar to above, enable the modem and try dialling using the following command and observe ofono debug log if SCO socket is created or rejected. And, of course, see if the audio is routed to Ubuntu.

bash$ ./enable-modem

bash$ ./dial-number +XXXXXXXXXXXX
...

Similarly, try calling up your iPhone and observe the ofono, pulseaudio logs. bash$ ./answer-calls

Looks like folks at pulseaudio are trying to get this working with bluez5.x and ofono but there doesn't seem to be a patch available publicly yet. The bug is being tracked here: https://bugs.freedesktop.org/show_bug.cgi?id=73325