String characteristic won't exceed 20 bytes in write

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
johnspeth
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

I have a custom UTF8S string characteristic that I've configured for 32 bytes in my projects' BLE PDL. Using CySmart, attempting to write a string having greater than 20 bytes will silently fail. I tried increasing the MTU size to 50 from 23 and the LL max Rx/Tx payload sizes to 100 from 27 and I still hit the same 20 byte limit. Can someone please tell me how to successfully write string characteristics having greater than 20 bytes?

0 Likes
1 Solution

Thanks Mr Yugandhar, your advice gave me the clues to fix this problem. My BLE component was configured for Max GATT MTU = 23. That's what limited the max string length (actually MTU-3 which is liberally documented). I changed it to 43 and now I have success. My phone (client) was requesting MTU = 512. My firmware (server) grants MTU = CY_BLE_GATT_MTU. CY_BLE_GATT_MTU is one of the generated constants that comes from the BLE component configuration.

Here's my GATT MTU negotiation code:

// Part of the BLE event callback function:
case CY_BLE_EVT_GATTS_XCNHG_MTU_REQ:
{
	// Client requests to use a larger MTU, server grants an equal or lesser size
	cy_stc_ble_gatt_xchg_mtu_param_t mtuParam;
	mtuParam.connHandle = ((cy_stc_ble_gatt_xchg_mtu_param_t*)(eventParam))->connHandle;
	mtuParam.mtu = CY_BLE_GATT_MTU;
	Cy_BLE_GATTS_ExchangeMtuRsp(&mtuParam);
}
break;

 

I was using CySmart on a mobile phone so I don't have access to the enhanced configuration featured on the desktop app.

JJS

View solution in original post

0 Likes
3 Replies
lock attach
Attachments are accessible only for community members.
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Some mobile phones have the default MTU size of 23 bytes. So, the negotiated MTU size becomes 23 regardless of the MTU size of your Peripheral device because your Central device's MTU size is 23.
Negotiated MTU size means the minimum of (MTU size of Central, MTU size of Peripheral). This negotiated MTU size will be used for the rest of the communication between Central and Peripheral.

Could you please check with some other phones ? If you are using Cysmart BLE dongle, then you can increase the GATT MTU size in Master settings as shown in attached image. 

Thanks,

P Yugandhar.

0 Likes

Thanks Mr Yugandhar, your advice gave me the clues to fix this problem. My BLE component was configured for Max GATT MTU = 23. That's what limited the max string length (actually MTU-3 which is liberally documented). I changed it to 43 and now I have success. My phone (client) was requesting MTU = 512. My firmware (server) grants MTU = CY_BLE_GATT_MTU. CY_BLE_GATT_MTU is one of the generated constants that comes from the BLE component configuration.

Here's my GATT MTU negotiation code:

// Part of the BLE event callback function:
case CY_BLE_EVT_GATTS_XCNHG_MTU_REQ:
{
	// Client requests to use a larger MTU, server grants an equal or lesser size
	cy_stc_ble_gatt_xchg_mtu_param_t mtuParam;
	mtuParam.connHandle = ((cy_stc_ble_gatt_xchg_mtu_param_t*)(eventParam))->connHandle;
	mtuParam.mtu = CY_BLE_GATT_MTU;
	Cy_BLE_GATTS_ExchangeMtuRsp(&mtuParam);
}
break;

 

I was using CySmart on a mobile phone so I don't have access to the enhanced configuration featured on the desktop app.

JJS

0 Likes
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

In the BLE component, if you put the ATT MTU Size to 512 bytes then the negotiated MTU size will be 512 bytes(because your phone (client) was requesting MTU = 512).

Thanks,

P Yugandhar.

0 Likes