使用私有框架BluetoothManager / iOS 5.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,蓝牙管理器在操作系统过滤结果后获取列表 - 这意味着您只能获取附近的耳机设备,而不是所有通用设备。如果您需要查找所有通用设备,则必须使用@rajagp 的答案。
如果找到耳机就足够了,那么您可以按照您所说的使用通知;发现设备的通知称为“BluetoothDeviceDiscoveredNotification”。您首先需要列出通知:
“your_discovery_method_name”是您编写的显示/接受通知的方法。它看起来像这样:
该设备来自 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:
the "your_discovery_method_name" is the method you write that shows/accepts the notification. It will look something like this:
The device is from type BluetoothDevice.
如果您正在为越狱手机进行开发,我会推荐第三方蓝牙库 - 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/.
替换
为
“我不知道为什么”,但您会发现附近的所有设备。然后您可以配对设备。
这就是我陷入困境的地方......我无法建立连接或交换数据
replace
with
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