【问题标题】:CoreBluetooth: didDisconnectPeripheral callback while in CBPeripheralStateConnectingCoreBluetooth:在 CBPeripheralStateConnecting 中的 didDisconnectPeripheral 回调
【发布时间】:2014-01-20 20:49:40
【问题描述】:

查看我的“CoreBluetooth”状态机生成的日志,发现有时会在外围设备位于CBPeripheralStateConnectingdidConnectPeripheral 之前调用didDisconnectPeripheral。代码不受这种奇怪的影响,但我想了解发生了什么。

还有其他人经历过这种情况或类似情况吗?我找不到任何合乎逻辑的解释。

【问题讨论】:

    标签: ios7 core-bluetooth


    【解决方案1】:

    在iOS6中CoreBluetooth还比较不成熟的时候,我采用了请求连接的连接策略,如果接下来2秒内没有连接,我会调用cancelPeripheralConnection然后再发出connectPeripheral这个循环会在终止并通知用户出现问题之前再继续 3 次。

    看来,对didDisconnectPeripheral 的调用,即使在未首次连接时,也是对cancelPeripheralConnection 的中间调用的结果。

    现在有了 iOS7 的稳定性,并且了解到 connectPeripheral 永远不会超时,我已经消除了中间 cancelPeripheralConnectionconnectPeripheral 调用的复杂性,只需等待连接超时。

    didDisconnectPeripheral 电话不再神秘!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-12
      • 2015-03-06
      • 2014-09-22
      • 2018-03-01
      • 2014-06-19
      • 1970-01-01
      • 2014-12-14
      • 2014-05-07
      相关资源
      最近更新 更多