Skip to content

Commit

Permalink
bluetooth: bap: Fix shift of requested_bis_sync
Browse files Browse the repository at this point in the history
The BIS_Sync bitfiled received over the air in Add Source and Modify
Source operations uses BIT(0) for BIS Index 1. Shift it when storing
it to match bis_sync bitfield where BIS Index 1 is at BIT(1).

Signed-off-by: Magdalena Kasenberg <[email protected]>
  • Loading branch information
mkasenberg authored and fabiobaltieri committed Nov 30, 2023
1 parent 2094183 commit c94cd30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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;

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
9 changes: 9 additions & 0 deletions subsys/bluetooth/audio/bap_scan_delegator.c
Original file line number Diff line number Diff line change
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

0 comments on commit c94cd30

Please sign in to comment.