1 /* btp_mcp.h - Bluetooth tester headers */
2 
3 /*
4  * Copyright (c) 2023 Codecoup
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 #include <zephyr/bluetooth/services/ots.h>
9 
10 /* MCP commands */
11 #define BTP_MCP_READ_SUPPORTED_COMMANDS		0x01
12 struct btp_mcp_read_supported_commands_rp {
13 	uint8_t data[0];
14 } __packed;
15 
16 #define BTP_MCP_DISCOVER			0x02
17 struct btp_mcp_discover_cmd {
18 	bt_addr_le_t address;
19 } __packed;
20 
21 #define BTP_MCP_TRACK_DURATION_READ		0x03
22 struct btp_mcp_track_duration_cmd {
23 	bt_addr_le_t address;
24 } __packed;
25 
26 #define BTP_MCP_TRACK_POSITION_READ		0x04
27 struct btp_mcp_track_position_read_cmd {
28 	bt_addr_le_t address;
29 } __packed;
30 
31 #define BTP_MCP_TRACK_POSITION_SET		0x05
32 struct btp_mcp_track_position_set_cmd {
33 	bt_addr_le_t address;
34 	int32_t pos;
35 } __packed;
36 
37 #define BTP_MCP_PLAYBACK_SPEED_READ		0x06
38 struct btp_mcp_playback_speed_read_cmd {
39 	bt_addr_le_t address;
40 } __packed;
41 
42 #define BTP_MCP_PLAYBACK_SPEED_SET		0x07
43 struct btp_mcp_playback_speed_set {
44 	bt_addr_le_t address;
45 	int8_t speed;
46 } __packed;
47 
48 #define BTP_MCP_SEEKING_SPEED_READ		0x08
49 struct btp_mcp_seeking_speed_read_cmd {
50 	bt_addr_le_t address;
51 } __packed;
52 
53 #define BTP_MCP_ICON_OBJ_ID_READ		0x09
54 struct btp_mcp_icon_obj_id_read_cmd {
55 	bt_addr_le_t address;
56 } __packed;
57 
58 #define BTP_MCP_NEXT_TRACK_OBJ_ID_READ		0x0a
59 struct btp_mcp_next_track_obj_id_cmd {
60 	bt_addr_le_t address;
61 } __packed;
62 
63 #define BTP_MCP_NEXT_TRACK_OBJ_ID_SET		0x0b
64 struct btp_mcp_set_next_track_obj_id_cmd {
65 	bt_addr_le_t address;
66 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
67 } __packed;
68 
69 #define BTP_MCP_PARENT_GROUP_OBJ_ID_READ	0x0c
70 struct btp_mcp_parent_group_obj_id_read_cmd {
71 	bt_addr_le_t address;
72 } __packed;
73 
74 #define BTP_MCP_CURRENT_GROUP_OBJ_ID_READ	0x0d
75 struct btp_mcp_current_group_obj_id_read_cmd {
76 	bt_addr_le_t address;
77 } __packed;
78 
79 #define BTP_MCP_CURRENT_GROUP_OBJ_ID_SET	0x0e
80 struct btp_mcp_current_group_obj_id_set_cmd {
81 	bt_addr_le_t address;
82 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
83 } __packed;
84 
85 #define BTP_MCP_PLAYING_ORDER_READ		0x0f
86 struct btp_mcp_playing_order_read_cmd {
87 	bt_addr_le_t address;
88 } __packed;
89 
90 #define BTP_MCP_PLAYING_ORDER_SET		0x10
91 struct btp_mcp_playing_order_set_cmd {
92 	bt_addr_le_t address;
93 	uint8_t order;
94 } __packed;
95 
96 #define BTP_MCP_PLAYING_ORDERS_SUPPORTED_READ	0x11
97 struct btp_mcp_playing_orders_supported_read_cmd {
98 	bt_addr_le_t address;
99 } __packed;
100 
101 #define BTP_MCP_MEDIA_STATE_READ		0x12
102 struct btp_mcp_media_state_read_cmd {
103 	bt_addr_le_t address;
104 } __packed;
105 
106 #define BTP_MCP_OPCODES_SUPPORTED_READ		0x13
107 struct btp_mcp_opcodes_supported_read_cmd {
108 	bt_addr_le_t address;
109 } __packed;
110 
111 #define BTP_MCP_CONTENT_CONTROL_ID_READ		0x14
112 struct btp_mcp_content_control_id_read_cmd {
113 	bt_addr_le_t address;
114 } __packed;
115 
116 #define BTP_MCP_SEGMENTS_OBJ_ID_READ		0x15
117 struct btp_mcp_segments_obj_id_read_cmd {
118 	bt_addr_le_t address;
119 } __packed;
120 
121 #define BTP_MCP_CURRENT_TRACK_OBJ_ID_READ	0x16
122 struct btp_mcp_current_track_obj_id_read_cmd {
123 	bt_addr_le_t address;
124 } __packed;
125 
126 #define BTP_MCP_CURRENT_TRACK_OBJ_ID_SET	0x17
127 struct btp_mcp_current_track_obj_id_set_cmd {
128 	bt_addr_le_t address;
129 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
130 } __packed;
131 
132 #define BTP_MCP_CMD_SEND			0x18
133 struct btp_mcp_send_cmd {
134 	bt_addr_le_t address;
135 	uint8_t  opcode;
136 	uint8_t use_param;
137 	int32_t param;
138 } __packed;
139 
140 #define BTP_MCP_CMD_SEARCH			0x19
141 struct btp_mcp_search_cmd {
142 	bt_addr_le_t address;
143 	uint8_t type;
144 	uint8_t param_len;
145 	uint8_t param[];
146 } __packed;
147 
148 /* MCP events */
149 #define BTP_MCP_DISCOVERED_EV			0x80
150 struct btp_mcp_discovered_ev {
151 	bt_addr_le_t address;
152 	uint8_t status;
153 	struct {
154 		uint16_t player_name;
155 		uint16_t icon_obj_id;
156 		uint16_t icon_url;
157 		uint16_t track_changed;
158 		uint16_t track_title;
159 		uint16_t track_duration;
160 		uint16_t track_position;
161 		uint16_t playback_speed;
162 		uint16_t seeking_speed;
163 		uint16_t segments_obj_id;
164 		uint16_t current_track_obj_id;
165 		uint16_t next_track_obj_id;
166 		uint16_t current_group_obj_id;
167 		uint16_t parent_group_obj_id;
168 		uint16_t playing_order;
169 		uint16_t playing_orders_supported;
170 		uint16_t media_state;
171 		uint16_t cp;
172 		uint16_t opcodes_supported;
173 		uint16_t search_results_obj_id;
174 		uint16_t scp;
175 		uint16_t content_control_id;
176 	} gmcs_handles;
177 
178 	struct {
179 		uint16_t feature;
180 		uint16_t obj_name;
181 		uint16_t obj_type;
182 		uint16_t obj_size;
183 		uint16_t obj_id;
184 		uint16_t obj_created;
185 		uint16_t obj_modified;
186 		uint16_t obj_properties;
187 		uint16_t oacp;
188 		uint16_t olcp;
189 	} ots_handles;
190 } __packed;
191 
192 #define BTP_MCP_TRACK_DURATION_EV		0x81
193 struct btp_mcp_track_duration_ev {
194 	bt_addr_le_t address;
195 	uint8_t status;
196 	int32_t dur;
197 } __packed;
198 
199 #define BTP_MCP_TRACK_POSITION_EV		0x82
200 struct btp_mcp_track_position_ev {
201 	bt_addr_le_t address;
202 	uint8_t status;
203 	int32_t pos;
204 } __packed;
205 
206 #define BTP_MCP_PLAYBACK_SPEED_EV		0x83
207 struct btp_mcp_playback_speed_ev {
208 	bt_addr_le_t address;
209 	uint8_t status;
210 	int8_t speed;
211 } __packed;
212 
213 #define BTP_MCP_SEEKING_SPEED_EV		0x84
214 struct btp_mcp_seeking_speed_ev {
215 	bt_addr_le_t address;
216 	uint8_t status;
217 	int8_t speed;
218 } __packed;
219 
220 #define BTP_MCP_ICON_OBJ_ID_EV			0x85
221 struct btp_mcp_icon_obj_id_ev {
222 	bt_addr_le_t address;
223 	uint8_t status;
224 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
225 } __packed;
226 
227 #define BTP_MCP_NEXT_TRACK_OBJ_ID_EV		0x86
228 struct btp_mcp_next_track_obj_id_ev {
229 	bt_addr_le_t address;
230 	uint8_t status;
231 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
232 } __packed;
233 
234 #define BTP_MCP_PARENT_GROUP_OBJ_ID_EV		0x87
235 struct btp_mcp_parent_group_obj_id_ev {
236 	bt_addr_le_t address;
237 	uint8_t status;
238 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
239 } __packed;
240 
241 #define BTP_MCP_CURRENT_GROUP_OBJ_ID_EV		0x88
242 struct btp_mcp_current_group_obj_id_ev {
243 	bt_addr_le_t address;
244 	uint8_t status;
245 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
246 } __packed;
247 
248 #define BTP_MCP_PLAYING_ORDER_EV		0x89
249 struct btp_mcp_playing_order_ev {
250 	bt_addr_le_t address;
251 	uint8_t status;
252 	uint8_t order;
253 } __packed;
254 
255 #define BTP_MCP_PLAYING_ORDERS_SUPPORTED_EV	0x8a
256 struct btp_mcp_playing_orders_supported_ev {
257 	bt_addr_le_t address;
258 	uint8_t status;
259 	uint16_t orders;
260 } __packed;
261 
262 #define BTP_MCP_MEDIA_STATE_EV			0x8b
263 struct btp_mcp_media_state_ev {
264 	bt_addr_le_t address;
265 	uint8_t status;
266 	uint8_t state;
267 } __packed;
268 
269 #define BTP_MCP_OPCODES_SUPPORTED_EV		0x8c
270 struct btp_mcp_opcodes_supported_ev {
271 	bt_addr_le_t address;
272 	uint8_t status;
273 	uint32_t opcodes;
274 } __packed;
275 
276 #define BTP_MCP_CONTENT_CONTROL_ID_EV		0x8d
277 struct btp_mcp_content_control_id_ev {
278 	bt_addr_le_t address;
279 	uint8_t status;
280 	uint8_t ccid;
281 } __packed;
282 
283 #define BTP_MCP_SEGMENTS_OBJ_ID_EV		0x8e
284 struct btp_mcp_segments_obj_id_ev {
285 	bt_addr_le_t address;
286 	uint8_t status;
287 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
288 } __packed;
289 
290 #define BTP_MCP_CURRENT_TRACK_OBJ_ID_EV		0x8f
291 struct btp_mcp_current_track_obj_id_ev {
292 	bt_addr_le_t address;
293 	uint8_t status;
294 	uint8_t id[BT_OTS_OBJ_ID_SIZE];
295 } __packed;
296 
297 #define BTP_MCP_MEDIA_CP_EV			0x90
298 struct btp_mcp_media_cp_ev {
299 	bt_addr_le_t address;
300 	uint8_t status;
301 	uint8_t opcode;
302 	bool  use_param;
303 	int32_t param;
304 } __packed;
305 
306 #define BTP_MCP_SEARCH_CP_EV			0x91
307 struct btp_mcp_search_cp_ev {
308 	bt_addr_le_t address;
309 	uint8_t status;
310 	uint8_t param_len;
311 	uint8_t search_type;
312 	uint8_t param[];
313 } __packed;
314 
315 #define BTP_MCP_NTF_EV				0x92
316 struct btp_mcp_cmd_ntf_ev {
317 	bt_addr_le_t address;
318 	uint8_t status;
319 	uint8_t requested_opcode;
320 	uint8_t result_code;
321 } __packed;
322 
323 #define BTP_SCP_NTF_EV				0x93
324 struct btp_scp_cmd_ntf_ev {
325 	bt_addr_le_t address;
326 	uint8_t status;
327 	uint8_t result_code;
328 } __packed;
329