使用私有框架BluetoothManager / iOS 5.0

发布于 2024-12-22 17:12:33 字数 137 浏览 2 评论 0原文

我可以在私有框架的帮助下启用蓝牙。

现在我必须搜索附近的设备。 我猜 deviceScanningEnabled 命令是正确的,但如何获取返回的设备?有回调函数吗?我读到一些通知将位于通知中心?!

在这种情况下我该如何使用它?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浮华 2024-12-29 17:12:33

据我所知,蓝牙管理器在操作系统过滤结果后获取列表 - 这意味着您只能获取附近的耳机设备,而不是所有通用设备。如果您需要查找所有通用设备,则必须使用@rajagp 的答案。

如果找到耳机就足够了,那么您可以按照您所说的使用通知;发现设备的通知称为“BluetoothDeviceDiscoveredNotification”。您首先需要列出通知:

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

“your_discovery_method_name”是您编写的显示/接受通知的方法。它看起来像这样:

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

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

该设备来自 BluetoothDevice 类型。

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.

醉殇 2024-12-29 17:12:33

如果您正在为越狱手机进行开发,我会推荐第三方蓝牙库 - BTStack。它易于使用,并且对我来说效果很好。其地址为:http://code.google.com/p/btstack/

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/.

深居我梦 2024-12-29 17:12:33

替换

[btManager setDeviceScanningEnabled:YES]; 

[btManager scanForServices:0xFFFFFFFF];

“我不知道为什么”,但您会发现附近的所有设备。然后您可以配对设备。

这就是我陷入困境的地方......我无法建立连接或交换数据

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文