Bluetooth: shell: Add command to print all bonds available
Add command to print all existing bonds. Useful for verifying that bonds are actually cleared when debugging. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
8d88beca34
commit
f6a6974186
|
@ -1122,6 +1122,29 @@ static int cmd_bondable(const struct shell *shell, size_t argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void bond_info(const struct bt_bond_info *info, void *user_data)
|
||||
{
|
||||
char addr[BT_ADDR_LE_STR_LEN];
|
||||
int *bond_count = user_data;
|
||||
|
||||
bt_addr_le_to_str(&info->addr, addr, sizeof(addr));
|
||||
shell_print(ctx_shell, "Remote Identity: %s", addr);
|
||||
(*bond_count)++;
|
||||
}
|
||||
|
||||
static int cmd_bonds(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
int bond_count = 0;
|
||||
|
||||
shell_print(shell, "Bonded devices:");
|
||||
|
||||
bt_foreach_bond(selected_id, bond_info, &bond_count);
|
||||
|
||||
shell_print(shell, "Total %d", bond_count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey)
|
||||
{
|
||||
char addr[BT_ADDR_LE_STR_LEN];
|
||||
|
@ -1639,6 +1662,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
|
|||
cmd_security, 2, 1),
|
||||
SHELL_CMD_ARG(bondable, NULL, "<bondable: on, off>", cmd_bondable,
|
||||
2, 0),
|
||||
SHELL_CMD_ARG(bonds, NULL, HELP_NONE, cmd_bonds, 1, 0),
|
||||
SHELL_CMD_ARG(auth, NULL,
|
||||
"<method: all, input, display, yesno, confirm, "
|
||||
"oob, none>",
|
||||
|
|
Loading…
Reference in a new issue