Basic Audio Profile

API Reference

group bt_bap

Bluetooth Basic Audio Profile (BAP)

Defines

BT_BAP_SCAN_DELEGATOR_MAX_METADATA_LEN
BT_BAP_SCAN_DELEGATOR_MAX_SUBGROUPS
BT_BAP_PA_INTERVAL_UNKNOWN

Value indicating that the periodic advertising interval is unknown

BT_BAP_BIS_SYNC_NO_PREF

Broadcast Assistant no BIS sync preference.

Value indicating that the Broadcast Assistant has no preference to which BIS the Scan Delegator syncs to

BROADCAST_SNK_STREAM_CNT
BROADCAST_SNK_SUBGROUP_CNT
BT_BAP_ASCS_RSP(c, r)

Macro used to initialise the object storing values of ASE Control Point notification.

Parameters:

Typedefs

typedef enum bt_bap_scan_delegator_iter (*bt_bap_scan_delegator_state_func_t)(const struct bt_bap_scan_delegator_recv_state *recv_state, void *user_data)

Callback function for Scan Delegator receive state search functions

Param recv_state:

The receive state.

Param user_data:

User data.

Return:

BT_BAP_SCAN_DELEGATOR_ITER_STOP to stop iterating or BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE to continue.

typedef void (*bt_bap_broadcast_assistant_recv_state_cb)(struct bt_conn *conn, int err, const struct bt_bap_scan_delegator_recv_state *state)

Callback function for when a receive state is read or updated.

Called whenever a receive state is read or updated.

Param conn:

The connection to the Broadcast Audio Scan Service server.

Param err:

Error value. 0 on success, GATT error on fail.

Param state:

The receive state.

typedef void (*bt_bap_broadcast_assistant_recv_state_rem_cb)(struct bt_conn *conn, int err, uint8_t src_id)

Callback function for when a receive state is removed.

Param conn:

The connection to the Broadcast Audio Scan Service server.

Param err:

Error value. 0 on success, GATT error on fail.

Param src_id:

The receive state.

typedef void (*bt_bap_broadcast_assistant_write_cb)(struct bt_conn *conn, int err)

Callback function for writes.

Param conn:

The connection to the peer device.

Param err:

Error value. 0 on success, GATT error on fail.

Enums

enum bt_bap_pa_state

Periodic advertising state reported by the Scan Delegator

Values:

enumerator BT_BAP_PA_STATE_NOT_SYNCED = 0x00

The periodic advertising has not been synchronized

enumerator BT_BAP_PA_STATE_INFO_REQ = 0x01

Waiting for SyncInfo from Broadcast Assistant

enumerator BT_BAP_PA_STATE_SYNCED = 0x02

Synchronized to periodic advertising

enumerator BT_BAP_PA_STATE_FAILED = 0x03

Failed to synchronized to periodic advertising

enumerator BT_BAP_PA_STATE_NO_PAST = 0x04

No periodic advertising sync transfer receiver from Broadcast Assistant

enum bt_bap_big_enc_state

Broadcast Isochronous Group encryption state reported by the Scan Delegator

Values:

enumerator BT_BAP_BIG_ENC_STATE_NO_ENC = 0x00

The Broadcast Isochronous Group not encrypted

enumerator BT_BAP_BIG_ENC_STATE_BCODE_REQ = 0x01

The Broadcast Isochronous Group broadcast code requested

enumerator BT_BAP_BIG_ENC_STATE_DEC = 0x02

The Broadcast Isochronous Group decrypted

enumerator BT_BAP_BIG_ENC_STATE_BAD_CODE = 0x03

The Broadcast Isochronous Group bad broadcast code

enum bt_bap_bass_att_err

Broadcast Audio Scan Service (BASS) specific ATT error codes

Values:

enumerator BT_BAP_BASS_ERR_OPCODE_NOT_SUPPORTED = 0x80

Opcode not supported

enumerator BT_BAP_BASS_ERR_INVALID_SRC_ID = 0x81

Invalid source ID supplied

enum bt_bap_ep_state

Endpoint states

Values:

enumerator BT_BAP_EP_STATE_IDLE = 0x00

Audio Stream Endpoint Idle state

enumerator BT_BAP_EP_STATE_CODEC_CONFIGURED = 0x01

Audio Stream Endpoint Codec Configured state

enumerator BT_BAP_EP_STATE_QOS_CONFIGURED = 0x02

Audio Stream Endpoint QoS Configured state

enumerator BT_BAP_EP_STATE_ENABLING = 0x03

Audio Stream Endpoint Enabling state

enumerator BT_BAP_EP_STATE_STREAMING = 0x04

Audio Stream Endpoint Streaming state

enumerator BT_BAP_EP_STATE_DISABLING = 0x05

Audio Stream Endpoint Disabling state

enumerator BT_BAP_EP_STATE_RELEASING = 0x06

Audio Stream Endpoint Streaming state

enum bt_bap_ascs_rsp_code

Response Status Code.

These are sent by the server to the client when a stream operation is requested.

Values:

enumerator BT_BAP_ASCS_RSP_CODE_SUCCESS = 0x00

Server completed operation successfully

enumerator BT_BAP_ASCS_RSP_CODE_NOT_SUPPORTED = 0x01

Server did not support operation by client

enumerator BT_BAP_ASCS_RSP_CODE_INVALID_LENGTH = 0x02

Server rejected due to invalid operation length

enumerator BT_BAP_ASCS_RSP_CODE_INVALID_ASE = 0x03

Invalid ASE ID

enumerator BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE = 0x04

Invalid ASE state

enumerator BT_BAP_ASCS_RSP_CODE_INVALID_DIR = 0x05

Invalid operation for direction

enumerator BT_BAP_ASCS_RSP_CODE_CAP_UNSUPPORTED = 0x06

Capabilities not supported by server

enumerator BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED = 0x07

Configuration parameters not supported by server

enumerator BT_BAP_ASCS_RSP_CODE_CONF_REJECTED = 0x08

Configuration parameters rejected by server

enumerator BT_BAP_ASCS_RSP_CODE_CONF_INVALID = 0x09

Invalid Configuration parameters

enumerator BT_BAP_ASCS_RSP_CODE_METADATA_UNSUPPORTED = 0x0a

Unsupported metadata

enumerator BT_BAP_ASCS_RSP_CODE_METADATA_REJECTED = 0x0b

Metadata rejected by server

enumerator BT_BAP_ASCS_RSP_CODE_METADATA_INVALID = 0x0c

Invalid metadata

enumerator BT_BAP_ASCS_RSP_CODE_NO_MEM = 0x0d

Server has insufficient resources

enumerator BT_BAP_ASCS_RSP_CODE_UNSPECIFIED = 0x0e

Unspecified error

enum bt_bap_ascs_reason

Response Reasons.

These are used if the bt_bap_ascs_rsp_code value is BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED, BT_BAP_ASCS_RSP_CODE_CONF_REJECTED or BT_BAP_ASCS_RSP_CODE_CONF_INVALID.

Values:

enumerator BT_BAP_ASCS_REASON_NONE = 0x00

No reason

enumerator BT_BAP_ASCS_REASON_CODEC = 0x01

Codec ID

enumerator BT_BAP_ASCS_REASON_CODEC_DATA = 0x02

Codec configuration

enumerator BT_BAP_ASCS_REASON_INTERVAL = 0x03

SDU interval

enumerator BT_BAP_ASCS_REASON_FRAMING = 0x04

Framing

enumerator BT_BAP_ASCS_REASON_PHY = 0x05

PHY

enumerator BT_BAP_ASCS_REASON_SDU = 0x06

Maximum SDU size

enumerator BT_BAP_ASCS_REASON_RTN = 0x07

RTN

enumerator BT_BAP_ASCS_REASON_LATENCY = 0x08

Max transport latency

enumerator BT_BAP_ASCS_REASON_PD = 0x09

Presendation delay

enumerator BT_BAP_ASCS_REASON_CIS = 0x0a

Invalid CIS mapping

enum bt_bap_scan_delegator_iter

Values:

enumerator BT_BAP_SCAN_DELEGATOR_ITER_STOP = 0
enumerator BT_BAP_SCAN_DELEGATOR_ITER_CONTINUE

Functions

int bt_bap_ep_get_info(const struct bt_bap_ep *ep, struct bt_bap_ep_info *info)

Return structure holding information of audio stream endpoint.

Parameters:
  • ep – The audio stream endpoint object.

  • info – The structure object to be filled with the info.

Returns:

0 in case of success or negative value in case of error.

void bt_bap_stream_cb_register(struct bt_bap_stream *stream, struct bt_bap_stream_ops *ops)

Register Audio callbacks for a stream.

Register Audio callbacks for a stream.

Parameters:
  • stream – Stream object.

  • ops – Stream operations structure.

int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_bap_ep *ep, struct bt_codec *codec)

Configure Audio Stream.

This procedure is used by a client to configure a new stream using the remote endpoint, local capability and codec configuration.

Parameters:
  • conn – Connection object

  • stream – Stream object being configured

  • ep – Remote Audio Endpoint being configured

  • codec – Codec configuration

Returns:

Allocated Audio Stream object or NULL in case of error.

int bt_bap_stream_reconfig(struct bt_bap_stream *stream, struct bt_codec *codec)

Reconfigure Audio Stream.

This procedure is used by a unicast client or unicast server to reconfigure a stream to use a different local codec configuration.

This can only be done for unicast streams.

Parameters:
  • stream – Stream object being reconfigured

  • codec – Codec configuration

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_qos(struct bt_conn *conn, struct bt_bap_unicast_group *group)

Configure Audio Stream QoS.

This procedure is used by a client to configure the Quality of Service of streams in a unicast group. All streams in the group for the specified conn will have the Quality of Service configured. This shall only be used to configure unicast streams.

Parameters:
  • conn – Connection object

  • group – Unicast group object

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_enable(struct bt_bap_stream *stream, struct bt_codec_data *meta, size_t meta_count)

Enable Audio Stream.

This procedure is used by a client to enable a stream.

This shall only be called for unicast streams, as broadcast streams will always be enabled once created.

Parameters:
  • stream – Stream object

  • meta_count – Number of metadata entries

  • meta – Metadata entries

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_metadata(struct bt_bap_stream *stream, struct bt_codec_data *meta, size_t meta_count)

Change Audio Stream Metadata.

This procedure is used by a unicast client or unicast server to change the metadata of a stream.

Parameters:
  • stream – Stream object

  • meta_count – Number of metadata entries

  • meta – Metadata entries

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_disable(struct bt_bap_stream *stream)

Disable Audio Stream.

This procedure is used by a unicast client or unicast server to disable a stream.

This shall only be called for unicast streams, as broadcast streams will always be enabled once created.

Parameters:
  • stream – Stream object

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_start(struct bt_bap_stream *stream)

Start Audio Stream.

This procedure is used by a unicast client or unicast server to make a stream start streaming.

For the unicast client, this will connect the CIS for the stream before sending the start command.

For the unicast server, this will put a BT_AUDIO_DIR_SINK stream into the streaming state if the CIS is connected (initialized by the unicast client). If the CIS is not connected yet, the stream will go into the streaming state as soon as the CIS is connected. BT_AUDIO_DIR_SOURCE streams will go into the streaming state when the unicast client sends the Receiver Start Ready operation, which will trigger the bt_bap_unicast_server_cb::start() callback.

This shall only be called for unicast streams.

Broadcast sinks will always be started once synchronized, and broadcast source streams shall be started with bt_bap_broadcast_source_start().

Parameters:
  • stream – Stream object

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_stop(struct bt_bap_stream *stream)

Stop Audio Stream.

This procedure is used by a client to make a stream stop streaming.

This shall only be called for unicast streams. Broadcast sinks cannot be stopped. Broadcast sources shall be stopped with bt_bap_broadcast_source_stop().

Parameters:
  • stream – Stream object

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_release(struct bt_bap_stream *stream)

Release Audio Stream.

This procedure is used by a unicast client or unicast server to release a unicast stream.

Broadcast sink streams cannot be released, but can be deleted by bt_bap_broadcast_sink_delete(). Broadcast source streams cannot be released, but can be deleted by bt_bap_broadcast_source_delete().

Parameters:
  • stream – Stream object

Returns:

0 in case of success or negative value in case of error.

int bt_bap_stream_send(struct bt_bap_stream *stream, struct net_buf *buf, uint16_t seq_num, uint32_t ts)

Send data to Audio stream.

Send data from buffer to the stream.

Note

Data will not be sent to linked streams since linking is only consider for procedures affecting the state machine.

Parameters:
  • stream – Stream object.

  • buf – Buffer containing data to be sent.

  • seq_num – Packet Sequence number. This value shall be incremented for each call to this function and at least once per SDU interval for a specific channel.

  • ts – Timestamp of the SDU in microseconds (us). This value can be used to transmit multiple SDUs in the same SDU interval in a CIG or BIG. Can be omitted by using BT_ISO_TIMESTAMP_NONE which will simply enqueue the ISO SDU in a FIFO manner.

Returns:

Bytes sent in case of success or negative value in case of error.

void bt_bap_scan_delegator_register_cb(struct bt_bap_scan_delegator_cb *cb)

Register the callbacks for the Basic Audio Profile Scan Delegator.

Parameters:
  • cb – Pointer to the callback struct

int bt_bap_scan_delegator_set_pa_state(uint8_t src_id, enum bt_bap_pa_state pa_state)

Set the periodic advertising sync state to syncing.

Set the periodic advertising sync state for a receive state to syncing, notifying Broadcast Assistants.

Parameters:
  • src_id – The source id used to identify the receive state.

  • pa_state – The Periodic Advertising sync state to set. BT_BAP_PA_STATE_NOT_SYNCED and BT_BAP_PA_STATE_SYNCED is not necessary to provide, as they are handled internally.

Returns:

int Error value. 0 on success, errno on fail.

int bt_bap_scan_delegator_set_bis_sync_state(uint8_t src_id, uint32_t bis_synced[0])

Set the sync state of a receive state in the server.

Parameters:
  • src_id – The source id used to identify the receive state.

  • bis_synced – Array of bitfields to set the BIS sync state for each subgroup.

Returns:

int Error value. 0 on success, ERRNO on fail.

int bt_bap_scan_delegator_add_src(const struct bt_bap_scan_delegator_add_src_param *param)

Add a receive state source locally.

This will notify any connected clients about the new source. This allows them to modify and even remove it.

If CONFIG_BT_BAP_BROADCAST_SINK is enabled, any Broadcast Sink sources are autonomously added.

Parameters:
  • param – The parameters for adding the new source

Returns:

int errno on failure, or source ID on success.

int bt_bap_scan_delegator_mod_src(const struct bt_bap_scan_delegator_mod_src_param *param)

Add a receive state source locally.

This will notify any connected clients about the new source. This allows them to modify and even remove it.

If CONFIG_BT_BAP_BROADCAST_SINK is enabled, any Broadcast Sink sources are autonomously modifed.

Parameters:
  • param – The parameters for adding the new source

Returns:

int errno on failure, or source ID on success.

int bt_bap_scan_delegator_rem_src(uint8_t src_id)

Remove a receive state source.

This will remove the receive state. If the receive state periodic advertising is synced, bt_bap_scan_delegator_cb.pa_sync_term_req() will be called.

If CONFIG_BT_BAP_BROADCAST_SINK is enabled, any Broadcast Sink sources are autonomously removed.

Parameters:
  • src_id – The source ID to remove

Returns:

int Error value. 0 on success, errno on fail.

void bt_bap_scan_delegator_foreach_state(bt_bap_scan_delegator_state_func_t func, void *user_data)

Iterate through all existing receive states.

Parameters:
  • func – The callback function

  • user_data – User specified data that sent to the callback function

const struct bt_bap_scan_delegator_recv_state *bt_bap_scan_delegator_find_state(bt_bap_scan_delegator_state_func_t func, void *user_data)

Find and return a receive state based on a compare function.

Parameters:
  • func – The compare callback function

  • user_data – User specified data that sent to the callback function

Returns:

The first receive state where the func returned true, or NULL

int bt_bap_broadcast_assistant_discover(struct bt_conn *conn)

Discover Broadcast Audio Scan Service on the server.

Warning: Only one connection can be active at any time; discovering for a new connection, will delete all previous data.

Parameters:
  • conn – The connection

Returns:

int Error value. 0 on success, GATT error or ERRNO on fail.

int bt_bap_broadcast_assistant_scan_start(struct bt_conn *conn, bool start_scan)

Scan start for BISes for a remote server.

This will let the Broadcast Audio Scan Service server know that this device is actively scanning for broadcast sources. The function can optionally also start scanning, if the caller does not want to start scanning itself.

Scan results, if start_scan is true, is sent to the bt_bap_broadcast_assistant_scan_cb callback.

Parameters:
  • conn – Connection to the Broadcast Audio Scan Service server. Used to let the server know that we are scanning.

  • start_scan – Start scanning if true. If false, the application should enable scan itself.

Returns:

int Error value. 0 on success, GATT error or ERRNO on fail.

int bt_bap_broadcast_assistant_scan_stop(struct bt_conn *conn)

Stop remote scanning for BISes for a server.

Parameters:
  • conn – Connection to the server.

Returns:

int Error value. 0 on success, GATT error or ERRNO on fail.

void bt_bap_broadcast_assistant_register_cb(struct bt_bap_broadcast_assistant_cb *cb)

Registers the callbacks used by Broadcast Audio Scan Service client.

int bt_bap_broadcast_assistant_add_src(struct bt_conn *conn, struct bt_bap_broadcast_assistant_add_src_param *param)

Add a source on the server.

Parameters:
  • conn – Connection to the server.

  • param – Parameter struct.

Returns:

Error value. 0 on success, GATT error or ERRNO on fail.

int bt_bap_broadcast_assistant_mod_src(struct bt_conn *conn, struct bt_bap_broadcast_assistant_mod_src_param *param)

Modify a source on the server.

Parameters:
  • conn – Connection to the server.

  • param – Parameter struct.

Returns:

Error value. 0 on success, GATT error or ERRNO on fail.

int bt_bap_broadcast_assistant_set_broadcast_code(struct bt_conn *conn, uint8_t src_id, uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE])

Set a broadcast code to the specified receive state.

Parameters:
  • conn – Connection to the server.

  • src_id – Source ID of the receive state.

  • broadcast_code – The broadcast code.

Returns:

Error value. 0 on success, GATT error or ERRNO on fail.

int bt_bap_broadcast_assistant_rem_src(struct bt_conn *conn, uint8_t src_id)

Remove a source from the server.

Parameters:
  • conn – Connection to the server.

  • src_id – Source ID of the receive state.

Returns:

Error value. 0 on success, GATT error or ERRNO on fail.

int bt_bap_broadcast_assistant_read_recv_state(struct bt_conn *conn, uint8_t idx)

Read the specified receive state from the server.

Parameters:
  • conn – Connection to the server.

  • idx – The index of the receive start (0 up to the value from bt_bap_broadcast_assistant_discover_cb)

Returns:

Error value. 0 on success, GATT error or ERRNO on fail.

struct bt_bap_ascs_rsp
#include <bap.h>

Structure storing values of fields of ASE Control Point notification.

Public Members

enum bt_bap_ascs_rsp_code code

Value of the Response Code field.

enum bt_bap_ascs_reason reason

Response reason.

If the Response Code is one of the following:

If the Response Code is one of the following:

enum bt_audio_metadata_type metadata_type

Response metadata type.

If the Response Code is one of the following:

union bt_bap_ascs_rsp.[anonymous] [anonymous]

Value of the Reason field.

The meaning of this value depend on the Response Code field.

struct bt_bap_scan_delegator_subgroup
#include <bap.h>

Struct to hold subgroup specific information for the receive state

Public Members

uint32_t bis_sync

BIS synced bitfield

uint8_t metadata_len

Length of the metadata

uint8_t metadata[0]

The metadata

struct bt_bap_scan_delegator_recv_state
#include <bap.h>

Represents the Broadcast Audio Scan Service receive state

Public Members

uint8_t src_id

The source ID

bt_addr_le_t addr

The Bluetooth address

uint8_t adv_sid

The advertising set ID

enum bt_bap_pa_state pa_sync_state

The periodic adverting sync state

enum bt_bap_big_enc_state encrypt_state

The broadcast isochronous group encryption state

uint32_t broadcast_id

The 24-bit broadcast ID

uint8_t bad_code[BT_AUDIO_BROADCAST_CODE_SIZE]

The bad broadcast code.

Only valid if encrypt_state is BT_BAP_BIG_ENC_STATE_BCODE_REQ

uint8_t num_subgroups

Number of subgroups

struct bt_bap_scan_delegator_subgroup subgroups[0]

Subgroup specific information

struct bt_bap_scan_delegator_cb
#include <bap.h>

Public Members

void (*recv_state_updated)(struct bt_conn *conn, const struct bt_bap_scan_delegator_recv_state *recv_state)

Receive state updated.

Param conn:

Pointer to the connection to a remote device if the change was caused by it, otherwise NULL.

Param recv_state:

Pointer to the receive state that was updated.

Return:

0 in case of success or negative value in case of error.

int (*pa_sync_req)(struct bt_conn *conn, const struct bt_bap_scan_delegator_recv_state *recv_state, bool past_avail, uint16_t pa_interval)

Periodic advertising sync request.

Request from peer device to synchronize with the periodic advertiser denoted by the recv_state. To notify the Broadcast Assistant about any pending sync

Param conn:

[in] Pointer to the connection requesting the periodic advertising sync.

Param recv_state:

[in] Pointer to the receive state that is being requested for periodic advertising sync.

Param past_avail:

[in] True if periodic advertising sync transfer is available.

Param pa_interval:

[in] The periodic advertising interval.

Param past_sync:

[out] Set to true if syncing via periodic advertising sync transfer, false otherwise. If past_avail is false, this value is ignored.

Return:

0 in case of accept, or other value to reject.

int (*pa_sync_term_req)(struct bt_conn *conn, const struct bt_bap_scan_delegator_recv_state *recv_state)

Periodic advertising sync termination request.

Request from peer device to terminate the periodic advertiser sync denoted by the recv_state.

Param conn:

Pointer to the connection requesting the periodic advertising sync termination.

Param recv_state:

Pointer to the receive state that is being requested for periodic advertising sync.

Return:

0 in case of success or negative value in case of error.

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])

Broadcast code received.

Broadcast code received from a broadcast assistant

Param conn:

Pointer to the connection providing the broadcast code.

Param recv_state:

Pointer to the receive state the broadcast code is being provided for.

Param broadcast_code:

The 16-octet broadcast code

int (*bis_sync_req)(struct bt_conn *conn, const struct bt_bap_scan_delegator_recv_state *recv_state, const uint32_t bis_sync_req[0])

Broadcast Isochronous Stream synchronize request.

Request from Broadcast Assistant device to modify the Broadcast Isochronous Stream states. The request shall be fulfilled with accordance to the bis_sync_req within reasonable time. The Broadcast Assistant may also request fewer, or none, indexes to be synchronized.

Param conn:

[in] Pointer to the connection of the Broadcast Assistant requesting the sync.

Param recv_state:

[in] Pointer to the receive state that is being requested for the sync.

Param bis_sync_req:

[in] Array of bitfields of which BIS indexes that is requested to sync for each subgroup by the Broadcast Assistant.

Return:

0 in case of accept, or other value to reject.

struct bt_bap_ep_info
#include <bap.h>

Structure holding information of audio stream endpoint

Public Members

uint8_t id

The ID of the endpoint

enum bt_bap_ep_state state

The state of the endpoint

enum bt_audio_dir dir

Capabilities type

struct bt_bap_stream
#include <bap.h>

Basic Audio Profile stream structure.

Streams represents a stream configuration of a Remote Endpoint and a Local Capability.

Note

Streams are unidirectional but can be paired with other streams to use a bidirectional connected isochronous stream.

Public Members

enum bt_audio_dir dir

Stream direction

struct bt_conn *conn

Connection reference

struct bt_bap_ep *ep

Endpoint reference

struct bt_codec *codec

Codec Configuration

struct bt_codec_qos *qos

QoS Configuration

struct bt_bap_stream_ops *ops

Audio stream operations

void *group

Unicast or Broadcast group - Used internally

void *user_data

Stream user data

struct bt_bap_stream_ops
#include <bap.h>

Stream operation.

Public Members

void (*started)(struct bt_bap_stream *stream)

Stream started callback.

Started callback is called whenever an Audio Stream has been started and will be usable for streaming.

Param stream:

Stream object that has been started.

void (*stopped)(struct bt_bap_stream *stream, uint8_t reason)

Stream stopped callback.

Stopped callback is called whenever an Audio Stream has been stopped.

Param stream:

Stream object that has been stopped.

Param reason:

BT_HCI_ERR_* reason for the disconnection.

struct bt_bap_scan_delegator_add_src_param
#include <bap.h>

Public Members

struct bt_le_per_adv_sync *pa_sync

The periodic adverting sync

enum bt_bap_big_enc_state encrypt_state

The broadcast isochronous group encryption state

uint32_t broadcast_id

The 24-bit broadcast ID

uint8_t num_subgroups

Number of subgroups

struct bt_bap_scan_delegator_subgroup subgroups[0]

Subgroup specific information

struct bt_bap_scan_delegator_mod_src_param
#include <bap.h>

Public Members

uint8_t src_id

The periodic adverting sync

enum bt_bap_big_enc_state encrypt_state

The broadcast isochronous group encryption state

uint32_t broadcast_id

The 24-bit broadcast ID

uint8_t num_subgroups

Number of subgroups

struct bt_bap_scan_delegator_subgroup subgroups[0]

Subgroup specific information.

If a subgroup’s metadata_len is set to 0, the existing metadata for the subgroup will remain unchanged

struct bt_bap_broadcast_assistant_cb
#include <bap.h>

Public Members

void (*discover)(struct bt_conn *conn, int err, uint8_t recv_state_count)

Callback function for bt_bap_broadcast_assistant_discover.

Param conn:

The connection that was used to discover Broadcast Audio Scan Service.

Param err:

Error value. 0 on success, GATT error or ERRNO on fail.

Param recv_state_count:

Number of receive states on the server.

void (*scan)(const struct bt_le_scan_recv_info *info, uint32_t broadcast_id)

Callback function for Broadcast Audio Scan Service client scan results.

Called when the scanner finds an advertiser that advertises the BT_UUID_BROADCAST_AUDIO UUID.

Param info:

Advertiser information.

Param broadcast_id:

24-bit broadcast ID.

void (*recv_state)(struct bt_conn *conn, int err, const struct bt_bap_scan_delegator_recv_state *state)

Callback function for when a receive state is read or updated.

Called whenever a receive state is read or updated.

Param conn:

The connection to the Broadcast Audio Scan Service server.

Param err:

Error value. 0 on success, GATT error on fail.

Param state:

The receive state or NULL if the receive state is empty.

void (*recv_state_removed)(struct bt_conn *conn, int err, uint8_t src_id)

Callback function for when a receive state is removed.

Param conn:

The connection to the Broadcast Audio Scan Service server.

Param err:

Error value. 0 on success, GATT error on fail.

Param src_id:

The receive state.

void (*scan_start)(struct bt_conn *conn, int err)

Callback function for bt_bap_broadcast_assistant_scan_start().

Param conn:

The connection to the peer device.

Param err:

Error value. 0 on success, GATT error on fail.

void (*scan_stop)(struct bt_conn *conn, int err)

Callback function for bt_bap_broadcast_assistant_scan_stop().

Param conn:

The connection to the peer device.

Param err:

Error value. 0 on success, GATT error on fail.

void (*add_src)(struct bt_conn *conn, int err)

Callback function for bt_bap_broadcast_assistant_add_src().

Param conn:

The connection to the peer device.

Param err:

Error value. 0 on success, GATT error on fail.

void (*mod_src)(struct bt_conn *conn, int err)

Callback function for bt_bap_broadcast_assistant_mod_src().

Param conn:

The connection to the peer device.

Param err:

Error value. 0 on success, GATT error on fail.

void (*broadcast_code)(struct bt_conn *conn, int err)

Callback function for bt_bap_broadcast_assistant_broadcast_code().

Param conn:

The connection to the peer device.

Param err:

Error value. 0 on success, GATT error on fail.

void (*rem_src)(struct bt_conn *conn, int err)

Callback function for bt_bap_broadcast_assistant_rem_src().

Param conn:

The connection to the peer device.

Param err:

Error value. 0 on success, GATT error on fail.

struct bt_bap_broadcast_assistant_add_src_param
#include <bap.h>

Parameters for adding a source to a Broadcast Audio Scan Service server

Public Members

bt_addr_le_t addr

Address of the advertiser.

uint8_t adv_sid

SID of the advertising set.

uint8_t pa_sync

Whether to sync to periodic advertisements.

uint32_t broadcast_id

24-bit broadcast ID

uint16_t pa_interval

Periodic advertising interval in milliseconds.

BT_BAP_PA_INTERVAL_UNKNOWN if unknown.

uint8_t num_subgroups

Number of subgroups

struct bt_bap_scan_delegator_subgroup *subgroups

Pointer to array of subgroups

struct bt_bap_broadcast_assistant_mod_src_param
#include <bap.h>

Parameters for modifying a source

Public Members

uint8_t src_id

Source ID of the receive state.

uint8_t pa_sync

Whether to sync to periodic advertisements.

uint16_t pa_interval

Periodic advertising interval.

BT_BAP_PA_INTERVAL_UNKNOWN if unknown.

uint8_t num_subgroups

Number of subgroups

struct bt_bap_scan_delegator_subgroup *subgroups

Pointer to array of subgroups

group bt_bap_unicast_client

Typedefs

typedef void (*bt_bap_unicast_client_discover_func_t)(struct bt_conn *conn, struct bt_codec *codec, struct bt_bap_ep *ep, struct bt_bap_unicast_client_discover_params *params)

Discover Audio capabilities and endpoints callback function.

If discovery procedure has complete both cap and ep are set to NULL.

The codec is only valid while in the callback, so the values must be stored by the receiver if future use is wanted.

If discovery procedure has complete both codec and ep are set to NULL.

Param conn:

Connection to the remote unicast server.

Param codec:

Remote capabilities.

Param ep:

Remote endpoint.

Param params:

Pointer to the discover parameters.

Functions

int bt_bap_unicast_group_create(struct bt_bap_unicast_group_param *param, struct bt_bap_unicast_group **unicast_group)

Create audio unicast group.

Create a new audio unicast group with one or more audio streams as a unicast client. Streams in a unicast group shall share the same interval, framing and latency (see bt_codec_qos).

Parameters:
  • param[in] The unicast group create parameters.

  • unicast_group[out] Pointer to the unicast group created.

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_unicast_group_add_streams(struct bt_bap_unicast_group *unicast_group, struct bt_bap_unicast_group_stream_pair_param params[], size_t num_param)

Add streams to a unicast group as a unicast client.

This function can be used to add additional streams to a bt_bap_unicast_group.

This can be called at any time before any of the streams in the group has been started (see bt_bap_stream_ops.started()). This can also be called after the streams have been stopped (see bt_bap_stream_ops.stopped()).

Once a stream has been added to a unicast group, it cannot be removed. To remove a stream from a group, the group must be deleted with bt_bap_unicast_group_delete(), but this will require all streams in the group to be released first.

Parameters:
  • unicast_group – Pointer to the unicast group

  • params – Array of stream parameters with streams being added to the group.

  • num_param – Number of paramers in params.

Returns:

0 in case of success or negative value in case of error.

int bt_bap_unicast_group_delete(struct bt_bap_unicast_group *unicast_group)

Delete audio unicast group.

Delete a audio unicast group as a client. All streams in the group shall be in the idle or configured state.

Parameters:
  • unicast_group – Pointer to the unicast group to delete

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_unicast_client_register_cb(const struct bt_bap_unicast_client_cb *cb)

Register unicast client callbacks.

Only one callback structure can be registered, and attempting to registering more than one will result in an error.

Parameters:
  • cb – Unicast client callback structure.

Returns:

0 in case of success or negative value in case of error.

int bt_bap_unicast_client_discover(struct bt_conn *conn, struct bt_bap_unicast_client_discover_params *params)

Discover remote capabilities and endpoints.

This procedure is used by a client to discover remote capabilities and endpoints and notifies via params callback.

Note

This procedure is asynchronous therefore the parameters need to remains valid while it is active.

Parameters:
  • conn – Connection object

  • params – Discover parameters

struct bt_bap_unicast_group_stream_param
#include <bap.h>

Parameter struct for each stream in the unicast group

Public Members

struct bt_bap_stream *stream

Pointer to a stream object.

struct bt_codec_qos *qos

The QoS settings for the stream object.

struct bt_bap_unicast_group_stream_pair_param
#include <bap.h>

Parameter struct for the unicast group functions.

Parameter struct for the bt_bap_unicast_group_create() and bt_bap_unicast_group_add_streams() functions.

Public Members

struct bt_bap_unicast_group_stream_param *rx_param

Pointer to a receiving stream parameters.

struct bt_bap_unicast_group_stream_param *tx_param

Pointer to a transmiting stream parameters.

struct bt_bap_unicast_group_param
#include <bap.h>

Public Members

size_t params_count

The number of parameters in params

struct bt_bap_unicast_group_stream_pair_param *params

Array of stream parameters

uint8_t packing

Unicast Group packing mode.

BT_ISO_PACKING_SEQUENTIAL or BT_ISO_PACKING_INTERLEAVED.

Note

This is a recommendation to the controller, which the controller may ignore.

struct bt_bap_unicast_client_cb
#include <bap.h>

Unicast Client callback structure

Public Members

void (*location)(struct bt_conn *conn, enum bt_audio_dir dir, enum bt_audio_location loc)

Remote Unicast Server Audio Locations.

This callback is called whenever the audio locations is read from the server or otherwise notified to the client.

Param conn:

Connection to the remote unicast server.

Param dir:

Direction of the location.

Param loc:

The location bitfield value.

Return:

0 in case of success or negative value in case of error.

void (*available_contexts)(struct bt_conn *conn, enum bt_audio_context snk_ctx, enum bt_audio_context src_ctx)

Remote Unicast Server Available Contexts.

This callback is called whenever the available contexts are read from the server or otherwise notified to the client.

Param conn:

Connection to the remote unicast server.

Param snk_ctx:

The sink context bitfield value.

Param src_ctx:

The source context bitfield value.

Return:

0 in case of success or negative value in case of error.

void (*config)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_config() and bt_bap_stream_reconfig().

Called when the codec configure operation is completed on the server.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

void (*qos)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_qos().

Called when the QoS configure operation is completed on the server. This will be called for each stream in the group that was being QoS configured.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

void (*enable)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_enable().

Called when the enable operation is completed on the server.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

void (*start)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_start().

Called when the start operation is completed on the server. This will only be called if the stream supplied to bt_bap_stream_start() is for a BT_AUDIO_DIR_SOURCE endpoint.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

void (*stop)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_stop().

Called when the stop operation is completed on the server. This will only be called if the stream supplied to bt_bap_stream_stop() is for a BT_AUDIO_DIR_SOURCE endpoint.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

void (*disable)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_disable().

Called when the disable operation is completed on the server.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

void (*metadata)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_metadata().

Called when the metadata operation is completed on the server.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

void (*release)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code, enum bt_bap_ascs_reason reason)

Callback function for bt_bap_stream_release().

Called when the release operation is completed on the server.

Param stream:

Stream the operation was performed on.

Param rsp_code:

Response code.

Param reason:

Reason code.

struct bt_bap_unicast_client_discover_params
#include <bap.h>

Public Members

enum bt_audio_dir dir

Capabilities type

bt_bap_unicast_client_discover_func_t func

Callback function

uint8_t num_caps

Number of capabilities found

uint8_t num_eps

Number of endpoints found

uint8_t err

Error code.

struct bt_gatt_read_params read

Read parameters used interally for discovery

struct bt_gatt_discover_params discover

Discover parameters used interally for discovery

group bt_bap_unicast_server

Typedefs

typedef void (*bt_bap_ep_func_t)(struct bt_bap_ep *ep, void *user_data)

The callback function called for each endpoint.

Param ep:

The structure object with endpoint info.

Param user_data:

Data to pass to the function.

Functions

int bt_bap_unicast_server_register_cb(const struct bt_bap_unicast_server_cb *cb)

Register unicast server callbacks.

Only one callback structure can be registered, and attempting to registering more than one will result in an error.

Parameters:
  • cb – Unicast server callback structure.

Returns:

0 in case of success or negative value in case of error.

int bt_bap_unicast_server_unregister_cb(const struct bt_bap_unicast_server_cb *cb)

Unregister unicast server callbacks.

May only unregister a callback structure that has previously been registered by bt_bap_unicast_server_register_cb().

Parameters:
  • cb – Unicast server callback structure.

Returns:

0 in case of success or negative value in case of error.

void bt_bap_unicast_server_foreach_ep(struct bt_conn *conn, bt_bap_ep_func_t func, void *user_data)

Iterate through all endpoints of the given connection.

Parameters:
  • conn – Connection object

  • func – Function to call for each endpoint.

  • user_data – Data to pass to the callback function.

int bt_bap_unicast_server_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_codec *codec, const struct bt_codec_qos_pref *qos_pref)

Initialize and configure a new ASE.

Parameters:
  • conn – Connection object

  • stream – Configured stream object to be attached to the ASE

  • codec – Codec configuration

  • qos_pref – Audio Stream Quality of Service Preference

Returns:

0 in case of success or negative value in case of error.

struct bt_bap_unicast_server_cb
#include <bap.h>

Unicast Server callback structure

Public Members

int (*config)(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir, const struct bt_codec *codec, struct bt_bap_stream **stream, struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)

Endpoint config request callback.

Config callback is called whenever an endpoint is requested to be configured

Param conn:

[in] Connection object.

Param ep:

[in] Local Audio Endpoint being configured.

Param dir:

[in] Direction of the endpoint.

Param codec:

[in] Codec configuration.

Param stream:

[out] Pointer to stream that will be configured for the endpoint.

Param pref:

[out] Pointer to a QoS preference object that shall be populated with values. Invalid values will reject the codec configuration request.

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*reconfig)(struct bt_bap_stream *stream, enum bt_audio_dir dir, const struct bt_codec *codec, struct bt_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp)

Stream reconfig request callback.

Reconfig callback is called whenever an Audio Stream needs to be reconfigured with different codec configuration.

Param stream:

[in] Stream object being reconfigured.

Param dir:

[in] Direction of the endpoint.

Param codec:

[in] Codec configuration.

Param pref:

[out] Pointer to a QoS preference object that shall be populated with values. Invalid values will reject the codec configuration request.

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*qos)(struct bt_bap_stream *stream, const struct bt_codec_qos *qos, struct bt_bap_ascs_rsp *rsp)

Stream QoS request callback.

QoS callback is called whenever an Audio Stream Quality of Service needs to be configured.

Param stream:

[in] Stream object being reconfigured.

Param qos:

[in] Quality of Service configuration.

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*enable)(struct bt_bap_stream *stream, const struct bt_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp)

Stream Enable request callback.

Enable callback is called whenever an Audio Stream is requested to be enabled to stream.

Param stream:

[in] Stream object being enabled.

Param meta:

[in] Metadata entries

Param meta_count:

[in] Number of metadata entries

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*start)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp)

Stream Start request callback.

Start callback is called whenever an Audio Stream is requested to start streaming.

Param stream:

[in] Stream object.

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*metadata)(struct bt_bap_stream *stream, const struct bt_codec_data *meta, size_t meta_count, struct bt_bap_ascs_rsp *rsp)

Stream Metadata update request callback.

Metadata callback is called whenever an Audio Stream is requested to update its metadata.

Param stream:

[in] Stream object.

Param meta:

[in] Metadata entries

Param meta_count:

[in] Number of metadata entries

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*disable)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp)

Stream Disable request callback.

Disable callback is called whenever an Audio Stream is requested to disable the stream.

Param stream:

[in] Stream object being disabled.

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*stop)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp)

Stream Stop callback.

Stop callback is called whenever an Audio Stream is requested to stop streaming.

Param stream:

[in] Stream object.

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

int (*release)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp)

Stream release callback.

Release callback is called whenever a new Audio Stream needs to be released and thus deallocated.

Param stream:

[in] Stream object.

Param rsp:

[out] Object for the ASE operation response. Only used if the return value is non-zero.

Return:

0 in case of success or negative value in case of error.

group bt_bap_broadcast

BAP Broadcast APIs.

struct bt_bap_base_bis_data
#include <bap.h>
struct bt_bap_base_subgroup
#include <bap.h>

Public Members

struct bt_codec codec

Codec information for the subgroup

If the data_count of the codec is 0, then codec specific data may be found for each BIS in the bis_data.

struct bt_bap_base
#include <bap.h>

Public Members

uint32_t pd

QoS Presentation Delay in microseconds.

Value range 0 to BT_AUDIO_PD_MAX.

group bt_bap_broadcast_sink

BAP Broadcast Sink APIs.

Functions

void bt_bap_broadcast_sink_register_cb(struct bt_bap_broadcast_sink_cb *cb)

Register Broadcast sink callbacks *.

Parameters:
  • cb – Broadcast sink callback structure.

int bt_bap_broadcast_sink_scan_start(const struct bt_le_scan_param *param)

Start scan for broadcast sources.

Starts a scan for broadcast sources. Scan results will be received by the scan_recv callback. Only reports from devices advertising broadcast audio support will be sent. Note that a broadcast source may advertise broadcast audio capabilities, but may not be streaming.

Parameters:
  • param – Scan parameters.

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_sink_scan_stop(void)

Stop scan for broadcast sources.

Stops ongoing scanning for broadcast sources.

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_sink_create(struct bt_le_per_adv_sync *pa_sync, uint32_t broadcast_id)

Create a Broadcast Sink from a periodic advertising sync.

This should only be done after verifying that the periodic advertising sync is from a Broadcast Source.

The created Broadcast Sink will need to be supplied to bt_bap_broadcast_sink_sync() in order to synchronize to the broadcast audio.

bt_bap_broadcast_sink_cb.pa_synced() will be called with the Broadcast Sink object created if this is successful.

Parameters:
  • pa_sync – Pointer to the periodic advertising sync object.

  • broadcast_id – 24-bit broadcast ID.

Returns:

0 in case of success or errno value in case of error.

int bt_bap_broadcast_sink_sync(struct bt_bap_broadcast_sink *sink, uint32_t indexes_bitfield, struct bt_bap_stream *streams[], const uint8_t broadcast_code[16])

Sync to a broadcaster’s audio.

Example: The string “Broadcast Code” shall be [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]

Parameters:
  • sink – Pointer to the sink object from the base_recv callback.

  • indexes_bitfield – Bitfield of the BIS index to sync to. To sync to e.g. BIS index 1 and 2, this should have the value of BIT(1) | BIT(2).

  • streams – Stream object pointers to be used for the receiver. If multiple BIS indexes shall be synchronized, multiple streams shall be provided.

  • broadcast_code – The 16-octet broadcast code. Shall be supplied if the broadcast is encrypted (see bt_bap_broadcast_sink_cb::syncable). If the value is a string or a the value is less than 16 octets, the remaining octets shall be 0.

Returns:

0 in case of success or negative value in case of error.

int bt_bap_broadcast_sink_stop(struct bt_bap_broadcast_sink *sink)

Stop audio broadcast sink.

Stop an audio broadcast sink. The broadcast sink will stop receiving BIGInfo, and audio data can no longer be streamed.

Parameters:
  • sink – Pointer to the broadcast sink

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_sink_delete(struct bt_bap_broadcast_sink *sink)

Release a broadcast sink.

Once a broadcast sink has been allocated after the pa_synced callback, it can be deleted using this function. If the sink has synchronized to any broadcast audio streams, these must first be stopped using bt_bap_stream_stop.

Parameters:
  • sink – Pointer to the sink object to delete.

Returns:

0 in case of success or negative value in case of error.

struct bt_bap_broadcast_sink_cb
#include <bap.h>

Broadcast Audio Sink callback structure

Public Members

bool (*scan_recv)(const struct bt_le_scan_recv_info *info, struct net_buf_simple *ad, uint32_t broadcast_id)

Scan receive callback.

Scan receive callback is called whenever a broadcast source has been found.

Param info:

Advertiser packet information.

Param ad:

Buffer containing advertiser data.

Param broadcast_id:

24-bit broadcast ID

Return:

true to sync to the broadcaster, else false. Syncing to the broadcaster will stop the current scan.

void (*pa_synced)(struct bt_bap_broadcast_sink *sink, struct bt_le_per_adv_sync *sync, uint32_t broadcast_id)

Periodic advertising sync callback.

Called when synchronized to a periodic advertising. When synchronized a bt_bap_broadcast_sink structure is allocated for future use.

Param sink:

Pointer to the allocated sink structure.

Param sync:

Pointer to the periodic advertising sync.

Param broadcast_id:

24-bit broadcast ID previously reported by scan_recv.

void (*base_recv)(struct bt_bap_broadcast_sink *sink, const struct bt_bap_base *base)

Broadcast Audio Source Endpoint (BASE) received.

Callback for when we receive a BASE from a broadcaster after syncing to the broadcaster’s periodic advertising.

Param sink:

Pointer to the sink structure.

Param base:

Broadcast Audio Source Endpoint (BASE).

void (*syncable)(struct bt_bap_broadcast_sink *sink, bool encrypted)

Broadcast sink is syncable.

Called whenever a broadcast sink is not synchronized to audio, but the audio is synchronizable. This is inferred when a BIGInfo report is received.

Once this callback has been called, it is possible to call bt_bap_broadcast_sink_sync() to synchronize to the audio stream(s).

Param sink:

Pointer to the sink structure.

Param encrypted:

Whether or not the broadcast is encrypted

void (*scan_term)(int err)

Scan terminated callback.

Scan terminated callback is called whenever a scan started by bt_bap_broadcast_sink_scan_start() is terminated before bt_bap_broadcast_sink_scan_stop().

Typical reasons for this are that the periodic advertising has synchronized (success criteria) or the scan timed out. It may also be called if the periodic advertising failed to synchronize.

Param err:

0 in case of success or negative value in case of error.

void (*pa_sync_lost)(struct bt_bap_broadcast_sink *sink)

Periodic advertising synchronization lost callback.

The periodic advertising synchronization lost callback is called if the periodic advertising sync is lost. If this happens, the sink object is deleted. To synchronize to the broadcaster again, bt_bap_broadcast_sink_scan_start() must be called.

Param sink:

Pointer to the sink structure.

group bt_bap_broadcast_source

BAP Broadcast Source APIs.

Functions

int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_create_param *param, struct bt_bap_broadcast_source **source)

Create audio broadcast source.

Create a new audio broadcast source with one or more audio streams.

The broadcast source will be visible for scanners once this has been called, and the device will advertise audio announcements.

No audio data can be sent until bt_bap_broadcast_source_start() has been called and no audio information (BIGInfo) will be visible to scanners (see bt_le_per_adv_sync_cb).

Parameters:
  • param[in] Pointer to parameters used to create the broadcast source.

  • source[out] Pointer to the broadcast source created

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source, struct bt_codec *codec, struct bt_codec_qos *qos)

Reconfigure audio broadcast source.

Reconfigure an audio broadcast source with a new codec and codec quality of service parameters. This can only be done when the source is stopped.

Parameters:
  • source – Pointer to the broadcast source

  • codec – Codec configuration.

  • qos – Quality of Service configuration

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_source_update_metadata(struct bt_bap_broadcast_source *source, const struct bt_codec_data meta[], size_t meta_count)

Modify the metadata of an audio broadcast source.

Modify the metadata an audio broadcast source. This can only be done when the source is started. To update the metadata in the stopped state, use bt_bap_broadcast_source_reconfig().

Parameters:
  • source – Pointer to the broadcast source.

  • meta – Metadata entries.

  • meta_count – Number of metadata entries.

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_source_start(struct bt_bap_broadcast_source *source, struct bt_le_ext_adv *adv)

Start audio broadcast source.

Start an audio broadcast source with one or more audio streams. The broadcast source will start advertising BIGInfo, and audio data can be streamed.

Parameters:
  • source – Pointer to the broadcast source

  • adv – Pointer to an extended advertising set with periodic advertising configured.

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_source_stop(struct bt_bap_broadcast_source *source)

Stop audio broadcast source.

Stop an audio broadcast source. The broadcast source will stop advertising BIGInfo, and audio data can no longer be streamed.

Parameters:
  • source – Pointer to the broadcast source

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_source_delete(struct bt_bap_broadcast_source *source)

Delete audio broadcast source.

Delete an audio broadcast source. The broadcast source will stop advertising entirely, and the source can no longer be used.

Parameters:
  • source – Pointer to the broadcast source

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_source_get_id(const struct bt_bap_broadcast_source *source, uint32_t *const broadcast_id)

Get the broadcast ID of a broadcast source.

This will return the 3-octet broadcast ID that should be advertised in the extended advertising data with BT_UUID_BROADCAST_AUDIO_VAL as BT_DATA_SVC_DATA16.

See table 3.14 in the Basic Audio Profile v1.0.1 for the structure.

Parameters:
  • source[in] Pointer to the broadcast source.

  • broadcast_id[out] Pointer to the 3-octet broadcast ID.

Returns:

Zero on success or (negative) error code otherwise.

int bt_bap_broadcast_source_get_base(struct bt_bap_broadcast_source *source, struct net_buf_simple *base_buf)

Get the Broadcast Audio Stream Endpoint of a broadcast source.

This will encode the BASE of a broadcast source into a buffer, that can be used for advertisement. The encoded BASE will thus be encoded as little-endian. The BASE shall be put into the periodic advertising data (see bt_le_per_adv_set_data()).

See table 3.15 in the Basic Audio Profile v1.0.1 for the structure.

Parameters:
  • source – Pointer to the broadcast source.

  • base_buf – Pointer to a buffer where the BASE will be inserted.

Returns:

Zero on success or (negative) error code otherwise.

struct bt_bap_broadcast_source_stream_param
#include <bap.h>

Broadcast Source stream parameters

Public Members

struct bt_bap_stream *stream

Audio stream

struct bt_bap_broadcast_source_subgroup_param
#include <bap.h>

Broadcast Source subgroup parameters

Public Members

size_t params_count

The number of parameters in stream_params

struct bt_bap_broadcast_source_stream_param *params

Array of stream parameters

struct bt_codec *codec

Subgroup Codec configuration.

struct bt_bap_broadcast_source_create_param
#include <bap.h>

Broadcast Source create parameters

Public Members

size_t params_count

The number of parameters in subgroup_params

struct bt_bap_broadcast_source_subgroup_param *params

Array of stream parameters

struct bt_codec_qos *qos

Quality of Service configuration.

uint8_t packing

Broadcast Source packing mode.

BT_ISO_PACKING_SEQUENTIAL or BT_ISO_PACKING_INTERLEAVED.

Note

This is a recommendation to the controller, which the controller may ignore.

bool encryption

Whether or not to encrypt the streams.

uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE]

Broadcast code.

If the value is a string or a the value is less than 16 octets, the remaining octets shall be 0.

Example: The string “Broadcast Code” shall be [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]