Re: total newbie..help needed..!
Hi, The way the Mac OS does this is very different then the BlueZ method on Linux. If you are refereeing to the HCITool inq command, then the information is available in the bluetooth system preference pane for any paired device. For inquiring in an application you have 2 options. You can use the Obj-C Bluetooth User Interface system, or the Carbon one. My suggestion will be to use the carbon one, so you don't need to worry about the Obj-C's language differences. The chat sever and client are good examples on how to use the bluetooth API, I have copied the relevant portions here for you. This specifies the actual class you want to use unsigned char gExampleChatServiceClassUUID[] = // 0DAD4365-5DF1-11D6-9F6E-00039353E858 { 0x0d, 0xad, 0x43, 0x65, 0x5d, 0xf1, 0x11, 0xd6, 0x9f, 0x6e, 0x00, 0x03, 0x93, 0x53, 0xe8, 0x58 }; If you wanted a simple Serial UUID then you can use this for example (this should work, but I haven't tested it) unsigned char gExampleChatServiceClassUUID[] = // 0DAD4365-5DF1-11D6-9F6E-00039353E858 { 0x11, 0x01 }; This creates a new service browser, where you can specify which options you want to give the user. // First, we create a service browser controller which will allow us to put up a panel to allow the user // to select a device and service. serviceBrowser = IOBluetoothServiceBrowserControllerCreate( kIOBluetoothServiceBrowserControllerOptionsNone ); This converts the above unsigned array to a proper UUID. The UUID is needed in this form to be passed to the service array. // Now we create an array with all the UUID we are interested in (in this case only our custom one): chatUUID = IOBluetoothSDPUUIDCreateWithBytes(gExampleChatServiceClassUUID, 16); Create an array which contains the different services that you want to match. If you want to work with more then one, put them in here. serviceArray = CFArrayCreate(NULL, (const void **)&chatUUID, 1, &kCFTypeArrayCallBacks); This actually creates a non-model (I always confuse this, but its a synchronous call, doesn't move till user goes ok/cancel) window with a list of currently known Bluetooth devices in the favorites and those that are in range. You can also use the pulldown menu to filter based on a specific class, mice, keyboards computers etc. // This call will return kIOReturnSuccess if the user has successfully selected a device and service that matches the // specified serviceArray. result = IOBluetoothServiceBrowserControllerDiscoverWithDeviceAttributes(serviceB rowser, &serviceRecord, NULL, serviceArray); When this returns you will either have an error in result, or you can use these commands to get the RFComm channel, and the actuall device you are connecting too. result = IOBluetoothSDPServiceRecordGetRFCOMMChannelID(serviceRecord, &rfcommChannelID); device = IOBluetoothSDPServiceRecordGetDevice( serviceRecord ); One major difference between the Bluez implementation and the Apple one, is that Apple requires an SDP record to be available and correct before it will connect. This will open a connection to the device on the RFComm channel specified in the SDP record. You can open multiple channels as needed using this method. The last two parameters specify the call back. The event listener is a method which allows you to handle anything that comes back on the channel. The self, is for specify which object/class will handle the callback. IOBluetoothDeviceOpenConnection(device, NULL, NULL) IOBluetoothDeviceOpenRFCOMMChannelSync(device ,&mRFCOMMChannelRef, rfcommChannelID, rfcommEventListener, (void*)self); The call back is handled by this method void rfcommEventListener( IOBluetoothRFCOMMChannelRef rfcommChannelRef, void *refCon, IOBluetoothRFCOMMChannelEvent *event ) which in turn calls - (void)handleIncomingEvent:(IOBluetoothRFCOMMChannelEvent *)event To handle all incoming data. Finally the method - (BOOL)sendData:(void*)buffer length:(UInt32)length Is used to actually send data across the bluetooth link. All of the code above is pulled from the RFComm chat sample, with a some additional information. If you need anything else just ask! Alex On 19-Feb-04, at 6:44 AM, axis wrote:
Sir,
Iam completely new to MAC environment and just
started exploring Bluetooth framework.I developed a
application based on bluez (bluetooth stack for linux)
and I want to port(or may be to write everything from
scratch using Objective-C and cocoa frameworks)this to
MAC.
In the Bluetooth framework,I could not find any
reference related to Inquiry command and when I
browsed through the archives,there were mails saying
that we have to use BluetoothUI framework to
accomplish this.But I could not find any sample source
code regarding this.
I checked out the rfcomm and obex examples in the
documentation and it would be great it anyone can
provide some sample code and any advice in order to
perform "Inquiry" and filter results based on "Class
of Device".
Hope to hear from you regarding this.
Thank You.
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
_______________________________________________
bluetooth-dev mailing list | bluetooth-dev@lists.apple.com
Help/Unsubscribe/Archives:
Do not post admin requests to the list. They will be ignored.
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s] _______________________________________________ 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)
-
Alex Eiser