Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Bluetooth Basic Audio Profile

Bluetooth Basic Audio Profile (BAP) . More...

Topics

 BAP Broadcast APIs
 BAP Broadcast APIs .
 
 BAP Broadcast Sink APIs
 BAP Broadcast Sink APIs .
 
 BAP Broadcast Source APIs
 BAP Broadcast Source APIs .
 
 BAP Unicast Client APIs
 
 
 BAP Unicast Server APIs
 
 

Data Structures

struct  bt_bap_qos_cfg
 QoS configuration structure. More...
 
struct  bt_bap_qos_cfg_pref
 Audio Stream Quality of Service Preference structure. More...
 
struct  bt_bap_ascs_rsp
 Structure storing values of fields of ASE Control Point notification. More...
 
struct  bt_bap_bass_subgroup
 Struct to hold subgroup specific information for the receive state. More...
 
struct  bt_bap_scan_delegator_recv_state
 Represents the Broadcast Audio Scan Service receive state. More...
 
struct  bt_bap_scan_delegator_cb
 Struct to hold the Basic Audio Profile Scan Delegator callbacks. More...
 
struct  bt_bap_ep_info
 Structure holding information of audio stream endpoint. More...
 
struct  bt_bap_stream
 Basic Audio Profile stream structure. More...
 
struct  bt_bap_stream_ops
 Stream operation. More...
 
struct  bt_bap_unicast_server_register_param
 Structure for registering Unicast Server. More...
 
struct  bt_bap_scan_delegator_add_src_param
 Parameters for bt_bap_scan_delegator_add_src() More...
 
struct  bt_bap_scan_delegator_mod_src_param
 Parameters for bt_bap_scan_delegator_mod_src() More...
 
struct  bt_bap_broadcast_assistant_cb
 Struct to hold the Basic Audio Profile Broadcast Assistant callbacks. More...
 
struct  bt_bap_broadcast_assistant_add_src_param
 Parameters for adding a source to a Broadcast Audio Scan Service server. More...
 
struct  bt_bap_broadcast_assistant_mod_src_param
 Parameters for modifying a source. More...
 

Macros

#define BT_BAP_QOS_CFG(_interval, _framing, _phy, _sdu, _rtn, _latency, _pd)
 Helper to declare elements of bt_bap_qos_cfg.
 
#define BT_BAP_QOS_CFG_UNFRAMED(_interval, _sdu, _rtn, _latency, _pd)
 Helper to declare Input Unframed bt_bap_qos_cfg.
 
#define BT_BAP_QOS_CFG_FRAMED(_interval, _sdu, _rtn, _latency, _pd)
 Helper to declare Input Framed bt_bap_qos_cfg.
 
#define BT_BAP_QOS_CFG_PREF(_unframed_supported, _phy, _rtn, _latency, _pd_min, _pd_max, _pref_pd_min, _pref_pd_max)
 Helper to declare elements of bt_bap_qos_cfg_pref.
 
#define BT_BAP_PA_INTERVAL_UNKNOWN   0xFFFF
 Value indicating that the periodic advertising interval is unknown.
 
#define BT_BAP_BIS_SYNC_NO_PREF   0xFFFFFFFF
 Broadcast Assistant no BIS sync preference.
 
#define BT_BAP_BIS_SYNC_FAILED   0xFFFFFFFF
 BIS sync value indicating that the BIG sync has failed for any reason.
 
#define BT_BAP_ASCS_RSP(c, r)
 Macro used to initialise the object storing values of ASE Control Point notification.
 

Typedefs

typedef bool(* 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.
 
typedef void(* bt_bap_broadcast_assistant_write_cb) (struct bt_conn *conn, int err)
 Callback function for writes.
 

Enumerations

enum  bt_bap_qos_cfg_framing { BT_BAP_QOS_CFG_FRAMING_UNFRAMED = 0x00 , BT_BAP_QOS_CFG_FRAMING_FRAMED = 0x01 }
 QoS Framing. More...
 
enum  { BT_BAP_QOS_CFG_1M = BIT(0) , BT_BAP_QOS_CFG_2M = BIT(1) , BT_BAP_QOS_CFG_CODED = BIT(2) }
 QoS Preferred PHY. More...
 
enum  bt_bap_pa_state {
  BT_BAP_PA_STATE_NOT_SYNCED = 0x00 , BT_BAP_PA_STATE_INFO_REQ = 0x01 , BT_BAP_PA_STATE_SYNCED = 0x02 , BT_BAP_PA_STATE_FAILED = 0x03 ,
  BT_BAP_PA_STATE_NO_PAST = 0x04
}
 Periodic advertising state reported by the Scan Delegator. More...
 
enum  bt_bap_big_enc_state { BT_BAP_BIG_ENC_STATE_NO_ENC = 0x00 , BT_BAP_BIG_ENC_STATE_BCODE_REQ = 0x01 , BT_BAP_BIG_ENC_STATE_DEC = 0x02 , BT_BAP_BIG_ENC_STATE_BAD_CODE = 0x03 }
 Broadcast Isochronous Group encryption state reported by the Scan Delegator. More...
 
enum  bt_bap_bass_att_err { BT_BAP_BASS_ERR_OPCODE_NOT_SUPPORTED = 0x80 , BT_BAP_BASS_ERR_INVALID_SRC_ID = 0x81 }
 Broadcast Audio Scan Service (BASS) specific ATT error codes. More...
 
enum  bt_bap_ep_state {
  BT_BAP_EP_STATE_IDLE = 0x00 , BT_BAP_EP_STATE_CODEC_CONFIGURED = 0x01 , BT_BAP_EP_STATE_QOS_CONFIGURED = 0x02 , BT_BAP_EP_STATE_ENABLING = 0x03 ,
  BT_BAP_EP_STATE_STREAMING = 0x04 , BT_BAP_EP_STATE_DISABLING = 0x05 , BT_BAP_EP_STATE_RELEASING = 0x06
}
 Endpoint states. More...
 
enum  bt_bap_ascs_rsp_code {
  BT_BAP_ASCS_RSP_CODE_SUCCESS = 0x00 , BT_BAP_ASCS_RSP_CODE_NOT_SUPPORTED = 0x01 , BT_BAP_ASCS_RSP_CODE_INVALID_LENGTH = 0x02 , BT_BAP_ASCS_RSP_CODE_INVALID_ASE = 0x03 ,
  BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE = 0x04 , BT_BAP_ASCS_RSP_CODE_INVALID_DIR = 0x05 , BT_BAP_ASCS_RSP_CODE_CAP_UNSUPPORTED = 0x06 , BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED = 0x07 ,
  BT_BAP_ASCS_RSP_CODE_CONF_REJECTED = 0x08 , BT_BAP_ASCS_RSP_CODE_CONF_INVALID = 0x09 , BT_BAP_ASCS_RSP_CODE_METADATA_UNSUPPORTED = 0x0a , BT_BAP_ASCS_RSP_CODE_METADATA_REJECTED = 0x0b ,
  BT_BAP_ASCS_RSP_CODE_METADATA_INVALID = 0x0c , BT_BAP_ASCS_RSP_CODE_NO_MEM = 0x0d , BT_BAP_ASCS_RSP_CODE_UNSPECIFIED = 0x0e
}
 Response Status Code. More...
 
enum  bt_bap_ascs_reason {
  BT_BAP_ASCS_REASON_NONE = 0x00 , BT_BAP_ASCS_REASON_CODEC = 0x01 , BT_BAP_ASCS_REASON_CODEC_DATA = 0x02 , BT_BAP_ASCS_REASON_INTERVAL = 0x03 ,
  BT_BAP_ASCS_REASON_FRAMING = 0x04 , BT_BAP_ASCS_REASON_PHY = 0x05 , BT_BAP_ASCS_REASON_SDU = 0x06 , BT_BAP_ASCS_REASON_RTN = 0x07 ,
  BT_BAP_ASCS_REASON_LATENCY = 0x08 , BT_BAP_ASCS_REASON_PD = 0x09 , BT_BAP_ASCS_REASON_CIS = 0x0a
}
 Response Reasons. More...
 

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.
 
void bt_bap_stream_cb_register (struct bt_bap_stream *stream, struct bt_bap_stream_ops *ops)
 Register Audio callbacks for a stream.
 
int bt_bap_stream_config (struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_bap_ep *ep, struct bt_audio_codec_cfg *codec_cfg)
 Configure Audio Stream.
 
int bt_bap_stream_reconfig (struct bt_bap_stream *stream, struct bt_audio_codec_cfg *codec_cfg)
 Reconfigure Audio Stream.
 
int bt_bap_stream_qos (struct bt_conn *conn, struct bt_bap_unicast_group *group)
 Configure Audio Stream QoS.
 
int bt_bap_stream_enable (struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len)
 Enable Audio Stream.
 
int bt_bap_stream_metadata (struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len)
 Change Audio Stream Metadata.
 
int bt_bap_stream_disable (struct bt_bap_stream *stream)
 Disable Audio Stream.
 
int bt_bap_stream_connect (struct bt_bap_stream *stream)
 Connect unicast audio stream.
 
int bt_bap_stream_start (struct bt_bap_stream *stream)
 Start Audio Stream.
 
int bt_bap_stream_stop (struct bt_bap_stream *stream)
 Stop Audio Stream.
 
int bt_bap_stream_release (struct bt_bap_stream *stream)
 Release Audio Stream.
 
int bt_bap_stream_send (struct bt_bap_stream *stream, struct net_buf *buf, uint16_t seq_num)
 Send data to Audio stream without timestamp.
 
int bt_bap_stream_send_ts (struct bt_bap_stream *stream, struct net_buf *buf, uint16_t seq_num, uint32_t ts)
 Send data to Audio stream with timestamp.
 
int bt_bap_stream_get_tx_sync (struct bt_bap_stream *stream, struct bt_iso_tx_info *info)
 Get ISO transmission timing info for a Basic Audio Profile stream.
 
int bt_bap_scan_delegator_register (struct bt_bap_scan_delegator_cb *cb)
 Register the Basic Audio Profile Scan Delegator and BASS.
 
int bt_bap_scan_delegator_unregister (void)
 unregister the Basic Audio Profile Scan Delegator and BASS.
 
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.
 
int bt_bap_scan_delegator_set_bis_sync_state (uint8_t src_id, uint32_t bis_synced[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS])
 Set the sync state of a receive state in the server.
 
int bt_bap_scan_delegator_add_src (const struct bt_bap_scan_delegator_add_src_param *param)
 Add a receive state source locally.
 
int bt_bap_scan_delegator_mod_src (const struct bt_bap_scan_delegator_mod_src_param *param)
 Add a receive state source locally.
 
int bt_bap_scan_delegator_rem_src (uint8_t src_id)
 Remove a receive state source.
 
void bt_bap_scan_delegator_foreach_state (bt_bap_scan_delegator_state_func_t func, void *user_data)
 Iterate through all existing receive states.
 
const struct bt_bap_scan_delegator_recv_statebt_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.
 
int bt_bap_broadcast_assistant_discover (struct bt_conn *conn)
 Discover Broadcast Audio Scan Service on the server.
 
int bt_bap_broadcast_assistant_scan_start (struct bt_conn *conn, bool start_scan)
 Scan start for BISes for a remote server.
 
int bt_bap_broadcast_assistant_scan_stop (struct bt_conn *conn)
 Stop remote scanning for BISes for a server.
 
int 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_unregister_cb (struct bt_bap_broadcast_assistant_cb *cb)
 Unregisters the callbacks used by the Broadcast Audio Scan Service client.
 
int bt_bap_broadcast_assistant_add_src (struct bt_conn *conn, const struct bt_bap_broadcast_assistant_add_src_param *param)
 Add a source on the server.
 
int bt_bap_broadcast_assistant_mod_src (struct bt_conn *conn, const struct bt_bap_broadcast_assistant_mod_src_param *param)
 Modify a source on the server.
 
int bt_bap_broadcast_assistant_set_broadcast_code (struct bt_conn *conn, uint8_t src_id, const uint8_t broadcast_code[16])
 Set a broadcast code to the specified receive state.
 
int bt_bap_broadcast_assistant_rem_src (struct bt_conn *conn, uint8_t src_id)
 Remove a source from the server.
 
int bt_bap_broadcast_assistant_read_recv_state (struct bt_conn *conn, uint8_t idx)
 Read the specified receive state from the server.
 

Detailed Description

Bluetooth Basic Audio Profile (BAP) .

Since
3.0
Version
0.8.0

The Basic Audio Profile (BAP) allows for both unicast and broadcast Audio Stream control.

Macro Definition Documentation

◆ BT_BAP_ASCS_RSP

#define BT_BAP_ASCS_RSP ( c,
r )

#include <zephyr/bluetooth/audio/bap.h>

Value:
(struct bt_bap_ascs_rsp) { .code = c, .reason = r }
workaround assembler barfing for ST r
Definition asm-macro-32-bit-gnu.h:24
Structure storing values of fields of ASE Control Point notification.
Definition bap.h:445

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

Parameters
cResponse Code field
rReason field - bt_bap_ascs_reason or bt_audio_metadata_type (see notes in bt_bap_ascs_rsp).

◆ BT_BAP_BIS_SYNC_FAILED

#define BT_BAP_BIS_SYNC_FAILED   0xFFFFFFFF

#include <zephyr/bluetooth/audio/bap.h>

BIS sync value indicating that the BIG sync has failed for any reason.

◆ BT_BAP_BIS_SYNC_NO_PREF

#define BT_BAP_BIS_SYNC_NO_PREF   0xFFFFFFFF

#include <zephyr/bluetooth/audio/bap.h>

Broadcast Assistant no BIS sync preference.

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

◆ BT_BAP_PA_INTERVAL_UNKNOWN

#define BT_BAP_PA_INTERVAL_UNKNOWN   0xFFFF

#include <zephyr/bluetooth/audio/bap.h>

Value indicating that the periodic advertising interval is unknown.

◆ BT_BAP_QOS_CFG

#define BT_BAP_QOS_CFG ( _interval,
_framing,
_phy,
_sdu,
_rtn,
_latency,
_pd )

#include <zephyr/bluetooth/audio/bap.h>

Value:
((struct bt_bap_qos_cfg){ \
.interval = _interval, \
.framing = _framing, \
.phy = _phy, \
.sdu = _sdu, \
.rtn = _rtn, \
IF_ENABLED(UTIL_OR(IS_ENABLED(CONFIG_BT_BAP_BROADCAST_SOURCE), \
IS_ENABLED(CONFIG_BT_BAP_UNICAST)), \
(.latency = _latency,)) \
.pd = _pd, \
})
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:140
#define UTIL_OR(a, b)
Like a || b, but does evaluation and short-circuiting at C preprocessor time.
Definition util_macro.h:394
QoS configuration structure.
Definition bap.h:113
uint16_t latency
Maximum Transport Latency.
Definition bap.h:167

Helper to declare elements of bt_bap_qos_cfg.

Parameters
_intervalSDU interval (usec)
_framingFraming
_phyTarget PHY
_sduMaximum SDU Size
_rtnRetransmission number
_latencyMaximum Transport Latency (msec)
_pdPresentation Delay (usec)

◆ BT_BAP_QOS_CFG_FRAMED

#define BT_BAP_QOS_CFG_FRAMED ( _interval,
_sdu,
_rtn,
_latency,
_pd )

#include <zephyr/bluetooth/audio/bap.h>

Value:
_latency, _pd)
#define BT_BAP_QOS_CFG(_interval, _framing, _phy, _sdu, _rtn, _latency, _pd)
Helper to declare elements of bt_bap_qos_cfg.
Definition bap.h:55
@ BT_BAP_QOS_CFG_FRAMING_FRAMED
Packets are always framed.
Definition bap.h:73
@ BT_BAP_QOS_CFG_2M
LE 2M PHY.
Definition bap.h:81

Helper to declare Input Framed bt_bap_qos_cfg.

Parameters
_intervalSDU interval (usec)
_sduMaximum SDU Size
_rtnRetransmission number
_latencyMaximum Transport Latency (msec)
_pdPresentation Delay (usec)

◆ BT_BAP_QOS_CFG_PREF

#define BT_BAP_QOS_CFG_PREF ( _unframed_supported,
_phy,
_rtn,
_latency,
_pd_min,
_pd_max,
_pref_pd_min,
_pref_pd_max )

#include <zephyr/bluetooth/audio/bap.h>

Value:
{ \
.unframed_supported = _unframed_supported, .phy = _phy, .rtn = _rtn, \
.latency = _latency, .pd_min = _pd_min, .pd_max = _pd_max, \
.pref_pd_min = _pref_pd_min, .pref_pd_max = _pref_pd_max, \
}

Helper to declare elements of bt_bap_qos_cfg_pref.

Parameters
_unframed_supportedUnframed PDUs supported
_phyPreferred Target PHY
_rtnPreferred Retransmission number
_latencyPreferred Maximum Transport Latency (msec)
_pd_minMinimum Presentation Delay (usec)
_pd_maxMaximum Presentation Delay (usec)
_pref_pd_minPreferred Minimum Presentation Delay (usec)
_pref_pd_maxPreferred Maximum Presentation Delay (usec)

◆ BT_BAP_QOS_CFG_UNFRAMED

#define BT_BAP_QOS_CFG_UNFRAMED ( _interval,
_sdu,
_rtn,
_latency,
_pd )

#include <zephyr/bluetooth/audio/bap.h>

Value:
_latency, _pd)
@ BT_BAP_QOS_CFG_FRAMING_UNFRAMED
Packets may be framed or unframed.
Definition bap.h:71

Helper to declare Input Unframed bt_bap_qos_cfg.

Parameters
_intervalSDU interval (usec)
_sduMaximum SDU Size
_rtnRetransmission number
_latencyMaximum Transport Latency (msec)
_pdPresentation Delay (usec)

Typedef Documentation

◆ bt_bap_broadcast_assistant_write_cb

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

#include <zephyr/bluetooth/audio/bap.h>

Callback function for writes.

Parameters
connThe connection to the peer device.
errError value. 0 on success, GATT error on fail.

◆ bt_bap_scan_delegator_state_func_t

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

#include <zephyr/bluetooth/audio/bap.h>

Callback function for Scan Delegator receive state search functions.

Parameters
recv_stateThe receive state.
user_dataUser data.
Return values
trueto stop iterating. If this is used in the context of bt_bap_scan_delegator_find_state(), the recv_state will be returned by bt_bap_scan_delegator_find_state()
falseto continue iterating

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <zephyr/bluetooth/audio/bap.h>

QoS Preferred PHY.

Enumerator
BT_BAP_QOS_CFG_1M 

LE 1M PHY.

BT_BAP_QOS_CFG_2M 

LE 2M PHY.

BT_BAP_QOS_CFG_CODED 

LE Coded PHY.

◆ bt_bap_ascs_reason

#include <zephyr/bluetooth/audio/bap.h>

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.

Enumerator
BT_BAP_ASCS_REASON_NONE 

No reason.

BT_BAP_ASCS_REASON_CODEC 

Codec ID.

BT_BAP_ASCS_REASON_CODEC_DATA 

Codec configuration.

BT_BAP_ASCS_REASON_INTERVAL 

SDU interval.

BT_BAP_ASCS_REASON_FRAMING 

Framing.

BT_BAP_ASCS_REASON_PHY 

PHY.

BT_BAP_ASCS_REASON_SDU 

Maximum SDU size.

BT_BAP_ASCS_REASON_RTN 

RTN.

BT_BAP_ASCS_REASON_LATENCY 

Max transport latency.

BT_BAP_ASCS_REASON_PD 

Presendation delay.

BT_BAP_ASCS_REASON_CIS 

Invalid CIS mapping.

◆ bt_bap_ascs_rsp_code

#include <zephyr/bluetooth/audio/bap.h>

Response Status Code.

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

Enumerator
BT_BAP_ASCS_RSP_CODE_SUCCESS 

Server completed operation successfully.

BT_BAP_ASCS_RSP_CODE_NOT_SUPPORTED 

Server did not support operation by client.

BT_BAP_ASCS_RSP_CODE_INVALID_LENGTH 

Server rejected due to invalid operation length.

BT_BAP_ASCS_RSP_CODE_INVALID_ASE 

Invalid ASE ID.

BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE 

Invalid ASE state.

BT_BAP_ASCS_RSP_CODE_INVALID_DIR 

Invalid operation for direction.

BT_BAP_ASCS_RSP_CODE_CAP_UNSUPPORTED 

Capabilities not supported by server.

BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED 

Configuration parameters not supported by server.

BT_BAP_ASCS_RSP_CODE_CONF_REJECTED 

Configuration parameters rejected by server.

BT_BAP_ASCS_RSP_CODE_CONF_INVALID 

Invalid Configuration parameters.

BT_BAP_ASCS_RSP_CODE_METADATA_UNSUPPORTED 

Unsupported metadata.

BT_BAP_ASCS_RSP_CODE_METADATA_REJECTED 

Metadata rejected by server.

BT_BAP_ASCS_RSP_CODE_METADATA_INVALID 

Invalid metadata.

BT_BAP_ASCS_RSP_CODE_NO_MEM 

Server has insufficient resources.

BT_BAP_ASCS_RSP_CODE_UNSPECIFIED 

Unspecified error.

◆ bt_bap_bass_att_err

#include <zephyr/bluetooth/audio/bap.h>

Broadcast Audio Scan Service (BASS) specific ATT error codes.

Enumerator
BT_BAP_BASS_ERR_OPCODE_NOT_SUPPORTED 

Opcode not supported.

BT_BAP_BASS_ERR_INVALID_SRC_ID 

Invalid source ID supplied.

◆ bt_bap_big_enc_state

#include <zephyr/bluetooth/audio/bap.h>

Broadcast Isochronous Group encryption state reported by the Scan Delegator.

Enumerator
BT_BAP_BIG_ENC_STATE_NO_ENC 

The Broadcast Isochronous Group not encrypted.

BT_BAP_BIG_ENC_STATE_BCODE_REQ 

The Broadcast Isochronous Group broadcast code requested.

BT_BAP_BIG_ENC_STATE_DEC 

The Broadcast Isochronous Group decrypted.

BT_BAP_BIG_ENC_STATE_BAD_CODE 

The Broadcast Isochronous Group bad broadcast code.

◆ bt_bap_ep_state

#include <zephyr/bluetooth/audio/bap.h>

Endpoint states.

Enumerator
BT_BAP_EP_STATE_IDLE 

Audio Stream Endpoint Idle state.

BT_BAP_EP_STATE_CODEC_CONFIGURED 

Audio Stream Endpoint Codec Configured state.

BT_BAP_EP_STATE_QOS_CONFIGURED 

Audio Stream Endpoint QoS Configured state.

BT_BAP_EP_STATE_ENABLING 

Audio Stream Endpoint Enabling state.

BT_BAP_EP_STATE_STREAMING 

Audio Stream Endpoint Streaming state.

BT_BAP_EP_STATE_DISABLING 

Audio Stream Endpoint Disabling state.

BT_BAP_EP_STATE_RELEASING 

Audio Stream Endpoint Streaming state.

◆ bt_bap_pa_state

#include <zephyr/bluetooth/audio/bap.h>

Periodic advertising state reported by the Scan Delegator.

Enumerator
BT_BAP_PA_STATE_NOT_SYNCED 

The periodic advertising has not been synchronized.

BT_BAP_PA_STATE_INFO_REQ 

Waiting for SyncInfo from Broadcast Assistant.

BT_BAP_PA_STATE_SYNCED 

Synchronized to periodic advertising.

BT_BAP_PA_STATE_FAILED 

Failed to synchronized to periodic advertising.

BT_BAP_PA_STATE_NO_PAST 

No periodic advertising sync transfer receiver from Broadcast Assistant.

◆ bt_bap_qos_cfg_framing

#include <zephyr/bluetooth/audio/bap.h>

QoS Framing.

Enumerator
BT_BAP_QOS_CFG_FRAMING_UNFRAMED 

Packets may be framed or unframed.

BT_BAP_QOS_CFG_FRAMING_FRAMED 

Packets are always framed.

Function Documentation

◆ bt_bap_broadcast_assistant_add_src()

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

#include <zephyr/bluetooth/audio/bap.h>

Add a source on the server.

Parameters
connConnection to the server.
paramParameter struct.
Return values
0Success
-EINVALconn is NULL or p conn has not done discovery or if param is invalid
-EBUSYAnother operation is already in progress for this conn
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected scan or GATT error

◆ bt_bap_broadcast_assistant_discover()

int bt_bap_broadcast_assistant_discover ( struct bt_conn * conn)

#include <zephyr/bluetooth/audio/bap.h>

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
connThe connection
Return values
0Success
-EINVALconn is NULL
-EBUSYAnother operation is already in progress for this conn
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected GATT error

◆ bt_bap_broadcast_assistant_mod_src()

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

#include <zephyr/bluetooth/audio/bap.h>

Modify a source on the server.

Parameters
connConnection to the server.
paramParameter struct.
Return values
0Success
-EINVALconn is NULL or p conn has not done discovery or if param is invalid
-EBUSYAnother operation is already in progress for this conn
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected scan or GATT error

◆ bt_bap_broadcast_assistant_read_recv_state()

int bt_bap_broadcast_assistant_read_recv_state ( struct bt_conn * conn,
uint8_t idx )

#include <zephyr/bluetooth/audio/bap.h>

Read the specified receive state from the server.

Parameters
connConnection to the server.
idxThe index of the receive start (0 up to the value from bt_bap_broadcast_assistant_discover_cb)
Return values
0Success
-EINVALconn is NULL or p conn has not done discovery or src_id is invalid
-EBUSYAnother operation is already in progress for this conn
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected scan or GATT error

◆ bt_bap_broadcast_assistant_register_cb()

int bt_bap_broadcast_assistant_register_cb ( struct bt_bap_broadcast_assistant_cb * cb)

#include <zephyr/bluetooth/audio/bap.h>

Registers the callbacks used by Broadcast Audio Scan Service client.

Parameters
cbThe callback structure.
Return values
0on success
-EINVALif cb is NULL
-EALREADYif cb was already registered

◆ bt_bap_broadcast_assistant_rem_src()

int bt_bap_broadcast_assistant_rem_src ( struct bt_conn * conn,
uint8_t src_id )

#include <zephyr/bluetooth/audio/bap.h>

Remove a source from the server.

Parameters
connConnection to the server.
src_idSource ID of the receive state.
Return values
0Success
-EINVALconn is NULL or p conn has not done discovery or src_id is invalid
-EBUSYAnother operation is already in progress for this conn
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected scan or GATT error

◆ bt_bap_broadcast_assistant_scan_start()

int bt_bap_broadcast_assistant_scan_start ( struct bt_conn * conn,
bool start_scan )

#include <zephyr/bluetooth/audio/bap.h>

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
connConnection to the Broadcast Audio Scan Service server. Used to let the server know that we are scanning.
start_scanStart scanning if true. If false, the application should enable scan itself.
Return values
0Success
-EINVALconn is NULL of if conn has not done discovery
-EBUSYAnother operation is already in progress for this conn
-EAGAINBluetooth has not been enabled.
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected scan or GATT error

◆ bt_bap_broadcast_assistant_scan_stop()

int bt_bap_broadcast_assistant_scan_stop ( struct bt_conn * conn)

#include <zephyr/bluetooth/audio/bap.h>

Stop remote scanning for BISes for a server.

Parameters
connConnection to the server.
Return values
0Success
-EINVALconn is NULL of if conn has not done discovery
-EBUSYAnother operation is already in progress for this conn
-EAGAINBluetooth has not been enabled.
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected scan or GATT error

◆ bt_bap_broadcast_assistant_set_broadcast_code()

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

#include <zephyr/bluetooth/audio/bap.h>

Set a broadcast code to the specified receive state.

Parameters
connConnection to the server.
src_idSource ID of the receive state.
broadcast_codeThe broadcast code.
Return values
0Success
-EINVALconn is NULL or p conn has not done discovery or src_id is invalid
-EBUSYAnother operation is already in progress for this conn
-ENOTCONNconn is not connected
-ENOMEMCould not allocated memory for the request
-ENOEXECUnexpected scan or GATT error

◆ bt_bap_broadcast_assistant_unregister_cb()

int bt_bap_broadcast_assistant_unregister_cb ( struct bt_bap_broadcast_assistant_cb * cb)

#include <zephyr/bluetooth/audio/bap.h>

Unregisters the callbacks used by the Broadcast Audio Scan Service client.

Parameters
cbThe callback structure.
Return values
0on success
-EINVALif cb is NULL
-EALREADYif cb was not registered

◆ bt_bap_ep_get_info()

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

#include <zephyr/bluetooth/audio/bap.h>

Return structure holding information of audio stream endpoint.

Parameters
epThe audio stream endpoint object.
infoThe structure object to be filled with the info.
Return values
0in case of success
-EINVALif ep or info are NULL

◆ bt_bap_scan_delegator_add_src()

int bt_bap_scan_delegator_add_src ( const struct bt_bap_scan_delegator_add_src_param * param)

#include <zephyr/bluetooth/audio/bap.h>

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
paramThe parameters for adding the new source
Returns
int errno on failure, or source ID on success.

◆ bt_bap_scan_delegator_find_state()

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 )

#include <zephyr/bluetooth/audio/bap.h>

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

Parameters
funcThe compare callback function
user_dataUser specified data that sent to the callback function
Returns
The first receive state where the func returned true, or NULL

◆ bt_bap_scan_delegator_foreach_state()

void bt_bap_scan_delegator_foreach_state ( bt_bap_scan_delegator_state_func_t func,
void * user_data )

#include <zephyr/bluetooth/audio/bap.h>

Iterate through all existing receive states.

Parameters
funcThe callback function
user_dataUser specified data that sent to the callback function

◆ bt_bap_scan_delegator_mod_src()

int bt_bap_scan_delegator_mod_src ( const struct bt_bap_scan_delegator_mod_src_param * param)

#include <zephyr/bluetooth/audio/bap.h>

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 modified.

Parameters
paramThe parameters for adding the new source
Returns
int errno on failure, or source ID on success.

◆ bt_bap_scan_delegator_register()

int bt_bap_scan_delegator_register ( struct bt_bap_scan_delegator_cb * cb)

#include <zephyr/bluetooth/audio/bap.h>

Register the Basic Audio Profile Scan Delegator and BASS.

Register the scan deligator and Broadcast Audio Scan Service (BASS) dynamically at runtime.

Only one set of callbacks can be registered at any one time, and calling this function multiple times will override any previously registered callbacks.

Parameters
cbPointer to the callback struct
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_scan_delegator_rem_src()

int bt_bap_scan_delegator_rem_src ( uint8_t src_id)

#include <zephyr/bluetooth/audio/bap.h>

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_idThe source ID to remove
Returns
int Error value. 0 on success, errno on fail.

◆ bt_bap_scan_delegator_set_bis_sync_state()

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

#include <zephyr/bluetooth/audio/bap.h>

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

Parameters
src_idThe source id used to identify the receive state.
bis_syncedArray of bitfields to set the BIS sync state for each subgroup.
Returns
int Error value. 0 on success, ERRNO on fail.

◆ bt_bap_scan_delegator_set_pa_state()

int bt_bap_scan_delegator_set_pa_state ( uint8_t src_id,
enum bt_bap_pa_state pa_state )

#include <zephyr/bluetooth/audio/bap.h>

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_idThe source id used to identify the receive state.
pa_stateThe 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.

◆ bt_bap_scan_delegator_unregister()

int bt_bap_scan_delegator_unregister ( void )

#include <zephyr/bluetooth/audio/bap.h>

unregister the Basic Audio Profile Scan Delegator and BASS.

Unregister the scan deligator and Broadcast Audio Scan Service (BASS) dynamically at runtime.

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

◆ bt_bap_stream_cb_register()

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

#include <zephyr/bluetooth/audio/bap.h>

Register Audio callbacks for a stream.

Register Audio callbacks for a stream.

Parameters
streamStream object.
opsStream operations structure.

◆ bt_bap_stream_config()

int bt_bap_stream_config ( struct bt_conn * conn,
struct bt_bap_stream * stream,
struct bt_bap_ep * ep,
struct bt_audio_codec_cfg * codec_cfg )

#include <zephyr/bluetooth/audio/bap.h>

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
connConnection object
streamStream object being configured
epRemote Audio Endpoint being configured
codec_cfgCodec configuration
Returns
Allocated Audio Stream object or NULL in case of error.

◆ bt_bap_stream_connect()

int bt_bap_stream_connect ( struct bt_bap_stream * stream)

#include <zephyr/bluetooth/audio/bap.h>

Connect unicast audio stream.

This procedure is used by a unicast client to connect the connected isochronous stream (CIS) associated with the audio stream. If two audio streams share a CIS, then this only needs to be done once for those streams. This can only be done for streams in the QoS configured or enabled states.

The bt_bap_stream_ops.connected() callback will be called on the streams once this has finished.

This shall only be called for unicast streams, and only as the unicast client ( CONFIG_BT_BAP_UNICAST_CLIENT ).

Parameters
streamStream object
Return values
0in case of success
-EINVALif the stream, endpoint, ISO channel or connection is NULL
-EBADMSGif the stream or ISO channel is in an invalid state for connection
-EOPNOTSUPPif the role of the stream is not BT_HCI_ROLE_CENTRAL
-EALREADYif the ISO channel is already connecting or connected
-EBUSYif another ISO channel is connecting
-ENOEXECif otherwise rejected by the ISO layer

◆ bt_bap_stream_disable()

int bt_bap_stream_disable ( struct bt_bap_stream * stream)

#include <zephyr/bluetooth/audio/bap.h>

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
streamStream object
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_stream_enable()

int bt_bap_stream_enable ( struct bt_bap_stream * stream,
const uint8_t meta[],
size_t meta_len )

#include <zephyr/bluetooth/audio/bap.h>

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
streamStream object
metaMetadata
meta_lenMetadata length
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_stream_get_tx_sync()

int bt_bap_stream_get_tx_sync ( struct bt_bap_stream * stream,
struct bt_iso_tx_info * info )

#include <zephyr/bluetooth/audio/bap.h>

Get ISO transmission timing info for a Basic Audio Profile stream.

Reads timing information for transmitted ISO packet on an ISO channel. The HCI_LE_Read_ISO_TX_Sync HCI command is used to retrieve this information from the controller.

Note
An SDU must have already been successfully transmitted on the ISO channel for this function to return successfully. Support for sending must be supported, determined by CONFIG_BT_AUDIO_TX .
Parameters
[in]streamStream object.
[out]infoTransmit info object.
Return values
0on success
-EINVALif the stream is invalid, if the stream is not configured for sending or if it is not connected with a isochronous stream
Anyreturn value from bt_iso_chan_get_tx_sync()

◆ bt_bap_stream_metadata()

int bt_bap_stream_metadata ( struct bt_bap_stream * stream,
const uint8_t meta[],
size_t meta_len )

#include <zephyr/bluetooth/audio/bap.h>

Change Audio Stream Metadata.

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

Parameters
streamStream object
metaMetadata
meta_lenMetadata length
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_stream_qos()

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

#include <zephyr/bluetooth/audio/bap.h>

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
connConnection object
groupUnicast group object
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_stream_reconfig()

int bt_bap_stream_reconfig ( struct bt_bap_stream * stream,
struct bt_audio_codec_cfg * codec_cfg )

#include <zephyr/bluetooth/audio/bap.h>

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
streamStream object being reconfigured
codec_cfgCodec configuration
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_stream_release()

int bt_bap_stream_release ( struct bt_bap_stream * stream)

#include <zephyr/bluetooth/audio/bap.h>

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
streamStream object
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_stream_send()

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

#include <zephyr/bluetooth/audio/bap.h>

Send data to Audio stream without timestamp.

Send data from buffer to the stream.

Note
Support for sending must be supported, determined by CONFIG_BT_AUDIO_TX .
Parameters
streamStream object.
bufBuffer containing data to be sent.
seq_numPacket Sequence number. This value shall be incremented for each call to this function and at least once per SDU interval for a specific channel.
Returns
Bytes sent in case of success or negative value in case of error.

◆ bt_bap_stream_send_ts()

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

#include <zephyr/bluetooth/audio/bap.h>

Send data to Audio stream with timestamp.

Send data from buffer to the stream.

Note
Support for sending must be supported, determined by CONFIG_BT_AUDIO_TX .
Parameters
streamStream object.
bufBuffer containing data to be sent.
seq_numPacket Sequence number. This value shall be incremented for each call to this function and at least once per SDU interval for a specific channel.
tsTimestamp 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.
Returns
Bytes sent in case of success or negative value in case of error.

◆ bt_bap_stream_start()

int bt_bap_stream_start ( struct bt_bap_stream * stream)

#include <zephyr/bluetooth/audio/bap.h>

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 send the receiver start ready command to the unicast server for BT_AUDIO_DIR_SOURCE ASEs. The CIS is required to be connected first by bt_bap_stream_connect() before the command can be sent.

For the unicast server, this will execute the receiver start ready command on the unicast server for BT_AUDIO_DIR_SINK ASEs. If the CIS is not connected yet, the stream will go into the streaming state as soon as the CIS is connected.

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
streamStream object
Returns
0 in case of success or negative value in case of error.

◆ bt_bap_stream_stop()

int bt_bap_stream_stop ( struct bt_bap_stream * stream)

#include <zephyr/bluetooth/audio/bap.h>

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
streamStream object
Returns
0 in case of success or negative value in case of error.