title: Reading long characteristic values using CoreBluetooth
body: <p>I have a characteristic value which contains the data for an image. In the peripheral I setup the value like this:</p>
  <pre><code>_photoUUID = [CBUUID UUIDWithString:bPhotoCharacteristicUUID];
  _photoCharacteristic = [[CBMutableCharacteristic alloc] initWithType:_photoUUID
                                                            properties:CBCharacteristicPropertyRead
                                                                 value:Nil
                                                           permissions:CBAttributePermissionsReadable];
  </code></pre>
  <p>My understanding is that when this value is requested, the <code>didReceiveReadRequest</code> callback will be called:</p>
  <pre><code>-(void) peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request {
  
      if ([request.characteristic.UUID isEqual:_photoUUID]) {
          if (request.offset &gt; request.characteristic.value.length) {
              [_peripheralManager respondToRequest:request withResult:CBATTErrorInvalidOffset];
              return;
          }
          else {
              // Get the photos
              if (request.offset == 0) {
                  _photoData = [NSKeyedArchiver archivedDataWithRootObject:_myProfile.photosImmutable];
              }
          
              request.value = [_photoData subdataWithRange:NSMakeRange(request.offset, request.characteristic.value.length - request.offset)];
              [_peripheralManager respondToRequest:request withResult:CBATTErrorSuccess];
          }
      }
  }
  </code></pre>
  <p>This comes pretty much from Apple's documentation. On the Central side in the <code>didDiscoverCharacteristic</code> callback I have the following code:</p>
  <pre><code>if ([characteristic.UUID isEqual:_photoUUID]) {
      _photoCharacteristic = characteristic;
      [peripheral readValueForCharacteristic:characteristic];
  }
  </code></pre>
  <p>Which in turn calls the <code>didUpdateValueForCharacteristic</code> callback:</p>
  <pre><code>- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error {
      NSLog(@&quot;updated value for characteristic&quot;);
  
      if ([characteristic.UUID isEqual:_photoUUID]) {
          NSArray * photos = [NSKeyedUnarchiver unarchiveObjectWithData:characteristic.value];
      }
  }
  </code></pre>
  <p>All of the callbacks are called but when I try to re-construct the array, it's corrupted because not all of the data is transferred correctly. I would expect the <code>didRecieveReadRequest</code> callback to be called multiple times with a different offset each time. However it's only called once.</p>
  <p>I was wondering if anyone knew what I'm doing wrong?</p>