CoreBluetooth: What is the lifetime of unique UUIDs(CoreBluetooth:唯一 UUID 的生命周期是多少)
问题描述
根据这个问题:
Corebluetooth,如何获取唯一的 UUID?
连接到外围设备后,我可以检索它的 CFUUIDRef
,这是唯一的,并且可以使用它通过 retrievePeripherals
重新连接.但是,我发现关闭应用程序后无法使用它重新连接.
After connecting to a peripheral, I can retrieve its CFUUIDRef
, which is unique, and can use it to reconnect via retrievePeripherals
. However, I have found that I can not use it to reconnect after closing the application.
连接后生成的唯一 UUID
是否仅在应用程序的生命周期内有效,还是我们应该能够保存它以供以后使用?我试图让我的应用程序记住一个特定的外围设备,但除了 peripheral.UUID
,我不知道任何其他唯一标识符.
Is the unique UUID
generated after a connection only valid for the lifetime of the application or are we supposed to be able to save it for later use? I am trying to have my application remember one particular peripheral, but besides peripheral.UUID
, I don't know of any other unique identifiers.
推荐答案
长话短说,是的,即使在关闭应用程序后,您也可以使用 UUID
重新连接到同一设备(在你怎么说).
Long story short, YES you can use the UUID
to reconnect to the same device even after you close the application (in exactly the way you say).
但是,我假设您实际上并没有与外围设备配对.这是一个大问题.您需要实际建立配对请求并让外围设备显示在蓝牙表中.然后,UUID
将与 iOS 设备一起固化,并一直保留到您刷新 iOS 设备的网络设置为止.
I assume however, that you are not actually pairing with peripheral. That's a big problem right there. You need to actually establish the pairing request and get the peripheral to show up in the bluetooth table. The UUID
will then be solidified with the iOS device and will remain until you flush the Network Settings of the iOS device.
另一种可能是您的 BLE 设备有固件问题,在您断开连接后,它会强制自己进入广告模式或其他什么东西.这也会影响您重新连接的能力.如果您有任何问题,请告诉我!
The other possibility is that your BLE device has a firmware problem, wherein after you disconnect, it forces itself into advertising mode or something. This will also mess with your ability to reconnect. Let me know if you have any questions!
这篇关于CoreBluetooth:唯一 UUID 的生命周期是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CoreBluetooth:唯一 UUID 的生命周期是多少
基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01