How to set bluetooth profile to allow iPhone to Mac pairing for audio communication

I had the intention of designing an audio routing app for the iPhone. My goal was to pair my iPhone (ME344LL/A) to a computer (MBP 11,1) and send audio over Bluetooth to the iPhone.


My problem is that my computer wont pair to my iPhone as an audio device. I looked into the Bluetooth profiles and it appears that if I can manually set the profile on my iPhone then my computer can pick it up.


This must be possible, maybe not by default but I must be able to override the iOS defaults. Thank you for any help anyone can provide!

UPDATE:


So by playing around with the CoreBluetooth framework I was able to establish a connection between the two devices. I configured the iPhone as the Central and connected to the computer as a peripheral. From that I can list the available services from the computer. The three services that show up are as follows: Device Info, <9FA480E0-4967-4542-9390-D343DC5D04AE>, and Continuity. None of the services are notifying, and I've looked through all of thier characteristics and I cant find anything promising for audio connectivity.


Also, I have already setup an AVAudioSession from the sharedInstance and set the configuration of PlayAndRecord with options of .allowBluetooth. Then I checked the available inputs and the only route listed was the iPhone Microphone.

UPDATE:


Unfortunately I was not able to get the audio to work from the iPhone so I moved to the mac and attempted to establish the connection from there. Immediately I noticed that there is no AVAudioSesion object available on OSX!


I read up on the documentation for the CoreBluetooth, CoreAudio and IOBluetooth APIs. I was able to use a IOBluetoothDevicyInquiry Object to find the iPhone, then create an IOBluetoothHandsFreeDevice.


How to:

Add IOBluetoothDeviceInquiryDelegate and IOBluetoothHandsFreeDeviceDelegate to the NSViewController.


Create the IOBluetoothDeviceInquiry object within the viewDidLoad method with self as the delegate and start the inquiry.


Define the deviceInquiryDeviceFound and deviceInquiryComplete functions inside of the NSViewController class for callback.


The deviceInquiryDeviceFound function stops the inquiry and the deviceInquiryComplete function creats the IOBluetoothHandsFreeDevice object with the iPhone as the device.


At this point I was able to call the connect method defined in the IOBluetoothHandsFree (IOBluetoothHandsFreeDevice inherits from IOBluetoothHandsFree) to establish a baseband connection between the iPhone and the Mac.


Heres where I’m stuck…


The IOBluetoothHandsFree.connect method documentation states:

“Connects to the device and sets up a service level connection (RFCOMM channel). Delegate methods will be called once the connection is complete or a failure occurs.”


It claims to establish the RFCOMMChannel but I cannot find any pointers to the channel from within the IOBluetoothHandsFreeDevice or the parent classes.


I added the IOBluetoothRFCOMMChannelDelegate to the NSViewController in hopes that it would callback from the connect method with the rfcommChannelOpenComplete and rfcommChannelData methods but alas nothing.


On the audio side:


I believe that if I can get access to the data pointer from the RFCOMMChannel then I can create an AVAudioPlayer object with the data as the source…BUT I want to send audio data from the mac to the iPhone not the other way around.

Hi @evanman, were you able to find any solution? My use case is to use the mac as Bluetooth headset/mic for iPhone, similar to how we do it in Linux: https://ostechnix.com/turn-your-linux-pc-into-bluetooth-speakers-for-your-phone/

How to set bluetooth profile to allow iPhone to Mac pairing for audio communication
 
 
Q