简体   繁体   English

CoreBluetooth [WARNING]未知错误:2

[英]CoreBluetooth[WARNING] Unknown error: 2

I'm developing a BLE app in iOS6. 我正在iOS6中开发BLE应用程序。 I got CoreBluetooth[WARNING] Unknown error: 2 when I call readValueForCharacteristic on a characteristic after it's set to notifying state. 我收到了CoreBluetooth[WARNING] Unknown error: 2当我将某个特征设置为通知状态后, 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.}

Please give some advice. 请给一些建议。

From what I can tell, you cannot read the value of a characteristic that is set to notify. 据我所知,您无法读取设置为要通知的特征的值。

You need to "subscribe" to notifications for that characteristic: 您需要“订阅”该特征的通知:

[peripheral setNotifyValue:YES forCharacteristic:characteristic];

The value can then be read in your delegate method: 然后可以在您的委托方法中读取该值:

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

The BLE docs for iOS are quite poor in this regard. 在这方面,iOS的BLE文档非常差。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM