JUCE Bluetooth MTU question

Hi. I am facing an issue related to transmission of sysex data from an (Juce) app running on Android 14 to a hardware device connected using Bluetooth.
When sending midi messages larger than the mtu size of the device, the messages are being truncated, and only the first part of the message reaches the device.
According to this documentation: Behavior changes: all apps  |  Android Developers you should not try to send a message larger than the mtu size. I cannot find anywhere in the Juce code where larger messages are being “chopped” into smaller chunks, so that they would fit into the mtu size.

If I understand this correctly it is simply not possible to send a sysex message larger than the mtu size?

I looked into a solution where I split the sysex message up myself, but the Juce method MidiOutput::sendMessageNow expects a “complete” message as I understand it, so if the message does not start with 0xF0 its not legal.

Any assistance you can provide would be greatly appreciated

John Parbo Andersen

Have you tried getting onMtuChanged wired up, and changing the MTU size to what you need for your session?

23 bytes is the minimum but you can increase it, apparently, to infinity.

(Disclaimer: I have not done this, just poking at the problem with you…)

Erm, seems its been encountered elsewhere, no solution offered though:

https://issuetracker.google.com/issues/246412047

Hi ibisum. Thank you for your suggestions. As I understand it, the mtu size is negotiated between the OS and the device. This is also what I see happens in my case, where it is the size reported by the device. I would assume that it should be possible to send a sysex message with a larger size than the mtu size, and this is also what I see is possible on Mac and iOS. I don’t expect that I should “care” about the mtu size at all, as I would expect the OS to take care of this.

Its important to understand that yes - while you are using a protocol that is intended for device-level integration, the “maximum transmittable unit” size is nevertheless a performance parameter and therefore your assumption that the OS will ‘just take care of it for you’ is maybe misguided. The OS could adjust MTU on any open streams (and in some cases in server-based applications can be made to do so effectively), but this is not something you should rely on at the user installation.

The purpose of the MTU being malleable is to allow application vendors (not OS vendors) the ability to tune the transmission characteristics of the connections involved in their applications. So, why not use it? Don’t neglect the fact that the MTU is supposed to be set per-socket, so you won’t be effecting other network services … and yes, some BLE MIDI devices might reject a set-MTU attempt, but that would not be per the BLE MIDI spec now, would it, mmkay …

(Also highlights: you’re going to need a bigger test boat.)

Hi ibisum. Again, thank you for your support. If I am supposed to “tune” the transmission from my Juce app, I would think that there should be some handles to do that? I.e.set/get mtu size? And still, I don’t think you should not be allowed to send a sysex package that is bigger than the mtu size, I can do that on iOS and MacOS, here I can transmit a sysex package that is larger than the mtu size set to what the device reported. Best regards