[英]How to disconnect completely on BLE using iOS Core Bluetooth
When using CBCentralManager.cancelPeripheralConnection(peripheral) , disconnection is only for the application level. 使用CBCentralManager.cancelPeripheralConnection(peripheral)时,断开连接仅适用于应用程序级别。 So can't connect again to the same device without turn off and on bluetooth.
因此,必须先关闭蓝牙再打开,才能再次连接到同一设备。
I know that CBCentralManager?.retrieveConnectedPeripherals(withServices: ) function is there, but I need to connect to the exact same device( based on MAC address [ This I'm getting from advertising data ] ) not to any device with the specific service. 我知道这里有CBCentralManager?.retrieveConnectedPeripherals(withServices:)函数,但是我需要连接到完全相同的设备(基于MAC地址[这是我从广告数据中得到的]),而不是连接到具有特定服务的任何设备。
Is there any way to disconnect completely? 有什么办法可以完全断开连接?
You don't need to disconnect completely. 您无需完全断开连接。
You can just call connect(_:options:)
within centralManager:didDisconnectPeripheral:error:
. 您可以只在
centralManager:didDisconnectPeripheral:error:
调用connect(_:options:)
。 The device will be reconnected once it is visible again. 再次可见后,设备将重新连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.