CoreBluetooth:唯一 UUID 的生命周期是多少

CoreBluetooth: What is the lifetime of unique UUIDs(CoreBluetooth:唯一 UUID 的生命周期是多少)
本文介绍了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 的生命周期是多少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Looking to understand the iOS UIViewController lifecycle(希望了解 iOS UIViewController 生命周期)
how to fix unresolved reference lifecycleScope?(如何修复未解析的引用生命周期clScope?)
Android Compose Navigation and ViewModel lifecycle(Android组合导航和ViewModel生命周期)
ActionBarSherlock with ViewPager not calling ViewPager fragments lifecycle methods when going to and returning from backstack(带有 ViewPager 的 ActionBarSherlock 在返回堆栈和返回堆栈时不调用 ViewPager 片段生命周期方法)
Android Lifecycle management of Fragments within ViewPager and FragmentPagerAdapter(ViewPager 和 FragmentPagerAdapter 中 Fragments 的 Android 生命周期管理)