This is WIP patch series based on top of Bluetooth A2DP codecs patch series: !227 (closed)
This patch series contains support for HSP and HFP profiles, asynchronous reimplementation of connecting for A2DP, HSP and HFP profiles, asynchronous support for switching between HSP, HFP and A2DP profiles (including switching between different A2DP codecs) and more fixes for internal pulseaudio HSP implmentation (now marked as legacy). ofono support was removed as it is incompatible with this new design. Also connecting to HSP AG role via legacy internal implementation was removed as it was broken for a long time. hsphpfd implementation support both HSP HS and AG roles and HFP HF and AG roles.
For connecting HFP profiles it is needed running hsphfpd daemon, my working prototype implementation is available here: https://github.com/pali/hsphfpd-prototype This implementation of hsphfpd daemon does not provide support for local HFP HF role (means that computer would behave like HFP headset) yet, but supports at least local HSP HS role (means computer can behave like HSP headset).
To run hsphfpd daemon you just need to clone above hsphpfd repository and run:
sudo apt-get install libnet-dbus-perl sudo cp org.hsphfpd.conf /etc/dbus-1/system.d/ sudo ./hsphfpd.pl
Please test this code and let me know of any problems.
If SELinux is enabled, it is required to properly configure it. Otherwise pulseaudio would not be able to receive from hsphfpd audio socket.