3
votes

In my application I discover my peripheral with a given service. I then check that all characteristics wanted are present before moving on.

When I write a value to my characteristics, the callback didWriteValueForCharacteristic: 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 yields this output:

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

The value is correct, same goes for the 128bit UUID of the characteristic, but in my peripheral I never actually get a value written.

Any suggestions to what might be wrong?

1
Did you have in the Console a message like: CoreBluetooth[WARNING]. Sometimes the real error is given there. And I still don't know why and how to catch them... - Larme
Not at the time. Answered my own question - chwi

1 Answers

4
votes

I originally sent a WriteWithoutResponse, changing this to WriteWithResponse gave me a CoreBluetooth[WARNING] error 13 as mentioned by @Larme in the comments. This value corresponded to Invalid Attribute Value Length, meaning I sent the wrong number format, i.e I sent a 16bit value while the peripheral expected 8bit.

Changing the peripheral to accept 16bit data solved the issue.