Re: Welcome to the "Bluetooth-dev" mailing list
site_archiver@lists.apple.com Delivered-To: bluetooth-dev@lists.apple.com User-agent: Microsoft-Entourage/11.0.0.040405
Hey Everyone, I am trying to use the deviceinquiry class from the bluetooth framework so I can discover devices and the reason I don't use the GUI is because I need to be able to select multiple devices. So my code is below but I am not too sure if it is the right way of using the class. When I go through in the debugger nothing seems to change or be set with the palmSizedDevice variable. Also I am not too sure on how to check if the inquiry has completed. The api says I should use the delegate methods and well I am not even sure that everything is setup properly. I have tried looking for examples on this but I can't find anything. Kinda frustrating. But below is my code and I am pretty sure I am missing something.
IOBluetoothDeviceInquiry * palmSizedDevices; id discoverDelegate; IOReturn isFoundDevices;
palmSizedDevices = [IOBluetoothDeviceInquiry inquiryWithDelegate: discoverDelegate];
//initilize the search object palmSizedDevices = [palmSizedDevices initWithDelegate: discoverDelegate];
//start search isFoundDevices = [palmSizedDevices start];
Hi Landon, You are reinitializing the object, with the call to initWithDelegate, which is not good. So just do this first: [IOBluetoothDeviceInquiry inquiryWithDelegate:discoverDelegate]; And don't call initWithDelegate, since there is no reason to do this second step, the above call implies the object is init'ed with your delegate. If you make this change, however, make sure you retain the inquiry, as the +inquiryWithDelegate class method will return an auto-released object, and thus won't call your delegate object because it would be gone. Once you call -start and it is successful (return value is 0), your delegate methods should start being called as things are found. You should at least get the - (void) deviceInquiryStarted:(IOBluetoothDeviceInquiry*)sender delegate method called if you implemented it in your delegate object. You should get found devices returned to you on this delegate method: - (void) deviceInquiryDeviceFound:(IOBluetoothDeviceInquiry*)sender device:(IOBluetoothDevice*)device Also, it never hurts to run the packet logger to see if the hardware is actually getting the inquiry request. Well, anyway, that should get you started. If you have further questions, just let us know. Jason bubba@apple.com _______________________________________________ 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
participants (1)
-
Bubba Giles