Bluetooth: shell: Updated advx command to use Adv Data Set

Updated the shell commands related to Advertising Extensions
to call the LE Set Extended Advertising Data command
functional interface for testing purposes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2020-01-27 17:13:30 +05:30 committed by Carles Cufí
commit 5f1301245c
2 changed files with 25 additions and 14 deletions

View file

@ -2487,8 +2487,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
#if defined(CONFIG_BT_LL_SW_SPLIT)
#if defined(CONFIG_BT_CTLR_ADV_EXT)
#if defined(CONFIG_BT_BROADCASTER)
SHELL_CMD_ARG(advx, NULL, "<on off> [coded] [anon] [txp]", cmd_advx,
2, 3),
SHELL_CMD_ARG(advx, NULL,
"<on hdcd ldcd off> [coded] [anon] [txp] [ad]",
cmd_advx, 2, 4),
#endif /* CONFIG_BT_BROADCASTER */
#if defined(CONFIG_BT_OBSERVER)
SHELL_CMD_ARG(scanx, NULL, "<on passive off> [coded]", cmd_scanx,

View file

@ -122,6 +122,7 @@ int cmd_test_end(const struct shell *shell, size_t argc, char *argv[])
#include "../controller/ll_sw/ull_adv_aux.h"
#include "../controller/ll_sw/lll.h"
#if defined(CONFIG_BT_BROADCASTER)
#define OWN_ADDR_TYPE 1
#define PEER_ADDR_TYPE 0
#define PEER_ADDR NULL
@ -135,15 +136,11 @@ int cmd_test_end(const struct shell *shell, size_t argc, char *argv[])
#define AD_OP 0x03
#define AD_FRAG_PREF 0x00
#define AD_LEN 0x00
#define AD_DATA NULL
#define SCAN_INTERVAL 0x0004
#define SCAN_WINDOW 0x0004
#define SCAN_OWN_ADDR_TYPE 1
#define SCAN_FILTER_POLICY 0
static const struct bt_data adv_data[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, BT_LE_AD_NO_BREDR),
};
#if defined(CONFIG_BT_BROADCASTER)
int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
{
uint16_t adv_interval = 0x20;
@ -151,6 +148,7 @@ int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
uint16_t evt_prop = 0U;
uint8_t adv_type;
uint8_t enable;
uint8_t ad = 0;
uint8_t phy_p;
int32_t err;
@ -188,6 +186,7 @@ int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
} else if (!strcmp(argv[2], "txp")) {
evt_prop |= BIT(6);
} else if (!strcmp(argv[2], "ad")) {
ad = 1;
} else {
handle = strtoul(argv[2], NULL, 16);
if (handle >= BT_CTLR_ADV_MAX) {
@ -202,6 +201,7 @@ int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
} else if (!strcmp(argv[3], "txp")) {
evt_prop |= BIT(6);
} else if (!strcmp(argv[3], "ad")) {
ad = 1;
} else {
handle = strtoul(argv[3], NULL, 16);
if (handle >= BT_CTLR_ADV_MAX) {
@ -214,6 +214,7 @@ int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
if (!strcmp(argv[4], "txp")) {
evt_prop |= BIT(6);
} else if (!strcmp(argv[4], "ad")) {
ad = 1;
} else {
handle = strtoul(argv[4], NULL, 16);
if (handle >= BT_CTLR_ADV_MAX) {
@ -224,6 +225,7 @@ int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
if (argc > 5) {
if (!strcmp(argv[5], "ad")) {
ad = 1;
} else {
handle = strtoul(argv[5], NULL, 16);
if (handle >= BT_CTLR_ADV_MAX) {
@ -255,11 +257,14 @@ do_enable:
}
#if defined(CONFIG_BT_LL_SW_SPLIT)
shell_print(shell, "ad data set...");
err = ll_adv_aux_ad_data_set(handle, AD_OP, AD_FRAG_PREF, AD_LEN,
AD_DATA);
if (err) {
goto exit;
if (ad) {
shell_print(shell, "ad data set...");
err = ll_adv_aux_ad_data_set(handle, AD_OP, AD_FRAG_PREF,
ARRAY_SIZE(adv_data),
(void *)adv_data);
if (err) {
goto exit;
}
}
#endif
@ -282,6 +287,11 @@ exit:
#endif /* CONFIG_BT_BROADCASTER */
#if defined(CONFIG_BT_OBSERVER)
#define SCAN_INTERVAL 0x0004
#define SCAN_WINDOW 0x0004
#define SCAN_OWN_ADDR_TYPE 1
#define SCAN_FILTER_POLICY 0
int cmd_scanx(const struct shell *shell, size_t argc, char *argv[])
{
uint8_t type = 0U;