我正在使用Linkey BLE锁从应用程序进行控制。我可以很容易地配对。但是当我断开外围设备时,我需要解除与外围设备的配对。有人能在这方面帮我吗?
发布于 2017-12-01 01:15:06
我有点困惑,因为BLE的工作原理不同于经典的蓝牙和connects and disconnects to peripherals。
我假设您正在通过中央管理器连接到锁,并且需要删除对外围设备的引用。如果是这样,在处理BLE连接的对象中,只需清除disconnect事件侦听器中对外围设备的所有引用:
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
// Something disconnected, check to see if it's our peripheral
// If so, clear active device/service
if peripheral == self.blePeripheral {
self.blePeripheral = nil
self.bleService = nil
}
// Scan for new devices using the function you initially connected to the perhipheral
self.scanForNewDevices()
}
如果外围设备处于打开状态且在广播范围内,则应重新连接。
https://stackoverflow.com/questions/47575218
复制相似问题