tzy****com
我们知道ATT MTU在bluetooth core的定义中,最大是517bytes,GATT MTU是512BYTS。
/**
****************************************************************************************
* @brief Set ATT_MTU size.
*
* @param[in] mtu: ATT_MTU size.
*
* @note This function should be called before exchange MTU operation. This MTU size is used to all connections.
* If not set these parameters, the stack will config the default value as (max_mtu = 512).
*
* @retval ::SDK_SUCCESS: Successfully get ATT_MTU.
* @retval ::SDK_ERR_DISALLOWED: Operation is disallowed.
****************************************************************************************
*/
uint16_t ble_gatt_mtu_set(uint16_t mtu);
【第一个问题】这个API注释写的是ATT_MTU,但是API名却是gatt mtu,这到底是gatt mtu,还是ATT_MTU。
/**
****************************************************************************************
* @brief Set L2CAP related parameters.
*
* @param[in] max_mtu: Maximal MTU acceptable for device, the range is 65~512.
* @param[in] max_mps: Maximal MPS Packet size acceptable for device (for COC SDU), the range is 65~max_mtu.
* @param[in] max_nb_lecb: Maximum number of LE Credit based connection that can be established, this range is 0x00~0x20.
* The actual number is decided by resource available.
*
* @retval SDK_SUCCESS: Operation is successful.
* @retval SDK_ERR_INVALID_PARAM: Invalid parameter supplied.
*
* @note If these parameters are not set, the stack will config the default value as (max_mtu = 512, max_mps = 512 and max_nb_lecb = 10).
****************************************************************************************
*/
uint16_t ble_gap_l2cap_params_set(uint16_t max_mtu,uint16_t max_mps,uint8_t max_nb_lecb);
【第二个问题】如果是l2cap层测mtu,这里max mtu其实应该就是ATT MTU,按照bluetooth core文档所述,最大应该是517,而不是这里的512.所以为什么不支持到517呢?
zhongchengzhi
您好,
1、您这边是什么应用场景需要配置517的MTU呢?
2、目前的SDK不支持配置517的MTU,若有需要的话,你提供下SDK的版本,我们提供一个patch;
tzy****com
在Bluetooth SIG
原文是这样的“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.
To read the entire value of an attributes larger than (ATT_MTU-1) octets, the
ATT_READ_BLOB_REQ PDU is used. It is possible to read the first
(ATT_MTU-1) octets of a long attribute value using the ATT_READ_REQ PDU.
To write the entire value of an attribute larger than (ATT_MTU-3) octets, the
ATT_PREPARE_WRITE_REQ and ATT_EXECUTE_WRITE_REQ PDUs are
used. It is possible to write the first (ATT_MTU-3) octets of a long attribute
value using the ATT_WRITE_CMD PDU.
It is not possible to determine if an attribute value is longer than (ATT_MTU-3)
octets using this protocol. A higher layer specification will state that a given
attribute can have a maximum length larger than (ATT_MTU-3) octets.
The maximum length of an attribute value shall be 512 octets.
Note: The protection of an attribute value changing when reading the value
using multiple Attribute Protocol PDUs is the responsibility of the higher layer.”
简单说就是属性值最大长度是512,MTU应该是ATT_PREPARE_WRITE_REQ抱头+512=517bytes
我们在android和ios、dialog、telink、esp32-s3也验证了,确实应该是517,所以想知道是否可以设置到517,如果现在不能,后期是否会更新sdk以支持这个特性。
zhongchengzhi
您好,
1、ble_gatt_mtu_set设置的是ATT 的MTU;
2、BLE MTU最大配置为512;
打开微信,使用“扫一扫”即可关注