Hello,
I have some troubles understanding the design of the MTU exchange within the Android Nordic Library.
We are using a NRF52840 SDK 17 softdevice version 7.2.0 and a mobile application which integrated the Android Nordic Library version 2.6.0.
In the Nordic SDK of the nrf52840, in module nrf_ble_gatt.c the function on_connected_evt will react to the connection and if the macro NRF_BLE_GATT_MTU_EXCHANGE_INITIATION_ENABLED is set, it will automatically make a call to the softdevice to make a mtu request to the peer. Which is visible from the Android logs as well as from the sniffer traces...
But then in the Android BLE Nordic library the internal MTU is not changed and if we want to perform some GATT write operation on the server on the nrf board the packets are splitted in small chunks which take the default MTU ( 23 )...
Then from the documentation inside the Nordic android library, it's then clear that if the MTU request is not issued by the central, the mtu is not the correct one as it's written in the documentation :
/**
* Returns the current MTU (Maximum Transfer Unit). MTU specifies the maximum number of bytes
* that can be sent in a single write operation. 3 bytes are used for internal purposes,
* so the maximum size is MTU-3. The value will changed only if requested with
* {@link #requestMtu(int)} and a successful callback is received. If the peripheral requests
* MTU change, the {@link BluetoothGattCallback#onMtuChanged(BluetoothGatt, int, int)}
* callback is not invoked, therefor the returned MTU value will not be correct.
* Use {@link android.bluetooth.BluetoothGattServerCallback#onMtuChanged(BluetoothDevice, int)}
* to get the callback with right value requested from the peripheral side.
*
* @return the current MTU value. Default to 23.
*/
@IntRange(from = 23, to = 517)
protected int getMtu() {
return requestHandler.getMtu();
}
So here I'm just wondering why it has been designed that way and why the mtu as requested by the peripheral is not taken into account ? The 2 software components ( nrf52840 sdk and the Android library ) seem not that interoperable in that specific matter.
Thank you for your help.