Skip to content

Commit 68fa047

Browse files
Thalleycarlescufi
authored andcommitted
Bluetooth: Audio: Add unicast client cp notify callbacks
Add callbacks for control point notifications sent by the unicast server. These will allow the upper layers to know if and why a specific operation failed. Signed-off-by: Emil Gydesen <[email protected]>
1 parent a2057cd commit 68fa047

File tree

4 files changed

+378
-160
lines changed

4 files changed

+378
-160
lines changed

include/zephyr/bluetooth/audio/bap.h

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,77 @@ enum bt_bap_ep_state {
8383
BT_BAP_EP_STATE_RELEASING = 0x06,
8484
};
8585

86+
/**
87+
* @brief Response Status Code
88+
*
89+
* These are sent by the server to the client when a stream operation is
90+
* requested.
91+
*/
92+
enum bt_bap_ascs_rsp_code {
93+
/** Server completed operation successfully */
94+
BT_BAP_ASCS_RSP_CODE_SUCCESS = 0x00,
95+
/** Server did not support operation by client */
96+
BT_BAP_ASCS_RSP_CODE_NOT_SUPPORTED = 0x01,
97+
/** Server rejected due to invalid operation length */
98+
BT_BAP_ASCS_RSP_CODE_INVALID_LENGTH = 0x02,
99+
/** Invalid ASE ID */
100+
BT_BAP_ASCS_RSP_CODE_INVALID_ASE = 0x03,
101+
/** Invalid ASE state */
102+
BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE = 0x04,
103+
/** Invalid operation for direction */
104+
BT_BAP_ASCS_RSP_CODE_INVALID_DIR = 0x05,
105+
/** Capabilities not supported by server */
106+
BT_BAP_ASCS_RSP_CODE_CAP_UNSUPPORTED = 0x06,
107+
/** Configuration parameters not supported by server */
108+
BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED = 0x07,
109+
/** Configuration parameters rejected by server */
110+
BT_BAP_ASCS_RSP_CODE_CONF_REJECTED = 0x08,
111+
/** Invalid Configuration parameters */
112+
BT_BAP_ASCS_RSP_CODE_CONF_INVALID = 0x09,
113+
/** Unsupported metadata */
114+
BT_BAP_ASCS_RSP_CODE_METADATA_UNSUPPORTED = 0x0a,
115+
/** Metadata rejected by server */
116+
BT_BAP_ASCS_RSP_CODE_METADATA_REJECTED = 0x0b,
117+
/** Invalid metadata */
118+
BT_BAP_ASCS_RSP_CODE_METADATA_INVALID = 0x0c,
119+
/** Server has insufficient resources */
120+
BT_BAP_ASCS_RSP_CODE_NO_MEM = 0x0d,
121+
/** Unspecified error */
122+
BT_BAP_ASCS_RSP_CODE_UNSPECIFIED = 0x0e,
123+
};
124+
125+
/**
126+
* @brief Response Reasons
127+
*
128+
* These are used if the @ref bt_bap_ascs_rsp_code value is
129+
* @ref BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED, @ref BT_BAP_ASCS_RSP_CODE_CONF_REJECTED or
130+
* @ref BT_BAP_ASCS_RSP_CODE_CONF_INVALID.
131+
*/
132+
enum bt_bap_ascs_reason {
133+
/** No reason */
134+
BT_BAP_ASCS_REASON_NONE = 0x00,
135+
/** Codec ID */
136+
BT_BAP_ASCS_REASON_CODEC = 0x01,
137+
/** Codec configuration */
138+
BT_BAP_ASCS_REASON_CODEC_DATA = 0x02,
139+
/** SDU interval */
140+
BT_BAP_ASCS_REASON_INTERVAL = 0x03,
141+
/** Framing */
142+
BT_BAP_ASCS_REASON_FRAMING = 0x04,
143+
/** PHY */
144+
BT_BAP_ASCS_REASON_PHY = 0x05,
145+
/** Maximum SDU size*/
146+
BT_BAP_ASCS_REASON_SDU = 0x06,
147+
/** RTN */
148+
BT_BAP_ASCS_REASON_RTN = 0x07,
149+
/** Max transport latency */
150+
BT_BAP_ASCS_REASON_LATENCY = 0x08,
151+
/** Presendation delay */
152+
BT_BAP_ASCS_REASON_PD = 0x09,
153+
/** Invalid CIS mapping */
154+
BT_BAP_ASCS_REASON_CIS = 0x0a,
155+
};
156+
86157
/** @brief Abstract Audio Broadcast Source structure. */
87158
struct bt_bap_broadcast_source;
88159

@@ -801,6 +872,108 @@ struct bt_bap_unicast_client_cb {
801872
*/
802873
void (*available_contexts)(struct bt_conn *conn, enum bt_audio_context snk_ctx,
803874
enum bt_audio_context src_ctx);
875+
876+
/**
877+
* @brief Callback function for bt_bap_stream_config() and bt_bap_stream_reconfig().
878+
*
879+
* Called when the codec configure operation is completed on the server.
880+
*
881+
* @param stream Stream the operation was performed on.
882+
* @param rsp_code Response code.
883+
* @param reason Reason code.
884+
*/
885+
void (*config)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
886+
enum bt_bap_ascs_reason reason);
887+
888+
/**
889+
* @brief Callback function for bt_bap_stream_qos().
890+
*
891+
* Called when the QoS configure operation is completed on the server.
892+
* This will be called for each stream in the group that was being QoS
893+
* configured.
894+
*
895+
* @param stream Stream the operation was performed on.
896+
* @param rsp_code Response code.
897+
* @param reason Reason code.
898+
*/
899+
void (*qos)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
900+
enum bt_bap_ascs_reason reason);
901+
902+
/**
903+
* @brief Callback function for bt_bap_stream_enable().
904+
*
905+
* Called when the enable operation is completed on the server.
906+
*
907+
* @param stream Stream the operation was performed on.
908+
* @param rsp_code Response code.
909+
* @param reason Reason code.
910+
*/
911+
void (*enable)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
912+
enum bt_bap_ascs_reason reason);
913+
914+
/**
915+
* @brief Callback function for bt_bap_stream_start().
916+
*
917+
* Called when the start operation is completed on the server. This will
918+
* only be called if the stream supplied to bt_bap_stream_start() is
919+
* for a @ref BT_AUDIO_DIR_SOURCE endpoint.
920+
*
921+
* @param stream Stream the operation was performed on.
922+
* @param rsp_code Response code.
923+
* @param reason Reason code.
924+
*/
925+
void (*start)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
926+
enum bt_bap_ascs_reason reason);
927+
928+
/**
929+
* @brief Callback function for bt_bap_stream_stop().
930+
*
931+
* Called when the stop operation is completed on the server. This will
932+
* only be called if the stream supplied to bt_bap_stream_stop() is
933+
* for a @ref BT_AUDIO_DIR_SOURCE endpoint.
934+
*
935+
* @param stream Stream the operation was performed on.
936+
* @param rsp_code Response code.
937+
* @param reason Reason code.
938+
*/
939+
void (*stop)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
940+
enum bt_bap_ascs_reason reason);
941+
942+
/**
943+
* @brief Callback function for bt_bap_stream_disable().
944+
*
945+
* Called when the disable operation is completed on the server.
946+
*
947+
* @param stream Stream the operation was performed on.
948+
* @param rsp_code Response code.
949+
* @param reason Reason code.
950+
*/
951+
void (*disable)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
952+
enum bt_bap_ascs_reason reason);
953+
954+
/**
955+
* @brief Callback function for bt_bap_stream_metadata().
956+
*
957+
* Called when the metadata operation is completed on the server.
958+
*
959+
* @param stream Stream the operation was performed on.
960+
* @param rsp_code Response code.
961+
* @param reason Reason code.
962+
*/
963+
void (*metadata)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
964+
enum bt_bap_ascs_reason reason);
965+
966+
/**
967+
* @brief Callback function for bt_bap_stream_release().
968+
*
969+
* Called when the release operation is completed on the server.
970+
*
971+
* @param stream Stream the operation was performed on.
972+
* @param rsp_code Response code.
973+
* @param reason Reason code.
974+
*/
975+
void (*release)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
976+
enum bt_bap_ascs_reason reason);
804977
};
805978

806979
/**

0 commit comments

Comments
 (0)