ios - 蓝牙IOS : connectPeripheral results a didDisconnectPeripheral with null error SOMETIMES

标签 ios ios7 bluetooth-lowenergy core-bluetooth

我正在做一个使用 ios 的 BLE 的项目

它工作得很好,除了有时当我调用 connectPeripheral(使用检索 p 或使用中央扫描)时,它需要 10 秒,然后断开外围设备(didDisconnectPeripheral有空错误)。有时会出现此错误,我必须关闭/打开我的 iPhone 才能使其正常工作。

我真的迷失了这个错误。

有什么想法吗?

非常感谢您的帮助

最佳答案

我让它工作了。 CoreBluetooth 框架很智能,在执行单次读/写后确实会断开连接。保持连接有效的方法是从外设订阅至少一个特征值。

以下是您可以执行此操作的方法: 中央代码: 当您找到外围设备的特性时,您有兴趣像这样订阅它 [yourPeripheral setNotifyValue:YES forCharacteristic:characteristic];

工作起来很有魅力:)

关于ios - 蓝牙IOS : connectPeripheral results a didDisconnectPeripheral with null error SOMETIMES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21752927/

相关文章:

iphone - 我在哪里可以找到在 Xcode 5 中运行 iOS 7.0 的非视网膜 iPhone 模拟器?

iphone - 在 iOS 7 中,为什么 View 高度与 iOS 6 中的相同 View 不同

android - LE 面向连接的 channel - Android 支持

Android BLE BluetoothGatt.writeDescriptor() 有时返回 false

javascript - 从室内自行车数据特征解码蓝牙数据

ios - 错误打印 user.default swift 3

iphone - 如何检测 UIActionSheet 何时滚动到底部?

ios - 我在 iOS UITableView 中有 NSInvalidArgumentException

ios - 单击 UITableViewCell 按钮时传递到 didSelectRowAtIndexPath

ios - 如何为 tableView Section 的第一个和最后一个单元格设置圆角