On iOS when I request the MTU I get different values for .withoutResponse
vs .withResponse
. I realize it could be different since the function takes that parameter, but why is it different?
Here's on device (BLE 4.2):
(lldb) po peripheral.maximumWriteValueLength(for: .withoutResponse)
182
(lldb) po peripheral.maximumWriteValueLength(for: .withResponse)
512
On another device (BLE 5) I get:
(lldb) po peripheral.maximumWriteValueLength(for: .withoutResponse)
509
(lldb) po peripheral.maximumWriteValueLength(for: .withResponse)
512
Write Without Response is directly related to the MTU. (MTU - 3).
When you use writeWithResponse
, iOS can either perform a Write With Response (max value length is MTU - 3), or a "Write Long Characteristic Values", which uses several ATT transactions to write the value. In the latter case the only restricting factor is the maximum length of a characteristic value, which is set to 512 bytes by the standard.