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