Bluetooth: Audio: define bt_bap_bass_subgroup struct.

The Broadcast Assistant API should be fully independent of the scan
delegator. Therefore the new struct bt_bap_bass_subgroup has been
defined to avoid a dependency.

Fixes: #68338

Signed-off-by: Ping Wang <pinw@demant.com>
This commit is contained in:
Ping Wang 2024-02-14 10:40:49 +01:00 committed by Henrik Brix Andersen
commit 5ccd75b49b
19 changed files with 95 additions and 110 deletions

View file

@ -25,15 +25,6 @@
extern "C" {
#endif
#if defined(CONFIG_BT_BAP_SCAN_DELEGATOR)
#define BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN
#define BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS
#else
#define BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN 0
#define BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS 0
#endif
/** Periodic advertising state reported by the Scan Delegator */
enum bt_bap_pa_state {
/** The periodic advertising has not been synchronized */
@ -255,15 +246,17 @@ struct bt_bap_unicast_group;
struct bt_bap_ep;
/** Struct to hold subgroup specific information for the receive state */
struct bt_bap_scan_delegator_subgroup {
struct bt_bap_bass_subgroup {
/** BIS synced bitfield */
uint32_t bis_sync;
/** Length of the metadata */
uint8_t metadata_len;
#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE)
/** The metadata */
uint8_t metadata[BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN];
uint8_t metadata[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE];
#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE */
};
/** Represents the Broadcast Audio Scan Service receive state */
@ -296,7 +289,7 @@ struct bt_bap_scan_delegator_recv_state {
uint8_t num_subgroups;
/** Subgroup specific information */
struct bt_bap_scan_delegator_subgroup subgroups[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
struct bt_bap_scan_delegator_cb {
@ -367,7 +360,6 @@ struct bt_bap_scan_delegator_cb {
void (*broadcast_code)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE]);
/**
* @brief Broadcast Isochronous Stream synchronize request
*
@ -391,7 +383,7 @@ struct bt_bap_scan_delegator_cb {
*/
int (*bis_sync_req)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS]);
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS]);
};
/** Structure holding information of audio stream endpoint */
@ -1921,7 +1913,7 @@ int bt_bap_scan_delegator_set_pa_state(uint8_t src_id,
*/
int bt_bap_scan_delegator_set_bis_sync_state(
uint8_t src_id,
uint32_t bis_synced[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS]);
uint32_t bis_synced[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS]);
struct bt_bap_scan_delegator_add_src_param {
/** The periodic adverting sync */
@ -1937,7 +1929,7 @@ struct bt_bap_scan_delegator_add_src_param {
uint8_t num_subgroups;
/** Subgroup specific information */
struct bt_bap_scan_delegator_subgroup subgroups[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
/**
@ -1974,7 +1966,7 @@ struct bt_bap_scan_delegator_mod_src_param {
* If a subgroup's metadata_len is set to 0, the existing metadata
* for the subgroup will remain unchanged
*/
struct bt_bap_scan_delegator_subgroup subgroups[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
/**
@ -2214,7 +2206,7 @@ struct bt_bap_broadcast_assistant_add_src_param {
uint8_t num_subgroups;
/** Pointer to array of subgroups */
struct bt_bap_scan_delegator_subgroup *subgroups;
struct bt_bap_bass_subgroup *subgroups;
};
/**
@ -2247,7 +2239,7 @@ struct bt_bap_broadcast_assistant_mod_src_param {
uint8_t num_subgroups;
/** Pointer to array of subgroups */
struct bt_bap_scan_delegator_subgroup *subgroups;
struct bt_bap_bass_subgroup *subgroups;
};
/** @brief Modify a source on the server.

View file

@ -801,7 +801,7 @@ struct bt_cap_commander_broadcast_reception_start_member_param {
*
* At least one bit in one of the subgroups bis_sync parameters shall be set.
*/
struct bt_bap_scan_delegator_subgroup *subgroups;
struct bt_bap_bass_subgroup *subgroups;
/** Number of subgroups */
size_t num_subgroups;

View file

@ -12,7 +12,3 @@ CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_BAP_BROADCAST_ASSISTANT=y
# CONFIG_BT_BAP_SCAN_DELEGATOR=y is required until the following
# bug is fixed: https://github.com/zephyrproject-rtos/zephyr/issues/68338
CONFIG_BT_BAP_SCAN_DELEGATOR=y

View file

@ -401,7 +401,7 @@ BT_CONN_CB_DEFINE(conn_callbacks) = {
int main(void)
{
int err;
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
struct bt_bap_broadcast_assistant_add_src_param param = { 0 };
err = bt_enable(NULL);

View file

@ -9,7 +9,7 @@ CONFIG_BT_BAP_SCAN_DELEGATOR=y
CONFIG_BT_ISO_MAX_CHAN=2
CONFIG_BT_BAP_BROADCAST_SNK_SUBGROUP_COUNT=2
CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT=2
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS=2
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS=2
CONFIG_BT_BUF_ACL_RX_SIZE=255
CONFIG_BT_BUF_ACL_TX_SIZE=251

View file

@ -708,7 +708,7 @@ static void broadcast_code_cb(struct bt_conn *conn,
static int bis_sync_req_cb(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS])
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
{
const bool bis_synced = k_sem_count_get(&sem_bis_synced) > 0U;

View file

@ -53,6 +53,16 @@ config BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE
help
Number of octets to support for Codec Specific Configuration metadata.
config BT_BAP_BASS_MAX_SUBGROUPS
int "Maximum number of subgroups supported for the BASS receive states"
default 1
range 1 24
help
This option sets the maximum number of subgroups supported.
Due to limitations in advertising data, the maximum size of all subgroups are 249.
The minimum size of a subgroup is 10 octets.
So effectively there can be a maximum of 24 subgroups in a BASE.
config BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE
int "Codec Capabilities Data Size"
default 19
@ -221,20 +231,6 @@ config BT_BAP_SCAN_DELEGATOR_RECV_STATE_COUNT
server. Each characteristic may hold information to sync to a
periodic advertise or a broadcast isochronous stream.
config BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN
int "Scan Delegator Maximum Metadata Length"
default 32
range 0 255
help
The maximum metadata length support by the BASS server.
config BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS
int "Scan Delegator Maximum Number of Subgroups support"
default 1
range 0 31
help
The maximum number of BIS subgroups supported.
config BT_BAP_SCAN_DELEGATOR_BUF_TIMEOUT
int "Milliseconds of timeout when handle concurrent access to the long read ASE buffer"
range 0 1000

View file

@ -144,7 +144,7 @@ static int parse_recv_state(const void *data, uint16_t length,
recv_state->num_subgroups = net_buf_simple_pull_u8(&buf);
for (int i = 0; i < recv_state->num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup = &recv_state->subgroups[i];
struct bt_bap_bass_subgroup *subgroup = &recv_state->subgroups[i];
uint8_t *metadata;
if (buf.len < sizeof(subgroup->bis_sync)) {

View file

@ -103,7 +103,7 @@ static void update_recv_state_big_synced(const struct bt_bap_broadcast_sink *sin
mod_src_param.num_subgroups = sink->subgroup_count;
for (uint8_t i = 0U; i < sink->subgroup_count; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup_param = &mod_src_param.subgroups[i];
struct bt_bap_bass_subgroup *subgroup_param = &mod_src_param.subgroups[i];
const struct bt_bap_broadcast_sink_subgroup *sink_subgroup = &sink->subgroups[i];
/* Set the bis_sync value to the indexes available per subgroup */
@ -440,7 +440,7 @@ static void broadcast_sink_add_src(struct bt_bap_broadcast_sink *sink)
static bool base_subgroup_meta_cb(const struct bt_bap_base_subgroup *subgroup, void *user_data)
{
struct bt_bap_scan_delegator_mod_src_param *mod_src_param = user_data;
struct bt_bap_scan_delegator_subgroup *subgroup_param;
struct bt_bap_bass_subgroup *subgroup_param;
uint8_t *meta;
int ret;
@ -496,7 +496,7 @@ static void update_recv_state_base(const struct bt_bap_broadcast_sink *sink,
mod_src_param.broadcast_id = recv_state->broadcast_id;
mod_src_param.num_subgroups = sink->subgroup_count;
for (uint8_t i = 0U; i < sink->subgroup_count; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup_param = &mod_src_param.subgroups[i];
struct bt_bap_bass_subgroup *subgroup_param = &mod_src_param.subgroups[i];
const struct bt_bap_broadcast_sink_subgroup *sink_subgroup = &sink->subgroups[i];
/* Set the bis_sync value to the indexes available per subgroup */

View file

@ -58,7 +58,7 @@ struct bass_recv_state_internal {
uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE];
struct bt_le_per_adv_sync *pa_sync;
/** Requested BIS sync bitfield for each subgroup */
uint32_t requested_bis_sync[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
uint32_t requested_bis_sync[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
ATOMIC_DEFINE(flags, BASS_RECV_STATE_INTERNAL_FLAG_NUM);
};
@ -131,7 +131,7 @@ static void bt_debug_dump_recv_state(const struct bass_recv_state_internal *recv
state->num_subgroups);
for (int i = 0; i < state->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];
const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
LOG_DBG("\tSubgroup[%d]: BIS sync %u (requested %u), metadata_len %zu, metadata: "
"%s",
@ -197,7 +197,7 @@ static void net_buf_put_recv_state(const struct bass_recv_state_internal *recv_s
}
(void)net_buf_simple_add_u8(&read_buf, state->num_subgroups);
for (int i = 0; i < state->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];
const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
(void)net_buf_simple_add_le32(&read_buf, subgroup->bis_sync >> 1);
(void)net_buf_simple_add_u8(&read_buf, subgroup->metadata_len);
@ -539,15 +539,15 @@ static int scan_delegator_add_source(struct bt_conn *conn,
pa_interval = net_buf_simple_pull_le16(buf);
state->num_subgroups = net_buf_simple_pull_u8(buf);
if (state->num_subgroups > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) {
if (state->num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
LOG_WRN("Too many subgroups %u/%u", state->num_subgroups,
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS);
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS);
return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES);
}
bis_sync_requested = false;
for (int i = 0; i < state->num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];
struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
uint8_t *metadata;
if (buf->len < (sizeof(subgroup->bis_sync) + sizeof(subgroup->metadata_len))) {
@ -595,9 +595,9 @@ static int scan_delegator_add_source(struct bt_conn *conn,
}
if (subgroup->metadata_len > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN) {
if (subgroup->metadata_len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) {
LOG_WRN("Metadata too long %u/%u", subgroup->metadata_len,
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN);
CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE);
return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES);
}
@ -661,8 +661,8 @@ static int scan_delegator_mod_src(struct bt_conn *conn,
bool state_changed = false;
uint16_t pa_interval;
uint8_t num_subgroups;
struct bt_bap_scan_delegator_subgroup
subgroups[CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS] = { 0 };
struct bt_bap_bass_subgroup
subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS] = { 0 };
uint8_t pa_sync;
uint32_t aggregated_bis_syncs = 0;
bool bis_sync_change_requested;
@ -695,16 +695,16 @@ static int scan_delegator_mod_src(struct bt_conn *conn,
pa_interval = net_buf_simple_pull_le16(buf);
num_subgroups = net_buf_simple_pull_u8(buf);
if (num_subgroups > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) {
if (num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
LOG_WRN("Too many subgroups %u/%u", num_subgroups,
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS);
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS);
return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES);
}
bis_sync_change_requested = false;
for (int i = 0; i < num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup = &subgroups[i];
struct bt_bap_bass_subgroup *subgroup = &subgroups[i];
uint32_t old_bis_sync_req;
uint8_t *metadata;
@ -753,9 +753,9 @@ static int scan_delegator_mod_src(struct bt_conn *conn,
return BT_GATT_ERR(BT_ATT_ERR_WRITE_REQ_REJECTED);
}
if (subgroup->metadata_len > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN) {
if (subgroup->metadata_len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) {
LOG_WRN("Metadata too long %u/%u", subgroup->metadata_len,
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN);
CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE);
return BT_GATT_ERR(BT_ATT_ERR_INSUFFICIENT_RESOURCES);
}
@ -1168,7 +1168,7 @@ int bt_bap_scan_delegator_set_pa_state(uint8_t src_id,
int bt_bap_scan_delegator_set_bis_sync_state(
uint8_t src_id,
uint32_t bis_synced[CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS])
uint32_t bis_synced[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
{
struct bass_recv_state_internal *internal_state = bass_lookup_src_id(src_id);
bool notify = false;
@ -1186,7 +1186,7 @@ int bt_bap_scan_delegator_set_bis_sync_state(
/* Verify state for all subgroups before assigning any data */
for (uint8_t i = 0U; i < internal_state->state.num_subgroups; i++) {
if (i >= CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) {
if (i >= CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
break;
}
@ -1201,10 +1201,10 @@ int bt_bap_scan_delegator_set_bis_sync_state(
}
for (uint8_t i = 0U; i < internal_state->state.num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup =
struct bt_bap_bass_subgroup *subgroup =
&internal_state->state.subgroups[i];
if (i >= CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) {
if (i >= CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
break;
}
@ -1247,16 +1247,16 @@ static bool valid_bt_bap_scan_delegator_add_src_param(
return false;
}
if (param->num_subgroups > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) {
if (param->num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
LOG_WRN("Too many subgroups %u/%u",
param->num_subgroups,
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS);
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS);
return false;
}
for (uint8_t i = 0U; i < param->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &param->subgroups[i];
const struct bt_bap_bass_subgroup *subgroup = &param->subgroups[i];
if (!bis_syncs_unique_or_no_pref(subgroup->bis_sync,
aggregated_bis_syncs)) {
@ -1265,7 +1265,7 @@ static bool valid_bt_bap_scan_delegator_add_src_param(
return false;
}
if (subgroup->metadata_len > BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN) {
if (subgroup->metadata_len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) {
LOG_DBG("subgroup[%u]: Invalid metadata_len: %u",
i, subgroup->metadata_len);
@ -1353,16 +1353,16 @@ static bool valid_bt_bap_scan_delegator_mod_src_param(
return false;
}
if (param->num_subgroups > CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS) {
if (param->num_subgroups > CONFIG_BT_BAP_BASS_MAX_SUBGROUPS) {
LOG_WRN("Too many subgroups %u/%u",
param->num_subgroups,
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS);
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS);
return false;
}
for (uint8_t i = 0U; i < param->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &param->subgroups[i];
const struct bt_bap_bass_subgroup *subgroup = &param->subgroups[i];
if (subgroup->bis_sync == BT_BAP_BIS_SYNC_NO_PREF ||
!bis_syncs_unique_or_no_pref(subgroup->bis_sync,
@ -1372,7 +1372,7 @@ static bool valid_bt_bap_scan_delegator_mod_src_param(
return false;
}
if (subgroup->metadata_len > BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN) {
if (subgroup->metadata_len > CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) {
LOG_DBG("subgroup[%u]: Invalid metadata_len: %u",
i, subgroup->metadata_len);
@ -1431,8 +1431,8 @@ int bt_bap_scan_delegator_mod_src(const struct bt_bap_scan_delegator_mod_src_par
}
for (uint8_t i = 0U; i < state->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *param_subgroup = &param->subgroups[i];
struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];
const struct bt_bap_bass_subgroup *param_subgroup = &param->subgroups[i];
struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
if (subgroup->bis_sync != param_subgroup->bis_sync) {
subgroup->bis_sync = param_subgroup->bis_sync;

View file

@ -34,7 +34,7 @@ static uint8_t received_base_size;
static struct bt_auto_scan {
uint32_t broadcast_id;
bool pa_sync;
struct bt_bap_scan_delegator_subgroup subgroup;
struct bt_bap_bass_subgroup subgroup;
} auto_scan = {
.broadcast_id = INVALID_BROADCAST_ID,
};
@ -128,7 +128,7 @@ static void bap_broadcast_assistant_recv_state_cb(
is_bad_code ? ", bad code" : "", is_bad_code ? bad_code : "");
for (int i = 0; i < state->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];
const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
struct net_buf_simple buf;
shell_print(ctx_shell, "\t[%d]: BIS sync 0x%04X, metadata_len %zu", i,
@ -361,7 +361,7 @@ static int cmd_bap_broadcast_assistant_add_src(const struct shell *sh,
size_t argc, char **argv)
{
struct bt_bap_broadcast_assistant_add_src_param param = { 0 };
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
unsigned long broadcast_id;
unsigned long adv_sid;
int result;
@ -586,7 +586,7 @@ static int cmd_bap_broadcast_assistant_add_broadcast_id(const struct shell *sh,
size_t argc,
char **argv)
{
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
static bool scan_cbs_registered;
unsigned long broadcast_id;
int err = 0;
@ -666,7 +666,7 @@ static int cmd_bap_broadcast_assistant_mod_src(const struct shell *sh,
size_t argc, char **argv)
{
struct bt_bap_broadcast_assistant_mod_src_param param = { 0 };
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
unsigned long src_id;
int result = 0;
@ -766,7 +766,7 @@ static int cmd_bap_broadcast_assistant_mod_src(const struct shell *sh,
static inline bool add_pa_sync_base_subgroup_bis_cb(const struct bt_bap_base_subgroup_bis *bis,
void *user_data)
{
struct bt_bap_scan_delegator_subgroup *subgroup_param = user_data;
struct bt_bap_bass_subgroup *subgroup_param = user_data;
subgroup_param->bis_sync |= BIT(bis->index);
@ -777,7 +777,7 @@ static inline bool add_pa_sync_base_subgroup_cb(const struct bt_bap_base_subgrou
void *user_data)
{
struct bt_bap_broadcast_assistant_add_src_param *param = user_data;
struct bt_bap_scan_delegator_subgroup *subgroup_param;
struct bt_bap_bass_subgroup *subgroup_param;
uint8_t *data;
int ret;

View file

@ -312,11 +312,11 @@ static void broadcast_code_cb(struct bt_conn *conn,
static int bis_sync_req_cb(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS])
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
{
printk("BIS sync request received for %p\n", recv_state);
for (int i = 0; i < BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS; i++) {
for (int i = 0; i < CONFIG_BT_BAP_BASS_MAX_SUBGROUPS; i++) {
printk(" [%d]: 0x%08x\n", i, bis_sync_req[i]);
}
@ -522,7 +522,7 @@ static int cmd_bap_scan_delegator_add_src(const struct shell *sh, size_t argc,
{
/* TODO: Add support to select which PA sync to BIG sync to */
struct bt_le_per_adv_sync *pa_sync = per_adv_syncs[0];
struct bt_bap_scan_delegator_subgroup *subgroup_param;
struct bt_bap_bass_subgroup *subgroup_param;
struct bt_bap_scan_delegator_add_src_param param;
unsigned long broadcast_id;
struct sync_state *state;
@ -619,7 +619,7 @@ static int cmd_bap_scan_delegator_add_src(const struct shell *sh, size_t argc,
static int cmd_bap_scan_delegator_mod_src(const struct shell *sh, size_t argc,
char **argv)
{
struct bt_bap_scan_delegator_subgroup *subgroup_param;
struct bt_bap_bass_subgroup *subgroup_param;
struct bt_bap_scan_delegator_mod_src_param param;
unsigned long broadcast_id;
unsigned long enc_state;
@ -753,7 +753,7 @@ static int cmd_bap_scan_delegator_rem_src(const struct shell *sh, size_t argc,
static int cmd_bap_scan_delegator_bis_synced(const struct shell *sh, size_t argc,
char **argv)
{
uint32_t bis_syncs[CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
uint32_t bis_syncs[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
unsigned long pa_sync_state;
unsigned long bis_synced;
unsigned long src_id;

View file

@ -138,8 +138,8 @@ CONFIG_BT_OTS_MAX_OBJ_CNT=0x30
CONFIG_BT_OTS_CLIENT=y
CONFIG_BT_BAP_SCAN_DELEGATOR=y
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS=2
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN=255
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS=2
CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE=255
CONFIG_BT_BAP_BROADCAST_ASSISTANT=y
# IAS

View file

@ -46,7 +46,7 @@ CONFIG_BT_BAP_BROADCAST_SNK_SUBGROUP_COUNT=2
# BASS
CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER=y
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN=255
CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE=255
CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER=y
# BASS notifications need higher MTU
CONFIG_BT_L2CAP_TX_MTU=255

View file

@ -32,8 +32,8 @@ static const uint32_t bis_index_mask = BIT_MASK(CONFIG_BT_BAP_BROADCAST_SNK_STRE
#define INVALID_BROADCAST_ID (BT_AUDIO_BROADCAST_ID_MAX + 1)
#define SYNC_RETRY_COUNT 6 /* similar to retries for connections */
#define PA_SYNC_SKIP 5
static struct bt_bap_scan_delegator_subgroup
delegator_subgroups[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
static struct bt_bap_bass_subgroup
delegator_subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
static inline struct btp_bap_broadcast_stream *stream_bap_to_broadcast(struct bt_bap_stream *stream)
{
@ -810,8 +810,8 @@ static void btp_send_broadcast_receive_state_ev(struct bt_conn *conn,
uint8_t *ptr;
tester_rsp_buffer_lock();
tester_rsp_buffer_allocate(sizeof(*ev) + BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS *
sizeof(struct bt_bap_scan_delegator_subgroup), (uint8_t **)&ev);
tester_rsp_buffer_allocate(sizeof(*ev) + CONFIG_BT_BAP_BASS_MAX_SUBGROUPS *
sizeof(struct bt_bap_bass_subgroup), (uint8_t **)&ev);
if (conn) {
bt_addr_le_copy(&ev->address, bt_conn_get_dst(conn));
@ -829,7 +829,7 @@ static void btp_send_broadcast_receive_state_ev(struct bt_conn *conn,
ptr = ev->subgroups;
for (uint8_t i = 0; i < ev->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];
const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
sys_put_le32(subgroup->bis_sync >> 1, ptr);
ptr += sizeof(subgroup->bis_sync);
@ -954,7 +954,7 @@ static void broadcast_code_cb(struct bt_conn *conn,
static int bis_sync_req_cb(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS])
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
{
struct btp_bap_broadcast_remote_source *broadcaster;
bool bis_synced = false;
@ -1391,12 +1391,12 @@ uint8_t btp_bap_broadcast_assistant_add_src(const void *cmd, uint16_t cmd_len,
param.pa_sync = cp->padv_sync > 0 ? true : false;
param.broadcast_id = sys_get_le24(cp->broadcast_id);
param.pa_interval = sys_le16_to_cpu(cp->padv_interval);
param.num_subgroups = MIN(cp->num_subgroups, BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS);
param.num_subgroups = MIN(cp->num_subgroups, CONFIG_BT_BAP_BASS_MAX_SUBGROUPS);
param.subgroups = delegator_subgroups;
ptr = cp->subgroups;
for (uint8_t i = 0; i < param.num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup = &delegator_subgroups[i];
struct bt_bap_bass_subgroup *subgroup = &delegator_subgroups[i];
subgroup->bis_sync = sys_get_le32(ptr);
if (subgroup->bis_sync != BT_BAP_BIS_SYNC_NO_PREF) {
@ -1462,12 +1462,12 @@ uint8_t btp_bap_broadcast_assistant_modify_src(const void *cmd, uint16_t cmd_len
param.src_id = cp->src_id;
param.pa_sync = cp->padv_sync > 0 ? true : false;
param.pa_interval = sys_le16_to_cpu(cp->padv_interval);
param.num_subgroups = MIN(cp->num_subgroups, BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS);
param.num_subgroups = MIN(cp->num_subgroups, CONFIG_BT_BAP_BASS_MAX_SUBGROUPS);
param.subgroups = delegator_subgroups;
ptr = cp->subgroups;
for (uint8_t i = 0; i < param.num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup = &delegator_subgroups[i];
struct bt_bap_bass_subgroup *subgroup = &delegator_subgroups[i];
subgroup->bis_sync = sys_get_le32(ptr);
if (subgroup->bis_sync != BT_BAP_BIS_SYNC_NO_PREF) {

View file

@ -113,7 +113,8 @@ CONFIG_BT_OTS_CLIENT=y
# Broadcast Audio Scan Service and client
CONFIG_BT_BAP_SCAN_DELEGATOR=y
CONFIG_BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN=255
CONFIG_BT_BAP_BASS_MAX_SUBGROUPS=1
CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE=255
CONFIG_BT_BAP_BROADCAST_ASSISTANT=y
# Hearing Access

View file

@ -121,7 +121,7 @@ static void bap_broadcast_assistant_recv_state_cb(
bad_code);
for (int i = 0; i < state->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];
const struct bt_bap_bass_subgroup *subgroup = &state->subgroups[i];
struct net_buf_simple buf;
printk("\t[%d]: BIS sync %u, metadata_len %u\n",
@ -396,7 +396,7 @@ static void test_bass_add_source(void)
{
int err;
struct bt_bap_broadcast_assistant_add_src_param add_src_param = { 0 };
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
printk("Adding source\n");
UNSET_FLAG(flag_write_complete);
@ -425,7 +425,7 @@ static void test_bass_mod_source(void)
{
int err;
struct bt_bap_broadcast_assistant_mod_src_param mod_src_param = { 0 };
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
printk("Modify source\n");
UNSET_FLAG(flag_cb_called);
@ -455,7 +455,7 @@ static void test_bass_mod_source_long_meta(void)
{
int err;
struct bt_bap_broadcast_assistant_mod_src_param mod_src_param = { 0 };
struct bt_bap_scan_delegator_subgroup subgroup = { 0 };
struct bt_bap_bass_subgroup subgroup = { 0 };
printk("Long write\n");
UNSET_FLAG(flag_cb_called);

View file

@ -237,7 +237,7 @@ static int pa_sync_term_req_cb(struct bt_conn *conn,
static int bis_sync_req_cb(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS])
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
{
printk("BIS sync request received for %p: 0x%08x\n", recv_state, bis_sync_req[0]);
/* We only care about a single subgroup in this test */

View file

@ -32,7 +32,7 @@ struct sync_state {
struct k_work_delayable pa_timer;
struct bt_le_per_adv_sync *pa_sync;
uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE];
uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS];
uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
} sync_states[CONFIG_BT_BAP_SCAN_DELEGATOR_RECV_STATE_COUNT];
static struct sync_state *sync_state_get(const struct bt_bap_scan_delegator_recv_state *recv_state)
@ -317,13 +317,13 @@ static void broadcast_code_cb(struct bt_conn *conn,
static int bis_sync_req_cb(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS])
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
{
struct sync_state *state;
bool sync_bis;
printk("BIS sync request received for %p\n", recv_state);
for (int i = 0; i < BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS; i++) {
for (int i = 0; i < CONFIG_BT_BAP_BASS_MAX_SUBGROUPS; i++) {
if (bis_sync_req[i]) {
sync_bis = true;
}
@ -482,7 +482,7 @@ static int add_source(struct sync_state *state)
param.num_subgroups = 1U;
for (uint8_t i = 0U; i < param.num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup_param = &param.subgroups[i];
struct bt_bap_bass_subgroup *subgroup_param = &param.subgroups[i];
subgroup_param->bis_sync = BT_BAP_BIS_SYNC_NO_PREF;
subgroup_param->metadata_len = 0U;
@ -541,7 +541,7 @@ static int mod_source(struct sync_state *state)
param.num_subgroups = 1U;
for (uint8_t i = 0U; i < param.num_subgroups; i++) {
struct bt_bap_scan_delegator_subgroup *subgroup_param = &param.subgroups[i];
struct bt_bap_bass_subgroup *subgroup_param = &param.subgroups[i];
subgroup_param->bis_sync = 0U;
subgroup_param->metadata_len = sizeof(pref_context_metadata);