Requesting MTU with Bluetooth Low Energy connection on Android 4.3-4.4 (API 18-20)

后端 未结 1 1881
栀梦
栀梦 2020-12-15 12:59

I have a Bluetooth Low Energy Application which requires an MTU size above the default 23 bytes.

Though Android introduced BluetoothGatt#requestMTU() in API 21, is

相关标签:
1条回答
  • 2020-12-15 13:25

    If you have control over the peripheral device, you can issue an MTU request (ATT_OP_MTU_REQ, opcode 0x02) from the peripheral. Android is capable of larger GATT MTUs (update: 517 bytes is the maximum value), if requested by the peripheral, and will happily send an according ATT_OP_MTU_RESP.

    The only tricky thing is that the MTU exchange may not overlap with a fragmented read/write. One workaround might be a client-side sleep at a given time of the handshake, where the peripheral sends an MTU request. Another possible workaround would be a READ or WRITE on a "magic" characteristic that triggers the MTU exchange.

    However, with an increased MTU, I'm much more often receiving Status=133 errors, possibly caused by a higher packet error rate with larger packets?

    0 讨论(0)
提交回复
热议问题