Allow negotiation of BLE MTU size


I would like to be able to call gatt.requestMtu(int mtu) upon device connection inside However, I cannot seem to get the instructions here to work properly for debugging. Perhaps I missed some documentation somewhere. Can this feature please be added to JUCE? I am happy to make a request in the Github repo if that is the proper workflow.


For anyone wondering, you can make this change by:

  1. In juce_android_Midi.cpp, change

DECLARE_JNI_CLASS_WITH_BYTECODE (JuceMidiSupport, "com/rmsl/juce/JuceMidiSupport", 23, javaMidiByteCode)


DECLARE_JNI_CLASS_WITH_MIN_SDK (JuceMidiSupport, "com/rmsl/juce/JuceMidiSupport", 23)

  1. Rename the folder juce_audio_devices/native/java to juce_audio_devices/native/javacore/

  2. Add the new folder to the sourceSets inside build.gradle

    sourceSets { +=
  1. In, add your new code:
            public void onConnectionStateChange (BluetoothGatt gatt, int status, int newState)
                if (newState == BluetoothProfile.STATE_CONNECTED)
                    gatt.requestConnectionPriority (BluetoothGatt.CONNECTION_PRIORITY_HIGH);
                    gatt.requestMtu(517); // Add your request here
                    owner.pairBluetoothDeviceStepTwo (gatt.getDevice ());

You should get a callback here:

            public void onMtuChanged (BluetoothGatt gatt, int mtu, int status) {
                Log.d ("JUCE", "MTU Changed to: " + mtu);

Would be lovely to see this option enabled from within the Projucer!