Bluetooth: shell: Add phy handling to the shell
Add phy update callback and command to the shell. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
322f70243e
commit
21a42f3b67
2 changed files with 44 additions and 0 deletions
|
@ -359,6 +359,15 @@ void le_data_len_updated(struct bt_conn *conn,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_BT_USER_PHY_UPDATE)
|
||||||
|
void le_phy_updated(struct bt_conn *conn,
|
||||||
|
struct bt_conn_le_phy_info *info)
|
||||||
|
{
|
||||||
|
shell_print(ctx_shell, "LE PHY updated: TX PHY %s, RX PHY %s",
|
||||||
|
phy2str(info->tx_phy), phy2str(info->rx_phy));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct bt_conn_cb conn_callbacks = {
|
static struct bt_conn_cb conn_callbacks = {
|
||||||
.connected = connected,
|
.connected = connected,
|
||||||
.disconnected = disconnected,
|
.disconnected = disconnected,
|
||||||
|
@ -376,6 +385,9 @@ static struct bt_conn_cb conn_callbacks = {
|
||||||
#if defined(CONFIG_BT_USER_DATA_LEN_UPDATE)
|
#if defined(CONFIG_BT_USER_DATA_LEN_UPDATE)
|
||||||
.le_data_len_updated = le_data_len_updated,
|
.le_data_len_updated = le_data_len_updated,
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(CONFIG_BT_USER_PHY_UPDATE)
|
||||||
|
.le_phy_updated = le_phy_updated,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_BT_CONN */
|
#endif /* CONFIG_BT_CONN */
|
||||||
|
|
||||||
|
@ -1548,6 +1560,31 @@ static int cmd_conn_data_len_update(const struct shell *shell, size_t argc,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_BT_USER_PHY_UPDATE)
|
||||||
|
static int cmd_conn_phy_update(const struct shell *shell, size_t argc,
|
||||||
|
char *argv[])
|
||||||
|
{
|
||||||
|
struct bt_conn_le_phy_param param;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
param.pref_tx_phy = strtoul(argv[1], NULL, 16);
|
||||||
|
if (argc > 2) {
|
||||||
|
param.pref_rx_phy = strtoul(argv[2], NULL, 16);
|
||||||
|
} else {
|
||||||
|
param.pref_rx_phy = param.pref_tx_phy;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bt_conn_le_phy_update(default_conn, ¶m);
|
||||||
|
if (err) {
|
||||||
|
shell_error(shell, "PHY update failed (err %d).", err);
|
||||||
|
} else {
|
||||||
|
shell_print(shell, "PHY update initiated.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_BT_CENTRAL)
|
#if defined(CONFIG_BT_CENTRAL)
|
||||||
static int cmd_chan_map(const struct shell *shell, size_t argc, char *argv[])
|
static int cmd_chan_map(const struct shell *shell, size_t argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -2393,6 +2430,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
|
||||||
SHELL_CMD_ARG(data-len-update, NULL, "<tx_max_len> [tx_max_time]",
|
SHELL_CMD_ARG(data-len-update, NULL, "<tx_max_len> [tx_max_time]",
|
||||||
cmd_conn_data_len_update, 2, 1),
|
cmd_conn_data_len_update, 2, 1),
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(CONFIG_BT_USER_PHY_UPDATE)
|
||||||
|
SHELL_CMD_ARG(phy-update, NULL, "<tx_phy> [rx_phy]",
|
||||||
|
cmd_conn_phy_update, 2, 1),
|
||||||
|
#endif
|
||||||
#if defined(CONFIG_BT_CENTRAL)
|
#if defined(CONFIG_BT_CENTRAL)
|
||||||
SHELL_CMD_ARG(channel-map, NULL, "<channel-map: XXXXXXXXXX> (36-0)",
|
SHELL_CMD_ARG(channel-map, NULL, "<channel-map: XXXXXXXXXX> (36-0)",
|
||||||
cmd_chan_map, 2, 1),
|
cmd_chan_map, 2, 1),
|
||||||
|
|
|
@ -36,3 +36,6 @@ CONFIG_SETTINGS=y
|
||||||
|
|
||||||
CONFIG_BT_USER_DATA_LEN_UPDATE=y
|
CONFIG_BT_USER_DATA_LEN_UPDATE=y
|
||||||
CONFIG_BT_AUTO_DATA_LEN_UPDATE=y
|
CONFIG_BT_AUTO_DATA_LEN_UPDATE=y
|
||||||
|
|
||||||
|
CONFIG_BT_USER_PHY_UPDATE=y
|
||||||
|
CONFIG_BT_AUTO_PHY_UPDATE=y
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue