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)
How to increase MTU size on GATT - Server
Re: How to increase MTU size on GATT - Server
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.
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
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
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
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.
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
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: How to increase MTU size on GATT - Server
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.
-
- Posts: 79
- Joined: Tue Apr 26, 2016 5:10 am
Re: How to increase MTU size on GATT - Server
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.
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
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
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
Increasing the MTU size on android requires version 21+ (Lollipop - 5.0)
The related API is https://developer.android.com/reference ... stMtu(int)
The related API is https://developer.android.com/reference ... stMtu(int)
Re: How to increase MTU size on GATT - Server
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
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
Who is online
Users browsing this forum: Bing [Bot] and 75 guests