-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bluetooth: CAP: Commander discovery support
Implement the CAP Commander discovery function. Adds support for it in the shell. This includes initial babblesim and unit testing as well. Signed-off-by: Emil Gydesen <[email protected]>
- Loading branch information
Showing
25 changed files
with
918 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* @file | ||
* @brief Shell APIs for Bluetooth CAP commander | ||
* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include <stdlib.h> | ||
|
||
#include <zephyr/types.h> | ||
#include <zephyr/shell/shell.h> | ||
#include <zephyr/bluetooth/conn.h> | ||
#include <zephyr/bluetooth/audio/cap.h> | ||
|
||
#include "shell/bt.h" | ||
#include "audio.h" | ||
|
||
static void cap_discover_cb(struct bt_conn *conn, int err, | ||
const struct bt_csip_set_coordinator_csis_inst *csis_inst) | ||
{ | ||
if (err != 0) { | ||
shell_error(ctx_shell, "discover failed (%d)", err); | ||
return; | ||
} | ||
|
||
shell_print(ctx_shell, "discovery completed%s", csis_inst == NULL ? "" : " with CSIS"); | ||
} | ||
|
||
static struct bt_cap_commander_cb cbs = { | ||
.discovery_complete = cap_discover_cb, | ||
}; | ||
|
||
static int cmd_cap_commander_discover(const struct shell *sh, size_t argc, char *argv[]) | ||
{ | ||
static bool cbs_registered; | ||
int err; | ||
|
||
if (default_conn == NULL) { | ||
shell_error(sh, "Not connected"); | ||
return -ENOEXEC; | ||
} | ||
|
||
if (ctx_shell == NULL) { | ||
ctx_shell = sh; | ||
} | ||
|
||
if (!cbs_registered) { | ||
bt_cap_commander_register_cb(&cbs); | ||
cbs_registered = true; | ||
} | ||
|
||
err = bt_cap_commander_discover(default_conn); | ||
if (err != 0) { | ||
shell_error(sh, "Fail: %d", err); | ||
} | ||
|
||
return err; | ||
} | ||
|
||
static int cmd_cap_commander(const struct shell *sh, size_t argc, char **argv) | ||
{ | ||
if (argc > 1) { | ||
shell_error(sh, "%s unknown parameter: %s", argv[0], argv[1]); | ||
} else { | ||
shell_error(sh, "%s Missing subcommand", argv[0]); | ||
} | ||
|
||
return -ENOEXEC; | ||
} | ||
|
||
SHELL_STATIC_SUBCMD_SET_CREATE( | ||
cap_commander_cmds, | ||
SHELL_CMD_ARG(discover, NULL, "Discover CAS", cmd_cap_commander_discover, 1, 0), | ||
SHELL_SUBCMD_SET_END | ||
); | ||
|
||
SHELL_CMD_ARG_REGISTER(cap_commander, &cap_commander_cmds, "Bluetooth CAP commander shell commands", | ||
cmd_cap_commander, 1, 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
project(bluetooth_ascs) | ||
find_package(Zephyr COMPONENTS unittest HINTS $ENV{ZEPHYR_BASE}) | ||
|
||
add_subdirectory(${ZEPHYR_BASE}/tests/bluetooth/audio/cap_commander/uut uut) | ||
|
||
target_link_libraries(testbinary PRIVATE uut) | ||
|
||
target_include_directories(testbinary PRIVATE include) | ||
|
||
target_sources(testbinary | ||
PRIVATE | ||
${ZEPHYR_BASE}/subsys/bluetooth/host/uuid.c | ||
src/main.c | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CONFIG_ZTEST=y | ||
|
||
CONFIG_BT=y | ||
CONFIG_BT_CENTRAL=y | ||
CONFIG_BT_AUDIO=y | ||
|
||
# Requirements for CAP commander | ||
CONFIG_BT_VCP_VOL_CTLR=y | ||
CONFIG_BT_CSIP_SET_COORDINATOR=y | ||
|
||
CONFIG_BT_CAP_COMMANDER=y | ||
|
||
CONFIG_LOG=y | ||
CONFIG_BT_CAP_COMMANDER_LOG_LEVEL_DBG=y | ||
|
||
CONFIG_ASSERT=y | ||
CONFIG_ASSERT_LEVEL=2 | ||
CONFIG_ASSERT_VERBOSE=y |
Oops, something went wrong.