Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bluetooth: bap: Fix shift of BIS_Sync parameter of notification #64665

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions subsys/bluetooth/audio/bap_broadcast_assistant.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ int bt_bap_broadcast_assistant_add_src(struct bt_conn *conn,

subgroup = net_buf_simple_add(&cp_buf, subgroup_size);

subgroup->bis_sync = param->subgroups[i].bis_sync;
/* The BIS Index bitfield to be sent must use BIT(0) for BIS Index 1 */
subgroup->bis_sync = param->subgroups[i].bis_sync >> 1;
Thalley marked this conversation as resolved.
Show resolved Hide resolved

CHECKIF(param->pa_sync == 0 && subgroup->bis_sync != 0) {
LOG_DBG("Only syncing to BIS is not allowed");
Expand Down Expand Up @@ -860,7 +861,8 @@ int bt_bap_broadcast_assistant_mod_src(struct bt_conn *conn,
}
subgroup = net_buf_simple_add(&cp_buf, subgroup_size);

subgroup->bis_sync = param->subgroups[i].bis_sync;
/* The BIS Index bitfield to be sent must use BIT(0) for BIS Index 1 */
subgroup->bis_sync = param->subgroups[i].bis_sync >> 1;

CHECKIF(param->pa_sync == 0 && subgroup->bis_sync != 0) {
LOG_DBG("Only syncing to BIS is not allowed");
Expand Down
11 changes: 10 additions & 1 deletion subsys/bluetooth/audio/bap_scan_delegator.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static void net_buf_put_recv_state(const struct bass_recv_state_internal *recv_s
for (int i = 0; i < state->num_subgroups; i++) {
const struct bt_bap_scan_delegator_subgroup *subgroup = &state->subgroups[i];

(void)net_buf_simple_add_le32(&read_buf, subgroup->bis_sync);
(void)net_buf_simple_add_le32(&read_buf, subgroup->bis_sync >> 1);
(void)net_buf_simple_add_u8(&read_buf, subgroup->metadata_len);
(void)net_buf_simple_add_mem(&read_buf, subgroup->metadata,
subgroup->metadata_len);
Expand Down Expand Up @@ -514,6 +514,10 @@ static int scan_delegator_add_source(struct bt_conn *conn,
}

internal_state->requested_bis_sync[i] = net_buf_simple_pull_le32(buf);
if (internal_state->requested_bis_sync[i] != BT_BAP_BIS_SYNC_NO_PREF) {
/* Received BIS Index bitfield uses BIT(0) for BIS Index 1 */
internal_state->requested_bis_sync[i] <<= 1;
}

if (internal_state->requested_bis_sync[i] &&
pa_sync == BT_BAP_BASS_PA_REQ_NO_SYNC) {
Expand Down Expand Up @@ -670,6 +674,11 @@ static int scan_delegator_mod_src(struct bt_conn *conn,
old_bis_sync_req = internal_state->requested_bis_sync[i];

internal_state->requested_bis_sync[i] = net_buf_simple_pull_le32(buf);
if (internal_state->requested_bis_sync[i] != BT_BAP_BIS_SYNC_NO_PREF) {
/* Received BIS Index bitfield uses BIT(0) for BIS Index 1 */
internal_state->requested_bis_sync[i] <<= 1;
}

if (internal_state->requested_bis_sync[i] &&
pa_sync == BT_BAP_BASS_PA_REQ_NO_SYNC) {
LOG_DBG("Cannot sync to BIS without PA");
Expand Down
Loading