I have a characteristic value that contains a large data set (~ 200 bytes)
Peripheral
_ch = [[CBMutableCharacteristic alloc] initWithType:_chUUID
properties:CBCharacteristicPropertyRead
value:nil
permissions:CBAttributePermissionsReadable ];
When this value is requested, the didRecieveRequest callback is called:
-(void) peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request {
if ([request.characteristic.UUID isEqual:_chUUID]) {
if (request.offset > _data.length) {
[_peripheralManager respondToRequest:request withResult:CBATTErrorInvalidOffset];
return;
}
else {
request.value = [_data subdataWithRange:NSMakeRange(request.offset, _data.length - request.offset)];
[_peripheralManager respondToRequest:request withResult:CBATTErrorSuccess];
}
}
This is pretty much the case for Apple.
On the central side, when the callback is called didUpdateValueCorCharacteristic:, I get an error
Error Domain=CBATTErrorDomain Code=11 "The attribute is not long."
I know that I could use the Notify mechanism to crop the data myself, as shown at WWDC 2012. But this is not an option, because I am not responsible for the central code.
I would suggest that it didReceiveReadRequest:should be called more than once (with an increase in offset), since the CB Framework should take care of the block, right? Am I missing something here?
Greetings