我的 CoreBluetooth 应用程序需要启用客户端特征配置描述符中的“指示位”。这是我所做的:
- 开始扫描
- 开始连接设备
- 称呼
discoverServices
discoverCharacteristics
在回调内部调用-(void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error
discoverDescriptorsForCharacteristic
在回调内部调用-(void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
内部回调
-(void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
我打了电话:
if ( [[descriptor.UUID representativeString] isEqualToString:@"2902" ] )
{
const unsigned char raw_data[] = {0x02};
NSData *myData = [NSData dataWithBytes: raw_data length: 2];
[self.cBCP writeValue:myData forDescriptor:descriptor];
}
但是我的应用程序在 : 中崩溃了writeVale
。控制台中的错误消息是:
无法使用此方法编写客户端特征配置描述符!
任何想法?谢谢