My CoreBluetooth application need to enable the "indication bit" in Client Characteristic Configuration descriptors. Here is what I did:

  1. Start to scan
  2. Start to connect to the device
  3. Call discoverServices
  4. Call discoverCharacteristics inside the callback

    -(void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error

  5. Call discoverDescriptorsForCharacteristic inside callback

    -(void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error

  6. Inside callback

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

I called:

        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];
        }

But My app crashes in writeVale: . The error message in console is :

Cannot write Client Characteristic Configuration descriptors using this method!

Any idea? Thanks

Edit
Report