Skip to content
Permalink
Browse files

Bluetooth: shell: Fix directed adv parameter check

Fix the mandatory and optional parameter counts for the
directed adv shell command definition. Also, refactor the
command for consistency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information...
cvinayak authored and carlescufi committed Aug 8, 2019
1 parent b611589 commit 857bcd96bdd3fe2ac04e4e7106d9c5548b8ec38b
Showing with 8 additions and 12 deletions.
  1. +8 −12 subsys/bluetooth/shell/bt.c
@@ -634,19 +634,15 @@ static int cmd_directed_adv(const struct shell *shell,
return err;
}

if (argc == 3) {
goto connect;
}

if (strcmp(argv[3], "low")) {
shell_help(shell);
/* shell returns 1 when help is printed */
return 1;
if (argc > 3) {
if (!strcmp(argv[3], "low")) {
param = BT_LE_ADV_CONN_DIR_LOW_DUTY;
} else {
shell_help(shell);
return -ENOEXEC;
}
}

param = BT_LE_ADV_CONN_DIR_LOW_DUTY;

connect:
conn = bt_conn_create_slave_le(&addr, param);
if (!conn) {
shell_error(shell, "Failed to start directed advertising");
@@ -1341,7 +1337,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(bt_cmds,
cmd_advertise, 2, 1),
#if defined(CONFIG_BT_PERIPHERAL)
SHELL_CMD_ARG(directed-adv, NULL, HELP_ADDR_LE " [mode: low]",
cmd_directed_adv, 1, 1),
cmd_directed_adv, 3, 1),
#endif /* CONFIG_BT_PERIPHERAL */
#endif /* CONFIG_BT_BROADCASTER */
#if defined(CONFIG_BT_CONN)

0 comments on commit 857bcd9

Please sign in to comment.
You can’t perform that action at this time.