Bluetooth: shell: Updates related to new ULL LLL architecture
Updates related to new ULL LLL controller architecture. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
749652080c
commit
5478e82993
6 changed files with 179 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
zephyr_library()
|
||||
zephyr_library_sources(
|
||||
bt.c
|
||||
hci.c
|
||||
)
|
||||
zephyr_library_sources_ifdef(
|
||||
CONFIG_BT_CONN
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "bt.h"
|
||||
#include "ll.h"
|
||||
#include "hci.h"
|
||||
|
||||
#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
|
||||
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
|
||||
|
@ -759,6 +760,7 @@ connect:
|
|||
#endif /* CONFIG_BT_PERIPHERAL */
|
||||
#endif /* CONFIG_BT_BROADCASTER */
|
||||
|
||||
#if defined(CONFIG_BT_CONN)
|
||||
#if defined(CONFIG_BT_CENTRAL)
|
||||
static int cmd_connect_le(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
|
@ -815,7 +817,6 @@ static int cmd_auto_conn(const struct shell *shell, size_t argc, char *argv[])
|
|||
}
|
||||
#endif /* CONFIG_BT_CENTRAL */
|
||||
|
||||
#if defined(CONFIG_BT_CONN)
|
||||
static int cmd_disconnect(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
@ -1391,6 +1392,9 @@ SHELL_CREATE_STATIC_SUBCMD_SET(bt_cmds) {
|
|||
#endif
|
||||
#endif /* CONFIG_BT_SMP || CONFIG_BT_BREDR) */
|
||||
#endif /* CONFIG_BT_CONN */
|
||||
#if defined(CONFIG_BT_HCI_MESH_EXT)
|
||||
SHELL_CMD(mesh_adv, NULL, "<on, off>", cmd_mesh_adv),
|
||||
#endif /* CONFIG_BT_HCI_MESH_EXT */
|
||||
#if defined(CONFIG_BT_CTLR_ADV_EXT)
|
||||
#if defined(CONFIG_BT_BROADCASTER)
|
||||
SHELL_CMD_ARG(advx, NULL, "<on off> [coded] [anon] [txp]", cmd_advx,
|
||||
|
@ -1411,6 +1415,14 @@ SHELL_CREATE_STATIC_SUBCMD_SET(bt_cmds) {
|
|||
4, 0),
|
||||
SHELL_CMD_ARG(test_end, NULL, HELP_NONE, cmd_test_end, 1, 0),
|
||||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
|
||||
#if defined(CONFIG_BT_LL_SW_SPLIT)
|
||||
SHELL_CMD(ull_reset, NULL, HELP_NONE, cmd_ull_reset),
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
SHELL_CMD(ull_tmp_enable, NULL, "<on off> [handle]",
|
||||
cmd_ull_tmp_enable),
|
||||
SHELL_CMD(ull_tmp_send, NULL, "[handle]", cmd_ull_tmp_send),
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
#endif /* CONFIG_BT_LL_SW_SPLIT */
|
||||
SHELL_SUBCMD_SET_END
|
||||
};
|
||||
|
||||
|
|
80
subsys/bluetooth/shell/hci.c
Normal file
80
subsys/bluetooth/shell/hci.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2017-2018 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <zephyr.h>
|
||||
#include <shell/shell.h>
|
||||
#include <misc/printk.h>
|
||||
#include <misc/byteorder.h>
|
||||
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_vs.h>
|
||||
#include <bluetooth/conn.h>
|
||||
|
||||
#include "../host/hci_core.h"
|
||||
|
||||
#if defined(CONFIG_BT_HCI_MESH_EXT)
|
||||
int cmd_mesh_adv(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
if (argc < 2) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "on")) {
|
||||
struct bt_hci_cp_mesh_advertise *cp;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_VS_MESH,
|
||||
sizeof(struct bt_hci_cp_mesh) +
|
||||
sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
net_buf_add_u8(buf, BT_HCI_OC_MESH_ADVERTISE);
|
||||
|
||||
/* TODO: fetch and fill cmdline params */
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
cp->adv_slot = 0;
|
||||
cp->own_addr_type = 0x01;
|
||||
memset(&cp->random_addr, 0, sizeof(bt_addr_t));
|
||||
cp->ch_map = 0x07;
|
||||
cp->tx_power = 0;
|
||||
cp->min_tx_delay = 0;
|
||||
cp->max_tx_delay = 0x32;
|
||||
cp->retx_count = 0x07;
|
||||
cp->retx_interval = 0x00;
|
||||
cp->scan_delay = 0x0a;
|
||||
cp->scan_duration = sys_cpu_to_le16(0x0064);
|
||||
cp->scan_filter = 0x00;
|
||||
cp->data_len = 0;
|
||||
memset(cp->data, 0, sizeof(cp->data));
|
||||
} else if (!strcmp(argv[1], "off")) {
|
||||
struct bt_hci_cp_mesh_advertise_cancel *cp;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_VS_MESH,
|
||||
sizeof(struct bt_hci_cp_mesh) +
|
||||
sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
net_buf_add_u8(buf, BT_HCI_OC_MESH_ADVERTISE_CANCEL);
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
cp->adv_slot = 0;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_MESH, buf, NULL);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BT_HCI_MESH_EXT */
|
7
subsys/bluetooth/shell/hci.h
Normal file
7
subsys/bluetooth/shell/hci.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
int cmd_mesh_adv(const struct shell *shell, size_t argc, char *argv[]);
|
|
@ -47,7 +47,7 @@ int cmd_ll_addr_get(const struct shell *shell, size_t argc, char *argv[])
|
|||
(void)ll_addr_get(addr_type, addr.val);
|
||||
bt_addr_to_str(&addr, str_addr, sizeof(str_addr));
|
||||
|
||||
shell_print(shell, "Current %s address: %s\n", str_type, str_addr);
|
||||
shell_print(shell, "Current %s address: %s", str_type, str_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ int cmd_test_end(const struct shell *shell, size_t argc, char *argv[])
|
|||
int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
u16_t adv_interval = 0x20;
|
||||
u16_t handle = 0;
|
||||
u16_t handle = 0U;
|
||||
u16_t evt_prop;
|
||||
u8_t adv_type;
|
||||
u8_t enable;
|
||||
|
@ -164,7 +164,6 @@ int cmd_advx(const struct shell *shell, size_t argc, char *argv[])
|
|||
adv_type = 0x05; /* Adv. Ext. */
|
||||
enable = 1U;
|
||||
} else if (!strcmp(argv[1], "hdcd")) {
|
||||
handle = 0U;
|
||||
evt_prop = 0U;
|
||||
adv_type = 0x01; /* Directed */
|
||||
adv_interval = 0U; /* High Duty Cycle */
|
||||
|
@ -258,6 +257,15 @@ do_enable:
|
|||
goto exit;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
#endif
|
||||
|
||||
disable:
|
||||
shell_print(shell, "adv enable (%u)...", enable);
|
||||
#if defined(CONFIG_BT_HCI_MESH_EXT)
|
||||
|
@ -334,3 +342,67 @@ exit:
|
|||
}
|
||||
#endif /* CONFIG_BT_OBSERVER */
|
||||
#endif /* CONFIG_BT_CTLR_ADV_EXT */
|
||||
|
||||
#if defined(CONFIG_BT_LL_SW_SPLIT)
|
||||
int cmd_ull_reset(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
ll_reset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_TMP)
|
||||
#include "../controller/ll_sw/ull_tmp.h"
|
||||
|
||||
int cmd_ull_tmp_enable(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
u16_t handle = 0;
|
||||
int enable;
|
||||
int err;
|
||||
|
||||
if (argc < 2) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
if (!strcmp(argv[1], "on")) {
|
||||
enable = 1;
|
||||
} else if (!strcmp(argv[1], "off")) {
|
||||
enable = 0;
|
||||
} else {
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
handle = strtoul(argv[2], NULL, 16);
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
err = ull_tmp_enable(handle);
|
||||
} else {
|
||||
err = ull_tmp_disable(handle);
|
||||
}
|
||||
|
||||
shell_print(shell, "Done (%d).", err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int cmd_ull_tmp_send(const struct shell *shell, size_t argc, char *argv[])
|
||||
{
|
||||
u16_t handle = 0;
|
||||
int err;
|
||||
|
||||
if (argc > 1) {
|
||||
handle = strtoul(argv[1], NULL, 16);
|
||||
}
|
||||
|
||||
err = ull_tmp_data_send(handle, 0, NULL);
|
||||
|
||||
shell_print(shell, "Done (%d).", err);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BT_TMP */
|
||||
#endif /* CONFIG_BT_LL_SW_SPLIT */
|
||||
|
|
|
@ -22,4 +22,7 @@ int cmd_test_tx(const struct shell *shell, size_t argc, char *argv[]);
|
|||
int cmd_test_rx(const struct shell *shell, size_t argc, char *argv[]);
|
||||
int cmd_test_end(const struct shell *shell, size_t argc, char *argv[]);
|
||||
|
||||
int cmd_ull_reset(const struct shell *shell, size_t argc, char *argv[]);
|
||||
int cmd_ull_tmp_enable(const struct shell *shell, size_t argc, char *argv[]);
|
||||
int cmd_ull_tmp_send(const struct shell *shell, size_t argc, char *argv[]);
|
||||
#endif /* __LL_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue