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 的生命周期是多少
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
