CoreBluetooth [警告]未知错误:2

时间:2013-01-23 14:33:11

标签: ios core-bluetooth

我正在开发iOS6中的BLE应用。在设置为通知状态后,我在特征上调用CoreBluetooth[WARNING] Unknown error: 2时得到readValueForCharacteristic

- (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.}

请提供一些建议。

1 个答案:

答案 0 :(得分:3)

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

您需要“订阅”此特征的通知:

[peripheral setNotifyValue:YES forCharacteristic:characteristic];

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

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

iOS的BLE文档在这方面相当差。