Bluetooth: shell: Add shell support for RPA expire callback and control
Add shell support for RPA expire callback. This prints a message when the callback is called on the specific advertising set. Add a command to control the return value of this callback for a specific advertising set. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
ba657c9570
commit
ff36bd42d0
1 changed files with 42 additions and 0 deletions
|
@ -77,6 +77,7 @@ enum {
|
||||||
SHELL_ADV_OPT_DISCOVERABLE,
|
SHELL_ADV_OPT_DISCOVERABLE,
|
||||||
SHELL_ADV_OPT_EXT_ADV,
|
SHELL_ADV_OPT_EXT_ADV,
|
||||||
SHELL_ADV_OPT_APPEARANCE,
|
SHELL_ADV_OPT_APPEARANCE,
|
||||||
|
SHELL_ADV_OPT_KEEP_RPA,
|
||||||
|
|
||||||
SHELL_ADV_OPT_NUM,
|
SHELL_ADV_OPT_NUM,
|
||||||
};
|
};
|
||||||
|
@ -275,6 +276,22 @@ static void adv_connected(struct bt_le_ext_adv *adv,
|
||||||
bt_le_ext_adv_get_index(adv), adv, str);
|
bt_le_ext_adv_get_index(adv), adv, str);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BT_PERIPHERAL */
|
#endif /* CONFIG_BT_PERIPHERAL */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BT_PRIVACY)
|
||||||
|
static bool adv_rpa_expired(struct bt_le_ext_adv *adv)
|
||||||
|
{
|
||||||
|
uint8_t adv_index = bt_le_ext_adv_get_index(adv);
|
||||||
|
|
||||||
|
bool keep_rpa = atomic_test_bit(adv_set_opt[adv_index],
|
||||||
|
SHELL_ADV_OPT_KEEP_RPA);
|
||||||
|
shell_print(ctx_shell, "Advertiser[%d] %p RPA %s",
|
||||||
|
adv_index, adv,
|
||||||
|
keep_rpa ? "not expired" : "expired");
|
||||||
|
|
||||||
|
return keep_rpa;
|
||||||
|
}
|
||||||
|
#endif /* defined(CONFIG_BT_PRIVACY) */
|
||||||
|
|
||||||
#endif /* CONFIG_BT_EXT_ADV */
|
#endif /* CONFIG_BT_EXT_ADV */
|
||||||
|
|
||||||
#if !defined(CONFIG_BT_CONN)
|
#if !defined(CONFIG_BT_CONN)
|
||||||
|
@ -564,6 +581,10 @@ static struct bt_le_ext_adv_cb adv_callbacks = {
|
||||||
#if defined(CONFIG_BT_PERIPHERAL)
|
#if defined(CONFIG_BT_PERIPHERAL)
|
||||||
.connected = adv_connected,
|
.connected = adv_connected,
|
||||||
#endif /* CONFIG_BT_PERIPHERAL */
|
#endif /* CONFIG_BT_PERIPHERAL */
|
||||||
|
#if defined(CONFIG_BT_PRIVACY)
|
||||||
|
.rpa_expired = adv_rpa_expired,
|
||||||
|
#endif /* defined(CONFIG_BT_PRIVACY) */
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_BT_BROADCASTER */
|
#endif /* CONFIG_BT_BROADCASTER */
|
||||||
#endif /* CONFIG_BT_EXT_ADV */
|
#endif /* CONFIG_BT_EXT_ADV */
|
||||||
|
@ -1800,6 +1821,24 @@ static int cmd_adv_oob(const struct shell *sh, size_t argc, char *argv[])
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BT_PERIPHERAL */
|
#endif /* CONFIG_BT_PERIPHERAL */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BT_PRIVACY)
|
||||||
|
static int cmd_adv_rpa_expire(const struct shell *sh, size_t argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (!strcmp(argv[1], "on")) {
|
||||||
|
atomic_clear_bit(adv_set_opt[selected_adv], SHELL_ADV_OPT_KEEP_RPA);
|
||||||
|
shell_print(sh, "RPA will expire on next timeout");
|
||||||
|
} else if (!strcmp(argv[1], "off")) {
|
||||||
|
atomic_set_bit(adv_set_opt[selected_adv], SHELL_ADV_OPT_KEEP_RPA);
|
||||||
|
shell_print(sh, "RPA will not expire on RPA timeout");
|
||||||
|
} else {
|
||||||
|
shell_error(sh, "Invalid argument: %s", argv[1]);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_BT_PER_ADV)
|
#if defined(CONFIG_BT_PER_ADV)
|
||||||
static int cmd_per_adv(const struct shell *sh, size_t argc, char *argv[])
|
static int cmd_per_adv(const struct shell *sh, size_t argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -3555,6 +3594,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
|
||||||
#if defined(CONFIG_BT_PERIPHERAL)
|
#if defined(CONFIG_BT_PERIPHERAL)
|
||||||
SHELL_CMD_ARG(adv-oob, NULL, HELP_NONE, cmd_adv_oob, 1, 0),
|
SHELL_CMD_ARG(adv-oob, NULL, HELP_NONE, cmd_adv_oob, 1, 0),
|
||||||
#endif /* CONFIG_BT_PERIPHERAL */
|
#endif /* CONFIG_BT_PERIPHERAL */
|
||||||
|
#if defined(CONFIG_BT_PRIVACY)
|
||||||
|
SHELL_CMD_ARG(adv-rpa-expire, NULL, HELP_ONOFF, cmd_adv_rpa_expire, 2, 0),
|
||||||
|
#endif
|
||||||
#if defined(CONFIG_BT_PER_ADV)
|
#if defined(CONFIG_BT_PER_ADV)
|
||||||
SHELL_CMD_ARG(per-adv, NULL, HELP_ONOFF, cmd_per_adv, 2, 0),
|
SHELL_CMD_ARG(per-adv, NULL, HELP_ONOFF, cmd_per_adv, 2, 0),
|
||||||
SHELL_CMD_ARG(per-adv-param, NULL,
|
SHELL_CMD_ARG(per-adv-param, NULL,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue