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