What is the process of sending long (chunked) messages over NUS?

Hiya. We're building a custom appliance on top of a Nordic chip that talks to an Android/iOS app developed with Flutter and a custom cross-platform Bluetooth plugin. 

We use Nordic UART Service extensively and just noticed that some of our messages are cut. E.g. a message leaving from our app BLE plugin such as "move 629 1 662 27 688 7 719 30 746 28" become "move 629 1 662 27 68" on the peripheral. Of course this makes total sense because of the 20 bytes limitation on BLE Characteristics. However sending the same message over the Android Nordic app magically works!

I went through the source of https://github.com/NordicSemiconductor/Android-BLE-Library to find the spell, but I could not locate it. So I thought maybe best ask the experts here: what is the procedure to cut NUS messages into chunks so that the chip in the other end will join them together?

For further information our plugin is just basically doing this to write messages: 

// This is Kotlin code for Android
val RxService = device!!.getService(RX_SERVICE_UUID)
val RxChar = RxService!!.getCharacteristic(RX_CHAR_UUID)

// I'm guessing I need to insert magical process here
RxChar!!.setValue(value)
val status = device!!.writeCharacteristic(RxChar)

Parents
  • Hello,

    Perhaps you need to look in the other end, and check how Flutter handles long messages in BLE. 20 bytes is not a hard limit. Typically devices will negotiate a higher message length (MTU) after connection. Perhaps this doesn't happen when you are using flutter?

    You can always try to capture a sniffer trace using the nRF Sniffer for Bluetooth Low Energy and compare the data on air when you are using the Nordic app.

    But my guess is that you need to look into the Flutter library, and see how it handles a larger MTU/MTU updates.

    Best regards,

    Edvin

Reply
  • Hello,

    Perhaps you need to look in the other end, and check how Flutter handles long messages in BLE. 20 bytes is not a hard limit. Typically devices will negotiate a higher message length (MTU) after connection. Perhaps this doesn't happen when you are using flutter?

    You can always try to capture a sniffer trace using the nRF Sniffer for Bluetooth Low Energy and compare the data on air when you are using the Nordic app.

    But my guess is that you need to look into the Flutter library, and see how it handles a larger MTU/MTU updates.

    Best regards,

    Edvin

Children
Related