androidiosflutteresp32espressif-idf

FLUTTER BLUE PLUS and esp32 - Is Android or the esp32 responsible for splitting a message that is bigger than the MTU size?


We are creating an app(Android and iOS) to connect to an esp32 via BLE using Flutter Blue Plus. The MTU is set to 500, but the message is 800+ bytes long. When connecting from iOS we get all the data successfully, but when connecting from Android we only see a partial message(500 bytes).

While debugging on the esp, I can see that both iOS and Android are triggering two read events, one with an offset of 0 and the second with an offset of 499. I see the second read after the following warning:

BT_GATT: attribute value too long, to be truncated to 499

So in both cases, it seems to be executing the same on the esp32 side. But on Android, I only get a partial message.

Edit: I'm working on the firmware side of the system and not on the mobile app, so I don't have a lot of information on how it is implemented on Android.


Solution

  • A GATT characteristic value can only be 512 bytes maximum, regardless of the MTU. If the characteristic value is longer than MTU then both Android and iOS use a sequence of multiple operations to read or write the whole value.

    If you need to send more data than what fits in a characteristic, you can for example send multiple notifications, each containing a different part of your data that you need to send. You then need a mechanism to reassemble the data at the receiver side.