title: Maximum data size when sending data via BTLE on iOS
body: <p>I am currently implementing an iOS application that uses CoreBluetooth to transfer data between 2 devices. For example, to send data from the central to the peripheral, I use this code:</p>
  
  <pre><code>NSData *data = [NSJSONSerialization dataWithJSONObject:dictionary options:NSJSONWritingPrettyPrinted error:nil];
  NSLog(@"Writing data of length %d", [data length]);
  [peripheral writeValue:data forCharacteristic:characteristic type:CBCharacteristicWriteWithResponse];
  </code></pre>
  
  <p>This works absolutely fine, but the thing is that I have read multiple times now that characteristics can transfer a maximum of 20 bytes at once. Also, when I look at <a href="https://developer.apple.com/Library/ios/samplecode/BTLE_Transfer/Introduction/Intro.html" rel="noreferrer">Apple's BTLE Example Code</a>  they implement a mechanism that splits the data into chunks of 20 bytes. But the above code prints something like <code>Writing data of length 124</code> - the data arrives fine at the other device, though.</p>
  
  <p>So: <strong>Why is this working at all? And even more so, I am afraid that this could break at some point, especially when non-iOS devices come into play.</strong>  </p>