연결 직후 FW에서 먼저 MTU Exchange 요청

- 기존: central이 MTU Exchange Request를 보내면 FW에서 응답값 전달
 → central에서 요청하지 않는 경우 기본값 23 유지됨
This commit is contained in:
2026-07-20 17:45:47 +09:00
parent 540c17e890
commit 046919b7d9
+39
View File
@@ -78,6 +78,35 @@ static void att_mtu_updated(struct bt_conn *conn, uint16_t tx, uint16_t rx)
(current_notify_mtu > 3U) ? (current_notify_mtu - 3U) : 0U);
}
/* MTU Exchange 연결 직후 요청 */
static void mtu_exchange_cb(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params)
{
uint16_t uatt;
ARG_UNUSED(params);
if (err)
{
DBG_ERR("[BLE] MTU exchange failed err=%u\r\n", err);
return;
}
uatt = bt_gatt_get_uatt_mtu(conn);
if (uatt != 0U)
{
current_notify_mtu = uatt;
}
DBG_PRINTF("[BLE] MTU exchange complete uatt=%u notify_payload=%u\r\n",
uatt,
(uatt > 3U) ? (uatt - 3U) : 0U);
}
static struct bt_gatt_exchange_params mtu_exchange_params =
{
.func = mtu_exchange_cb,
};
static struct bt_gatt_cb gatt_callbacks =
{
.att_mtu_updated = att_mtu_updated,
@@ -416,6 +445,16 @@ static void connected(struct bt_conn *conn, uint8_t err)
bt_addr_le_to_str(bt_conn_get_dst(conn), addr_str, sizeof(addr_str));
DBG_CORE("[BLE] Peer: %s\r\n", addr_str); // 연결 정보 출력
err = bt_gatt_exchange_mtu(conn, &mtu_exchange_params);
if (err)
{
DBG_ERR("[BLE] MTU exchange request failed err=%d\r\n", err);
}
else
{
DBG_PRINTF("[BLE] MTU exchange requested\r\n");
}
conn_param_update_attempts = 0U;
last_rx_conn_param_update_ms = 0;