site_archiver@lists.apple.com Delivered-To: bluetooth-dev@lists.apple.com Thread-index: Achj+IXsxEWjI8/rEdyi3QAWy4XsLw== Thread-topic: Leopard & Bluetooth RFCOMM channels User-agent: Microsoft-Entourage/11.3.6.070618 Looks like you do not really know which channel to open, because your iteration through the service directory simply returns the first channel which is not necessarily the right one. The channels are defined in "BluetoothAssignedNumbers.h". You can ask for a certain channel ID e.g. for a serial port like this: BluetoothRFCOMMChannelID getSerialPortChannel (IOBluetoothDevice *inDevice) { IOBluetoothSDPServiceRecord *dialupServiceRecord; BluetoothRFCOMMChannelID channel = 255; IOBluetoothSDPUUID *ourUUID = [IOBluetoothSDPUUID uuid16:(UInt16)kBluetoothSDPUUID16ServiceClassSerialPort]; dialupServiceRecord = [ inDevice getServiceRecordForUUID:ourUUID]; if (dialupServiceRecord) { IOReturn status = [dialupServiceRecord getRFCOMMChannelID:&channel]; if (status == noErr) return channel; } return 255; } You need to know the UUID of the service you want to connect to. If it is a predefined service like serial port, you find it in "SDPServiceClasses" otherwise you must create a SDPServiceClasses yourself. On 31.01.2008 11:21 Uhr, "Janusz Bossy" <janusz.bossy@gmail.com> wrote:
On 1/31/08, Joseph Kelly <joeman@mac.com> wrote:
Post the code that you're using to open the channel to the list and maybe somebody can spot something.
Here it goes:
-(void)awakeFromNib { isConnected = false; [IOBluetoothDevice registerForConnectNotifications:self selector:@selector(newConnection:fromDevi ce:)]; }
- (IBAction)click: (id)sender { NSArray *devices = [IOBluetoothDevice pairedDevices]; IOBluetoothDevice* dev = [devices objectAtIndex:0]; [dev openConnection]; }
-(void)newConnection:(IOBluetoothUserNotification*)notification fromDevice:(IOBluetoothDevice*)device { NSLog(@"New connection from %@", [device getName]);
IOReturn ret; NSArray* services = [device getServices];
BluetoothRFCOMMChannelID rfcommChannelID;
for (IOBluetoothSDPServiceRecord* service in services) { NSLog(@"Service: %@", [service getServiceName]); ret = [service getRFCOMMChannelID:&rfcommChannelID]; if (ret == kIOReturnSuccess) { NSLog(@"ChannelID FOUND"); break; } }
[device openRFCOMMChannelAsync:&channel withChannelID:rfcommChannelID delegate:self]; }
This is just a cut from the source code that seems adequate to my question. Console output for this code is:
2008-01-31 11:16:24.600 BluetoothGPS[1059:10b] New connection from BT GPS V10 2008-01-31 11:16:24.601 BluetoothGPS[1059:10b] Service: Spp 2008-01-31 11:16:24.603 BluetoothGPS[1059:10b] ChannelID FOUND
Ofcourse the class implements also all the RFCOMM delegate methods which don't get called at all.
- (void)rfcommChannelOpenComplete:(IOBluetoothRFCOMMChannel*)rfcommChannel status:(IOReturn)error; - (void)rfcommChannelData:(IOBluetoothRFCOMMChannel*)rfcommChannel data:(void *)dataPointer length:(size_t)dataLength; - (void)rfcommChannelClosed:(IOBluetoothRFCOMMChannel*)rfcommChannel; - (void)rfcommChannelControlSignalsChanged:(IOBluetoothRFCOMMChannel*)rfcommChan nel; -
(void)rfcommChannelFlowControlChanged:(IOBluetoothRFCOMMChannel*)rfcommChannel> ;
- (void)rfcommChannelWriteComplete:(IOBluetoothRFCOMMChannel*)rfcommChannel refcon:(void*)refcon status:(IOReturn)error; - (void)rfcommChannelQueueSpaceAvailable:(IOBluetoothRFCOMMChannel*)rfcommChanne l;
Ralf _______________________________________________ Do not post admin requests to the list. They will be ignored. Bluetooth-dev mailing list (Bluetooth-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/bluetooth-dev/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com