From b8159d546c7f4aeeb3ea7c695f5ce85f824c0b3a Mon Sep 17 00:00:00 2001 From: Can Wang Date: Fri, 16 May 2025 19:51:57 +0800 Subject: [PATCH 1/3] Bluetooth: Shell: Remove redundant spaces in string. This string contains two consecutive spaces. Remove one of them. Signed-off-by: Can Wang --- subsys/bluetooth/host/shell/bt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/shell/bt.c b/subsys/bluetooth/host/shell/bt.c index a2ee453b2ea7..95f39604b90e 100644 --- a/subsys/bluetooth/host/shell/bt.c +++ b/subsys/bluetooth/host/shell/bt.c @@ -836,7 +836,7 @@ static void disconnected(struct bt_conn *conn, uint8_t reason) static bool le_param_req(struct bt_conn *conn, struct bt_le_conn_param *param) { - bt_shell_print("LE conn param req: int (0x%04x, 0x%04x) lat %d to %d", + bt_shell_print("LE conn param req: int (0x%04x, 0x%04x) lat %d to %d", param->interval_min, param->interval_max, param->latency, param->timeout); From a8f1c987727be8a6168385d6deb39dbbd00dc7a6 Mon Sep 17 00:00:00 2001 From: Can Wang Date: Fri, 16 May 2025 20:24:20 +0800 Subject: [PATCH 2/3] Bluetooth: Shell: Fix issue that BR security level cannot be set to 4. Host stack supports to set BR security level to 4 but the security level cannot be set to 4 by the shell command. Update the code to support BR security level 4. Signed-off-by: Can Wang --- subsys/bluetooth/host/shell/bt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/shell/bt.c b/subsys/bluetooth/host/shell/bt.c index 95f39604b90e..8a45830db07a 100644 --- a/subsys/bluetooth/host/shell/bt.c +++ b/subsys/bluetooth/host/shell/bt.c @@ -3847,7 +3847,7 @@ static int cmd_security(const struct shell *sh, size_t argc, char *argv[]) sec = *argv[1] - '0'; if ((info.type == BT_CONN_TYPE_BR && - (sec < BT_SECURITY_L0 || sec > BT_SECURITY_L3))) { + (sec < BT_SECURITY_L0 || sec > BT_SECURITY_L4))) { shell_error(sh, "Invalid BR/EDR security level (%d)", sec); return -ENOEXEC; } @@ -5121,7 +5121,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds, SHELL_CMD_ARG(oob, NULL, HELP_NONE, cmd_oob, 1, 0), SHELL_CMD_ARG(clear, NULL, "[all] ["HELP_ADDR_LE"]", cmd_clear, 2, 1), #if defined(CONFIG_BT_SMP) || defined(CONFIG_BT_CLASSIC) - SHELL_CMD_ARG(security, NULL, " [force-pair]", cmd_security, 1, 2), SHELL_CMD_ARG(bondable, NULL, HELP_ONOFF, cmd_bondable, From 5b26acda2c9eb0412aed9210babcaa037ab106ff Mon Sep 17 00:00:00 2001 From: Can Wang Date: Fri, 16 May 2025 20:42:21 +0800 Subject: [PATCH 3/3] Bluetooth: Shell: Fix issue that BR connection is not selected. LE and BR connection have already been established, after that, LE disconnection occurs, BR connection will not be selected as the next default connection. Fix this issue by searching for both BR and LE after disconnection occurs. Signed-off-by: Can Wang --- subsys/bluetooth/host/shell/bt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/shell/bt.c b/subsys/bluetooth/host/shell/bt.c index 8a45830db07a..722b1cab3559 100644 --- a/subsys/bluetooth/host/shell/bt.c +++ b/subsys/bluetooth/host/shell/bt.c @@ -826,11 +826,17 @@ static void disconnected(struct bt_conn *conn, uint8_t reason) bt_shell_print("Disconnected: %s (reason 0x%02x)", addr, reason); if (default_conn == conn) { + enum bt_conn_type conn_type = BT_CONN_TYPE_LE; + + if (IS_ENABLED(CONFIG_BT_CLASSIC)) { + conn_type |= BT_CONN_TYPE_BR; + } + bt_conn_unref(default_conn); default_conn = NULL; /* If we are connected to other devices, set one of them as default */ - bt_conn_foreach(BT_CONN_TYPE_LE, disconnected_set_new_default_conn_cb, NULL); + bt_conn_foreach(conn_type, disconnected_set_new_default_conn_cb, NULL); } }