IOS bluetooth: Unknown error while writing to characteristic

In my application, I find my peripheral with the given service. Then I check that all the required stats are present before moving on.

When I write a value for my characteristics that didWriteValueForCharacteristic:

invokes the callback trigger:

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

    NSLog(@"Did write characteristic value : %@ with ID %@", characteristic.value, characteristic.UUID);
    NSLog(@"With error: %@", [error localizedDescription]);
}  

      

and outputs this result:

Did write characteristic value : <005c> with ID Unknown (<00005004 1212efde 1523785f eabcd123>)
With error: Unknown error.

      

The value is correct, the same applies to the 128 bit UUID of the characteristic, but in my peripherals I never get the written value.

Any suggestions on what might be wrong?

+3


source to share


1 answer


I originally posted a WriteWithoutResponse

, changing that to WriteWithResponse

, gave it to me CoreBluetooth[WARNING] error 13

as @Larme mentioned in the comments. This value corresponds to Invalid attribute length value, that is, I sent the wrong number format, that is, I sent a 16-bit value, and the peripheral expected 8 bits.



Changing the peripheral to accept 16-bit data solved the problem.

+4


source







All Articles