From 4611c402e2d02c585a18ad5487f2d6859a53de18 Mon Sep 17 00:00:00 2001 From: Lyle Zhu Date: Mon, 3 Mar 2025 21:08:26 +0800 Subject: [PATCH] Bluetooth: tester: Support BR for security related commands Look up the BR connection if the address type is BTP_BR_ADDRESS_TYPE. Signed-off-by: Lyle Zhu --- tests/bluetooth/tester/src/btp_gap.c | 55 +++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/tests/bluetooth/tester/src/btp_gap.c b/tests/bluetooth/tester/src/btp_gap.c index dd68b2ba9f1..80a6483449b 100644 --- a/tests/bluetooth/tester/src/btp_gap.c +++ b/tests/bluetooth/tester/src/btp_gap.c @@ -1282,7 +1282,16 @@ static uint8_t pair(const void *cmd, uint16_t cmd_len, struct bt_conn *conn; int err; - conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + if (cp->address.type == BTP_BR_ADDRESS_TYPE) { + if (IS_ENABLED(CONFIG_BT_CLASSIC)) { + conn = bt_conn_lookup_addr_br(&cp->address.a); + } else { + return BTP_STATUS_FAILED; + } + } else { + conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + } + if (!conn) { LOG_ERR("Unknown connection"); return BTP_STATUS_FAILED; @@ -1306,7 +1315,16 @@ static uint8_t unpair(const void *cmd, uint16_t cmd_len, struct bt_conn *conn; int err; - conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + if (cp->address.type == BTP_BR_ADDRESS_TYPE) { + if (IS_ENABLED(CONFIG_BT_CLASSIC)) { + conn = bt_conn_lookup_addr_br(&cp->address.a); + } else { + return BTP_STATUS_FAILED; + } + } else { + conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + } + if (!conn) { LOG_INF("Unknown connection"); goto keys; @@ -1336,7 +1354,16 @@ static uint8_t passkey_entry(const void *cmd, uint16_t cmd_len, struct bt_conn *conn; int err; - conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + if (cp->address.type == BTP_BR_ADDRESS_TYPE) { + if (IS_ENABLED(CONFIG_BT_CLASSIC)) { + conn = bt_conn_lookup_addr_br(&cp->address.a); + } else { + return BTP_STATUS_FAILED; + } + } else { + conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + } + if (!conn) { LOG_ERR("Unknown connection"); return BTP_STATUS_FAILED; @@ -1360,7 +1387,16 @@ static uint8_t passkey_confirm(const void *cmd, uint16_t cmd_len, struct bt_conn *conn; int err; - conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + if (cp->address.type == BTP_BR_ADDRESS_TYPE) { + if (IS_ENABLED(CONFIG_BT_CLASSIC)) { + conn = bt_conn_lookup_addr_br(&cp->address.a); + } else { + return BTP_STATUS_FAILED; + } + } else { + conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + } + if (!conn) { LOG_ERR("Unknown connection"); return BTP_STATUS_FAILED; @@ -1400,7 +1436,16 @@ static uint8_t conn_param_update(const void *cmd, uint16_t cmd_len, struct bt_conn *conn; int err; - conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + if (cp->address.type == BTP_BR_ADDRESS_TYPE) { + if (IS_ENABLED(CONFIG_BT_CLASSIC)) { + conn = bt_conn_lookup_addr_br(&cp->address.a); + } else { + return BTP_STATUS_FAILED; + } + } else { + conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, &cp->address); + } + if (!conn) { LOG_ERR("Unknown connection"); return BTP_STATUS_FAILED;