1 /* btp_aics.h - Bluetooth tester headers */
2 
3 /*
4  * Copyright (c) 2022 Codecoup
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include <zephyr/sys/util.h>
10 #include <zephyr/bluetooth/conn.h>
11 
12 /*AICS service */
13 struct btp_aics_instance {
14 	/** Number of Audio Input Control Service instances */
15 	uint8_t aics_cnt;
16 	/** Array of pointers to Audio Input Control Service instances */
17 	struct bt_aics **aics;
18 };
19 
20 extern struct bt_aics_cb aics_client_cb;
21 extern struct btp_aics_instance aics_client_instance;
22 extern struct btp_aics_instance aics_server_instance;
23 void btp_send_aics_state_ev(struct bt_conn *conn, uint8_t att_status, int8_t gain, uint8_t mute,
24 			    uint8_t mode);
25 void btp_send_gain_setting_properties_ev(struct bt_conn *conn, uint8_t att_status, uint8_t units,
26 					 int8_t minimum, int8_t maximum);
27 void btp_send_aics_input_type_event(struct bt_conn *conn, uint8_t att_status, uint8_t input_type);
28 void btp_send_aics_status_ev(struct bt_conn *conn, uint8_t att_status, bool active);
29 void btp_send_aics_description_ev(struct bt_conn *conn, uint8_t att_status, uint8_t data_len,
30 				  char *description);
31 void btp_send_aics_procedure_ev(struct bt_conn *conn, uint8_t att_status, uint8_t opcode);
32 
33 #define BTP_AICS_READ_SUPPORTED_COMMANDS	0x01
34 struct btp_aics_read_supported_commands_rp {
35 	uint8_t data[0];
36 } __packed;
37 
38 /* AICS client/server commands */
39 #define BTP_AICS_SET_GAIN			0x02
40 struct btp_aics_set_gain_cmd {
41 	bt_addr_le_t address;
42 	int8_t gain;
43 } __packed;
44 
45 #define BTP_AICS_MUTE				0x03
46 struct btp_aics_mute_cmd {
47 	bt_addr_le_t address;
48 } __packed;
49 
50 #define BTP_AICS_UNMUTE				0x04
51 struct btp_aics_unmute_cmd {
52 	bt_addr_le_t address;
53 } __packed;
54 
55 #define BTP_AICS_MAN_GAIN_SET			0x05
56 struct btp_aics_manual_gain_cmd {
57 	bt_addr_le_t address;
58 } __packed;
59 
60 #define BTP_AICS_AUTO_GAIN_SET			0x06
61 struct btp_aics_auto_gain_cmd {
62 	bt_addr_le_t address;
63 } __packed;
64 
65 #define BTP_AICS_SET_MAN_GAIN_ONLY		0x07
66 #define BTP_AICS_SET_AUTO_GAIN_ONLY		0x08
67 #define BTP_AICS_AUDIO_DESCRIPTION_SET		0x09
68 struct btp_aics_audio_desc_cmd {
69 	uint8_t desc_len;
70 	uint8_t desc[0];
71 } __packed;
72 
73 #define BTP_AICS_MUTE_DISABLE			0x0a
74 #define BTP_AICS_GAIN_SETTING_PROP_GET		0x0b
75 struct btp_aics_gain_setting_prop_cmd {
76 	bt_addr_le_t address;
77 } __packed;
78 
79 #define BTP_AICS_TYPE_GET			0x0c
80 struct btp_aics_type_cmd {
81 	bt_addr_le_t address;
82 } __packed;
83 
84 #define BTP_AICS_STATUS_GET			0x0d
85 struct btp_aics_status_cmd {
86 	bt_addr_le_t address;
87 } __packed;
88 
89 #define BTP_AICS_STATE_GET			0x0e
90 struct btp_aics_state_cmd {
91 	bt_addr_le_t address;
92 } __packed;
93 
94 #define BTP_AICS_DESCRIPTION_GET		0x0f
95 struct btp_aics_desc_cmd {
96 	bt_addr_le_t address;
97 } __packed;
98 
99 /* AICS events */
100 #define BTP_AICS_STATE_EV			0x80
101 struct btp_aics_state_ev {
102 	bt_addr_le_t address;
103 	uint8_t att_status;
104 	int8_t gain;
105 	uint8_t mute;
106 	uint8_t mode;
107 } __packed;
108 
109 #define BTP_GAIN_SETTING_PROPERTIES_EV		0x81
110 struct btp_gain_setting_properties_ev {
111 	bt_addr_le_t address;
112 	uint8_t att_status;
113 	uint8_t units;
114 	int8_t minimum;
115 	int8_t maximum;
116 } __packed;
117 
118 #define BTP_AICS_INPUT_TYPE_EV			0x82
119 struct btp_aics_input_type_ev {
120 	bt_addr_le_t address;
121 	uint8_t att_status;
122 	uint8_t input_type;
123 } __packed;
124 
125 #define BTP_AICS_STATUS_EV			0x83
126 struct btp_aics_status_ev {
127 	bt_addr_le_t address;
128 	uint8_t att_status;
129 	bool active;
130 } __packed;
131 
132 #define BTP_AICS_DESCRIPTION_EV			0x84
133 struct btp_aics_description_ev {
134 	bt_addr_le_t address;
135 	uint8_t att_status;
136 	uint8_t data_len;
137 	char data[0];
138 } __packed;
139 
140 #define BTP_AICS_PROCEDURE_EV			0x85
141 struct btp_aics_procedure_ev {
142 	bt_addr_le_t address;
143 	uint8_t att_status;
144 	uint8_t opcode;
145 } __packed;
146