Skip to content

Commit

Permalink
Bluetooth: CAP: Shell: Add cancel command
Browse files Browse the repository at this point in the history
We didn't have a cancel command for the CAP commander, so adding this
command here.

Signed-off-by: Andries Kruithof <[email protected]>
  • Loading branch information
kruithofa authored and aescolar committed Apr 17, 2024
1 parent 7477636 commit d96f981
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/connectivity/bluetooth/api/shell/cap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ the optionally included CSIS instance by calling (:code:`cap_commander discover`
cap_commander - Bluetooth CAP commander shell commands
Subcommands:
discover :Discover CAS
cancel :CAP commander cancel current procedure
change_volume :Change volume on all connections <volume>
change_volume_mute :Change volume mute state on all connections <mute>
change_volume_offset :Change volume offset per connection <volume_offset
Expand Down
15 changes: 15 additions & 0 deletions subsys/bluetooth/audio/shell/cap_commander.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ static struct bt_cap_commander_cb cbs = {
#endif /* CONFIG_BT_MICP_MIC_CTLR */
};

static int cmd_cap_commander_cancel(const struct shell *sh, size_t argc, char *argv[])
{
int err;

err = bt_cap_commander_cancel();
if (err != 0) {
shell_print(sh, "Failed to cancel CAP commander procedure: %d", err);
return -ENOEXEC;
}

return 0;
}

static int cmd_cap_commander_discover(const struct shell *sh, size_t argc, char *argv[])
{
static bool cbs_registered;
Expand Down Expand Up @@ -472,6 +485,8 @@ static int cmd_cap_commander(const struct shell *sh, size_t argc, char **argv)
SHELL_STATIC_SUBCMD_SET_CREATE(
cap_commander_cmds,
SHELL_CMD_ARG(discover, NULL, "Discover CAS", cmd_cap_commander_discover, 1, 0),
SHELL_CMD_ARG(cancel, NULL, "CAP commander cancel current procedure",
cmd_cap_commander_cancel, 1, 0),
#if defined(CONFIG_BT_VCP_VOL_CTLR)
SHELL_CMD_ARG(change_volume, NULL, "Change volume on all connections <volume>",
cmd_cap_commander_change_volume, 2, 0),
Expand Down

0 comments on commit d96f981

Please sign in to comment.