Page 1 of 3

How to increase MTU size on GATT - Server

Posted: Mon Jul 17, 2017 12:35 pm
by Abhiram
Hi , all

I wanted forums help in knowing how can I increase the size of BLE MTU = 500 bytes for GATT Server. ?

so that any client connecting to this server is aware of the modified BLE MTU = 500 Bytes , and not 23 bytes, ( How this will be conveyed to the Client ) ?

I changed the GATT_DEF_BLE_MTU_SIZE = 23 to 500 in gatt_api.h , but I see the change is not taken. If I exchange the packet of size 30 , I get the error message as " BT: attribute value too long, to be truncated to 22". Or my services or characteristic doesn't get displayed on the Client application ( NRFConnect)

Re: How to increase MTU size on GATT - Server

Posted: Mon Jul 17, 2017 1:33 pm
by mh-dev
The constant you mentioned is used by the gatt client not the server.

Theoretically the client can request an increase of the MTU size, but I never tested it.

Re: How to increase MTU size on GATT - Server

Posted: Mon Jul 17, 2017 1:36 pm
by Abhiram
Thanks mh-dev

So would you say that its only on client request , server can change the default MTU size ?
Any way for server to increase the size of its MTU ( to be used in characteristic - attribute ) and convey it to client while connecting ?

Thanks for help

Re: How to increase MTU size on GATT - Server

Posted: Mon Jul 17, 2017 1:45 pm
by mh-dev
I don't know if there's a way to force this from the server.
My research related to android clients tells me so far that the MTU size is hard coded at least for older devices and can not be changed.

What I use so far is the auto response with the service table. The ESP-IDF SDK is in this mode able to perform long writes. That allows to send and receive up to 512 bytes. It does this via a multi packet protocol, but you don't have to manually deal with that. Don't expect this be fast. I might do some research how this can be achieved without auto response. Since this has also drawbacks.
Be aware that to my knowledge that a bug that I reported a few days ago is still not fixed. This bug has problems if you set the attribute via esp_ble_gatts_set_attr_value in this mode. My bug ticket contains a fix that you can apply locally if you need it.

Re: How to increase MTU size on GATT - Server

Posted: Mon Jul 17, 2017 2:08 pm
by kolban

Re: How to increase MTU size on GATT - Server

Posted: Mon Jul 17, 2017 2:19 pm
by mh-dev
kolban wrote:This API might be a clue ...

http://esp-idf.readthedocs.io/en/latest ... t8uint16_t
This should have an effect if the the client request an MTU size increase.
All files that contain gattc instead of gatts are for the client library.

Re: How to increase MTU size on GATT - Server

Posted: Tue Jul 18, 2017 2:59 am
by Lucas.Hutchinson
Hi All,

As previously mentioned it is the gatt client that needs to request an MTU change.
The gatt sever is unable to change the mtu size without a request from the gatt client.

I have tested this with the esp32 and it works very well.
In my case my gatt client always requests an MTU change of a peripheral on connection. If the peripheral doesnt support the new MTU, this will result in a failed MTU update.

On android phones (using the nrf Connect app) you can request an MTU change up to the max allowed by the BLE standard (517)

On iOS i have found that this MTU change request is not allowed to be performed by user code on a user app. However I have also found that an MTU change request is automatically negotiated by the iOS BLE stack on connection to a peripheral. from iOS 10+ the requested MTU size is 185 (various reasons for this related to very low level ble stack operations, and optimisations).

Hope this helps.

Re: How to increase MTU size on GATT - Server

Posted: Tue Jul 18, 2017 10:32 am
by Abhiram
Thanks Lucas.Hutchinson for your comments , you have mentioned "On android phones (using the nrf Connect app) you can request an MTU change up to the max allowed by the BLE standard (517) " - Could please let me know how we could do this ?

Because I see " Note: The source code of nRF Connect is not available. " @ https://github.com/NordicSemiconductor/ ... RF-Connect

Re: How to increase MTU size on GATT - Server

Posted: Tue Jul 18, 2017 12:09 pm
by mh-dev
Increasing the MTU size on android requires version 21+ (Lollipop - 5.0)

The related API is https://developer.android.com/reference ... stMtu(int)

Re: How to increase MTU size on GATT - Server

Posted: Thu Jul 20, 2017 12:51 pm
by SW_Adnan
Hi all,

I understand that to increase the MTU size the request has to come from the client. The server then replies with the maximum MTU it can support.

It seems that for the server, the MTU exchange request is handled by the Bluedroid stack. Is there a way to change the max MTU that is supported by the server?

Also there is esp_ble_gap_set_pkt_data_len in the GAP API, I don't really understand what is the purpose of this function. Does it have anything to do with the MTU?

Cheers