ios - didDisconnectPeripheral 自己调用

标签 ios bluetooth-lowenergy core-bluetooth cbperipheral cbperipheralmanager

我有一个应用程序应该使用 CoreBluetooth 一次连接到不同的设备。
我的问题是发生意外断开连接。一旦我连接到任何外围设备,该方法

func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {

被自己调用,这意味着设备已断开连接。
我浏览了文档,但没有发现任何有用的信息。我知道 BLE 可以是一对多的,那么这个问题来自哪里?
我在 iOS BLE peripherals keep disconnecting immediately after discoverServices is called 中查看答案而且我已经将 CBPeripherals 保存在一个数组中,但问题仍然存在。

我得到的输出示例
Connect to <CBPeripheral: 0x15e85a80, identifier = 1BD21078-B2B7-1EE9-5BDC-324DEC7A1BD6, name = Mac mini, state = connected>

Connect to <CBPeripheral: 0x15d83b20, identifier = 6BA160A7-55E7-501D-F195-437CDCD2B558, name = Mac mini, state = connected>
Disconnect from <CBPeripheral: 0x15e85a80, identifier = 1BD21078-B2B7-1EE9-5BDC-324DEC7A1BD6, name = Mac mini, state = disconnected>错误域 = CBErrorDomain 代码 = 6 “连接已意外超时。” UserInfo={NSLocalizedDescription=连接意外超时。}

最佳答案

链接断开连接有一些不同的原因。任何一方启动断开程序。错误 6“连接已意外超时”表示蓝牙链路在 radio 级别失去连接,例如由于超出范围或其他类型的干扰。

关于ios - didDisconnectPeripheral 自己调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43612064/

相关文章:

ios - 如何解读 TI(德州仪器)SensorTag 运动传感器数据组件?

ios - NSTextStorage 子类在删除字符时崩溃

ios - CGContext .normal 和 .color 混合模式的 CIFilter 等价物

ios - 如何打开事件并在选择 Collection View 单元格时传递变量?

bluetooth-lowenergy - 在 CoreBluetooth iOS 中计算 Tx 功率电平

ios - iOS10上的CoreBluetooth:CBPeripheral discoverServices之后超时

ios - 以编程方式设置导航栏?

iOS BLE "Characteristic User Description"

electron - Electron Web蓝牙API requestDevice()错误

ios - 连接到 iOS 的蓝牙外设在后台不工作