requestHighestValueLength

Requests the highest possible MTU (ATT_MTU_MAX).

The MTU will be automatically requested when the peripheral is reconnected when connected using AutoConnect.

The MTU is negotiated between the client and the server and set to the highest value supported by both devices.

Although it was possible to request any MTU from 23 to 517, since Android 14 the system will always request value 517 ignoring the requested value. Hence, this method does not allow to set the MTU value.

Important

It is known that some Android devices (i.e. Samsung Galaxy Tab A8) fail to negotiate LL MTU (packet size on the Link Layer) using Data Length Extension (DLE). They mistakenly claim supporting only 27 bytes of TX, but then try to send up to 251 bytes, causing the connection to terminate. For such devices it is recommended not to request higher MTU or never sending more than 20 bytes in a single write operation.

Throws

If the device is not connected.

If MTU could not be requested.

If BLUETOOTH_CONNECT permission is denied.