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

cross mob
jakub
Level 1
Level 1
10 sign-ins 5 sign-ins First like given

Hello,

recently I noticed that during initialization I am getting "WICED_BT_GATT_INVALID_ATTR_LEN" from "wiced_bt_gatt_register" and "wiced_bt_gatt_db_init". I noticed that in the "wiced_bt_cfg_settings_t" the "gatt_cfg" specifies that the MTU should be max_att_len + 5 (/**< Maximum MTU size for GATT connections, should be between 23 and (max_attr_len + 5) */).

I used the throughput example to configure my application - https://github.com/Infineon/mtb-example-btsdk-ble-throughput/blob/master/GATT_server/app_bt_cfg.c

MTU and max attribute length are set to 247 and 244 respectively, considering that the attribute header is supposed to be 3. 

Any ideas why the documentation says difference between the two should be 5?

And also if this is the cause for the WICED_BT_GATT_INVALID_ATTR_LEN?

Thanks,

Jakub

0 Likes
1 Solution
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

The error can be caused if the Value to read will not fit within the buffer. That is when the below condition becomes false. Have you modified the peer device's attribute length and att_mtu?
"if (app_gatt_db_ext_attr_tbl[i].cur_len <= max_len)"

ATT MTU is defined on top of L2CAP. As L2CAP implementation should support a minimum MTU of 23 octets, ATT MTU should also support a minimum of 23 octets and can go up to 65535 octets. But, the maximum length of an attribute value shall be 512 octets only. No matter what the MTU size is defined for the app.

In the throughput application (Both client and server), we have chosen ATT MTU as 247 bytes (Meaning 244 bytes of ATT data will fit into a single packet ). Because the GATT data size selected in the application is 244 bytes. So maximum throughput can be achieved.

But for the Android Bluetooth ATT MTU is 517 bytes. This could be because of 2 extra bytes of offset parameter (for Long attribute values) on top of a 1-byte opcode and a 2-byte ATT handle. I believe, the comment you have mentioned above considered such conditions as well. So Max MTU can be (max_attr_len + 5).

Note:
The longest attribute that can be sent in a single packet is (ATT_MTU-1) octets in size. At a minimum, the Attribute Opcode is included in an Attribute PDU. An attribute value may be defined to be larger than (ATT_MTU-1) octets in size. These attributes are called long attributes.

 

Please check the Bluetooth core spec (Vol3, Part F)  for more info.

https://www.bluetooth.com/specifications/specs/core-specification-5-3/ 

 

Thanks,
-Dheeraj.P.K

View solution in original post

0 Likes
1 Reply
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi,

The error can be caused if the Value to read will not fit within the buffer. That is when the below condition becomes false. Have you modified the peer device's attribute length and att_mtu?
"if (app_gatt_db_ext_attr_tbl[i].cur_len <= max_len)"

ATT MTU is defined on top of L2CAP. As L2CAP implementation should support a minimum MTU of 23 octets, ATT MTU should also support a minimum of 23 octets and can go up to 65535 octets. But, the maximum length of an attribute value shall be 512 octets only. No matter what the MTU size is defined for the app.

In the throughput application (Both client and server), we have chosen ATT MTU as 247 bytes (Meaning 244 bytes of ATT data will fit into a single packet ). Because the GATT data size selected in the application is 244 bytes. So maximum throughput can be achieved.

But for the Android Bluetooth ATT MTU is 517 bytes. This could be because of 2 extra bytes of offset parameter (for Long attribute values) on top of a 1-byte opcode and a 2-byte ATT handle. I believe, the comment you have mentioned above considered such conditions as well. So Max MTU can be (max_attr_len + 5).

Note:
The longest attribute that can be sent in a single packet is (ATT_MTU-1) octets in size. At a minimum, the Attribute Opcode is included in an Attribute PDU. An attribute value may be defined to be larger than (ATT_MTU-1) octets in size. These attributes are called long attributes.

 

Please check the Bluetooth core spec (Vol3, Part F)  for more info.

https://www.bluetooth.com/specifications/specs/core-specification-5-3/ 

 

Thanks,
-Dheeraj.P.K

0 Likes