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

Option to overwrite a Receive State in the Scan Delegator #62609

Closed
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
28 changes: 28 additions & 0 deletions include/zephyr/bluetooth/audio/bap.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,25 @@ struct bt_bap_scan_delegator_recv_state {
};

struct bt_bap_scan_delegator_cb {

/**
* @brief Attempt to add a new source to a receive state failed
*
* An attempt to add a new broadcast source to a receive state
* failed.
*
* @param conn Pointer to the connection to a remote device if
* the change was caused by it, otherwise NULL.
* @param state_info Pointer to the receive state that was
* attempted to be added.
* @param err errno explaining why adding the source failed
*
* return true if operation was successful, or false if unsuccessful
*
*/
bool (*recv_state_add_failed)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *state_info,
int err);
/**
* @brief Receive state updated
*
Expand Down Expand Up @@ -1665,6 +1684,15 @@ int bt_bap_broadcast_sink_stop(struct bt_bap_broadcast_sink *sink);
*/
int bt_bap_broadcast_sink_delete(struct bt_bap_broadcast_sink *sink);

/**
* @brief Find a broadcast sink by its BASS Source ID
*
* @param src_id which comes from of the @ref bt_bap_scan_delegator_recv_state
*
* @return Pointer to the broadcast sink found
*/
struct bt_bap_broadcast_sink *bt_bap_broadcast_sink_get_by_src_id(uint8_t src_id);

/** @} */ /* End of group bt_bap_broadcast_sink */

/**
Expand Down
2 changes: 2 additions & 0 deletions samples/bluetooth/broadcast_audio_sink/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ 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_SCAN_DELEGATOR_OVERWRITE_OLDEST=y

CONFIG_BT_DEVICE_NAME="Broadcast Audio Sink"

8 changes: 8 additions & 0 deletions subsys/bluetooth/audio/Kconfig.bap
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ config BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS
help
The maximum number of BIS subgroups supported.

config BT_BAP_SCAN_DELEGATOR_OVERWRITE_OLDEST
bool "Overwrite oldest inactive receive state"
help
If enabled, if there are no available free receive states,
the oldest inactive receive state will be overwritten. An
inactive receive state is a receive state that has neither a
Periodic Advertising or Broadcast Isochronous Group (BIG) sync.

endif # BT_BAP_SCAN_DELEGATOR

config BT_BAP_BROADCAST_ASSISTANT
Expand Down
11 changes: 11 additions & 0 deletions subsys/bluetooth/audio/bap_broadcast_sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,17 @@ int bt_bap_broadcast_sink_delete(struct bt_bap_broadcast_sink *sink)
return 0;
}

struct bt_bap_broadcast_sink *bt_bap_broadcast_sink_get_by_src_id(uint8_t bass_src_id)
{
for (size_t i = 0U; i < ARRAY_SIZE(broadcast_sinks); i++) {
if (broadcast_sinks[i].bass_src_id == bass_src_id) {
return &broadcast_sinks[i];
}
}

return NULL;
}

static int broadcast_sink_init(void)
{
static struct bt_le_per_adv_sync_cb cb = {
Expand Down
Loading
Loading