This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Changing MTU on CC2640 depending on android version

Other Parts Discussed in Thread: CC2640

Hi, i would like to change programmatically the BLE MTU size on a custom cc2640 board, depending on the Android version of the tablet/smartphone I use.

To be more specific, I need to have the biggest throughput possible, as I have several Mbits of data to send as fast as possible. The BLE Stack V2.1 allows bigger MTU than 23, which is great. 

However, it doesn't work if i manually change MAX_PDU_SIZE to something greater than 27 and use Android API 4.4 because the requestMTU() functionnality has been implemented since Android 5.0.

The following resumes my point:

- MAX_PDU_SIZE  > 27 with Android 5.0 or more : WORK

- MAX_PDU_SIZE > 27 with Android 4.4 or less : DOESN'T WORK

- MAX_PDU_SIZE = 27 with Android 4.4 or less : WORK 

- MAX_PDU_SIZE = 27 with Android 5.0 or more : WORK but not optimal

So, my goal is to manually set MAX_PDU_SIZE to 27 in order to work with Android 4.4, but to programmatically change it if Android 5.0 or more is being used.

Many thanks. 

Regards, 

Etienne 

  • Hello. It is up to the GATT client (Android) to request the MTU and configure the MTU. This is so the GATT server does not have to do what you are trying to do. Furthermore, there is no way to do this in our stack as it is configured at compile time.

    Can you provide more information about how MAX_PDU of 27 doesn't work with Android 4.4. Are you saying the MTU update doesn't work or the connection fails? If it is the latter, this sounds like an Android bug.
  • Hi Tim, thanks for your answer. 

    As previously said, a MAX_PDU of 27 does work with Android 4.4 (third point), but the value cannot be changed, as Android 4.4 doesn't implement the requestMTU() functionnality. It has been implemented since Android 5.0 (Lollipop). So, it only works with the default MTU size for BLE, which is 23. 

    As we want to have our app compatible with Android 4.4, I simply wanted to leave MAX_PDU at 27 and, if the client is Android 5.0 or more, to change MAX_PDU to something greater than 27 (150 for example).

    If you say that it is impossible to change the MTU programatically, even with a disconnection, then i guess i have to find another solution. 

    Regards, 

    Etienne

  • Hello Etienne,

    Can you be more specific with regards to "not working when > 27"? If you configure MAX_PDU_SIZE > 27, and the Client (e.g., Android 4.4 phone) doesn't request an MTU exchange, the MTU for that connection will remain the default (e.g., ATT_MTU 23). In other words, if Android doesn't implement the MTU Exchange, the stack will continue to use the default 27 MTU.

    Best wishes
  • I've seen this while integrating a peripheral using CC26X. iOS is quite nice and seems to auto-negotiate the mtu for maximum throughput, however it wasn't until Android API 21 that the function requestMtu() was added, meaning the App needs to handle this negotiation based on the API level. The peripheral can only specify what the maximum mtu it supports, which if you use the Bluetopia stack for example, already should set it to the maximum.