【问题标题】:CoreBluetooth[WARNING] Unknown error: 2CoreBluetooth [警告] 未知错误:2
【发布时间】:2013-01-23 14:33:11
【问题描述】:

我正在 iOS6 中开发一个 BLE 应用程序。在设置为通知状态后,当我在某个特性上调用 readValueForCharacteristic 时,我得到了 CoreBluetooth[WARNING] Unknown error: 2

- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error`

The delegate callback gets called with an unknown error from NSLog: `Error updating value for characteristic Unknown (<fef2>) error: Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x1dd3b7e0 {NSLocalizedDescription=Unknown error.}

请给点建议。

【问题讨论】:

    标签: ios core-bluetooth


    【解决方案1】:

    据我所知,您无法读取设置为通知的特征的值。

    您需要“订阅”该特性的通知:

    [peripheral setNotifyValue:YES forCharacteristic:characteristic];
    

    然后可以在您的委托方法中读取该值:

    - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
    

    iOS 的 BLE 文档在这方面做得很差。

    【讨论】:

    猜你喜欢
    • 2013-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-24
    • 2017-05-31
    • 2018-03-18
    • 2018-04-10
    相关资源
    最近更新 更多