Posts

Post not yet marked as solved
5 Replies
0 Views
I would look into the IOBluetooth API. It defines a IOBluetoothDeviceInquiry object that finds all bluetooth devices within range.The downside:IOBluetooth framework is only available on MacOS.https://developer.apple.com/documentation/iobluetoothThe iOS framework for CoreBluetooth might be of some assistance but from my experience it is a high level API with little to no ability to commicate with the kernel.https://developer.apple.com/documentation/corebluetooth
Post not yet marked as solved
3 Replies
0 Views
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.
Post not yet marked as solved
3 Replies
0 Views
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.