Skip to content

Commit a00d508

Browse files
lylezhu2012aescolar
authored andcommitted
Bluetooth: shell: Add command conn-bondable
Add command `conn-bondable` to enable/disable the pairing bondable flag of a specific ACL connection. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
1 parent d5160f6 commit a00d508

File tree

1 file changed

+32
-0
lines changed
  • subsys/bluetooth/host/shell

1 file changed

+32
-0
lines changed

subsys/bluetooth/host/shell/bt.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,6 +3902,35 @@ static int cmd_bondable(const struct shell *sh, size_t argc, char *argv[])
39023902
return 0;
39033903
}
39043904

3905+
#if defined(CONFIG_BT_BONDABLE_PER_CONNECTION)
3906+
static int cmd_conn_bondable(const struct shell *sh, size_t argc, char *argv[])
3907+
{
3908+
int err = 0;
3909+
bool enable;
3910+
3911+
if (!default_conn) {
3912+
shell_error(sh, "Not connected");
3913+
return -ENOEXEC;
3914+
}
3915+
3916+
enable = shell_strtobool(argv[1], 0, &err);
3917+
if (err) {
3918+
shell_help(sh);
3919+
return SHELL_CMD_HELP_PRINTED;
3920+
}
3921+
3922+
shell_print(sh, "[%p] set conn bondable %s", default_conn, argv[1]);
3923+
3924+
err = bt_conn_set_bondable(default_conn, enable);
3925+
if (err) {
3926+
shell_error(sh, "Set conn bondable failed: err %d", err);
3927+
return -ENOEXEC;
3928+
}
3929+
shell_print(sh, "Set conn bondable done");
3930+
return 0;
3931+
}
3932+
#endif /* CONFIG_BT_BONDABLE_PER_CONNECTION */
3933+
39053934
static void bond_info(const struct bt_bond_info *info, void *user_data)
39063935
{
39073936
char addr[BT_ADDR_LE_STR_LEN];
@@ -5079,6 +5108,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
50795108
cmd_security, 1, 2),
50805109
SHELL_CMD_ARG(bondable, NULL, HELP_ONOFF, cmd_bondable,
50815110
2, 0),
5111+
#if defined(CONFIG_BT_BONDABLE_PER_CONNECTION)
5112+
SHELL_CMD_ARG(conn-bondable, NULL, HELP_ONOFF, cmd_conn_bondable, 2, 0),
5113+
#endif /* CONFIG_BT_BONDABLE_PER_CONNECTION */
50825114
SHELL_CMD_ARG(bonds, NULL, HELP_NONE, cmd_bonds, 1, 0),
50835115
SHELL_CMD_ARG(connections, NULL, HELP_NONE, cmd_connections, 1, 0),
50845116
SHELL_CMD_ARG(auth, NULL,

0 commit comments

Comments
 (0)