Reputation: 707
I understand that in Android, the MTU for writing data to a Characterisitc is around 23 bytes (3 bytes used so you have around 20 bytes free) and that you can request a higher MTU (up to 512) to allow you to write/send larger data packets to a bluetooth device.
However, do you also need to do this when reading data from a characterisitic?
Both Reading and Notification updates?
If say, I have a characteristic that sends data in 123 byte chunks, but I only ever have to send at most 2 bytes to it, do I need to negotiate a large MTU?
Upvotes: 0
Views: 1925
Reputation: 18452
I can recommend you to read the ATT and GATT chapters in the Bluetooth Core standard. Those explain the protocol.
By default Android does not negotiate a larger MTU than the default (23 bytes). You can do that yourself though by calling the requestMtu
function.
Android automatically under the hood uses "Write Long Characteristic Values" and "Read Long Characteristic Values" when the MTU is not big enough when reading/writing values in order to transfer the whole value. However these procedures are very inefficient since they require multiple roundtrips. The read operation also is not atomic.
Notifications and Indications don't have any "Long" variant with multiple roundtrips, so these will be truncated to fit the MTU.
Upvotes: 1