【问题标题】:getting iOS centralManager:didDisconnectPeripheral call but device is not really disconnected获取 iOS centralManager:didDisconnectPeripheral 调用,但设备并未真正断开连接
【发布时间】:2014-03-03 21:43:12
【问题描述】:

运行 iOS7 的 iPhone 正在扮演管理员角色,它连接到扮演外围角色的电子设备,[centralManager connectPeripheral:peripheral options:nil]

当我调用 [centralManager cancelPeripheralConnection:peripheral] didDisconnectPeripheral 时,总是会被调用,但有时,并非总是如此,我知道电子设备并没有真正断开连接。该电子设备未连接到任何其他应用程序。

有什么想法吗?

【问题讨论】:

标签: ios ios7 core-bluetooth


【解决方案1】:

didDisconnectCallback 与真正断开连接之间存在延迟。在 iOS 6 中它曾经是几秒钟,在 iOS 7 中它更少。 cancelPeripheralConnection 实际上是向操作系统发出的信号,表明应用程序不再使用该连接。然后由操作系统决定何时真正断开连接。您可以通过从外围设备端断开连接来规避此限制。

【讨论】:

  • 是的,我刚刚发现了自己。在我的情况下,我需要大约 7 秒的时间来连接,但我已经意识到状态栏上的蓝牙图标在真正断开连接时是如何变成灰色的。所以对我来说,操作系统以某种方式知道断开连接是有道理的。
猜你喜欢
  • 1970-01-01
  • 2012-11-14
  • 1970-01-01
  • 2014-07-17
  • 1970-01-01
  • 2013-05-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多