問題描述
根據這個問題:
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 的生命周期是多少的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!