3

I send data over BLE using the following call

[peripheral writeValue:dataPiece forCharacteristic:characteristic
    type:CBCharacteristicWriteWithResponse];

when the dataPiece size is 180 bytes or less everything works fine: accepting device receives all the data, on calling device corresponding callback (peripheral: didWriteValueForCharacteristic: error:) is called. When the size goes large (>180) receiving device still gets all the data (in two chunks: of 180 bytes and the rest). However in the latter case the callback on transmitting device is not called.

Also [peripheral maximumWriteValueLengthForType:CBCharacteristicWriteWithResponse] returns 512 which is more than 180, so I would expect 200 to work fine.

Am I missing something (obviously yes, but what)?

sbeliakov
  • 2,169
  • 1
  • 20
  • 37
  • 1
    By mistake, I've tried to write MTU-Size bytes to the characteristic and experienced the very same result, as you did (callback not beeing called at all). After changing the write size to MTU-3, everything works well. Thanks a lot for sharing! – Torsten Robitzki Aug 07 '17 at 17:43

1 Answers1

0

For peripheral, it should respond descriptor when central call readValueForDescriptor: method.
If it did not respond, central can not write data to it.

See:

  • (void)readValueForDescriptor:(CBDescriptor *)descriptor;
  • (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(nullable NSError *)error;
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68