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 /* BAP commands */
10 #define BTP_BAP_READ_SUPPORTED_COMMANDS		0x01
11 struct btp_bap_read_supported_commands_rp {
12 	uint8_t data[0];
13 } __packed;
14 
15 #define BTP_BAP_DISCOVER			0x02
16 struct btp_bap_discover_cmd {
17 	bt_addr_le_t address;
18 } __packed;
19 
20 #define BTP_BAP_DISCOVERY_STATUS_SUCCESS	0x00
21 #define BTP_BAP_DISCOVERY_STATUS_FAILED		0x01
22 
23 #define BTP_BAP_SEND				0x03
24 struct btp_bap_send_cmd {
25 	bt_addr_le_t address;
26 	uint8_t ase_id;
27 	uint8_t data_len;
28 	uint8_t data[0];
29 } __packed;
30 
31 struct btp_bap_send_rp {
32 	uint8_t data_len;
33 } __packed;
34 
35 #define BTP_BAP_BROADCAST_SOURCE_SETUP		0x04
36 struct btp_bap_broadcast_source_setup_cmd {
37 	uint8_t streams_per_subgroup;
38 	uint8_t subgroups;
39 	uint8_t sdu_interval[3];
40 	uint8_t framing;
41 	uint16_t max_sdu;
42 	uint8_t retransmission_num;
43 	uint16_t max_transport_latency;
44 	uint8_t presentation_delay[3];
45 	uint8_t coding_format;
46 	uint16_t vid;
47 	uint16_t cid;
48 	uint8_t cc_ltvs_len;
49 	uint8_t cc_ltvs[];
50 } __packed;
51 struct btp_bap_broadcast_source_setup_rp {
52 	uint32_t gap_settings;
53 	uint8_t broadcast_id[3];
54 } __packed;
55 
56 #define BTP_BAP_BROADCAST_SOURCE_RELEASE	0x05
57 struct btp_bap_broadcast_source_release_cmd {
58 	uint8_t broadcast_id[3];
59 } __packed;
60 
61 #define BTP_BAP_BROADCAST_ADV_START		0x06
62 struct btp_bap_broadcast_adv_start_cmd {
63 	uint8_t broadcast_id[3];
64 } __packed;
65 
66 #define BTP_BAP_BROADCAST_ADV_STOP		0x07
67 struct btp_bap_broadcast_adv_stop_cmd {
68 	uint8_t broadcast_id[3];
69 } __packed;
70 
71 #define BTP_BAP_BROADCAST_SOURCE_START		0x08
72 struct btp_bap_broadcast_source_start_cmd {
73 	uint8_t broadcast_id[3];
74 } __packed;
75 
76 #define BTP_BAP_BROADCAST_SOURCE_STOP		0x09
77 struct btp_bap_broadcast_source_stop_cmd {
78 	uint8_t broadcast_id[3];
79 } __packed;
80 
81 #define BTP_BAP_BROADCAST_SINK_SETUP		0x0a
82 struct btp_bap_broadcast_sink_setup_cmd {
83 } __packed;
84 
85 #define BTP_BAP_BROADCAST_SINK_RELEASE		0x0b
86 struct btp_bap_broadcast_sink_release_cmd {
87 } __packed;
88 
89 #define BTP_BAP_BROADCAST_SCAN_START		0x0c
90 struct btp_bap_broadcast_scan_start_cmd {
91 } __packed;
92 
93 #define BTP_BAP_BROADCAST_SCAN_STOP		0x0d
94 struct btp_bap_broadcast_scan_stop_cmd {
95 } __packed;
96 
97 #define BTP_BAP_BROADCAST_SINK_SYNC		0x0e
98 struct btp_bap_broadcast_sink_sync_cmd {
99 	bt_addr_le_t address;
100 	uint8_t broadcast_id[3];
101 	uint8_t advertiser_sid;
102 	uint16_t skip;
103 	uint16_t sync_timeout;
104 } __packed;
105 
106 #define BTP_BAP_BROADCAST_SINK_STOP		0x0f
107 struct btp_bap_broadcast_sink_stop_cmd {
108 	bt_addr_le_t address;
109 	uint8_t broadcast_id[3];
110 } __packed;
111 
112 /* BAP events */
113 #define BTP_BAP_EV_DISCOVERY_COMPLETED		0x80
114 struct btp_bap_discovery_completed_ev {
115 	bt_addr_le_t address;
116 	uint8_t status;
117 } __packed;
118 
119 #define BTP_BAP_EV_CODEC_CAP_FOUND		0x81
120 struct btp_bap_codec_cap_found_ev {
121 	bt_addr_le_t address;
122 	uint8_t dir;
123 	uint8_t coding_format;
124 	uint16_t frequencies;
125 	uint8_t frame_durations;
126 	uint32_t octets_per_frame;
127 	uint8_t channel_counts;
128 } __packed;
129 
130 #define BTP_BAP_EV_ASE_FOUND			0x82
131 struct btp_ascs_ase_found_ev {
132 	bt_addr_le_t address;
133 	uint8_t dir;
134 	uint8_t ase_id;
135 } __packed;
136 
137 #define BTP_BAP_EV_STREAM_RECEIVED		0x83
138 struct btp_bap_stream_received_ev {
139 	bt_addr_le_t address;
140 	uint8_t ase_id;
141 	uint8_t data_len;
142 	uint8_t data[];
143 } __packed;
144 
145 #define BTP_BAP_EV_BAA_FOUND			0x84
146 struct btp_bap_baa_found_ev {
147 	bt_addr_le_t address;
148 	uint8_t broadcast_id[3];
149 	uint8_t advertiser_sid;
150 	uint16_t padv_interval;
151 } __packed;
152 
153 #define BTP_BAP_EV_BIS_FOUND			0x85
154 struct btp_bap_bis_found_ev {
155 	bt_addr_le_t address;
156 	uint8_t broadcast_id[3];
157 	uint8_t presentation_delay[3];
158 	uint8_t subgroup_id;
159 	uint8_t bis_id;
160 	uint8_t coding_format;
161 	uint16_t vid;
162 	uint16_t cid;
163 	uint8_t cc_ltvs_len;
164 	uint8_t cc_ltvs[];
165 } __packed;
166 
167 #define BTP_BAP_EV_BIS_SYNCED			0x86
168 struct btp_bap_bis_syned_ev {
169 	bt_addr_le_t address;
170 	uint8_t broadcast_id[3];
171 	uint8_t bis_id;
172 } __packed;
173 
174 #define BTP_BAP_EV_BIS_STREAM_RECEIVED		0x87
175 struct btp_bap_bis_stream_received_ev {
176 	bt_addr_le_t address;
177 	uint8_t broadcast_id[3];
178 	uint8_t bis_id;
179 	uint8_t data_len;
180 	uint8_t data[];
181 } __packed;
182