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

标签 ios bluetooth-lowenergy core-bluetooth nrf51

我们的应用程序通过CoreBluetooth连接到Bluetooth LE设备。

在iOS 8和9上,一切正常。在iOS 10上,我们遇到了超时错误(Error Domain=CBErrorDomain Code=6 "The connection has timed out unexpectedly.")
CBCentralManagerDelegate:

- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error;

在连接的discoverServices上调用CBPeripheral之后。

有人知道出什么事了吗?这是iOS 10问题吗?是否有某些BLE日志要检查?

使用Nordic Semiconductor nRF51822在iPad Pro 9.7上设置iOS 10.0.1(14A403)

最佳答案

好,我解决了问题。我混合了CBUUIDNSUUID从iOS 10开始CBPeripheral discoverServices仅接受CBUUIDNSUUID不再起作用。也许NSUUID仅在较旧的iOS版本上偶然起作用。该文档明确指出:

代表要发现的服务类型的CBUUID对象的列表。

NSArray *services = @[
    [CBUUID UUIDWithString:ServiceUUID] //Correct
    //[[NSUUID alloc] initWithUUIDString:ServiceUUID] //Does work on iOS 9 but not on iOS 10
];
[self.peripheral discoverServices:services];

期待将应用移植到强类型的Swift。

关于ios - iOS10上的CoreBluetooth:CBPeripheral discoverServices之后超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39591564/

相关文章:

ios - Swift 枚举的可用性重要吗?

ios - iPhone 蓝牙 : specification of the native camera app control

ios - 将NSString转换为NSDate

iOS CoreData 和 AES 256 加密

ios - 如何在 IOS 的 wkwebview 中隐藏 html 元素?

Flutter Ble 广告

ios - 将类类型作为参数传递,然后创建它的实例

bluetooth - BLE 设备无法连续发送多个 GATT 通知

android - BLE - 我无法同时读取 2 个特性,一个是温度服务,另一个是电池服务

ios - 使用PogoConnect SDK时_CBCentralManagerOptionShowPowerAlertKey