xref: /haiku/headers/os/bluetooth/HCI/btHCI_event.h (revision 8195a5a835117ab2da405e0d477153570b75d921)
1 /*
2  * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3  *
4  * All rights reserved. Distributed under the terms of the MIT License.
5  *
6  */
7 
8 #ifndef _BTHCI_EVENT_H_
9 #define _BTHCI_EVENT_H_
10 
11 #include <bluetooth/bluetooth.h>
12 
13 #define HCI_EVENT_HDR_SIZE   2
14 
15 struct hci_event_header {
16 	uint8 	ecode;
17 	uint8 	elen;
18 } __attribute__ ((packed));
19 
20 
21 /* ---- HCI Events ---- */
22 #define HCI_EVENT_INQUIRY_COMPLETE	0x01
23 
24 #define HCI_EVENT_INQUIRY_RESULT	0x02
25 struct inquiry_info {
26 	bdaddr_t  bdaddr;
27 	uint8     pscan_rep_mode;
28 	uint8     pscan_period_mode;
29 	uint8     pscan_mode;
30 	uint8     dev_class[3];
31 	uint16    clock_offset;
32 } __attribute__ ((packed));
33 
34 #define HCI_EVENT_CONN_COMPLETE 	0x03
35 struct hci_ev_conn_complete {
36 	uint8     status;
37 	uint16    handle;
38 	bdaddr_t  bdaddr;
39 	uint8     link_type;
40 	uint8     encrypt_mode;
41 } __attribute__ ((packed));
42 
43 #define HCI_EVENT_CONN_REQUEST	0x04
44 struct hci_ev_conn_request {
45 	bdaddr_t bdaddr;
46 	uint8     dev_class[3];
47 	uint8     link_type;
48 } __attribute__ ((packed));
49 
50 #define HCI_EVENT_DISCONNECTION_COMPLETE	0x05
51 struct hci_disconnection_complete_reply {
52 	uint8     status;
53 	uint16    handle;
54 	uint8     reason;
55 } __attribute__ ((packed));
56 
57 #define HCI_EVENT_AUTH_COMPLETE	0x06
58 struct hci_ev_auth_complete {
59 	uint8     status;
60 	uint16    handle;
61 } __attribute__ ((packed));
62 
63 #define HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE	0x07
64 struct hci_remote_name_request_complete_reply {
65 	uint8     status;
66 	bdaddr_t  bdaddr;
67 	char	  remote_name[248];
68 } __attribute__ ((packed));
69 
70 #define HCI_EVENT_ENCRYPT_CHANGE	0x08
71 struct hci_ev_encrypt_change {
72 	uint8     status;
73 	uint16    handle;
74 	uint8     encrypt;
75 } __attribute__ ((packed));
76 
77 #define HCI_EVENT_CHANGE_CONN_LINK_KEY_COMPLETE	0x09
78 struct hci_ev_change_conn_link_key_complete {
79 	uint8     status;
80 	uint16    handle;
81 } __attribute__ ((packed));
82 
83 #define HCI_EVENT_MASTER_LINK_KEY_COMPL	0x0a
84 struct hci_ev_master_link_key_complete {
85 	uint8	 status;     /* 0x00 - success */
86 	uint16	 handle;     /* Connection handle */
87 	uint8	 key_flag;   /* Key flag */
88 } __attribute__ ((packed));
89 
90 #define HCI_EVENT_RMT_FEATURES	0x0B
91 struct hci_ev_rmt_features {
92 	uint8     status;
93 	uint16    handle;
94 	uint8     features[8];
95 } __attribute__ ((packed));
96 
97 #define HCI_EVENT_RMT_VERSION	0x0C
98 struct hci_ev_rmt_version {
99 	uint8     status;
100 	uint16    handle;
101 	uint8     lmp_ver;
102 	uint16    manufacturer;
103 	uint16    lmp_subver;
104 } __attribute__ ((packed));
105 
106 #define HCI_EVENT_QOS_SETUP_COMPLETE	0x0D
107 struct hci_qos {
108 	uint8     service_type;
109 	uint32    token_rate;
110 	uint32    peak_bandwidth;
111 	uint32    latency;
112 	uint32    delay_variation;
113 } __attribute__ ((packed));
114 struct hci_ev_qos_setup_complete {
115 	uint8     status;
116 	uint16    handle;
117 	struct   hci_qos qos;
118 } __attribute__ ((packed));
119 
120 #define HCI_EVENT_CMD_COMPLETE 	0x0E
121 struct hci_ev_cmd_complete {
122 	uint8     ncmd;
123 	uint16    opcode;
124 } __attribute__ ((packed));
125 
126 #define HCI_EVENT_CMD_STATUS 	0x0F
127 struct hci_ev_cmd_status {
128 	uint8     status;
129 	uint8     ncmd;
130 	uint16    opcode;
131 } __attribute__ ((packed));
132 
133 #define HCI_EVENT_HARDWARE_ERROR		0x10
134 struct hci_ev_hardware_error {
135 	uint8	hardware_code; /* hardware error code */
136 } __attribute__ ((packed)) ;
137 
138 #define HCI_EVENT_FLUSH_OCCUR		0x11
139 struct hci_ev_flush_occur {
140 	uint16	handle; /* connection handle */
141 } __attribute__ ((packed)) ;
142 
143 #define HCI_EVENT_ROLE_CHANGE	0x12
144 struct hci_ev_role_change {
145 	uint8     status;
146 	bdaddr_t bdaddr;
147 	uint8     role;
148 } __attribute__ ((packed));
149 
150 #define HCI_EVENT_NUM_COMP_PKTS	0x13
151     struct handle_and_number {
152 			uint16	handle;
153 			uint16  num_completed;
154 		} __attribute__ ((packed));
155 
156 	struct hci_ev_num_comp_pkts {
157 		uint8     num_hndl;
158 		// struct   handle_and_number; hardcoded...
159 	} __attribute__ ((packed));
160 
161 #define HCI_EVENT_MODE_CHANGE	0x14
162 struct hci_ev_mode_change {
163 	uint8     status;
164 	uint16    handle;
165 	uint8     mode;
166 	uint16    interval;
167 } __attribute__ ((packed));
168 
169 #define HCI_EVENT_RETURN_LINK_KEYS		0x15
170 struct link_key_info {
171 	bdaddr_t	bdaddr;
172 	uint8		link_key[HCI_LINK_KEY_SIZE];
173 } __attribute__ ((packed)) ;
174 struct hci_ev_return_link_keys {
175 	uint8					num_keys;    /* # of keys */
176 	struct link_key_info	link_keys;   /* As much as num_keys param */
177 } __attribute__ ((packed)) ;
178 
179 #define HCI_EVENT_PIN_CODE_REQ	0x16
180 struct hci_ev_pin_code_req {
181 	bdaddr_t bdaddr;
182 } __attribute__ ((packed));
183 
184 #define HCI_EVENT_LINK_KEY_REQ	0x17
185 struct hci_ev_link_key_req {
186 	bdaddr_t bdaddr;
187 } __attribute__ ((packed));
188 
189 #define HCI_EVENT_LINK_KEY_NOTIFY	0x18
190 struct hci_ev_link_key_notify {
191 	bdaddr_t bdaddr;
192 	uint8	 link_key[16];
193 	uint8	 key_type;
194 } __attribute__ ((packed));
195 
196 #define HCI_EVENT_LOOPBACK_COMMAND		0x19
197 struct hci_ev_loopback_command {
198 	uint8		command[0]; /* depends of command */
199 } __attribute__ ((packed)) ;
200 
201 #define HCI_EVENT_DATA_BUFFER_OVERFLOW	0x1a
202 struct hci_ev_data_buffer_overflow {
203 	uint8		link_type; /* Link type */
204 } __attribute__ ((packed)) ;
205 
206 #define HCI_EVENT_MAX_SLOT_CHANGE		0x1b
207 struct hci_ev_max_slot_change {
208 	uint16	handle;    /* connection handle */
209 	uint8	lmp_max_slots; /* Max. # of slots allowed */
210 } __attribute__ ((packed)) ;
211 
212 #define HCI_EVENT_READ_CLOCK_OFFSET_COMPL	0x1c
213 struct hci_ev_read_clock_offset_compl {
214 	uint8		status;       /* 0x00 - success */
215 	uint16		handle;       /* Connection handle */
216 	uint16		clock_offset; /* Clock offset */
217 } __attribute__ ((packed)) ;
218 
219 #define HCI_EVENT_CON_PKT_TYPE_CHANGED	0x1d
220 struct hci_ev_con_pkt_type_changed {
221 	uint8		status;     /* 0x00 - success */
222 	uint16		handle; /* connection handle */
223 	uint16		pkt_type;   /* packet type */
224 } __attribute__ ((packed));
225 
226 #define HCI_EVENT_QOS_VIOLATION		0x1e
227 struct hci_ev_qos_violation {
228 	uint16		handle; /* connection handle */
229 } __attribute__ ((packed)) ;
230 
231 #define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE	0x20
232 struct hci_ev_page_scan_rep_mode_change {
233 	bdaddr_t	bdaddr;             /* destination address */
234 	uint8	    page_scan_rep_mode; /* page scan repetition mode */
235 } __attribute__ ((packed));
236 
237 /* Events Beyond Bluetooth 1.1 */
238 #define HCI_EVENT_FLOW_SPECIFICATION		0x21
239 struct hci_ev_flow_specification {
240 	uint8		status;
241 	uint16		handle;
242 	uint8		flags;
243 	uint8		flow_direction;
244 	uint8		service_type;
245 	uint32		token_rate;
246 	uint32 		token_bucket_size;
247 	uint32		peak_bandwidth;
248 	uint32		access_latency;
249 } __attribute__ ((packed));
250 
251 #define HCI_EVENT_INQUIRY_RESULT_WITH_RSSI	0x22
252 struct hci_ev_inquiry_info_with_rssi {
253 	bdaddr_t bdaddr;
254 	uint8     pscan_rep_mode;
255 	uint8     pscan_period_mode;
256 	uint8     dev_class[3];
257 	uint16    clock_offset;
258 	int8      rssi;
259 } __attribute__ ((packed));
260 
261 #define HCI_EVENT_REMOTE_EXTENDED_FEATURES	0x23
262 struct hci_ev_remote_extended_features {
263 	uint8     status;
264 	uint16    handle;
265 	uint8     page_number;
266 	uint8	  maximun_page_number;
267 	uint64	  extended_lmp_features;
268 } __attribute__ ((packed));
269 
270 #define HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETED	0x2C
271 struct hci_ev_sychronous_connection_completed {
272 	uint8     status;
273 	uint16    handle;
274 	bdaddr_t  bdaddr;
275 	uint8	  link_type;
276 	uint8	  transmission_interval;
277 	uint8	  retransmission_window;
278 	uint16	  rx_packet_length;
279 	uint16	  tx_packet_length;
280 	uint8	  air_mode;
281 } __attribute__ ((packed));
282 
283 #define HCI_EVENT_SYNCHRONOUS_CONNECTION_CHANGED	0x2D
284 struct hci_ev_sychronous_connection_changed {
285 	uint8     status;
286 	uint16    handle;
287 	uint8	  transmission_interval;
288 	uint8	  retransmission_window;
289 	uint16	  rx_packet_length;
290 	uint16	  tx_packet_length;
291 } __attribute__ ((packed));
292 
293 // TODO: Define remaining Bluetooth 2.1 events structures
294 #define HCI_EVENT_EXTENDED_INQUIRY_RESULT			0x2F
295 
296 #define HCI_EVENT_ENCRYPTION_KEY_REFERSH_COMPLETE	0x30
297 
298 #define HCI_EVENT_IO_CAPABILITY_REQUEST				0x31
299 
300 #define HCI_EVENT_IO_CAPABILITY_RESPONSE			0x32
301 
302 #define HCI_EVENT_USER_CONFIRMATION_REQUEST			0x33
303 
304 #define HCI_EVENT_USER_PASSKEY_REQUEST				0x34
305 
306 #define HCI_EVENT_OOB_DATA_REQUEST					0x35
307 
308 #define HCI_EVENT_SIMPLE_PAIRING_COMPLETE			0x36
309 
310 #define HCI_EVENT_LINK_SUPERVISION_TIMEOUT_CHANGED	0x38
311 
312 #define HCI_EVENT_ENHANCED_FLUSH_COMPLETE			0x39
313 
314 #define HCI_EVENT_KEYPRESS_NOTIFICATION				0x3C
315 
316 #define HCI_EVENT_REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION	0x3D
317 
318 
319 
320 
321 /* HAIKU Internal Events, not produced by the transport devices but
322  * by some entity of the Haiku Bluetooth Stack.
323  * The MSB 0xE is chosen for this purpose
324  */
325 
326 #define HCI_HAIKU_EVENT_SERVER_QUITTING				0xE0
327 #define HCI_HAIKU_EVENT_DEVICE_REMOVED				0xE1
328 
329 
330 #endif
331