
这是从机通过notify方式发送给主机的数据,包长为195个字节,从机只用1包就发送给主机了。

通过BTool工具主机给从机发送相同的数据也是195字节,主机却是按照90个字节分包处理的,导致在从机的读数据回调函数:simpleProfile_ReadAttrCB回调了多次,我是做蓝牙透传,以后收到了多包就往串口透传了多包,虽然会通过offset来指定分包的偏移,但是对于从机而言从机怎么知道还有没有后续分包?主机为何不能像从机一样一包发送吗?是哪里需要设置吗?(注:连接成功后,通过GATT_ExtchangMTU设置最大MTU为251字节)。
Viki Shi:
用uint16 L2CAP_GetParamValue看下MTU返回值多少
cao jia:
回复 Viki Shi:
Viki Shi:hi!查看API文档说明:uint16 L2CAP_GetParamValue返回的是参数,请问具体返回的是什么参数啊?实际测试发现在host和peripheral使用此函数读到的都是0x0000。我本想使用L2CAP_GetMTU()去获取MTU大小,但是协议栈1.50的SDK不支持该命令。
Alvin Chen:
回复 cao jia:
Configuring for Larger MTU Values
A client device can request a larger ATT_MTU during a connection by using the GATT_ExchangeMTU() command. During this procedure, the client informs the server of its maximum supported receive MTU size and the server responds with its maximum supported receive MTU size. Only the client can initiate this procedure. When the messages are exchanged, the ATT_MTU for the duration of the connection is the minimum of the client MTU and server MTU values. If the client indicates it can support an MTU of 200 bytes and the server responds with a maximum size of 150 bytes, the ATT_MTU size is 150 for that connection.
For more information, see the MTU Exchange section of the Bluetooth Core Specification Version 4.2.
Take the following steps to configure the stack to support larger MTU values.
Set the MAX_PDU_SIZE preprocessor symbol in the application project to the desired value to the maximum desired size of the L2CAP PDU size. The maximum ATT_MTU size is always 4 bytes less than the value of the MAX_PDU_SIZE.
Call GATT_ExchangeMTU() after a connection is formed (GATT client only). The MTU parameter passed into this function must be less than or equal to the definition from step 1.
Receive the ATT_MTU_UPDATED_EVENT in the calling task to verify that the MTU was successfully updated. This update requires the calling task to have registered for GATT messages. See Registering to Receive Additional GATT Events in the Application for more information.Though the stack can be configured to support a MAX_PDU_SIZE up to 255 bytes, each Bluetooth low energy connection initially uses the default 27 bytes (ATT_MTU = 23 bytes) value until the exchange MTU procedure results in a larger MTU size. The exchange MTU procedure must be performed on each Bluetooth low energy connection and must be initiated by the client.
TI中文支持网
