我的CoreBluetooth应用程序需要启用客户端特征配置描述符中的“指示位”.这是我做的:
>开始扫描
>开始连接设备
>调用discoverServices
>在回调中调用discoverCharacteristics
– (void)peripheral:(CBPeripheral *)peripheral diddiscoverServices:(NSError *)错误
>在回调内调用discoverDescriptorsForCharacteristic
– (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error
>内部回调
– (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)特征错误:(NSError *)错误
我打了电话:
- 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崩溃:.控制台中的错误消息是:
Cannot write Client Characteristic Configuration descriptors using
this method!
任何的想法?谢谢