Re: RFCOMM + SCO connection
Re: RFCOMM + SCO connection
- Subject: Re: RFCOMM + SCO connection
- From: "Harel M. Williams" <email@hidden>
- Date: Thu, 19 Apr 2007 11:13:13 -0400
Hi Mihnea,
It is definitely possible, and even necessary to have an RFCOMM
connection established in order for the SCO connection to be
established. I think what you are missing are the initialization steps
that you need to send across RFCOMM as well as advertising the 'Audio
Gateway'. You should refer to the Bluetooth Headset Profile Spec to
figure that out.
First, make sure you are advertising the 'Audio Gateway' profile on
your Mac (there is a plist for this service available somewhere in
/Developer/Examples/Bluetooth/...). An RFCOMM channel will be assigned
to this service, and you will have to make sure to communicate over
that specific channel. The headset should automatically communicate
with this channel because it is specified in the advertised service.
Second, the headset must be paired with the Mac. You can do this
through the Bluetooth Setup Assistant. It is nearly impossible to do
this programatically because the APIs for HCI aren't public. (On a
semi-related note, if you use Parallels to load up your favorite
variant of Linux, you can access the HCI layers using BlueZ, so I am
guessing that the developers of Parallels were granted access to these
"Private" APIs. If I am correct, that doesn't seem very fair. Do Apple
Engineers really want us using AppleScript to take care of pairing,
for example, programatically?)
Third, you must establish the RFCOMM connection. The headset will send
a bunch of AT commands over the link and you must respond as indicated
in the headset profile.
Once you have responded correctly, audio will be sent across the SCO
link. The difficult part here is getting a handle on the Audio data
from the Audio Device created by IOBluetoothAddSCOAudioDevice. As
Marco mentioned earlier on the bluetooth-dev list, you have to do a
bunch of CoreAudio gymnastics. But, before you delve into this, just
go into Audio System Preferences, and see if the meter on the SCO
Audio Device Output is moving as you scream into your Bluetooth
headset :) There may be a simpler way to get to the audio, but only
certain special people get access to the SCO Bluetooth Classes....
Hopefully that'll get you started. I intend on writing a guide on how
to do all of this, step by step, sometime soon. Also, I feel your
pain. I have struggled with similar issues, with very few hints from
the bluetooth-dev list. Apple Engineers, is there a reason that on
this specific issue you have been relatively silent as far back as I
can tell according to the archives? It seems to me that everyone who
has figured out this problem has used a technical incident and then
say they can't help because they are under NDA. I don't get it...and
not all of us can (afford to) attend the WDC.
-Harel
On 4/19/07, Mihnea Galca <email@hidden> wrote:
Hello,
Is it possible to have a rfcomm connection with a bluetooth headset
on top of which to start/stop SCO connection ?
Usage scenario: a RFCOMM connection has to be maintained to a bluetooth
headset to get button press events, but in the same time, SCO is
activated to play/record sounds using the headset.
So far, I could make a RFCOMM connection to capture button press events,
but I couldn't start SCO in any way. SCO seems connected to a system audio
device which connects/disconnects the headset when needed. I couldn't find
any method to control SCO from API.
How can I solve the problem in the above given scenario ?
Do I need to develop my own SCO layer over RFCOMM and create a new audio
device driver ? Any pointers to do such a thing ? I've tried
IOBluetoothAddSCOAudioDevice, but it's a deprecated function
and the only thing it does, is to create the associated audio device, if
such a device is not already present. My code is the following:
void* keys[1];
keys[0]=[[NSString alloc] initWithCString:"IOAudioControls"];
void* values[1];
id array=[[NSMutableArray alloc] init];
values[0]=array;
CFDictionaryRef dictionary=CFDictionaryCreate(NULL,keys,values,1,
&kCFTypeDictionaryKeyCallBacks,&kCFTypeDictionaryValueCallBacks);
IOReturn res=IOBluetoothAddSCOAudioDevice(m_headset,dictionary);
The operation was successful in the case when the audio device didn't
exist. In the case when the device existed (created using bluetooth
interface in the OS), the function returned a general error.
Regards,
Mihnea GALCA
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden