1 /* btp_bap.h - Bluetooth tester headers */
2 
3 /*
4  * Copyright (c) 2023 Codecoup
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include <zephyr/bluetooth/audio/audio.h>
10 
11 /* BAP commands */
12 #define BTP_BAP_READ_SUPPORTED_COMMANDS		0x01
13 struct btp_bap_read_supported_commands_rp {
14 	uint8_t data[0];
15 } __packed;
16 
17 #define BTP_BAP_DISCOVER			0x02
18 struct btp_bap_discover_cmd {
19 	bt_addr_le_t address;
20 } __packed;
21 
22 #define BTP_BAP_DISCOVERY_STATUS_SUCCESS	0x00
23 #define BTP_BAP_DISCOVERY_STATUS_FAILED		0x01
24 
25 #define BTP_BAP_SEND				0x03
26 struct btp_bap_send_cmd {
27 	bt_addr_le_t address;
28 	uint8_t ase_id;
29 	uint8_t data_len;
30 	uint8_t data[0];
31 } __packed;
32 
33 struct btp_bap_send_rp {
34 	uint8_t data_len;
35 } __packed;
36 
37 #define BTP_BAP_BROADCAST_SOURCE_SETUP		0x04
38 struct btp_bap_broadcast_source_setup_cmd {
39 	uint8_t streams_per_subgroup;
40 	uint8_t subgroups;
41 	uint8_t sdu_interval[3];
42 	uint8_t framing;
43 	uint16_t max_sdu;
44 	uint8_t retransmission_num;
45 	uint16_t max_transport_latency;
46 	uint8_t presentation_delay[3];
47 	uint8_t coding_format;
48 	uint16_t vid;
49 	uint16_t cid;
50 	uint8_t cc_ltvs_len;
51 	uint8_t cc_ltvs[];
52 } __packed;
53 struct btp_bap_broadcast_source_setup_rp {
54 	uint32_t gap_settings;
55 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
56 } __packed;
57 
58 #define BTP_BAP_BROADCAST_SOURCE_RELEASE	0x05
59 struct btp_bap_broadcast_source_release_cmd {
60 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
61 } __packed;
62 
63 #define BTP_BAP_BROADCAST_ADV_START		0x06
64 struct btp_bap_broadcast_adv_start_cmd {
65 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
66 } __packed;
67 
68 #define BTP_BAP_BROADCAST_ADV_STOP		0x07
69 struct btp_bap_broadcast_adv_stop_cmd {
70 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
71 } __packed;
72 
73 #define BTP_BAP_BROADCAST_SOURCE_START		0x08
74 struct btp_bap_broadcast_source_start_cmd {
75 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
76 } __packed;
77 
78 #define BTP_BAP_BROADCAST_SOURCE_STOP		0x09
79 struct btp_bap_broadcast_source_stop_cmd {
80 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
81 } __packed;
82 
83 #define BTP_BAP_BROADCAST_SINK_SETUP		0x0a
84 struct btp_bap_broadcast_sink_setup_cmd {
85 } __packed;
86 
87 #define BTP_BAP_BROADCAST_SINK_RELEASE		0x0b
88 struct btp_bap_broadcast_sink_release_cmd {
89 } __packed;
90 
91 #define BTP_BAP_BROADCAST_SCAN_START		0x0c
92 struct btp_bap_broadcast_scan_start_cmd {
93 } __packed;
94 
95 #define BTP_BAP_BROADCAST_SCAN_STOP		0x0d
96 struct btp_bap_broadcast_scan_stop_cmd {
97 } __packed;
98 
99 #define BTP_BAP_BROADCAST_SINK_SYNC		0x0e
100 struct btp_bap_broadcast_sink_sync_cmd {
101 	bt_addr_le_t address;
102 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
103 	uint8_t advertiser_sid;
104 	uint16_t skip;
105 	uint16_t sync_timeout;
106 	uint8_t past_avail;
107 	uint8_t src_id;
108 } __packed;
109 
110 #define BTP_BAP_BROADCAST_SINK_STOP		0x0f
111 struct btp_bap_broadcast_sink_stop_cmd {
112 	bt_addr_le_t address;
113 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
114 } __packed;
115 
116 #define BTP_BAP_BROADCAST_SINK_BIS_SYNC		0x10
117 struct btp_bap_broadcast_sink_bis_sync_cmd {
118 	bt_addr_le_t address;
119 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
120 	uint32_t requested_bis_sync;
121 } __packed;
122 
123 #define BTP_BAP_DISCOVER_SCAN_DELEGATORS	0x11
124 struct btp_bap_discover_scan_delegators_cmd {
125 	bt_addr_le_t address;
126 } __packed;
127 
128 #define BTP_BAP_BROADCAST_ASSISTANT_SCAN_START	0x12
129 struct btp_bap_broadcast_assistant_scan_start_cmd {
130 	bt_addr_le_t address;
131 } __packed;
132 
133 #define BTP_BAP_BROADCAST_ASSISTANT_SCAN_STOP	0x13
134 struct btp_bap_broadcast_assistant_scan_stop_cmd {
135 	bt_addr_le_t address;
136 } __packed;
137 
138 #define BTP_BAP_ADD_BROADCAST_SRC		0x14
139 struct btp_bap_add_broadcast_src_cmd {
140 	bt_addr_le_t address;
141 	bt_addr_le_t broadcaster_address;
142 	uint8_t advertiser_sid;
143 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
144 	uint8_t padv_sync;
145 	uint16_t padv_interval;
146 	uint8_t num_subgroups;
147 	uint8_t subgroups[0];
148 } __packed;
149 
150 #define BTP_BAP_REMOVE_BROADCAST_SRC		0x15
151 struct btp_bap_remove_broadcast_src_cmd {
152 	bt_addr_le_t address;
153 	uint8_t src_id;
154 } __packed;
155 
156 #define BTP_BAP_MODIFY_BROADCAST_SRC		0x16
157 struct btp_bap_modify_broadcast_src_cmd {
158 	bt_addr_le_t address;
159 	uint8_t src_id;
160 	uint8_t padv_sync;
161 	uint16_t padv_interval;
162 	uint8_t num_subgroups;
163 	uint8_t subgroups[0];
164 } __packed;
165 
166 #define BTP_BAP_SET_BROADCAST_CODE		0x17
167 struct btp_bap_set_broadcast_code_cmd {
168 	bt_addr_le_t address;
169 	uint8_t src_id;
170 	uint8_t broadcast_code[BT_ISO_BROADCAST_CODE_SIZE];
171 } __packed;
172 
173 #define BTP_BAP_SEND_PAST			0x18
174 struct btp_bap_send_past_cmd {
175 	bt_addr_le_t address;
176 	uint8_t src_id;
177 } __packed;
178 
179 #define BTP_BAP_BROADCAST_SOURCE_SETUP_V2	0x19
180 struct btp_bap_broadcast_source_setup_v2_cmd {
181 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
182 	uint8_t streams_per_subgroup;
183 	uint8_t subgroups;
184 	uint8_t sdu_interval[3];
185 	uint8_t framing;
186 	uint16_t max_sdu;
187 	uint8_t retransmission_num;
188 	uint16_t max_transport_latency;
189 	uint8_t presentation_delay[3];
190 	uint8_t coding_format;
191 	uint16_t vid;
192 	uint16_t cid;
193 	uint8_t cc_ltvs_len;
194 	uint8_t cc_ltvs[];
195 } __packed;
196 struct btp_bap_broadcast_source_setup_v2_rp {
197 	uint32_t gap_settings;
198 } __packed;
199 
200 /* BAP events */
201 #define BTP_BAP_EV_DISCOVERY_COMPLETED		0x80
202 struct btp_bap_discovery_completed_ev {
203 	bt_addr_le_t address;
204 	uint8_t status;
205 } __packed;
206 
207 #define BTP_BAP_EV_CODEC_CAP_FOUND		0x81
208 struct btp_bap_codec_cap_found_ev {
209 	bt_addr_le_t address;
210 	uint8_t dir;
211 	uint8_t coding_format;
212 	uint16_t frequencies;
213 	uint8_t frame_durations;
214 	uint32_t octets_per_frame;
215 	uint8_t channel_counts;
216 } __packed;
217 
218 #define BTP_BAP_EV_ASE_FOUND			0x82
219 struct btp_ascs_ase_found_ev {
220 	bt_addr_le_t address;
221 	uint8_t dir;
222 	uint8_t ase_id;
223 } __packed;
224 
225 #define BTP_BAP_EV_STREAM_RECEIVED		0x83
226 struct btp_bap_stream_received_ev {
227 	bt_addr_le_t address;
228 	uint8_t ase_id;
229 	uint8_t data_len;
230 	uint8_t data[];
231 } __packed;
232 
233 #define BTP_BAP_EV_BAA_FOUND			0x84
234 struct btp_bap_baa_found_ev {
235 	bt_addr_le_t address;
236 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
237 	uint8_t advertiser_sid;
238 	uint16_t padv_interval;
239 } __packed;
240 
241 #define BTP_BAP_EV_BIS_FOUND			0x85
242 struct btp_bap_bis_found_ev {
243 	bt_addr_le_t address;
244 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
245 	uint8_t presentation_delay[3];
246 	uint8_t subgroup_id;
247 	uint8_t bis_id;
248 	uint8_t coding_format;
249 	uint16_t vid;
250 	uint16_t cid;
251 	uint8_t cc_ltvs_len;
252 	uint8_t cc_ltvs[];
253 } __packed;
254 
255 #define BTP_BAP_EV_BIS_SYNCED			0x86
256 struct btp_bap_bis_syned_ev {
257 	bt_addr_le_t address;
258 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
259 	uint8_t bis_id;
260 } __packed;
261 
262 #define BTP_BAP_EV_BIS_STREAM_RECEIVED		0x87
263 struct btp_bap_bis_stream_received_ev {
264 	bt_addr_le_t address;
265 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
266 	uint8_t bis_id;
267 	uint8_t data_len;
268 	uint8_t data[];
269 } __packed;
270 
271 #define BTP_BAP_EV_SCAN_DELEGATOR_FOUND		0x88
272 struct btp_bap_scan_delegator_found_ev {
273 	bt_addr_le_t address;
274 } __packed;
275 
276 #define BTP_BAP_EV_BROADCAST_RECEIVE_STATE	0x89
277 struct btp_bap_broadcast_receive_state_ev {
278 	bt_addr_le_t address;
279 	uint8_t src_id;
280 	bt_addr_le_t broadcaster_address;
281 	uint8_t advertiser_sid;
282 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
283 	uint8_t pa_sync_state;
284 	uint8_t big_encryption;
285 	uint8_t num_subgroups;
286 	uint8_t subgroups[0];
287 } __packed;
288 
289 #define BTP_BAP_EV_PA_SYNC_REQ			0x8a
290 struct btp_bap_pa_sync_req_ev {
291 	bt_addr_le_t address;
292 	uint8_t src_id;
293 	uint8_t advertiser_sid;
294 	uint8_t broadcast_id[BT_AUDIO_BROADCAST_ID_SIZE];
295 	uint8_t past_avail;
296 	uint16_t pa_interval;
297 } __packed;
298