Bluetooth: shell: Use the new advertising callbacks
Add advertising sent connected and scanned callback and print the information available. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
7c92ffdcb3
commit
fe597c07bf
1 changed files with 40 additions and 1 deletions
|
@ -115,6 +115,37 @@ static void scan_timeout(void)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BT_OBSERVER */
|
#endif /* CONFIG_BT_OBSERVER */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BT_BROADCASTER) && defined(CONFIG_BT_EXT_ADV)
|
||||||
|
static void adv_sent(struct bt_le_ext_adv *adv,
|
||||||
|
struct bt_le_ext_adv_sent_info *info)
|
||||||
|
{
|
||||||
|
shell_print(ctx_shell, "Advertiser[%d] %p sent %d",
|
||||||
|
bt_le_ext_adv_get_index(adv), adv, info->num_sent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void adv_connected(struct bt_le_ext_adv *adv,
|
||||||
|
struct bt_le_ext_adv_connected_info *info)
|
||||||
|
{
|
||||||
|
char str[BT_ADDR_LE_STR_LEN];
|
||||||
|
|
||||||
|
bt_addr_le_to_str(bt_conn_get_dst(info->conn), str, sizeof(str));
|
||||||
|
|
||||||
|
shell_print(ctx_shell, "Advertiser[%d] %p connected by %s",
|
||||||
|
bt_le_ext_adv_get_index(adv), adv, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void adv_scanned(struct bt_le_ext_adv *adv,
|
||||||
|
struct bt_le_ext_adv_scanned_info *info)
|
||||||
|
{
|
||||||
|
char str[BT_ADDR_LE_STR_LEN];
|
||||||
|
|
||||||
|
bt_addr_le_to_str(info->addr, str, sizeof(str));
|
||||||
|
|
||||||
|
shell_print(ctx_shell, "Advertiser[%d] %p scanned by %s",
|
||||||
|
bt_le_ext_adv_get_index(adv), adv, str);
|
||||||
|
}
|
||||||
|
#endif /* defined(CONFIG_BT_BROADCASTER) && defined(CONFIG_BT_EXT_ADV) */
|
||||||
|
|
||||||
#if !defined(CONFIG_BT_CONN)
|
#if !defined(CONFIG_BT_CONN)
|
||||||
#if 0 /* FIXME: Add support for changing prompt */
|
#if 0 /* FIXME: Add support for changing prompt */
|
||||||
static const char *current_prompt(void)
|
static const char *current_prompt(void)
|
||||||
|
@ -325,6 +356,14 @@ static struct bt_le_scan_cb scan_callbacks = {
|
||||||
};
|
};
|
||||||
#endif /* defined(CONFIG_BT_OBSERVER) */
|
#endif /* defined(CONFIG_BT_OBSERVER) */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BT_BROADCASTER) && defined(CONFIG_BT_EXT_ADV)
|
||||||
|
static struct bt_le_ext_adv_cb adv_callbacks = {
|
||||||
|
.sent = adv_sent,
|
||||||
|
.connected = adv_connected,
|
||||||
|
.scanned = adv_scanned,
|
||||||
|
};
|
||||||
|
#endif /* defined(CONFIG_BT_BROADCASTER) && defined(CONFIG_BT_EXT_ADV) */
|
||||||
|
|
||||||
static void bt_ready(int err)
|
static void bt_ready(int err)
|
||||||
{
|
{
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -834,7 +873,7 @@ static int cmd_adv_create(const struct shell *shell, size_t argc, char *argv[])
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = bt_le_ext_adv_create(¶m, NULL, &adv);
|
err = bt_le_ext_adv_create(¶m, &adv_callbacks, &adv);
|
||||||
if (err) {
|
if (err) {
|
||||||
shell_error(shell, "Failed to create advertiser set (%d)", err);
|
shell_error(shell, "Failed to create advertiser set (%d)", err);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue