ItsameMario
ItsameMario

Reputation: 121

Using the Private Framework BluetoothManager / iOS 5.0

I'm able to enable Bluetooth with help of the Private Framework.

Now I have to search for nearby devices. I guess the deviceScanningEnabled command is the right one, but how do I get the returned Devices? Is there any callback-Function? I read about some Notifications which will be in the NotificationCenter?!

How do I use it in this context?

Upvotes: 1

Views: 2075

Answers (3)

lucianoenrico
lucianoenrico

Reputation: 1494

replace

[btManager setDeviceScanningEnabled:YES]; 

with

[btManager scanForServices:0xFFFFFFFF];

i don't know why, but you'll discover all the devices nearby. Then you can pair the device.

This is where i got stuck... i am not able to get connections or exchange data

Upvotes: 0

Gilad_Gr
Gilad_Gr

Reputation: 303

As far as I know, the bluetooth manager gets the list after OS has filtered the results - meaning you will only get the nearby headset devices and not all generic devices. If you need to find all generic devices you will have to use @rajagp's answer.

In the case that finding headsets are enough, then you can use notifications as you said; the notification for discovering a device is called "BluetoothDeviceDiscoveredNotification". You first need to list the notifications with:

[[NSNotificationCenter defaultCenter] 
    addObserver: self
    selector: @selector( your_discovery_method_name)
    name: @"BluetoothDeviceDiscoveredNotification"
    object: nil];

the "your_discovery_method_name" is the method you write that shows/accepts the notification. It will look something like this:

-(void) your_discovery_method_name:(NSNotification *) notification {
     self.device = [notification object];

     NSLog(@"found: %@",self.device.address);
     // ...
}

The device is from type BluetoothDevice.

Upvotes: 2

rajagp
rajagp

Reputation: 1443

If you are developing for a jailbroken phone , I'd recommend the third party BlueTooth library - BTStack. Its easy to use and has been working quite well for me. Its available at : http://code.google.com/p/btstack/.

Upvotes: 0

Related Questions