Skip to content

Commit

Permalink
Bluetooth: BAP: Shell: Add BASS service data to ext-adv
Browse files Browse the repository at this point in the history
As per the BAP spec, the scan delegator device should add the BASS service
data in the extended advertising data when it requests a broadcast
assistant to scan for it. For testing purposes that's usually the case
with the shell, extended advertising data shall be populated with the
BASS service data.

Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
  • Loading branch information
niym-ot authored and fabiobaltieri committed Apr 25, 2024
1 parent 4968021 commit 9241796
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions subsys/bluetooth/audio/shell/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ssize_t audio_ad_data_add(struct bt_data *data, const size_t data_size, const bo
ssize_t audio_pa_data_add(struct bt_data *data_array, const size_t data_array_size);
ssize_t csis_ad_data_add(struct bt_data *data, const size_t data_size, const bool discoverable);
size_t cap_acceptor_ad_data_add(struct bt_data data[], size_t data_size, bool discoverable);
size_t bap_scan_delegator_ad_data_add(struct bt_data data[], size_t data_size);
size_t gmap_ad_data_add(struct bt_data data[], size_t data_size);
size_t pbp_ad_data_add(struct bt_data data[], size_t data_size);
ssize_t cap_initiator_ad_data_add(struct bt_data *data_array, const size_t data_array_size,
Expand Down
5 changes: 5 additions & 0 deletions subsys/bluetooth/audio/shell/bap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3914,6 +3914,11 @@ static ssize_t connectable_ad_data_add(struct bt_data *data_array,
ad_len++;
}

if (IS_ENABLED(CONFIG_BT_BAP_SCAN_DELEGATOR)) {
ad_len += bap_scan_delegator_ad_data_add(&data_array[ad_len],
data_array_size - ad_len);
}

if (IS_ENABLED(CONFIG_BT_CAP_ACCEPTOR)) {
ad_len += cap_acceptor_ad_data_add(&data_array[ad_len], data_array_size - ad_len,
true);
Expand Down
14 changes: 14 additions & 0 deletions subsys/bluetooth/audio/shell/bap_scan_delegator.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ struct sync_state {

static bool past_preference = true;

size_t bap_scan_delegator_ad_data_add(struct bt_data data[], size_t data_size)
{
static uint8_t ad_bap_scan_delegator[2] = {
BT_UUID_16_ENCODE(BT_UUID_BASS_VAL),
};

__ASSERT(data_size > 0, "No space for ad_bap_scan_delegator");
data[0].type = BT_DATA_SVC_DATA16;
data[0].data_len = ARRAY_SIZE(ad_bap_scan_delegator);
data[0].data = &ad_bap_scan_delegator[0];

return 1U;
}

static struct sync_state *sync_state_get(const struct bt_bap_scan_delegator_recv_state *recv_state)
{
for (size_t i = 0U; i < ARRAY_SIZE(sync_states); i++) {
Expand Down

0 comments on commit 9241796

Please sign in to comment.