From: Eric Brown <esb@apple.com> To: Keith Phu <kphu@hotmail.com> CC: bluetooth-dev@lists.apple.com Subject: Re: RFCOMMClient and Server Examples Date: Wed, 18 Sep 2002 11:44:54 -0700 On Wednesday, September 18, 2002, at 03:34 AM, Keith Phu wrote: Has anyone gotten the RFCOMMServer and RFCOMMClient example code to work? I can start the server, and the 'chat server' service is visible on the client side. But when I try to select the 'chat server' service, no connection is made. After a day of debugging I think I've narrowed down my problem. I think the server software isn't detecting the incoming RFCOMM Channel being set up by the client. Stepping through the client code, the client is stalling on the following line. if ((result == kIOReturnSuccess) && (IOBluetoothDeviceOpenRFCOMMChannel(connectToDevice ,rfcommChannelID, &rfcommChannel) == kIOReturnSuccess)) { which led me to believe that the server is not registering an incoming data listener. Now looking through the server code, it appears that it registers an incoming data listener in the newRFCOMMChannelOpened function. This function is supposed to be called automatically when an incoming channel is detected. It's setup in the following line incomgingChannelNotification = [IOBluetoothRFCOMMChannel registerForChannelOpenNotifications:self selector:@selector(newRFCOMMChannelOpened:) withChannelID:serverChannelID direction:kIOBluetoothUserNotificationChannelDirectionIncoming]; This line is the problem. There was a change in the way that channel open notifications work made between the preview release and Jaguar. A change is needed in the @selector() passed to the register method. The line should read: incomgingChannelNotification = [IOBluetoothRFCOMMChannel registerForChannelOpenNotifications:self selector:@selector(newRFCOMMChannelOpened:channel:) withChannelID:serverChannelID direction:kIOBluetoothUserNotificationChannelDirectionIncoming]; The sample will be fixed in a future release. Using BluetoothMonitor, I can see that an RFCOMM channel does in fact exist. So I think that the handler (newRFCOMMChannelOpened:) is not being called when an incoming channel event occurs. But, I don't know what to do about it. Does anyone have any ideas? Even if the example code worked perfectly for you without modifications, I'd like to know. Thanks Keith - Eric Thanks for the tip. After applying the change, I ran into one more problem on the server side. An exception would be raised after the connection was made. I found the problem, The function that removes the 'chat service' from the service dictionary was being called twice, once in chatBluetoothServiceInterface and once in ChatServerController. I just commented out [myBluetoothInterface StopProvidingChatServices] from the chatServerController code and everything works now. Changing the StopProvidingChatServices function to be more robust would probably be a better solution, but this fix is good enough for me now. I have one more tip. The service name offered by the server will be called '(Computer name) Chat Server'. My computer name contained Japanese characters and the client was unable to find the service. Changing my computer's name to plain english characters fixed the problem. Keith _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com _______________________________________________ bluetooth-dev mailing list | bluetooth-dev@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/bluetooth-dev Do not post admin requests to the list. They will be ignored.
participants (1)
-
Keith Phu