I am developping my first Smart Bluetooth (BLE) software on IOS 6.
I am able to receive notifications and read chracteristics values exchanged with a Nordic Development kit including from a custom GATT profile I have created (with specific UUIDs for service and characteristics).
But, everytime I am trying to write a value in a characteristic, I get the error message Unknown Error
without more information. No error code, no CoreBluetooth[WARNING]
from XCode.
I have set my service and characteristics attributes permissions to write without authentication. Using a development Nordic tool, I am able to write a value in my characteristic, so it would not be a permission problem.
Here is the code I am using to write the value
uint16_t val = 2;
NSData * valData = [NSData dataWithBytes:(void*)&val length:sizeof(val)];
[testPeripheral writeValue:valData forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
And the callback where the error "Unknown error" is rised
- (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]);
//code...
}
The error text in the console is
Did write characteristic value : <068c0e00 fedc070c 050b3200 04> with ID Unknown (<4444>)
With error: Unknown error.
The value in the error message is not what I am trying to write??!! 444 is the correct UUID I am using for my tests.
Is the length of the value to write important?
After looking hoirs on the internet and tried a lot tests, I need SO to figure it out. Any advice?