Im trying to open a L2Cap HID Channel And Interrupt channel so I can send HID commands to a bluetooth device.
I've done all my service advertising and device paring and established a baseband connection.
The Hid Control channel opens fine. When I try to create my kBluetoothL2CAPPSMHIDInterrupt connection
l2capChannelQueueSpaceAvailable
delegate method called (not sure what this means) followed by
l2capChannelOpenComplete
but the connection closes immediately calling
l2capChannelClosed
How can I correctly open these connection?
I've spent a long time digging through the IOBlueTooth framework and the bluetooth.org HID spec but theres barely any helpful information (that I can find at least).
When i trace out my L2Cap channels I see some null values for
mIncomingDataListener
and
mEventDataListener
. I dont know how to set these or if they have anything to do with my problem.... just speculating.
The code snippet below is my attempt so far to make the connections after a connection to the device has been established.
-(void)establishL2CappConnections:(IOBluetoothDevice*)device
{
IOReturn r;
IOBluetoothL2CAPChannel *ch1;
r = [device openL2CAPChannelSync:&ch1
withPSM:(BluetoothL2CAPPSM)kBluetoothL2CAPPSMHIDControl
delegate:self];
self.mL2CappChannel=ch1;
NSLog(@"r == %i",r);
IOBluetoothL2CAPChannel *ch2;
r = [device openL2CAPChannelSync:&ch2
withPSM:(BluetoothL2CAPPSM)kBluetoothL2CAPPSMHIDInterrupt
delegate:self];
self.mL2CappInterruptChannel=ch2;
NSLog(@"r == %i",r);
}
Edit:1
I've attached my packet logs. It's strange, a request for
kBluetoothL2CAPPSMSDP 0x0001
gets made without me requesting it and then everything starts disconnecting.