1 /*
2  * Copyright (c) 2023 Codecoup
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/bluetooth/audio/bap.h>
8 #include <zephyr/bluetooth/conn.h>
9 #include <zephyr/bluetooth/gatt.h>
10 
11 #define test_ase_snk_get(_num_ase, ...) test_ase_get(BT_UUID_ASCS_ASE_SNK, _num_ase, __VA_ARGS__)
12 #define test_ase_src_get(_num_ase, ...) test_ase_get(BT_UUID_ASCS_ASE_SRC, _num_ase, __VA_ARGS__)
13 
14 struct test_ase_chrc_value_hdr {
15 	uint8_t ase_id;
16 	uint8_t ase_state;
17 	uint8_t params[0];
18 } __packed;
19 
20 struct test_ase_cp_chrc_value_param {
21 	uint8_t ase_id;
22 	uint8_t response_code;
23 	uint8_t reason;
24 } __packed;
25 
26 struct test_ase_cp_chrc_value_hdr {
27 	uint8_t opcode;
28 	uint8_t number_of_ases;
29 	struct test_ase_cp_chrc_value_param params[0];
30 } __packed;
31 
32 #define TEST_ASE_CP_CHRC_VALUE_SIZE(number_of_ases)                                                \
33 	(sizeof(struct test_ase_cp_chrc_value_hdr) +                                               \
34 	 number_of_ases * sizeof(struct test_ase_cp_chrc_value_param))
35 
36 void test_mocks_init(void);
37 void test_mocks_cleanup(void);
38 void test_mocks_reset(void);
39 
40 /* Initialize connection object for test */
41 void test_conn_init(struct bt_conn *conn);
42 uint8_t test_ase_get(const struct bt_uuid *uuid, int num_ase, ...);
43 uint8_t test_ase_id_get(const struct bt_gatt_attr *ase);
44 const struct bt_gatt_attr *test_ase_control_point_get(void);
45 
46 /* client-initiated ASE Control Operations */
47 void test_ase_control_client_config_codec(struct bt_conn *conn, uint8_t ase_id,
48 					  struct bt_bap_stream *stream);
49 void test_ase_control_client_config_qos(struct bt_conn *conn, uint8_t ase_id);
50 void test_ase_control_client_enable(struct bt_conn *conn, uint8_t ase_id);
51 void test_ase_control_client_disable(struct bt_conn *conn, uint8_t ase_id);
52 void test_ase_control_client_release(struct bt_conn *conn, uint8_t ase_id);
53 void test_ase_control_client_update_metadata(struct bt_conn *conn, uint8_t ase_id);
54 void test_ase_control_client_receiver_start_ready(struct bt_conn *conn, uint8_t ase_id);
55 void test_ase_control_client_receiver_stop_ready(struct bt_conn *conn, uint8_t ase_id);
56 
57 /* preambles */
58 void test_preamble_state_codec_configured(struct bt_conn *conn, uint8_t ase_id,
59 					  struct bt_bap_stream *stream);
60 void test_preamble_state_qos_configured(struct bt_conn *conn, uint8_t ase_id,
61 					struct bt_bap_stream *stream);
62 void test_preamble_state_enabling(struct bt_conn *conn, uint8_t ase_id,
63 				  struct bt_bap_stream *stream);
64 void test_preamble_state_streaming(struct bt_conn *conn, uint8_t ase_id,
65 				   struct bt_bap_stream *stream, struct bt_iso_chan **chan,
66 				   bool source);
67 void test_preamble_state_disabling(struct bt_conn *conn, uint8_t ase_id,
68 				   struct bt_bap_stream *stream, struct bt_iso_chan **chan);
69