Bluetooth: BAP: Remove dir from BAP discovery parameters

The direction has been moved to a function parameter instead,
and we keep a local copy of the value in the stack instead.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2023-03-23 14:37:07 +01:00 committed by Carles Cufí
commit ffca5f9b2f
7 changed files with 132 additions and 85 deletions

View file

@ -1222,14 +1222,15 @@ struct bt_bap_unicast_client_cb {
* @param conn Connection to the remote unicast server.
* @param err Error value. 0 on success, GATT error on positive value or errno on
* negative value.
* @param dir The type of remote endpoints and capabilities discovered.
* @param codec Remote capabilities.
* @param ep Remote endpoint.
* @param params Pointer to the discover parameters.
*
* If discovery procedure has complete both @p codec and @p ep are set to NULL.
*/
void (*discover)(struct bt_conn *conn, int err, struct bt_codec *codec,
struct bt_bap_ep *ep,
void (*discover)(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params);
};
@ -1246,9 +1247,6 @@ struct bt_bap_unicast_client_cb {
int bt_bap_unicast_client_register_cb(const struct bt_bap_unicast_client_cb *cb);
struct bt_bap_unicast_client_discover_params {
/** Capabilities type */
enum bt_audio_dir dir;
/** Read parameters used interally for discovery */
struct bt_gatt_read_params read;
@ -1266,9 +1264,10 @@ struct bt_bap_unicast_client_discover_params {
* remains valid while it is active.
*
* @param conn Connection object
* @param dir The type of remote endpoints and capabilities to discover.
* @param params Discover parameters
*/
int bt_bap_unicast_client_discover(struct bt_conn *conn,
int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir,
struct bt_bap_unicast_client_discover_params *params);
/** @} */ /* End of group bt_bap_unicast_client */

View file

@ -583,8 +583,8 @@ static void print_remote_codec(struct bt_codec *codec_capabilities, enum bt_audi
print_codec_capabilities(codec_capabilities);
}
static void discover_sinks_cb(struct bt_conn *conn, int err, struct bt_codec *codec,
struct bt_bap_ep *ep,
static void discover_sinks_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
if (err != 0 && err != BT_ATT_ERR_ATTRIBUTE_NOT_FOUND) {
@ -593,7 +593,7 @@ static void discover_sinks_cb(struct bt_conn *conn, int err, struct bt_codec *co
}
if (codec != NULL) {
print_remote_codec(codec, params->dir);
print_remote_codec(codec, dir);
return;
}
@ -614,8 +614,8 @@ static void discover_sinks_cb(struct bt_conn *conn, int err, struct bt_codec *co
k_sem_give(&sem_sinks_discovered);
}
static void discover_sources_cb(struct bt_conn *conn, int err, struct bt_codec *codec,
struct bt_bap_ep *ep,
static void discover_sources_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
if (err != 0 && err != BT_ATT_ERR_ATTRIBUTE_NOT_FOUND) {
@ -624,7 +624,7 @@ static void discover_sources_cb(struct bt_conn *conn, int err, struct bt_codec *
}
if (codec != NULL) {
print_remote_codec(codec, params->dir);
print_remote_codec(codec, dir);
return;
}
@ -796,9 +796,8 @@ static int discover_sinks(void)
int err;
unicast_client_cbs.discover = discover_sinks_cb;
params.dir = BT_AUDIO_DIR_SINK;
err = bt_bap_unicast_client_discover(default_conn, &params);
err = bt_bap_unicast_client_discover(default_conn, BT_AUDIO_DIR_SINK, &params);
if (err != 0) {
printk("Failed to discover sinks: %d\n", err);
return err;
@ -819,9 +818,8 @@ static int discover_sources(void)
int err;
unicast_client_cbs.discover = discover_sources_cb;
params.dir = BT_AUDIO_DIR_SOURCE;
err = bt_bap_unicast_client_discover(default_conn, &params);
err = bt_bap_unicast_client_discover(default_conn, BT_AUDIO_DIR_SOURCE, &params);
if (err != 0) {
printk("Failed to discover sources: %d\n", err);
return err;

View file

@ -86,6 +86,10 @@ static struct unicast_client {
struct bt_gatt_discover_params loc_cc_disc;
struct bt_gatt_discover_params avail_ctx_cc_disc;
/* Discovery parameters */
enum bt_audio_dir dir;
bool busy;
/* The read_buf needs to use the maximum ATT attribute size as a single
* PAC record may use the full size
*/
@ -1447,8 +1451,17 @@ static int unicast_client_ep_subscribe(struct bt_conn *conn, struct bt_bap_ep *e
static void discover_cb(struct bt_conn *conn, int err, struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
struct unicast_client *client = &uni_cli_insts[bt_conn_index(conn)];
const enum bt_audio_dir dir = client->dir;
if (err != 0 || (codec == NULL && ep == NULL)) {
/* Discover complete - Reset discovery values */
client->dir = 0U;
client->busy = false;
}
if (unicast_client_cbs != NULL && unicast_client_cbs->discover != NULL) {
unicast_client_cbs->discover(conn, err, codec, ep, params);
unicast_client_cbs->discover(conn, err, dir, codec, ep, params);
}
}
@ -2905,7 +2918,7 @@ static uint8_t unicast_client_ase_read_func(struct bt_conn *conn, uint8_t err,
goto fail;
}
ep = unicast_client_ep_get(conn, params->dir, handle);
ep = unicast_client_ep_get(conn, client->dir, handle);
if (!ep) {
/* The BAP spec declares that the unicast client shall subscribe to all ASEs.
* In case that we cannot support this due to memory restrictions, we should
@ -2941,6 +2954,7 @@ static uint8_t unicast_client_ase_discover_cb(struct bt_conn *conn,
struct bt_gatt_discover_params *discover)
{
struct bt_bap_unicast_client_discover_params *params;
struct unicast_client *client;
struct bt_gatt_chrc *chrc;
int err;
@ -2959,12 +2973,13 @@ static uint8_t unicast_client_ase_discover_cb(struct bt_conn *conn,
}
chrc = attr->user_data;
client = &uni_cli_insts[bt_conn_index(conn)];
LOG_DBG("conn %p attr %p handle 0x%04x dir %s",
conn, attr, chrc->value_handle, bt_audio_dir_str(params->dir));
LOG_DBG("conn %p attr %p handle 0x%04x dir %s", conn, attr, chrc->value_handle,
bt_audio_dir_str(client->dir));
/* Reset to use for long read */
reset_read_buf(&uni_cli_insts[bt_conn_index(conn)]);
reset_read_buf(client);
params->read.func = unicast_client_ase_read_func;
params->read.handle_count = 1U;
@ -2985,11 +3000,15 @@ static int unicast_client_ase_discover(struct bt_conn *conn,
struct bt_bap_unicast_client_discover_params *params,
uint16_t start_handle)
{
struct unicast_client *client;
LOG_DBG("conn %p params %p", conn, params);
if (params->dir == BT_AUDIO_DIR_SINK) {
client = &uni_cli_insts[bt_conn_index(conn)];
if (client->dir == BT_AUDIO_DIR_SINK) {
params->discover.uuid = ase_snk_uuid;
} else if (params->dir == BT_AUDIO_DIR_SOURCE) {
} else if (client->dir == BT_AUDIO_DIR_SOURCE) {
params->discover.uuid = ase_src_uuid;
} else {
return -EINVAL;
@ -3187,17 +3206,19 @@ static uint8_t unicast_client_pacs_location_read_func(struct bt_conn *conn, uint
const void *data, uint16_t length)
{
struct bt_bap_unicast_client_discover_params *params;
struct unicast_client *client;
struct net_buf_simple buf;
uint32_t location;
int cb_err;
params = CONTAINER_OF(read, struct bt_bap_unicast_client_discover_params, read);
client = &uni_cli_insts[bt_conn_index(conn)];
LOG_DBG("conn %p err 0x%02x len %u", conn, err, length);
if (err || data == NULL || length != sizeof(location)) {
LOG_DBG("Unable to read PACS location for dir %s: %u, %p, %u",
bt_audio_dir_str(params->dir), err, data, length);
bt_audio_dir_str(client->dir), err, data, length);
if (err == BT_ATT_ERR_SUCCESS) {
err = BT_ATT_ERR_INVALID_ATTRIBUTE_LEN;
@ -3211,10 +3232,10 @@ static uint8_t unicast_client_pacs_location_read_func(struct bt_conn *conn, uint
net_buf_simple_init_with_data(&buf, (void *)data, length);
location = net_buf_simple_pull_le32(&buf);
LOG_DBG("dir %s loc %X", bt_audio_dir_str(params->dir), location);
LOG_DBG("dir %s loc %X", bt_audio_dir_str(client->dir), location);
if (unicast_client_cbs != NULL && unicast_client_cbs->location != NULL) {
unicast_client_cbs->location(conn, params->dir, (enum bt_audio_location)location);
unicast_client_cbs->location(conn, client->dir, (enum bt_audio_location)location);
}
/* Read available contexts */
@ -3322,9 +3343,10 @@ static uint8_t unicast_client_pacs_location_discover_cb(struct bt_conn *conn,
LOG_DBG("conn %p attr %p handle 0x%04x", conn, attr, chrc->value_handle);
if (chrc->properties & BT_GATT_CHRC_NOTIFY) {
const struct unicast_client *client = &uni_cli_insts[index];
struct bt_gatt_subscribe_params *sub_params;
if (params->dir == BT_AUDIO_DIR_SINK) {
if (client->dir == BT_AUDIO_DIR_SINK) {
sub_params = &uni_cli_insts[index].snk_loc_subscribe;
} else {
sub_params = &uni_cli_insts[index].src_loc_subscribe;
@ -3357,11 +3379,13 @@ static int
unicast_client_pacs_location_discover(struct bt_conn *conn,
struct bt_bap_unicast_client_discover_params *params)
{
LOG_DBG("conn %p params %p", conn, params);
const struct unicast_client *client = &uni_cli_insts[bt_conn_index(conn)];
if (params->dir == BT_AUDIO_DIR_SINK) {
LOG_DBG("conn %p params %p dir %s", conn, params, bt_audio_dir_str(client->dir));
if (client->dir == BT_AUDIO_DIR_SINK) {
params->discover.uuid = pacs_snk_loc_uuid;
} else if (params->dir == BT_AUDIO_DIR_SOURCE) {
} else if (client->dir == BT_AUDIO_DIR_SOURCE) {
params->discover.uuid = pacs_src_loc_uuid;
} else {
return -EINVAL;
@ -3414,6 +3438,7 @@ static uint8_t unicast_client_pacs_context_discover_cb(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
struct bt_gatt_discover_params *discover)
{
const struct unicast_client *client = &uni_cli_insts[bt_conn_index(conn)];
struct bt_bap_unicast_client_discover_params *params;
struct bt_gatt_chrc *chrc;
int err;
@ -3422,8 +3447,7 @@ static uint8_t unicast_client_pacs_context_discover_cb(struct bt_conn *conn,
discover);
if (attr == NULL) {
LOG_ERR("Unable to find %s PAC context",
bt_audio_dir_str(params->dir));
LOG_ERR("Unable to find %s PAC context", bt_audio_dir_str(client->dir));
discover_cb(conn, BT_ATT_ERR_ATTRIBUTE_NOT_FOUND, NULL, NULL, params);
@ -3432,8 +3456,8 @@ static uint8_t unicast_client_pacs_context_discover_cb(struct bt_conn *conn,
chrc = attr->user_data;
LOG_DBG("conn %p attr %p handle 0x%04x dir %s",
conn, attr, chrc->value_handle, bt_audio_dir_str(params->dir));
LOG_DBG("conn %p attr %p handle 0x%04x dir %s", conn, attr, chrc->value_handle,
bt_audio_dir_str(client->dir));
/* TODO: Subscribe to PAC context */
@ -3528,7 +3552,7 @@ static uint8_t unicast_client_read_func(struct bt_conn *conn, uint8_t err,
void *cc_ltv, *meta_ltv;
struct bt_codec codec;
LOG_DBG("pac #%u", i);
LOG_DBG("pac #%u/%u", i + 1, rsp->num_pac);
if (buf->len < sizeof(*pac_codec)) {
LOG_ERR("Malformed PAC: remaining len %u expected %zu",
@ -3610,6 +3634,7 @@ static uint8_t unicast_client_pac_discover_cb(struct bt_conn *conn,
const struct bt_gatt_attr *attr,
struct bt_gatt_discover_params *discover)
{
const struct unicast_client *client = &uni_cli_insts[bt_conn_index(conn)];
struct bt_bap_unicast_client_discover_params *params;
struct bt_gatt_chrc *chrc;
int err;
@ -3617,7 +3642,7 @@ static uint8_t unicast_client_pac_discover_cb(struct bt_conn *conn,
params = CONTAINER_OF(discover, struct bt_bap_unicast_client_discover_params, discover);
if (attr == NULL) {
LOG_ERR("Unable to find %s PAC", bt_audio_dir_str(params->dir));
LOG_ERR("Unable to find %s PAC", bt_audio_dir_str(client->dir));
discover_cb(conn, BT_ATT_ERR_ATTRIBUTE_NOT_FOUND, NULL, NULL, params);
@ -3626,8 +3651,8 @@ static uint8_t unicast_client_pac_discover_cb(struct bt_conn *conn,
chrc = attr->user_data;
LOG_DBG("conn %p attr %p handle 0x%04x dir %s",
conn, attr, chrc->value_handle, bt_audio_dir_str(params->dir));
LOG_DBG("conn %p attr %p handle 0x%04x dir %s", conn, attr, chrc->value_handle,
bt_audio_dir_str(client->dir));
/* TODO: Subscribe to PAC */
@ -3660,11 +3685,13 @@ static struct bt_conn_cb conn_cbs = {
.disconnected = unicast_client_disconnected,
};
int bt_bap_unicast_client_discover(struct bt_conn *conn,
int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir,
struct bt_bap_unicast_client_discover_params *params)
{
struct unicast_client *client;
static bool conn_cb_registered;
uint8_t role;
int err;
if (!conn || conn->state != BT_CONN_CONNECTED) {
return -ENOTCONN;
@ -3676,9 +3703,15 @@ int bt_bap_unicast_client_discover(struct bt_conn *conn,
return -EINVAL;
}
if (params->dir == BT_AUDIO_DIR_SINK) {
client = &uni_cli_insts[bt_conn_index(conn)];
if (client->busy) {
LOG_DBG("Client connection is busy");
return -EBUSY;
}
if (dir == BT_AUDIO_DIR_SINK) {
params->discover.uuid = snk_uuid;
} else if (params->dir == BT_AUDIO_DIR_SOURCE) {
} else if (dir == BT_AUDIO_DIR_SOURCE) {
params->discover.uuid = src_uuid;
} else {
return -EINVAL;
@ -3694,7 +3727,15 @@ int bt_bap_unicast_client_discover(struct bt_conn *conn,
conn_cb_registered = true;
}
return bt_gatt_discover(conn, &params->discover);
err = bt_gatt_discover(conn, &params->discover);
if (err != 0) {
return err;
}
client->dir = dir;
client->busy = true;
return 0;
}
int bt_bap_unicast_client_register_cb(const struct bt_bap_unicast_client_cb *cbs)

View file

@ -747,23 +747,24 @@ static void add_source(const struct bt_conn *conn, struct bt_bap_ep *ep)
}
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0 */
static void discover_cb(struct bt_conn *conn, int err, struct bt_codec *codec, struct bt_bap_ep *ep,
static void discover_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
if (codec != NULL) {
print_remote_codec(conn, codec, params->dir);
print_remote_codec(conn, codec, dir);
return;
}
if (ep) {
#if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0
if (params->dir == BT_AUDIO_DIR_SINK) {
if (dir == BT_AUDIO_DIR_SINK) {
add_sink(conn, ep);
}
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
#if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0
if (params->dir == BT_AUDIO_DIR_SOURCE) {
if (dir == BT_AUDIO_DIR_SOURCE) {
add_source(conn, ep);
}
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0*/
@ -776,23 +777,24 @@ static void discover_cb(struct bt_conn *conn, int err, struct bt_codec *codec, s
memset(params, 0, sizeof(*params));
}
static void discover_all(struct bt_conn *conn, int err, struct bt_codec *codec,
struct bt_bap_ep *ep, struct bt_bap_unicast_client_discover_params *params)
static void discover_all(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
if (codec != NULL) {
print_remote_codec(conn, codec, params->dir);
print_remote_codec(conn, codec, dir);
return;
}
if (ep) {
#if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0
if (params->dir == BT_AUDIO_DIR_SINK) {
if (dir == BT_AUDIO_DIR_SINK) {
add_sink(conn, ep);
}
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT > 0 */
#if CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0
if (params->dir == BT_AUDIO_DIR_SOURCE) {
if (dir == BT_AUDIO_DIR_SOURCE) {
add_source(conn, ep);
}
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT > 0*/
@ -801,14 +803,14 @@ static void discover_all(struct bt_conn *conn, int err, struct bt_codec *codec,
}
/* Sinks discovery complete, now discover sources */
if (params->dir == BT_AUDIO_DIR_SINK) {
if (dir == BT_AUDIO_DIR_SINK) {
dir = BT_AUDIO_DIR_SOURCE;
unicast_client_cbs.discover = discover_cb;
params->dir = BT_AUDIO_DIR_SOURCE;
err = bt_bap_unicast_client_discover(default_conn, params);
err = bt_bap_unicast_client_discover(default_conn, dir, params);
if (err) {
shell_error(ctx_shell, "bt_bap_unicast_client_discover err %d", err);
discover_cb(conn, err, NULL, NULL, params);
discover_cb(conn, err, dir, NULL, NULL, params);
}
}
}
@ -900,6 +902,7 @@ static int cmd_discover(const struct shell *sh, size_t argc, char *argv[])
{
static struct bt_bap_unicast_client_discover_params params;
static bool cbs_registered;
enum bt_audio_dir dir;
uint8_t conn_index;
int err;
@ -925,21 +928,21 @@ static int cmd_discover(const struct shell *sh, size_t argc, char *argv[])
}
unicast_client_cbs.discover = discover_all;
params.dir = BT_AUDIO_DIR_SINK;
dir = BT_AUDIO_DIR_SINK;
if (argc > 1) {
if (!strcmp(argv[1], "sink")) {
unicast_client_cbs.discover = discover_cb;
} else if (!strcmp(argv[1], "source")) {
unicast_client_cbs.discover = discover_cb;
params.dir = BT_AUDIO_DIR_SOURCE;
dir = BT_AUDIO_DIR_SOURCE;
} else {
shell_error(sh, "Unsupported dir: %s", argv[1]);
return -ENOEXEC;
}
}
err = bt_bap_unicast_client_discover(default_conn, &params);
err = bt_bap_unicast_client_discover(default_conn, dir, &params);
if (err != 0) {
return -ENOEXEC;
}

View file

@ -21,6 +21,10 @@ CONFIG_BT_AUDIO=y
CONFIG_BT_BAP_UNICAST_SERVER=y
CONFIG_BT_BAP_UNICAST_CLIENT=y
CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT=2
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT=2
CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT=2
CONFIG_BT_ASCS_ASE_SNK_COUNT=2
CONFIG_BT_ASCS_ASE_SRC_COUNT=2
CONFIG_BT_BAP_BROADCAST_SOURCE=y
CONFIG_BT_BAP_BROADCAST_SINK=y
CONFIG_BT_CODEC_MAX_DATA_LEN=128

View file

@ -208,14 +208,20 @@ static void add_remote_sink(struct bt_bap_ep *ep)
}
}
FAIL("Could not add source ep\n");
FAIL("Could not add sink ep\n");
}
static void add_remote_source(struct bt_bap_ep *ep, uint8_t index)
static void add_remote_source(struct bt_bap_ep *ep)
{
printk("Source #%u: ep %p\n", index, ep);
for (size_t i = 0U; i < ARRAY_SIZE(g_sources); i++) {
if (g_sources[i] == NULL) {
printk("Source #%u: ep %p\n", i, ep);
g_sources[i] = ep;
return;
}
}
g_sources[index] = ep;
FAIL("Could not add source ep\n");
}
static void print_remote_codec(struct bt_codec *codec, enum bt_audio_dir dir)
@ -225,8 +231,8 @@ static void print_remote_codec(struct bt_codec *codec, enum bt_audio_dir dir)
print_codec(codec);
}
static void discover_sinks_cb(struct bt_conn *conn, int err, struct bt_codec *codec,
struct bt_bap_ep *ep,
static void discover_sinks_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
static bool codec_found;
@ -238,17 +244,17 @@ static void discover_sinks_cb(struct bt_conn *conn, int err, struct bt_codec *co
}
if (codec != NULL) {
print_remote_codec(codec, params->dir);
print_remote_codec(codec, dir);
codec_found = true;
return;
}
if (ep != NULL) {
if (params->dir == BT_AUDIO_DIR_SINK) {
if (dir == BT_AUDIO_DIR_SINK) {
add_remote_sink(ep);
endpoint_found = true;
} else {
FAIL("Invalid param dir: %u\n", params->dir);
FAIL("Invalid param dir: %u\n", dir);
}
return;
@ -265,8 +271,8 @@ static void discover_sinks_cb(struct bt_conn *conn, int err, struct bt_codec *co
}
}
static void discover_sources_cb(struct bt_conn *conn, int err, struct bt_codec *codec,
struct bt_bap_ep *ep,
static void discover_sources_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
static bool codec_found;
@ -278,17 +284,17 @@ static void discover_sources_cb(struct bt_conn *conn, int err, struct bt_codec *
}
if (codec != NULL) {
print_remote_codec(codec, params->dir);
print_remote_codec(codec, dir);
codec_found = true;
return;
}
if (ep != NULL) {
if (params->dir == BT_AUDIO_DIR_SOURCE) {
add_remote_source(ep, params->num_eps);
if (dir == BT_AUDIO_DIR_SOURCE) {
add_remote_source(ep);
endpoint_found = true;
} else {
FAIL("Invalid param dir: %u\n", params->dir);
FAIL("Invalid param dir: %u\n", dir);
}
return;
@ -377,11 +383,10 @@ static void discover_sinks(void)
unicast_client_cbs.discover = discover_sinks_cb;
params.dir = BT_AUDIO_DIR_SINK;
UNSET_FLAG(flag_sink_discovered);
err = bt_bap_unicast_client_discover(default_conn, &params);
err = bt_bap_unicast_client_discover(default_conn, BT_AUDIO_DIR_SINK, &params);
if (err != 0) {
printk("Failed to discover sink: %d\n", err);
return;
@ -398,11 +403,10 @@ static void discover_sources(void)
int err;
unicast_client_cbs.discover = discover_sources_cb;
params.dir = BT_AUDIO_DIR_SOURCE;
UNSET_FLAG(flag_source_discovered);
err = bt_bap_unicast_client_discover(default_conn, &params);
err = bt_bap_unicast_client_discover(default_conn, BT_AUDIO_DIR_SOURCE, &params);
if (err != 0) {
printk("Failed to discover sink: %d\n", err);
return;

View file

@ -262,8 +262,8 @@ static void print_remote_codec(struct bt_codec *codec, enum bt_audio_dir dir)
print_codec(codec);
}
static void discover_sink_cb(struct bt_conn *conn, int err, struct bt_codec *codec,
struct bt_bap_ep *ep,
static void discover_sink_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir,
struct bt_codec *codec, struct bt_bap_ep *ep,
struct bt_bap_unicast_client_discover_params *params)
{
static bool codec_found;
@ -275,18 +275,18 @@ static void discover_sink_cb(struct bt_conn *conn, int err, struct bt_codec *cod
}
if (codec != NULL) {
print_remote_codec(codec, params->dir);
print_remote_codec(codec, dir);
codec_found = true;
return;
}
if (ep != NULL) {
if (params->dir == BT_AUDIO_DIR_SINK) {
if (dir == BT_AUDIO_DIR_SINK) {
add_remote_sink(ep);
endpoint_found = true;
} else {
FAIL("Invalid param dir: %u\n", params->dir);
FAIL("Invalid param dir: %u\n", dir);
}
return;
@ -379,9 +379,7 @@ static void discover_sink(void)
static struct bt_bap_unicast_client_discover_params params;
int err;
params.dir = BT_AUDIO_DIR_SINK;
err = bt_bap_unicast_client_discover(default_conn, &params);
err = bt_bap_unicast_client_discover(default_conn, BT_AUDIO_DIR_SINK, &params);
if (err != 0) {
printk("Failed to discover sink: %d\n", err);
return;