STM32WB55 获取蓝牙链接过程协商的MTU值

1、
app_conf.h修改配置宏 设备默认支持的MTU数值

/**
 * Maximum supported ATT_MTU size
 */
#define CFG_BLE_MAX_ATT_MTU             (250)

调用aci_gatt_exchange_config这个api可以产生mtu交互事件。

/**
  * @brief Perform an ATT MTU exchange procedure.
When the ATT MTU exchange procedure is completed, a @ref aci_att_exchange_mtu_resp_event
event is generated. A @ref aci_gatt_proc_complete_event event is also generated
to indicate the end of the procedure.
  * @param Connection_Handle Connection handle for which the command is given.
  * Values:
  - 0x0000 ... 0x0EFF
  * @retval Value indicating success or error code.
*/
tBleStatus aci_gatt_exchange_config(uint16_t Connection_Handle);

把它放在链接事件回调
在这里插入图片描述
2、添加mtu事件的回调

case EVT_BLUE_ATT_EXCHANGE_MTU_RESP:
{
	aci_att_exchange_mtu_resp_event_rp0 * exchange_mtu_resp;
	APP_DBG_MSG("EVT_BLUE_ATT_EXCHANGE_MTU_RESP \n");					
    exchange_mtu_resp = (aci_att_exchange_mtu_resp_event_rp0 *)blue_evt->data;
    APP_DBG_MSG("MTU_size = %d \n",exchange_mtu_resp->Server_RX_MTU );
}
	break;

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_28851611/article/details/107435375
今日推荐