1 /* $NetBSD: hci.h,v 1.19 2007/11/28 20:16:12 plunky Exp $ */ 2 3 /*- 4 * Copyright (c) 2005 Iain Hibbert. 5 * Copyright (c) 2006 Itronix Inc. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. The name of Itronix Inc. may not be used to endorse 17 * or promote products derived from this software without specific 18 * prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 * ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 /*- 33 * Copyright (c) 2001 Maksim Yevmenkin <m_evmenkin@yahoo.com> 34 * All rights reserved. 35 * 36 * Redistribution and use in source and binary forms, with or without 37 * modification, are permitted provided that the following conditions 38 * are met: 39 * 1. Redistributions of source code must retain the above copyright 40 * notice, this list of conditions and the following disclaimer. 41 * 2. Redistributions in binary form must reproduce the above copyright 42 * notice, this list of conditions and the following disclaimer in the 43 * documentation and/or other materials provided with the distribution. 44 * 45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 55 * SUCH DAMAGE. 56 * 57 * $Id: hci.h,v 1.19 2007/11/28 20:16:12 plunky Exp $ 58 * $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $ 59 */ 60 61 /* 62 * This file contains everything that applications need to know from 63 * Host Controller Interface (HCI). Information taken from Bluetooth 64 * Core Specifications (v1.1 and v2.0) 65 * 66 * This file can be included by both kernel and userland applications. 67 * 68 * NOTE: Here and after Bluetooth device is called a "unit". Bluetooth 69 * specification refers to both devices and units. They are the 70 * same thing (I think), so to be consistent word "unit" will be 71 * used. 72 */ 73 74 #ifndef _NETBT_HCI_H_ 75 #define _NETBT_HCI_H_ 76 77 #include <netbt/bluetooth.h> 78 79 /************************************************************************** 80 ************************************************************************** 81 ** Common defines and types (HCI) 82 ************************************************************************** 83 **************************************************************************/ 84 85 #define HCI_LAP_SIZE 3 /* unit LAP */ 86 #define HCI_KEY_SIZE 16 /* link key */ 87 #define HCI_PIN_SIZE 16 /* link PIN */ 88 #define HCI_EVENT_MASK_SIZE 8 /* event mask */ 89 #define HCI_CLASS_SIZE 3 /* unit class */ 90 #define HCI_FEATURES_SIZE 8 /* LMP features */ 91 #define HCI_UNIT_NAME_SIZE 248 /* unit name size */ 92 #define HCI_DEVNAME_SIZE 16 /* same as dv_xname */ 93 94 /* HCI specification */ 95 #define HCI_SPEC_V10 0x00 /* v1.0 */ 96 #define HCI_SPEC_V11 0x01 /* v1.1 */ 97 #define HCI_SPEC_V12 0x02 /* v1.2 */ 98 #define HCI_SPEC_V20 0x03 /* v2.0 */ 99 /* 0x02 - 0xFF - reserved for future use */ 100 101 /* LMP features (and page 0 of extended features) */ 102 /* ------------------- byte 0 --------------------*/ 103 #define HCI_LMP_3SLOT 0x01 104 #define HCI_LMP_5SLOT 0x02 105 #define HCI_LMP_ENCRYPTION 0x04 106 #define HCI_LMP_SLOT_OFFSET 0x08 107 #define HCI_LMP_TIMIACCURACY 0x10 108 #define HCI_LMP_ROLE_SWITCH 0x20 109 #define HCI_LMP_HOLD_MODE 0x40 110 #define HCI_LMP_SNIFF_MODE 0x80 111 /* ------------------- byte 1 --------------------*/ 112 #define HCI_LMP_PARK_MODE 0x01 113 #define HCI_LMP_RSSI 0x02 114 #define HCI_LMP_CHANNEL_QUALITY 0x04 115 #define HCI_LMP_SCO_LINK 0x08 116 #define HCI_LMP_HV2_PKT 0x10 117 #define HCI_LMP_HV3_PKT 0x20 118 #define HCI_LMP_ULAW_LOG 0x40 119 #define HCI_LMP_ALAW_LOG 0x80 120 /* ------------------- byte 2 --------------------*/ 121 #define HCI_LMP_CVSD 0x01 122 #define HCI_LMP_PAGISCHEME 0x02 123 #define HCI_LMP_POWER_CONTROL 0x04 124 #define HCI_LMP_TRANSPARENT_SCO 0x08 125 #define HCI_LMP_FLOW_CONTROL_LAG0 0x10 126 #define HCI_LMP_FLOW_CONTROL_LAG1 0x20 127 #define HCI_LMP_FLOW_CONTROL_LAG2 0x40 128 #define HCI_LMP_BC_ENCRYPTION 0x80 129 /* ------------------- byte 3 --------------------*/ 130 /* reserved 0x01 */ 131 #define HCI_LMP_EDR_ACL_2MBPS 0x02 132 #define HCI_LMP_EDR_ACL_3MBPS 0x04 133 #define HCI_LMP_ENHANCED_ISCAN 0x08 134 #define HCI_LMP_INTERLACED_ISCAN 0x10 135 #define HCI_LMP_INTERLACED_PSCAN 0x20 136 #define HCI_LMP_RSSI_INQUIRY 0x40 137 #define HCI_LMP_EV3_PKT 0x80 138 /* ------------------- byte 4 --------------------*/ 139 #define HCI_LMP_EV4_PKT 0x01 140 #define HCI_LMP_EV5_PKT 0x02 141 /* reserved 0x04 */ 142 #define HCI_LMP_AFH_CAPABLE_SLAVE 0x08 143 #define HCI_LMP_AFH_CLASS_SLAVE 0x10 144 /* reserved 0x20 */ 145 /* reserved 0x40 */ 146 #define HCI_LMP_3SLOT_EDR_ACL 0x80 147 /* ------------------- byte 5 --------------------*/ 148 #define HCI_LMP_5SLOT_EDR_ACL 0x01 149 /* reserved 0x02 */ 150 /* reserved 0x04 */ 151 #define HCI_LMP_AFH_CAPABLE_MASTER 0x08 152 #define HCI_LMP_AFH_CLASS_MASTER 0x10 153 #define HCI_LMP_EDR_eSCO_2MBPS 0x20 154 #define HCI_LMP_EDR_eSCO_3MBPS 0x40 155 #define HCI_LMP_3SLOT_EDR_eSCO 0x80 156 /* ------------------- byte 6 --------------------*/ 157 /* reserved */ 158 /* ------------------- byte 7 --------------------*/ 159 #define HCI_LMP_EXTENDED_FEATURES 0x80 160 161 /* Link types */ 162 #define HCI_LINK_SCO 0x00 /* Voice */ 163 #define HCI_LINK_ACL 0x01 /* Data */ 164 #define HCI_LINK_eSCO 0x02 /* eSCO */ 165 /* 0x03 - 0xFF - reserved for future use */ 166 167 /* 168 * ACL/SCO packet type bits are set to enable the 169 * packet type, except for 2MBPS and 3MBPS when they 170 * are unset to enable the packet type. 171 */ 172 /* ACL Packet types for "Create Connection" */ 173 #define HCI_PKT_2MBPS_DH1 0x0002 174 #define HCI_PKT_3MBPS_DH1 0x0004 175 #define HCI_PKT_DM1 0x0008 176 #define HCI_PKT_DH1 0x0010 177 #define HCI_PKT_2MBPS_DH3 0x0100 178 #define HCI_PKT_3MBPS_DH3 0x0200 179 #define HCI_PKT_DM3 0x0400 180 #define HCI_PKT_DH3 0x0800 181 #define HCI_PKT_2MBPS_DH5 0x1000 182 #define HCI_PKT_3MBPS_DH5 0x2000 183 #define HCI_PKT_DM5 0x4000 184 #define HCI_PKT_DH5 0x8000 185 186 /* SCO Packet types for "Setup Synchronous Connection" */ 187 #define HCI_PKT_HV1 0x0001 188 #define HCI_PKT_HV2 0x0002 189 #define HCI_PKT_HV3 0x0004 190 #define HCI_PKT_EV3 0x0008 191 #define HCI_PKT_EV4 0x0010 192 #define HCI_PKT_EV5 0x0020 193 #define HCI_PKT_2MBPS_EV3 0x0040 194 #define HCI_PKT_3MBPS_EV3 0x0080 195 #define HCI_PKT_2MBPS_EV5 0x0100 196 #define HCI_PKT_3MBPS_EV5 0x0200 197 198 /* 199 * Connection modes/Unit modes 200 * 201 * This is confusing. It means that one of the units change its mode 202 * for the specific connection. For example one connection was put on 203 * hold (but i could be wrong :) 204 */ 205 206 /* Page scan modes (are deprecated) */ 207 #define HCI_MANDATORY_PAGE_SCAN_MODE 0x00 208 #define HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01 209 #define HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02 210 #define HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03 211 /* 0x04 - 0xFF - reserved for future use */ 212 213 /* Page scan repetition modes */ 214 #define HCI_SCAN_REP_MODE0 0x00 215 #define HCI_SCAN_REP_MODE1 0x01 216 #define HCI_SCAN_REP_MODE2 0x02 217 /* 0x03 - 0xFF - reserved for future use */ 218 219 /* Page scan period modes */ 220 #define HCI_PAGE_SCAN_PERIOD_MODE0 0x00 221 #define HCI_PAGE_SCAN_PERIOD_MODE1 0x01 222 #define HCI_PAGE_SCAN_PERIOD_MODE2 0x02 223 /* 0x03 - 0xFF - reserved for future use */ 224 225 /* Scan enable */ 226 #define HCI_NO_SCAN_ENABLE 0x00 227 #define HCI_INQUIRY_SCAN_ENABLE 0x01 228 #define HCI_PAGE_SCAN_ENABLE 0x02 229 /* 0x04 - 0xFF - reserved for future use */ 230 231 /* Hold mode activities */ 232 #define HCI_HOLD_MODE_NO_CHANGE 0x00 233 #define HCI_HOLD_MODE_SUSPEND_PAGE_SCAN 0x01 234 #define HCI_HOLD_MODE_SUSPEND_INQUIRY_SCAN 0x02 235 #define HCI_HOLD_MODE_SUSPEND_PERIOD_INQUIRY 0x04 236 /* 0x08 - 0x80 - reserved for future use */ 237 238 /* Connection roles */ 239 #define HCI_ROLE_MASTER 0x00 240 #define HCI_ROLE_SLAVE 0x01 241 /* 0x02 - 0xFF - reserved for future use */ 242 243 /* Key flags */ 244 #define HCI_USE_SEMI_PERMANENT_LINK_KEYS 0x00 245 #define HCI_USE_TEMPORARY_LINK_KEY 0x01 246 /* 0x02 - 0xFF - reserved for future use */ 247 248 /* Pin types */ 249 #define HCI_PIN_TYPE_VARIABLE 0x00 250 #define HCI_PIN_TYPE_FIXED 0x01 251 252 /* Link key types */ 253 #define HCI_LINK_KEY_TYPE_COMBINATION_KEY 0x00 254 #define HCI_LINK_KEY_TYPE_LOCAL_UNIT_KEY 0x01 255 #define HCI_LINK_KEY_TYPE_REMOTE_UNIT_KEY 0x02 256 /* 0x03 - 0xFF - reserved for future use */ 257 258 /* Encryption modes */ 259 #define HCI_ENCRYPTION_MODE_NONE 0x00 260 #define HCI_ENCRYPTION_MODE_P2P 0x01 261 #define HCI_ENCRYPTION_MODE_ALL 0x02 262 /* 0x03 - 0xFF - reserved for future use */ 263 264 /* Quality of service types */ 265 #define HCI_SERVICE_TYPE_NO_TRAFFIC 0x00 266 #define HCI_SERVICE_TYPE_BEST_EFFORT 0x01 267 #define HCI_SERVICE_TYPE_GUARANTEED 0x02 268 /* 0x03 - 0xFF - reserved for future use */ 269 270 /* Link policy settings */ 271 #define HCI_LINK_POLICY_DISABLE_ALL_LM_MODES 0x0000 272 #define HCI_LINK_POLICY_ENABLE_ROLE_SWITCH 0x0001 /* Master/Slave switch */ 273 #define HCI_LINK_POLICY_ENABLE_HOLD_MODE 0x0002 274 #define HCI_LINK_POLICY_ENABLE_SNIFF_MODE 0x0004 275 #define HCI_LINK_POLICY_ENABLE_PARK_MODE 0x0008 276 /* 0x0010 - 0x8000 - reserved for future use */ 277 278 /* Event masks */ 279 #define HCI_EVMSK_ALL 0x00000000ffffffff 280 #define HCI_EVMSK_NONE 0x0000000000000000 281 #define HCI_EVMSK_INQUIRY_COMPL 0x0000000000000001 282 #define HCI_EVMSK_INQUIRY_RESULT 0x0000000000000002 283 #define HCI_EVMSK_CON_COMPL 0x0000000000000004 284 #define HCI_EVMSK_CON_REQ 0x0000000000000008 285 #define HCI_EVMSK_DISCON_COMPL 0x0000000000000010 286 #define HCI_EVMSK_AUTH_COMPL 0x0000000000000020 287 #define HCI_EVMSK_REMOTE_NAME_REQ_COMPL 0x0000000000000040 288 #define HCI_EVMSK_ENCRYPTION_CHANGE 0x0000000000000080 289 #define HCI_EVMSK_CHANGE_CON_LINK_KEY_COMPL 0x0000000000000100 290 #define HCI_EVMSK_MASTER_LINK_KEY_COMPL 0x0000000000000200 291 #define HCI_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000400 292 #define HCI_EVMSK_READ_REMOTE_VER_INFO_COMPL 0x0000000000000800 293 #define HCI_EVMSK_QOS_SETUP_COMPL 0x0000000000001000 294 #define HCI_EVMSK_COMMAND_COMPL 0x0000000000002000 295 #define HCI_EVMSK_COMMAND_STATUS 0x0000000000004000 296 #define HCI_EVMSK_HARDWARE_ERROR 0x0000000000008000 297 #define HCI_EVMSK_FLUSH_OCCUR 0x0000000000010000 298 #define HCI_EVMSK_ROLE_CHANGE 0x0000000000020000 299 #define HCI_EVMSK_NUM_COMPL_PKTS 0x0000000000040000 300 #define HCI_EVMSK_MODE_CHANGE 0x0000000000080000 301 #define HCI_EVMSK_RETURN_LINK_KEYS 0x0000000000100000 302 #define HCI_EVMSK_PIN_CODE_REQ 0x0000000000200000 303 #define HCI_EVMSK_LINK_KEY_REQ 0x0000000000400000 304 #define HCI_EVMSK_LINK_KEY_NOTIFICATION 0x0000000000800000 305 #define HCI_EVMSK_LOOPBACK_COMMAND 0x0000000001000000 306 #define HCI_EVMSK_DATA_BUFFER_OVERFLOW 0x0000000002000000 307 #define HCI_EVMSK_MAX_SLOT_CHANGE 0x0000000004000000 308 #define HCI_EVMSK_READ_CLOCK_OFFSET_COMLETE 0x0000000008000000 309 #define HCI_EVMSK_CON_PKT_TYPE_CHANGED 0x0000000010000000 310 #define HCI_EVMSK_QOS_VIOLATION 0x0000000020000000 311 #define HCI_EVMSK_PAGE_SCAN_MODE_CHANGE 0x0000000040000000 312 #define HCI_EVMSK_PAGE_SCAN_REP_MODE_CHANGE 0x0000000080000000 313 /* 0x0000000100000000 - 0x8000000000000000 - reserved for future use */ 314 315 /* Filter types */ 316 #define HCI_FILTER_TYPE_NONE 0x00 317 #define HCI_FILTER_TYPE_INQUIRY_RESULT 0x01 318 #define HCI_FILTER_TYPE_CON_SETUP 0x02 319 /* 0x03 - 0xFF - reserved for future use */ 320 321 /* Filter condition types for HCI_FILTER_TYPE_INQUIRY_RESULT */ 322 #define HCI_FILTER_COND_INQUIRY_NEW_UNIT 0x00 323 #define HCI_FILTER_COND_INQUIRY_UNIT_CLASS 0x01 324 #define HCI_FILTER_COND_INQUIRY_BDADDR 0x02 325 /* 0x03 - 0xFF - reserved for future use */ 326 327 /* Filter condition types for HCI_FILTER_TYPE_CON_SETUP */ 328 #define HCI_FILTER_COND_CON_ANY_UNIT 0x00 329 #define HCI_FILTER_COND_CON_UNIT_CLASS 0x01 330 #define HCI_FILTER_COND_CON_BDADDR 0x02 331 /* 0x03 - 0xFF - reserved for future use */ 332 333 /* Xmit level types */ 334 #define HCI_XMIT_LEVEL_CURRENT 0x00 335 #define HCI_XMIT_LEVEL_MAXIMUM 0x01 336 /* 0x02 - 0xFF - reserved for future use */ 337 338 /* Host Controller to Host flow control */ 339 #define HCI_HC2H_FLOW_CONTROL_NONE 0x00 340 #define HCI_HC2H_FLOW_CONTROL_ACL 0x01 341 #define HCI_HC2H_FLOW_CONTROL_SCO 0x02 342 #define HCI_HC2H_FLOW_CONTROL_BOTH 0x03 343 /* 0x04 - 0xFF - reserved future use */ 344 345 /* Loopback modes */ 346 #define HCI_LOOPBACK_NONE 0x00 347 #define HCI_LOOPBACK_LOCAL 0x01 348 #define HCI_LOOPBACK_REMOTE 0x02 349 /* 0x03 - 0xFF - reserved future use */ 350 351 /************************************************************************** 352 ************************************************************************** 353 ** Link level defines, headers and types 354 ************************************************************************** 355 **************************************************************************/ 356 357 /* 358 * Macro(s) to combine OpCode and extract OGF (OpCode Group Field) 359 * and OCF (OpCode Command Field) from OpCode. 360 */ 361 362 #define HCI_OPCODE(gf,cf) ((((gf) & 0x3f) << 10) | ((cf) & 0x3ff)) 363 #define HCI_OCF(op) ((op) & 0x3ff) 364 #define HCI_OGF(op) (((op) >> 10) & 0x3f) 365 366 /* 367 * Macro(s) to extract/combine connection handle, BC (Broadcast) and 368 * PB (Packet boundary) flags. 369 */ 370 371 #define HCI_CON_HANDLE(h) ((h) & 0x0fff) 372 #define HCI_PB_FLAG(h) (((h) & 0x3000) >> 12) 373 #define HCI_BC_FLAG(h) (((h) & 0xc000) >> 14) 374 #define HCI_MK_CON_HANDLE(h, pb, bc) \ 375 (((h) & 0x0fff) | (((pb) & 3) << 12) | (((bc) & 3) << 14)) 376 377 /* PB flag values */ 378 /* 00 - reserved for future use */ 379 #define HCI_PACKET_FRAGMENT 0x1 380 #define HCI_PACKET_START 0x2 381 /* 11 - reserved for future use */ 382 383 /* BC flag values */ 384 #define HCI_POINT2POINT 0x0 /* only Host controller to Host */ 385 #define HCI_BROADCAST_ACTIVE 0x1 /* both directions */ 386 #define HCI_BROADCAST_PICONET 0x2 /* both directions */ 387 /* 11 - reserved for future use */ 388 389 /* HCI command packet header */ 390 typedef struct { 391 uint8_t type; /* MUST be 0x01 */ 392 uint16_t opcode; /* OpCode */ 393 uint8_t length; /* parameter(s) length in bytes */ 394 } __attribute__ ((__packed__)) hci_cmd_hdr_t; 395 396 #define HCI_CMD_PKT 0x01 397 #define HCI_CMD_PKT_SIZE (sizeof(hci_cmd_hdr_t) + 0xff) 398 399 /* ACL data packet header */ 400 typedef struct { 401 uint8_t type; /* MUST be 0x02 */ 402 uint16_t con_handle; /* connection handle + PB + BC flags */ 403 uint16_t length; /* payload length in bytes */ 404 } __attribute__ ((__packed__)) hci_acldata_hdr_t; 405 406 #define HCI_ACL_DATA_PKT 0x02 407 #define HCI_ACL_PKT_SIZE (sizeof(hci_acldata_hdr_t) + 0xffff) 408 409 /* SCO data packet header */ 410 typedef struct { 411 uint8_t type; /* MUST be 0x03 */ 412 uint16_t con_handle; /* connection handle + reserved bits */ 413 uint8_t length; /* payload length in bytes */ 414 } __attribute__ ((__packed__)) hci_scodata_hdr_t; 415 416 #define HCI_SCO_DATA_PKT 0x03 417 #define HCI_SCO_PKT_SIZE (sizeof(hci_scodata_hdr_t) + 0xff) 418 419 /* HCI event packet header */ 420 typedef struct { 421 uint8_t type; /* MUST be 0x04 */ 422 uint8_t event; /* event */ 423 uint8_t length; /* parameter(s) length in bytes */ 424 } __attribute__ ((__packed__)) hci_event_hdr_t; 425 426 #define HCI_EVENT_PKT 0x04 427 #define HCI_EVENT_PKT_SIZE (sizeof(hci_event_hdr_t) + 0xff) 428 429 /* HCI status return parameter */ 430 typedef struct { 431 uint8_t status; /* 0x00 - success */ 432 } __attribute__ ((__packed__)) hci_status_rp; 433 434 /************************************************************************** 435 ************************************************************************** 436 ** OGF 0x01 Link control commands and return parameters 437 ************************************************************************** 438 **************************************************************************/ 439 440 #define HCI_OGF_LINK_CONTROL 0x01 441 442 #define HCI_OCF_INQUIRY 0x0001 443 #define HCI_CMD_INQUIRY 0x0401 444 typedef struct { 445 uint8_t lap[HCI_LAP_SIZE]; /* LAP */ 446 uint8_t inquiry_length; /* (N x 1.28) sec */ 447 uint8_t num_responses; /* Max. # of responses */ 448 } __attribute__ ((__packed__)) hci_inquiry_cp; 449 /* No return parameter(s) */ 450 451 #define HCI_OCF_INQUIRY_CANCEL 0x0002 452 #define HCI_CMD_INQUIRY_CANCEL 0x0402 453 /* No command parameter(s) */ 454 typedef hci_status_rp hci_inquiry_cancel_rp; 455 456 #define HCI_OCF_PERIODIC_INQUIRY 0x0003 457 #define HCI_CMD_PERIODIC_INQUIRY 0x0403 458 typedef struct { 459 uint16_t max_period_length; /* Max. and min. amount of time */ 460 uint16_t min_period_length; /* between consecutive inquiries */ 461 uint8_t lap[HCI_LAP_SIZE]; /* LAP */ 462 uint8_t inquiry_length; /* (inquiry_length * 1.28) sec */ 463 uint8_t num_responses; /* Max. # of responses */ 464 } __attribute__ ((__packed__)) hci_periodic_inquiry_cp; 465 466 typedef hci_status_rp hci_periodic_inquiry_rp; 467 468 #define HCI_OCF_EXIT_PERIODIC_INQUIRY 0x0004 469 #define HCI_CMD_EXIT_PERIODIC_INQUIRY 0x0404 470 /* No command parameter(s) */ 471 typedef hci_status_rp hci_exit_periodic_inquiry_rp; 472 473 #define HCI_OCF_CREATE_CON 0x0005 474 #define HCI_CMD_CREATE_CON 0x0405 475 typedef struct { 476 bdaddr_t bdaddr; /* destination address */ 477 uint16_t pkt_type; /* packet type */ 478 uint8_t page_scan_rep_mode; /* page scan repetition mode */ 479 uint8_t page_scan_mode; /* reserved - set to 0x00 */ 480 uint16_t clock_offset; /* clock offset */ 481 uint8_t accept_role_switch; /* accept role switch? 0x00 == No */ 482 } __attribute__ ((__packed__)) hci_create_con_cp; 483 /* No return parameter(s) */ 484 485 #define HCI_OCF_DISCONNECT 0x0006 486 #define HCI_CMD_DISCONNECT 0x0406 487 typedef struct { 488 uint16_t con_handle; /* connection handle */ 489 uint8_t reason; /* reason to disconnect */ 490 } __attribute__ ((__packed__)) hci_discon_cp; 491 /* No return parameter(s) */ 492 493 /* Add SCO Connection is deprecated */ 494 #define HCI_OCF_ADD_SCO_CON 0x0007 495 #define HCI_CMD_ADD_SCO_CON 0x0407 496 typedef struct { 497 uint16_t con_handle; /* connection handle */ 498 uint16_t pkt_type; /* packet type */ 499 } __attribute__ ((__packed__)) hci_add_sco_con_cp; 500 /* No return parameter(s) */ 501 502 #define HCI_OCF_CREATE_CON_CANCEL 0x0008 503 #define HCI_CMD_CREATE_CON_CANCEL 0x0408 504 typedef struct { 505 bdaddr_t bdaddr; /* destination address */ 506 } __attribute__ ((__packed__)) hci_create_con_cancel_cp; 507 508 typedef struct { 509 uint8_t status; /* 0x00 - success */ 510 bdaddr_t bdaddr; /* destination address */ 511 } __attribute__ ((__packed__)) hci_create_con_cancel_rp; 512 513 #define HCI_OCF_ACCEPT_CON 0x0009 514 #define HCI_CMD_ACCEPT_CON 0x0409 515 typedef struct { 516 bdaddr_t bdaddr; /* address of unit to be connected */ 517 uint8_t role; /* connection role */ 518 } __attribute__ ((__packed__)) hci_accept_con_cp; 519 /* No return parameter(s) */ 520 521 #define HCI_OCF_REJECT_CON 0x000a 522 #define HCI_CMD_REJECT_CON 0x040A 523 typedef struct { 524 bdaddr_t bdaddr; /* remote address */ 525 uint8_t reason; /* reason to reject */ 526 } __attribute__ ((__packed__)) hci_reject_con_cp; 527 /* No return parameter(s) */ 528 529 #define HCI_OCF_LINK_KEY_REP 0x000b 530 #define HCI_CMD_LINK_KEY_REP 0x040B 531 typedef struct { 532 bdaddr_t bdaddr; /* remote address */ 533 uint8_t key[HCI_KEY_SIZE]; /* key */ 534 } __attribute__ ((__packed__)) hci_link_key_rep_cp; 535 536 typedef struct { 537 uint8_t status; /* 0x00 - success */ 538 bdaddr_t bdaddr; /* unit address */ 539 } __attribute__ ((__packed__)) hci_link_key_rep_rp; 540 541 #define HCI_OCF_LINK_KEY_NEG_REP 0x000c 542 #define HCI_CMD_LINK_KEY_NEG_REP 0x040C 543 typedef struct { 544 bdaddr_t bdaddr; /* remote address */ 545 } __attribute__ ((__packed__)) hci_link_key_neg_rep_cp; 546 547 typedef struct { 548 uint8_t status; /* 0x00 - success */ 549 bdaddr_t bdaddr; /* unit address */ 550 } __attribute__ ((__packed__)) hci_link_key_neg_rep_rp; 551 552 #define HCI_OCF_PIN_CODE_REP 0x000d 553 #define HCI_CMD_PIN_CODE_REP 0x040D 554 typedef struct { 555 bdaddr_t bdaddr; /* remote address */ 556 uint8_t pin_size; /* pin code length (in bytes) */ 557 uint8_t pin[HCI_PIN_SIZE]; /* pin code */ 558 } __attribute__ ((__packed__)) hci_pin_code_rep_cp; 559 560 typedef struct { 561 uint8_t status; /* 0x00 - success */ 562 bdaddr_t bdaddr; /* unit address */ 563 } __attribute__ ((__packed__)) hci_pin_code_rep_rp; 564 565 #define HCI_OCF_PIN_CODE_NEG_REP 0x000e 566 #define HCI_CMD_PIN_CODE_NEG_REP 0x040E 567 typedef struct { 568 bdaddr_t bdaddr; /* remote address */ 569 } __attribute__ ((__packed__)) hci_pin_code_neg_rep_cp; 570 571 typedef struct { 572 uint8_t status; /* 0x00 - success */ 573 bdaddr_t bdaddr; /* unit address */ 574 } __attribute__ ((__packed__)) hci_pin_code_neg_rep_rp; 575 576 #define HCI_OCF_CHANGE_CON_PACKET_TYPE 0x000f 577 #define HCI_CMD_CHANGE_CON_PACKET_TYPE 0x040F 578 typedef struct { 579 uint16_t con_handle; /* connection handle */ 580 uint16_t pkt_type; /* packet type */ 581 } __attribute__ ((__packed__)) hci_change_con_pkt_type_cp; 582 /* No return parameter(s) */ 583 584 #define HCI_OCF_AUTH_REQ 0x0011 585 #define HCI_CMD_AUTH_REQ 0x0411 586 typedef struct { 587 uint16_t con_handle; /* connection handle */ 588 } __attribute__ ((__packed__)) hci_auth_req_cp; 589 /* No return parameter(s) */ 590 591 #define HCI_OCF_SET_CON_ENCRYPTION 0x0013 592 #define HCI_CMD_SET_CON_ENCRYPTION 0x0413 593 typedef struct { 594 uint16_t con_handle; /* connection handle */ 595 uint8_t encryption_enable; /* 0x00 - disable, 0x01 - enable */ 596 } __attribute__ ((__packed__)) hci_set_con_encryption_cp; 597 /* No return parameter(s) */ 598 599 #define HCI_OCF_CHANGE_CON_LINK_KEY 0x0015 600 #define HCI_CMD_CHANGE_CON_LINK_KEY 0x0415 601 typedef struct { 602 uint16_t con_handle; /* connection handle */ 603 } __attribute__ ((__packed__)) hci_change_con_link_key_cp; 604 /* No return parameter(s) */ 605 606 #define HCI_OCF_MASTER_LINK_KEY 0x0017 607 #define HCI_CMD_MASTER_LINK_KEY 0x0417 608 typedef struct { 609 uint8_t key_flag; /* key flag */ 610 } __attribute__ ((__packed__)) hci_master_link_key_cp; 611 /* No return parameter(s) */ 612 613 #define HCI_OCF_REMOTE_NAME_REQ 0x0019 614 #define HCI_CMD_REMOTE_NAME_REQ 0x0419 615 typedef struct { 616 bdaddr_t bdaddr; /* remote address */ 617 uint8_t page_scan_rep_mode; /* page scan repetition mode */ 618 uint8_t page_scan_mode; /* page scan mode */ 619 uint16_t clock_offset; /* clock offset */ 620 } __attribute__ ((__packed__)) hci_remote_name_req_cp; 621 /* No return parameter(s) */ 622 623 #define HCI_OCF_REMOTE_NAME_REQ_CANCEL 0x001a 624 #define HCI_CMD_REMOTE_NAME_REQ_CANCEL 0x041A 625 typedef struct { 626 bdaddr_t bdaddr; /* remote address */ 627 } __attribute__ ((__packed__)) hci_remote_name_req_cancel_cp; 628 629 typedef struct { 630 uint8_t status; /* 0x00 - success */ 631 bdaddr_t bdaddr; /* remote address */ 632 } __attribute__ ((__packed__)) hci_remote_name_req_cancel_rp; 633 634 #define HCI_OCF_READ_REMOTE_FEATURES 0x001b 635 #define HCI_CMD_READ_REMOTE_FEATURES 0x041B 636 typedef struct { 637 uint16_t con_handle; /* connection handle */ 638 } __attribute__ ((__packed__)) hci_read_remote_features_cp; 639 /* No return parameter(s) */ 640 641 #define HCI_OCF_READ_REMOTE_EXTENDED_FEATURES 0x001c 642 #define HCI_CMD_READ_REMOTE_EXTENDED_FEATURES 0x041C 643 typedef struct { 644 uint16_t con_handle; /* connection handle */ 645 uint8_t page; /* page number */ 646 } __attribute__ ((__packed__)) hci_read_remote_extended_features_cp; 647 /* No return parameter(s) */ 648 649 #define HCI_OCF_READ_REMOTE_VER_INFO 0x001d 650 #define HCI_CMD_READ_REMOTE_VER_INFO 0x041D 651 typedef struct { 652 uint16_t con_handle; /* connection handle */ 653 } __attribute__ ((__packed__)) hci_read_remote_ver_info_cp; 654 /* No return parameter(s) */ 655 656 #define HCI_OCF_READ_CLOCK_OFFSET 0x001f 657 #define HCI_CMD_READ_CLOCK_OFFSET 0x041F 658 typedef struct { 659 uint16_t con_handle; /* connection handle */ 660 } __attribute__ ((__packed__)) hci_read_clock_offset_cp; 661 /* No return parameter(s) */ 662 663 #define HCI_OCF_READ_LMP_HANDLE 0x0020 664 #define HCI_CMD_READ_LMP_HANDLE 0x0420 665 typedef struct { 666 uint16_t con_handle; /* connection handle */ 667 } __attribute__ ((__packed__)) hci_read_lmp_handle_cp; 668 669 typedef struct { 670 uint8_t status; /* 0x00 - success */ 671 uint16_t con_handle; /* connection handle */ 672 uint8_t lmp_handle; /* LMP handle */ 673 uint32_t reserved; /* reserved */ 674 } __attribute__ ((__packed__)) hci_read_lmp_handle_rp; 675 676 #define HCI_OCF_SETUP_SCO_CON 0x0028 677 #define HCI_CMD_SETUP_SCO_CON 0x0428 678 typedef struct { 679 uint16_t con_handle; /* connection handle */ 680 uint32_t tx_bandwidth; /* transmit bandwidth */ 681 uint32_t rx_bandwidth; /* receive bandwidth */ 682 uint16_t latency; /* maximum latency */ 683 uint16_t voice; /* voice setting */ 684 uint8_t rt_effort; /* retransmission effort */ 685 uint16_t pkt_type; /* packet types */ 686 } __attribute__ ((__packed__)) hci_setup_sco_con_cp; 687 /* No return parameter(s) */ 688 689 #define HCI_OCF_ACCEPT_SCO_CON_REQ 0x0029 690 #define HCI_CMD_ACCEPT_SCO_CON_REQ 0x0429 691 typedef struct { 692 bdaddr_t bdaddr; /* remote address */ 693 uint32_t tx_bandwidth; /* transmit bandwidth */ 694 uint32_t rx_bandwidth; /* receive bandwidth */ 695 uint16_t latency; /* maximum latency */ 696 uint16_t content; /* voice setting */ 697 uint8_t rt_effort; /* retransmission effort */ 698 uint16_t pkt_type; /* packet types */ 699 } __attribute__ ((__packed__)) hci_accept_sco_con_req_cp; 700 /* No return parameter(s) */ 701 702 #define HCI_OCF_REJECT_SCO_CON_REQ 0x002a 703 #define HCI_CMD_REJECT_SCO_CON_REQ 0x042a 704 typedef struct { 705 bdaddr_t bdaddr; /* remote address */ 706 uint8_t reason; /* reject error code */ 707 } __attribute__ ((__packed__)) hci_reject_sco_con_req_cp; 708 /* No return parameter(s) */ 709 710 /************************************************************************** 711 ************************************************************************** 712 ** OGF 0x02 Link policy commands and return parameters 713 ************************************************************************** 714 **************************************************************************/ 715 716 #define HCI_OGF_LINK_POLICY 0x02 717 718 #define HCI_OCF_HOLD_MODE 0x0001 719 #define HCI_CMD_HOLD_MODE 0x0801 720 typedef struct { 721 uint16_t con_handle; /* connection handle */ 722 uint16_t max_interval; /* (max_interval * 0.625) msec */ 723 uint16_t min_interval; /* (max_interval * 0.625) msec */ 724 } __attribute__ ((__packed__)) hci_hold_mode_cp; 725 /* No return parameter(s) */ 726 727 #define HCI_OCF_SNIFF_MODE 0x0003 728 #define HCI_CMD_SNIFF_MODE 0x0803 729 typedef struct { 730 uint16_t con_handle; /* connection handle */ 731 uint16_t max_interval; /* (max_interval * 0.625) msec */ 732 uint16_t min_interval; /* (max_interval * 0.625) msec */ 733 uint16_t attempt; /* (2 * attempt - 1) * 0.625 msec */ 734 uint16_t timeout; /* (2 * attempt - 1) * 0.625 msec */ 735 } __attribute__ ((__packed__)) hci_sniff_mode_cp; 736 /* No return parameter(s) */ 737 738 #define HCI_OCF_EXIT_SNIFF_MODE 0x0004 739 #define HCI_CMD_EXIT_SNIFF_MODE 0x0804 740 typedef struct { 741 uint16_t con_handle; /* connection handle */ 742 } __attribute__ ((__packed__)) hci_exit_sniff_mode_cp; 743 /* No return parameter(s) */ 744 745 #define HCI_OCF_PARK_MODE 0x0005 746 #define HCI_CMD_PARK_MODE 0x0805 747 typedef struct { 748 uint16_t con_handle; /* connection handle */ 749 uint16_t max_interval; /* (max_interval * 0.625) msec */ 750 uint16_t min_interval; /* (max_interval * 0.625) msec */ 751 } __attribute__ ((__packed__)) hci_park_mode_cp; 752 /* No return parameter(s) */ 753 754 #define HCI_OCF_EXIT_PARK_MODE 0x0006 755 #define HCI_CMD_EXIT_PARK_MODE 0x0806 756 typedef struct { 757 uint16_t con_handle; /* connection handle */ 758 } __attribute__ ((__packed__)) hci_exit_park_mode_cp; 759 /* No return parameter(s) */ 760 761 #define HCI_OCF_QOS_SETUP 0x0007 762 #define HCI_CMD_QOS_SETUP 0x0807 763 typedef struct { 764 uint16_t con_handle; /* connection handle */ 765 uint8_t flags; /* reserved for future use */ 766 uint8_t service_type; /* service type */ 767 uint32_t token_rate; /* bytes per second */ 768 uint32_t peak_bandwidth; /* bytes per second */ 769 uint32_t latency; /* microseconds */ 770 uint32_t delay_variation; /* microseconds */ 771 } __attribute__ ((__packed__)) hci_qos_setup_cp; 772 /* No return parameter(s) */ 773 774 #define HCI_OCF_ROLE_DISCOVERY 0x0009 775 #define HCI_CMD_ROLE_DISCOVERY 0x0809 776 typedef struct { 777 uint16_t con_handle; /* connection handle */ 778 } __attribute__ ((__packed__)) hci_role_discovery_cp; 779 780 typedef struct { 781 uint8_t status; /* 0x00 - success */ 782 uint16_t con_handle; /* connection handle */ 783 uint8_t role; /* role for the connection handle */ 784 } __attribute__ ((__packed__)) hci_role_discovery_rp; 785 786 #define HCI_OCF_SWITCH_ROLE 0x000b 787 #define HCI_CMD_SWITCH_ROLE 0x080B 788 typedef struct { 789 bdaddr_t bdaddr; /* remote address */ 790 uint8_t role; /* new local role */ 791 } __attribute__ ((__packed__)) hci_switch_role_cp; 792 /* No return parameter(s) */ 793 794 #define HCI_OCF_READ_LINK_POLICY_SETTINGS 0x000c 795 #define HCI_CMD_READ_LINK_POLICY_SETTINGS 0x080C 796 typedef struct { 797 uint16_t con_handle; /* connection handle */ 798 } __attribute__ ((__packed__)) hci_read_link_policy_settings_cp; 799 800 typedef struct { 801 uint8_t status; /* 0x00 - success */ 802 uint16_t con_handle; /* connection handle */ 803 uint16_t settings; /* link policy settings */ 804 } __attribute__ ((__packed__)) hci_read_link_policy_settings_rp; 805 806 #define HCI_OCF_WRITE_LINK_POLICY_SETTINGS 0x000d 807 #define HCI_CMD_WRITE_LINK_POLICY_SETTINGS 0x080D 808 typedef struct { 809 uint16_t con_handle; /* connection handle */ 810 uint16_t settings; /* link policy settings */ 811 } __attribute__ ((__packed__)) hci_write_link_policy_settings_cp; 812 813 typedef struct { 814 uint8_t status; /* 0x00 - success */ 815 uint16_t con_handle; /* connection handle */ 816 } __attribute__ ((__packed__)) hci_write_link_policy_settings_rp; 817 818 #define HCI_OCF_READ_DEFAULT_LINK_POLICY_SETTINGS 0x000e 819 #define HCI_CMD_READ_DEFAULT_LINK_POLICY_SETTINGS 0x080E 820 /* No command parameter(s) */ 821 typedef struct { 822 uint8_t status; /* 0x00 - success */ 823 uint16_t settings; /* link policy settings */ 824 } __attribute__ ((__packed__)) hci_read_default_link_policy_settings_rp; 825 826 #define HCI_OCF_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x000f 827 #define HCI_CMD_WRITE_DEFAULT_LINK_POLICY_SETTINGS 0x080F 828 typedef struct { 829 uint16_t settings; /* link policy settings */ 830 } __attribute__ ((__packed__)) hci_write_default_link_policy_settings_cp; 831 832 typedef hci_status_rp hci_write_default_link_policy_settings_rp; 833 834 #define HCI_OCF_FLOW_SPECIFICATION 0x0010 835 #define HCI_CMD_FLOW_SPECIFICATION 0x0810 836 typedef struct { 837 uint16_t con_handle; /* connection handle */ 838 uint8_t flags; /* reserved */ 839 uint8_t flow_direction; 840 uint8_t service_type; 841 uint32_t token_rate; 842 uint32_t token_bucket; 843 uint32_t peak_bandwidth; 844 uint32_t latency; 845 } __attribute__ ((__packed__)) hci_flow_specification_cp; 846 /* No return parameter(s) */ 847 848 /************************************************************************** 849 ************************************************************************** 850 ** OGF 0x03 Host Controller and Baseband commands and return parameters 851 ************************************************************************** 852 **************************************************************************/ 853 854 #define HCI_OGF_HC_BASEBAND 0x03 855 856 #define HCI_OCF_SET_EVENT_MASK 0x0001 857 #define HCI_CMD_SET_EVENT_MASK 0x0C01 858 typedef struct { 859 uint8_t event_mask[HCI_EVENT_MASK_SIZE]; /* event_mask */ 860 } __attribute__ ((__packed__)) hci_set_event_mask_cp; 861 862 typedef hci_status_rp hci_set_event_mask_rp; 863 864 #define HCI_OCF_RESET 0x0003 865 #define HCI_CMD_RESET 0x0C03 866 /* No command parameter(s) */ 867 typedef hci_status_rp hci_reset_rp; 868 869 #define HCI_OCF_SET_EVENT_FILTER 0x0005 870 #define HCI_CMD_SET_EVENT_FILTER 0x0C05 871 typedef struct { 872 uint8_t filter_type; /* filter type */ 873 uint8_t filter_condition_type; /* filter condition type */ 874 /* variable size condition 875 uint8_t condition[]; -- conditions */ 876 } __attribute__ ((__packed__)) hci_set_event_filter_cp; 877 878 typedef hci_status_rp hci_set_event_filter_rp; 879 880 #define HCI_OCF_FLUSH 0x0008 881 #define HCI_CMD_FLUSH 0x0C08 882 typedef struct { 883 uint16_t con_handle; /* connection handle */ 884 } __attribute__ ((__packed__)) hci_flush_cp; 885 886 typedef struct { 887 uint8_t status; /* 0x00 - success */ 888 uint16_t con_handle; /* connection handle */ 889 } __attribute__ ((__packed__)) hci_flush_rp; 890 891 #define HCI_OCF_READ_PIN_TYPE 0x0009 892 #define HCI_CMD_READ_PIN_TYPE 0x0C09 893 /* No command parameter(s) */ 894 typedef struct { 895 uint8_t status; /* 0x00 - success */ 896 uint8_t pin_type; /* PIN type */ 897 } __attribute__ ((__packed__)) hci_read_pin_type_rp; 898 899 #define HCI_OCF_WRITE_PIN_TYPE 0x000a 900 #define HCI_CMD_WRITE_PIN_TYPE 0x0C0A 901 typedef struct { 902 uint8_t pin_type; /* PIN type */ 903 } __attribute__ ((__packed__)) hci_write_pin_type_cp; 904 905 typedef hci_status_rp hci_write_pin_type_rp; 906 907 #define HCI_OCF_CREATE_NEW_UNIT_KEY 0x000b 908 #define HCI_CMD_CREATE_NEW_UNIT_KEY 0x0C0B 909 /* No command parameter(s) */ 910 typedef hci_status_rp hci_create_new_unit_key_rp; 911 912 #define HCI_OCF_READ_STORED_LINK_KEY 0x000d 913 #define HCI_CMD_READ_STORED_LINK_KEY 0x0C0D 914 typedef struct { 915 bdaddr_t bdaddr; /* address */ 916 uint8_t read_all; /* read all keys? 0x01 - yes */ 917 } __attribute__ ((__packed__)) hci_read_stored_link_key_cp; 918 919 typedef struct { 920 uint8_t status; /* 0x00 - success */ 921 uint16_t max_num_keys; /* Max. number of keys */ 922 uint16_t num_keys_read; /* Number of stored keys */ 923 } __attribute__ ((__packed__)) hci_read_stored_link_key_rp; 924 925 #define HCI_OCF_WRITE_STORED_LINK_KEY 0x0011 926 #define HCI_CMD_WRITE_STORED_LINK_KEY 0x0C11 927 typedef struct { 928 uint8_t num_keys_write; /* # of keys to write */ 929 /* these are repeated "num_keys_write" times 930 bdaddr_t bdaddr; --- remote address(es) 931 uint8_t key[HCI_KEY_SIZE]; --- key(s) */ 932 } __attribute__ ((__packed__)) hci_write_stored_link_key_cp; 933 934 typedef struct { 935 uint8_t status; /* 0x00 - success */ 936 uint8_t num_keys_written; /* # of keys successfully written */ 937 } __attribute__ ((__packed__)) hci_write_stored_link_key_rp; 938 939 #define HCI_OCF_DELETE_STORED_LINK_KEY 0x0012 940 #define HCI_CMD_DELETE_STORED_LINK_KEY 0x0C12 941 typedef struct { 942 bdaddr_t bdaddr; /* address */ 943 uint8_t delete_all; /* delete all keys? 0x01 - yes */ 944 } __attribute__ ((__packed__)) hci_delete_stored_link_key_cp; 945 946 typedef struct { 947 uint8_t status; /* 0x00 - success */ 948 uint16_t num_keys_deleted; /* Number of keys deleted */ 949 } __attribute__ ((__packed__)) hci_delete_stored_link_key_rp; 950 951 #define HCI_OCF_WRITE_LOCAL_NAME 0x0013 952 #define HCI_CMD_WRITE_LOCAL_NAME 0x0C13 953 typedef struct { 954 char name[HCI_UNIT_NAME_SIZE]; /* new unit name */ 955 } __attribute__ ((__packed__)) hci_write_local_name_cp; 956 957 typedef hci_status_rp hci_write_local_name_rp; 958 959 #define HCI_OCF_READ_LOCAL_NAME 0x0014 960 #define HCI_CMD_READ_LOCAL_NAME 0x0C14 961 /* No command parameter(s) */ 962 typedef struct { 963 uint8_t status; /* 0x00 - success */ 964 char name[HCI_UNIT_NAME_SIZE]; /* unit name */ 965 } __attribute__ ((__packed__)) hci_read_local_name_rp; 966 967 #define HCI_OCF_READ_CON_ACCEPT_TIMEOUT 0x0015 968 #define HCI_CMD_READ_CON_ACCEPT_TIMEOUT 0x0C15 969 /* No command parameter(s) */ 970 typedef struct { 971 uint8_t status; /* 0x00 - success */ 972 uint16_t timeout; /* (timeout * 0.625) msec */ 973 } __attribute__ ((__packed__)) hci_read_con_accept_timeout_rp; 974 975 #define HCI_OCF_WRITE_CON_ACCEPT_TIMEOUT 0x0016 976 #define HCI_CMD_WRITE_CON_ACCEPT_TIMEOUT 0x0C16 977 typedef struct { 978 uint16_t timeout; /* (timeout * 0.625) msec */ 979 } __attribute__ ((__packed__)) hci_write_con_accept_timeout_cp; 980 981 typedef hci_status_rp hci_write_con_accept_timeout_rp; 982 983 #define HCI_OCF_READ_PAGE_TIMEOUT 0x0017 984 #define HCI_CMD_READ_PAGE_TIMEOUT 0x0C17 985 /* No command parameter(s) */ 986 typedef struct { 987 uint8_t status; /* 0x00 - success */ 988 uint16_t timeout; /* (timeout * 0.625) msec */ 989 } __attribute__ ((__packed__)) hci_read_page_timeout_rp; 990 991 #define HCI_OCF_WRITE_PAGE_TIMEOUT 0x0018 992 #define HCI_CMD_WRITE_PAGE_TIMEOUT 0x0C18 993 typedef struct { 994 uint16_t timeout; /* (timeout * 0.625) msec */ 995 } __attribute__ ((__packed__)) hci_write_page_timeout_cp; 996 997 typedef hci_status_rp hci_write_page_timeout_rp; 998 999 #define HCI_OCF_READ_SCAN_ENABLE 0x0019 1000 #define HCI_CMD_READ_SCAN_ENABLE 0x0C19 1001 /* No command parameter(s) */ 1002 typedef struct { 1003 uint8_t status; /* 0x00 - success */ 1004 uint8_t scan_enable; /* Scan enable */ 1005 } __attribute__ ((__packed__)) hci_read_scan_enable_rp; 1006 1007 #define HCI_OCF_WRITE_SCAN_ENABLE 0x001a 1008 #define HCI_CMD_WRITE_SCAN_ENABLE 0x0C1A 1009 typedef struct { 1010 uint8_t scan_enable; /* Scan enable */ 1011 } __attribute__ ((__packed__)) hci_write_scan_enable_cp; 1012 1013 typedef hci_status_rp hci_write_scan_enable_rp; 1014 1015 #define HCI_OCF_READ_PAGE_SCAN_ACTIVITY 0x001b 1016 #define HCI_CMD_READ_PAGE_SCAN_ACTIVITY 0x0C1B 1017 /* No command parameter(s) */ 1018 typedef struct { 1019 uint8_t status; /* 0x00 - success */ 1020 uint16_t page_scan_interval; /* interval * 0.625 msec */ 1021 uint16_t page_scan_window; /* window * 0.625 msec */ 1022 } __attribute__ ((__packed__)) hci_read_page_scan_activity_rp; 1023 1024 #define HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY 0x001c 1025 #define HCI_CMD_WRITE_PAGE_SCAN_ACTIVITY 0x0C1C 1026 typedef struct { 1027 uint16_t page_scan_interval; /* interval * 0.625 msec */ 1028 uint16_t page_scan_window; /* window * 0.625 msec */ 1029 } __attribute__ ((__packed__)) hci_write_page_scan_activity_cp; 1030 1031 typedef hci_status_rp hci_write_page_scan_activity_rp; 1032 1033 #define HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY 0x001d 1034 #define HCI_CMD_READ_INQUIRY_SCAN_ACTIVITY 0x0C1D 1035 /* No command parameter(s) */ 1036 typedef struct { 1037 uint8_t status; /* 0x00 - success */ 1038 uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ 1039 uint16_t inquiry_scan_window; /* window * 0.625 msec */ 1040 } __attribute__ ((__packed__)) hci_read_inquiry_scan_activity_rp; 1041 1042 #define HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY 0x001e 1043 #define HCI_CMD_WRITE_INQUIRY_SCAN_ACTIVITY 0x0C1E 1044 typedef struct { 1045 uint16_t inquiry_scan_interval; /* interval * 0.625 msec */ 1046 uint16_t inquiry_scan_window; /* window * 0.625 msec */ 1047 } __attribute__ ((__packed__)) hci_write_inquiry_scan_activity_cp; 1048 1049 typedef hci_status_rp hci_write_inquiry_scan_activity_rp; 1050 1051 #define HCI_OCF_READ_AUTH_ENABLE 0x001f 1052 #define HCI_CMD_READ_AUTH_ENABLE 0x0C1F 1053 /* No command parameter(s) */ 1054 typedef struct { 1055 uint8_t status; /* 0x00 - success */ 1056 uint8_t auth_enable; /* 0x01 - enabled */ 1057 } __attribute__ ((__packed__)) hci_read_auth_enable_rp; 1058 1059 #define HCI_OCF_WRITE_AUTH_ENABLE 0x0020 1060 #define HCI_CMD_WRITE_AUTH_ENABLE 0x0C20 1061 typedef struct { 1062 uint8_t auth_enable; /* 0x01 - enabled */ 1063 } __attribute__ ((__packed__)) hci_write_auth_enable_cp; 1064 1065 typedef hci_status_rp hci_write_auth_enable_rp; 1066 1067 #define HCI_OCF_READ_ENCRYPTION_MODE 0x0021 1068 #define HCI_CMD_READ_ENCRYPTION_MODE 0x0C21 1069 /* No command parameter(s) */ 1070 typedef struct { 1071 uint8_t status; /* 0x00 - success */ 1072 uint8_t encryption_mode; /* encryption mode */ 1073 } __attribute__ ((__packed__)) hci_read_encryption_mode_rp; 1074 1075 #define HCI_OCF_WRITE_ENCRYPTION_MODE 0x0022 1076 #define HCI_CMD_WRITE_ENCRYPTION_MODE 0x0C22 1077 typedef struct { 1078 uint8_t encryption_mode; /* encryption mode */ 1079 } __attribute__ ((__packed__)) hci_write_encryption_mode_cp; 1080 1081 typedef hci_status_rp hci_write_encryption_mode_rp; 1082 1083 #define HCI_OCF_READ_UNIT_CLASS 0x0023 1084 #define HCI_CMD_READ_UNIT_CLASS 0x0C23 1085 /* No command parameter(s) */ 1086 typedef struct { 1087 uint8_t status; /* 0x00 - success */ 1088 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 1089 } __attribute__ ((__packed__)) hci_read_unit_class_rp; 1090 1091 #define HCI_OCF_WRITE_UNIT_CLASS 0x0024 1092 #define HCI_CMD_WRITE_UNIT_CLASS 0x0C24 1093 typedef struct { 1094 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 1095 } __attribute__ ((__packed__)) hci_write_unit_class_cp; 1096 1097 typedef hci_status_rp hci_write_unit_class_rp; 1098 1099 #define HCI_OCF_READ_VOICE_SETTING 0x0025 1100 #define HCI_CMD_READ_VOICE_SETTING 0x0C25 1101 /* No command parameter(s) */ 1102 typedef struct { 1103 uint8_t status; /* 0x00 - success */ 1104 uint16_t settings; /* voice settings */ 1105 } __attribute__ ((__packed__)) hci_read_voice_setting_rp; 1106 1107 #define HCI_OCF_WRITE_VOICE_SETTING 0x0026 1108 #define HCI_CMD_WRITE_VOICE_SETTING 0x0C26 1109 typedef struct { 1110 uint16_t settings; /* voice settings */ 1111 } __attribute__ ((__packed__)) hci_write_voice_setting_cp; 1112 1113 typedef hci_status_rp hci_write_voice_setting_rp; 1114 1115 #define HCI_OCF_READ_AUTO_FLUSH_TIMEOUT 0x0027 1116 #define HCI_CMD_READ_AUTO_FLUSH_TIMEOUT 0x0C27 1117 typedef struct { 1118 uint16_t con_handle; /* connection handle */ 1119 } __attribute__ ((__packed__)) hci_read_auto_flush_timeout_cp; 1120 1121 typedef struct { 1122 uint8_t status; /* 0x00 - success */ 1123 uint16_t con_handle; /* connection handle */ 1124 uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ 1125 } __attribute__ ((__packed__)) hci_read_auto_flush_timeout_rp; 1126 1127 #define HCI_OCF_WRITE_AUTO_FLUSH_TIMEOUT 0x0028 1128 #define HCI_CMD_WRITE_AUTO_FLUSH_TIMEOUT 0x0C28 1129 typedef struct { 1130 uint16_t con_handle; /* connection handle */ 1131 uint16_t timeout; /* 0x00 - no flush, timeout * 0.625 msec */ 1132 } __attribute__ ((__packed__)) hci_write_auto_flush_timeout_cp; 1133 1134 typedef struct { 1135 uint8_t status; /* 0x00 - success */ 1136 uint16_t con_handle; /* connection handle */ 1137 } __attribute__ ((__packed__)) hci_write_auto_flush_timeout_rp; 1138 1139 #define HCI_OCF_READ_NUM_BROADCAST_RETRANS 0x0029 1140 #define HCI_CMD_READ_NUM_BROADCAST_RETRANS 0x0C29 1141 /* No command parameter(s) */ 1142 typedef struct { 1143 uint8_t status; /* 0x00 - success */ 1144 uint8_t counter; /* number of broadcast retransmissions */ 1145 } __attribute__ ((__packed__)) hci_read_num_broadcast_retrans_rp; 1146 1147 #define HCI_OCF_WRITE_NUM_BROADCAST_RETRANS 0x002a 1148 #define HCI_CMD_WRITE_NUM_BROADCAST_RETRANS 0x0C2A 1149 typedef struct { 1150 uint8_t counter; /* number of broadcast retransmissions */ 1151 } __attribute__ ((__packed__)) hci_write_num_broadcast_retrans_cp; 1152 1153 typedef hci_status_rp hci_write_num_broadcast_retrans_rp; 1154 1155 #define HCI_OCF_READ_HOLD_MODE_ACTIVITY 0x002b 1156 #define HCI_CMD_READ_HOLD_MODE_ACTIVITY 0x0C2B 1157 /* No command parameter(s) */ 1158 typedef struct { 1159 uint8_t status; /* 0x00 - success */ 1160 uint8_t hold_mode_activity; /* Hold mode activities */ 1161 } __attribute__ ((__packed__)) hci_read_hold_mode_activity_rp; 1162 1163 #define HCI_OCF_WRITE_HOLD_MODE_ACTIVITY 0x002c 1164 #define HCI_CMD_WRITE_HOLD_MODE_ACTIVITY 0x0C2C 1165 typedef struct { 1166 uint8_t hold_mode_activity; /* Hold mode activities */ 1167 } __attribute__ ((__packed__)) hci_write_hold_mode_activity_cp; 1168 1169 typedef hci_status_rp hci_write_hold_mode_activity_rp; 1170 1171 #define HCI_OCF_READ_XMIT_LEVEL 0x002d 1172 #define HCI_CMD_READ_XMIT_LEVEL 0x0C2D 1173 typedef struct { 1174 uint16_t con_handle; /* connection handle */ 1175 uint8_t type; /* Xmit level type */ 1176 } __attribute__ ((__packed__)) hci_read_xmit_level_cp; 1177 1178 typedef struct { 1179 uint8_t status; /* 0x00 - success */ 1180 uint16_t con_handle; /* connection handle */ 1181 char level; /* -30 <= level <= 30 dBm */ 1182 } __attribute__ ((__packed__)) hci_read_xmit_level_rp; 1183 1184 #define HCI_OCF_READ_SCO_FLOW_CONTROL 0x002e 1185 #define HCI_CMD_READ_SCO_FLOW_CONTROL 0x0C2E 1186 /* No command parameter(s) */ 1187 typedef struct { 1188 uint8_t status; /* 0x00 - success */ 1189 uint8_t flow_control; /* 0x00 - disabled */ 1190 } __attribute__ ((__packed__)) hci_read_sco_flow_control_rp; 1191 1192 #define HCI_OCF_WRITE_SCO_FLOW_CONTROL 0x002f 1193 #define HCI_CMD_WRITE_SCO_FLOW_CONTROL 0x0C2F 1194 typedef struct { 1195 uint8_t flow_control; /* 0x00 - disabled */ 1196 } __attribute__ ((__packed__)) hci_write_sco_flow_control_cp; 1197 1198 typedef hci_status_rp hci_write_sco_flow_control_rp; 1199 1200 #define HCI_OCF_HC2H_FLOW_CONTROL 0x0031 1201 #define HCI_CMD_HC2H_FLOW_CONTROL 0x0C31 1202 typedef struct { 1203 uint8_t hc2h_flow; /* Host Controller to Host flow control */ 1204 } __attribute__ ((__packed__)) hci_hc2h_flow_control_cp; 1205 1206 typedef hci_status_rp hci_h2hc_flow_control_rp; 1207 1208 #define HCI_OCF_HOST_BUFFER_SIZE 0x0033 1209 #define HCI_CMD_HOST_BUFFER_SIZE 0x0C33 1210 typedef struct { 1211 uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ 1212 uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ 1213 uint16_t num_acl_pkts; /* Max. number of ACL packets */ 1214 uint16_t num_sco_pkts; /* Max. number of SCO packets */ 1215 } __attribute__ ((__packed__)) hci_host_buffer_size_cp; 1216 1217 typedef hci_status_rp hci_host_buffer_size_rp; 1218 1219 #define HCI_OCF_HOST_NUM_COMPL_PKTS 0x0035 1220 #define HCI_CMD_HOST_NUM_COMPL_PKTS 0x0C35 1221 typedef struct { 1222 uint8_t nu_con_handles; /* # of connection handles */ 1223 /* these are repeated "num_con_handles" times 1224 uint16_t con_handle; --- connection handle(s) 1225 uint16_t compl_pkts; --- # of completed packets */ 1226 } __attribute__ ((__packed__)) hci_host_num_compl_pkts_cp; 1227 /* No return parameter(s) */ 1228 1229 #define HCI_OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036 1230 #define HCI_CMD_READ_LINK_SUPERVISION_TIMEOUT 0x0C36 1231 typedef struct { 1232 uint16_t con_handle; /* connection handle */ 1233 } __attribute__ ((__packed__)) hci_read_link_supervision_timeout_cp; 1234 1235 typedef struct { 1236 uint8_t status; /* 0x00 - success */ 1237 uint16_t con_handle; /* connection handle */ 1238 uint16_t timeout; /* Link supervision timeout * 0.625 msec */ 1239 } __attribute__ ((__packed__)) hci_read_link_supervision_timeout_rp; 1240 1241 #define HCI_OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037 1242 #define HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT 0x0C37 1243 typedef struct { 1244 uint16_t con_handle; /* connection handle */ 1245 uint16_t timeout; /* Link supervision timeout * 0.625 msec */ 1246 } __attribute__ ((__packed__)) hci_write_link_supervision_timeout_cp; 1247 1248 typedef struct { 1249 uint8_t status; /* 0x00 - success */ 1250 uint16_t con_handle; /* connection handle */ 1251 } __attribute__ ((__packed__)) hci_write_link_supervision_timeout_rp; 1252 1253 #define HCI_OCF_READ_NUM_SUPPORTED_IAC 0x0038 1254 #define HCI_CMD_READ_NUM_SUPPORTED_IAC 0x0C38 1255 /* No command parameter(s) */ 1256 typedef struct { 1257 uint8_t status; /* 0x00 - success */ 1258 uint8_t num_iac; /* # of supported IAC during scan */ 1259 } __attribute__ ((__packed__)) hci_read_num_supported_iac_rp; 1260 1261 #define HCI_OCF_READ_IAC_LAP 0x0039 1262 #define HCI_CMD_READ_IAC_LAP 0x0C39 1263 /* No command parameter(s) */ 1264 typedef struct { 1265 uint8_t status; /* 0x00 - success */ 1266 uint8_t num_iac; /* # of IAC */ 1267 /* these are repeated "num_iac" times 1268 uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ 1269 } __attribute__ ((__packed__)) hci_read_iac_lap_rp; 1270 1271 #define HCI_OCF_WRITE_IAC_LAP 0x003a 1272 #define HCI_CMD_WRITE_IAC_LAP 0x0C3A 1273 typedef struct { 1274 uint8_t num_iac; /* # of IAC */ 1275 /* these are repeated "num_iac" times 1276 uint8_t laps[HCI_LAP_SIZE]; --- LAPs */ 1277 } __attribute__ ((__packed__)) hci_write_iac_lap_cp; 1278 1279 typedef hci_status_rp hci_write_iac_lap_rp; 1280 1281 #define HCI_OCF_READ_PAGE_SCAN_PERIOD 0x003b 1282 #define HCI_CMD_READ_PAGE_SCAN_PERIOD 0x0C3B 1283 /* No command parameter(s) */ 1284 typedef struct { 1285 uint8_t status; /* 0x00 - success */ 1286 uint8_t page_scan_period_mode; /* Page scan period mode */ 1287 } __attribute__ ((__packed__)) hci_read_page_scan_period_rp; 1288 1289 #define HCI_OCF_WRITE_PAGE_SCAN_PERIOD 0x003c 1290 #define HCI_CMD_WRITE_PAGE_SCAN_PERIOD 0x0C3C 1291 typedef struct { 1292 uint8_t page_scan_period_mode; /* Page scan period mode */ 1293 } __attribute__ ((__packed__)) hci_write_page_scan_period_cp; 1294 1295 typedef hci_status_rp hci_write_page_scan_period_rp; 1296 1297 /* Read Page Scan Mode is deprecated */ 1298 #define HCI_OCF_READ_PAGE_SCAN 0x003d 1299 #define HCI_CMD_READ_PAGE_SCAN 0x0C3D 1300 /* No command parameter(s) */ 1301 typedef struct { 1302 uint8_t status; /* 0x00 - success */ 1303 uint8_t page_scan_mode; /* Page scan mode */ 1304 } __attribute__ ((__packed__)) hci_read_page_scan_rp; 1305 1306 /* Write Page Scan Mode is deprecated */ 1307 #define HCI_OCF_WRITE_PAGE_SCAN 0x003e 1308 #define HCI_CMD_WRITE_PAGE_SCAN 0x0C3E 1309 typedef struct { 1310 uint8_t page_scan_mode; /* Page scan mode */ 1311 } __attribute__ ((__packed__)) hci_write_page_scan_cp; 1312 1313 typedef hci_status_rp hci_write_page_scan_rp; 1314 1315 #define HCI_OCF_SET_AFH_CLASSIFICATION 0x003f 1316 #define HCI_CMD_SET_AFH_CLASSIFICATION 0x0C3F 1317 typedef struct { 1318 uint8_t classification[10]; 1319 } __attribute__ ((__packed__)) hci_set_afh_classification_cp; 1320 1321 typedef hci_status_rp hci_set_afh_classification_rp; 1322 1323 #define HCI_OCF_READ_INQUIRY_SCAN_TYPE 0x0042 1324 #define HCI_CMD_READ_INQUIRY_SCAN_TYPE 0x0C42 1325 /* No command parameter(s) */ 1326 1327 typedef struct { 1328 uint8_t status; /* 0x00 - success */ 1329 uint8_t type; /* inquiry scan type */ 1330 } __attribute__ ((__packed__)) hci_read_inquiry_scan_type_rp; 1331 1332 #define HCI_OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043 1333 #define HCI_CMD_WRITE_INQUIRY_SCAN_TYPE 0x0C43 1334 typedef struct { 1335 uint8_t type; /* inquiry scan type */ 1336 } __attribute__ ((__packed__)) hci_write_inquiry_scan_type_cp; 1337 1338 typedef hci_status_rp hci_write_inquiry_scan_type_rp; 1339 1340 #define HCI_OCF_READ_INQUIRY_MODE 0x0044 1341 #define HCI_CMD_READ_INQUIRY_MODE 0x0C44 1342 /* No command parameter(s) */ 1343 1344 typedef struct { 1345 uint8_t status; /* 0x00 - success */ 1346 uint8_t mode; /* inquiry mode */ 1347 } __attribute__ ((__packed__)) hci_read_inquiry_mode_rp; 1348 1349 #define HCI_OCF_WRITE_INQUIRY_MODE 0x0045 1350 #define HCI_CMD_WRITE_INQUIRY_MODE 0x0C45 1351 typedef struct { 1352 uint8_t mode; /* inquiry mode */ 1353 } __attribute__ ((__packed__)) hci_write_inquiry_mode_cp; 1354 1355 typedef hci_status_rp hci_write_inquiry_mode_rp; 1356 1357 #define HCI_OCF_READ_PAGE_SCAN_TYPE 0x0046 1358 #define HCI_CMD_READ_PAGE_SCAN_TYPE 0x0C46 1359 /* No command parameter(s) */ 1360 1361 typedef struct { 1362 uint8_t status; /* 0x00 - success */ 1363 uint8_t type; /* page scan type */ 1364 } __attribute__ ((__packed__)) hci_read_page_scan_type_rp; 1365 1366 #define HCI_OCF_WRITE_PAGE_SCAN_TYPE 0x0047 1367 #define HCI_CMD_WRITE_PAGE_SCAN_TYPE 0x0C47 1368 typedef struct { 1369 uint8_t type; /* page scan type */ 1370 } __attribute__ ((__packed__)) hci_write_page_scan_type_cp; 1371 1372 typedef hci_status_rp hci_write_page_scan_type_rp; 1373 1374 #define HCI_OCF_READ_AFH_ASSESSMENT 0x0048 1375 #define HCI_CMD_READ_AFH_ASSESSMENT 0x0C48 1376 /* No command parameter(s) */ 1377 1378 typedef struct { 1379 uint8_t status; /* 0x00 - success */ 1380 uint8_t mode; /* assessment mode */ 1381 } __attribute__ ((__packed__)) hci_read_afh_assessment_rp; 1382 1383 #define HCI_OCF_WRITE_AFH_ASSESSMENT 0x0049 1384 #define HCI_CMD_WRITE_AFH_ASSESSMENT 0x0C49 1385 typedef struct { 1386 uint8_t mode; /* assessment mode */ 1387 } __attribute__ ((__packed__)) hci_write_afh_assessment_cp; 1388 1389 typedef hci_status_rp hci_write_afh_assessment_rp; 1390 1391 /************************************************************************** 1392 ************************************************************************** 1393 ** OGF 0x04 Informational commands and return parameters 1394 ************************************************************************** 1395 **************************************************************************/ 1396 1397 #define HCI_OGF_INFO 0x04 1398 1399 #define HCI_OCF_READ_LOCAL_VER 0x0001 1400 #define HCI_CMD_READ_LOCAL_VER 0x1001 1401 /* No command parameter(s) */ 1402 typedef struct { 1403 uint8_t status; /* 0x00 - success */ 1404 uint8_t hci_version; /* HCI version */ 1405 uint16_t hci_revision; /* HCI revision */ 1406 uint8_t lmp_version; /* LMP version */ 1407 uint16_t manufacturer; /* Hardware manufacturer name */ 1408 uint16_t lmp_subversion; /* LMP sub-version */ 1409 } __attribute__ ((__packed__)) hci_read_local_ver_rp; 1410 1411 #define HCI_OCF_READ_LOCAL_COMMANDS 0x0002 1412 #define HCI_CMD_READ_LOCAL_COMMANDS 0x1002 1413 /* No command parameter(s) */ 1414 typedef struct { 1415 uint8_t status; /* 0x00 - success */ 1416 uint8_t commands[64]; /* opcode bitmask */ 1417 } __attribute__ ((__packed__)) hci_read_local_commands_rp; 1418 1419 #define HCI_OCF_READ_LOCAL_FEATURES 0x0003 1420 #define HCI_CMD_READ_LOCAL_FEATURES 0x1003 1421 /* No command parameter(s) */ 1422 typedef struct { 1423 uint8_t status; /* 0x00 - success */ 1424 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 1425 } __attribute__ ((__packed__)) hci_read_local_features_rp; 1426 1427 #define HCI_OCF_READ_LOCAL_EXTENDED_FEATURES 0x0004 1428 #define HCI_CMD_READ_LOCAL_EXTENDED_FEATURES 0x1004 1429 typedef struct { 1430 uint8_t page; /* page number */ 1431 } __attribute__ ((__packed__)) hci_read_local_extended_features_cp; 1432 1433 typedef struct { 1434 uint8_t status; /* 0x00 - success */ 1435 uint8_t page; /* page number */ 1436 uint8_t max_page; /* maximum page number */ 1437 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features */ 1438 } __attribute__ ((__packed__)) hci_read_local_extended_features_rp; 1439 1440 #define HCI_OCF_READ_BUFFER_SIZE 0x0005 1441 #define HCI_CMD_READ_BUFFER_SIZE 0x1005 1442 /* No command parameter(s) */ 1443 typedef struct { 1444 uint8_t status; /* 0x00 - success */ 1445 uint16_t max_acl_size; /* Max. size of ACL packet (bytes) */ 1446 uint8_t max_sco_size; /* Max. size of SCO packet (bytes) */ 1447 uint16_t num_acl_pkts; /* Max. number of ACL packets */ 1448 uint16_t num_sco_pkts; /* Max. number of SCO packets */ 1449 } __attribute__ ((__packed__)) hci_read_buffer_size_rp; 1450 1451 /* Read Country Code is deprecated */ 1452 #define HCI_OCF_READ_COUNTRY_CODE 0x0007 1453 #define HCI_CMD_READ_COUNTRY_CODE 0x1007 1454 /* No command parameter(s) */ 1455 typedef struct { 1456 uint8_t status; /* 0x00 - success */ 1457 uint8_t country_code; /* 0x00 - NAM, EUR, JP; 0x01 - France */ 1458 } __attribute__ ((__packed__)) hci_read_country_code_rp; 1459 1460 #define HCI_OCF_READ_BDADDR 0x0009 1461 #define HCI_CMD_READ_BDADDR 0x1009 1462 /* No command parameter(s) */ 1463 typedef struct { 1464 uint8_t status; /* 0x00 - success */ 1465 bdaddr_t bdaddr; /* unit address */ 1466 } __attribute__ ((__packed__)) hci_read_bdaddr_rp; 1467 1468 /************************************************************************** 1469 ************************************************************************** 1470 ** OGF 0x05 Status commands and return parameters 1471 ************************************************************************** 1472 **************************************************************************/ 1473 1474 #define HCI_OGF_STATUS 0x05 1475 1476 #define HCI_OCF_READ_FAILED_CONTACT_CNTR 0x0001 1477 #define HCI_CMD_READ_FAILED_CONTACT_CNTR 0x1401 1478 typedef struct { 1479 uint16_t con_handle; /* connection handle */ 1480 } __attribute__ ((__packed__)) hci_read_failed_contact_cntr_cp; 1481 1482 typedef struct { 1483 uint8_t status; /* 0x00 - success */ 1484 uint16_t con_handle; /* connection handle */ 1485 uint16_t counter; /* number of consecutive failed contacts */ 1486 } __attribute__ ((__packed__)) hci_read_failed_contact_cntr_rp; 1487 1488 #define HCI_OCF_RESET_FAILED_CONTACT_CNTR 0x0002 1489 #define HCI_CMD_RESET_FAILED_CONTACT_CNTR 0x1402 1490 typedef struct { 1491 uint16_t con_handle; /* connection handle */ 1492 } __attribute__ ((__packed__)) hci_reset_failed_contact_cntr_cp; 1493 1494 typedef struct { 1495 uint8_t status; /* 0x00 - success */ 1496 uint16_t con_handle; /* connection handle */ 1497 } __attribute__ ((__packed__)) hci_reset_failed_contact_cntr_rp; 1498 1499 #define HCI_OCF_READ_LINK_QUALITY 0x0003 1500 #define HCI_CMD_READ_LINK_QUALITY 0x1403 1501 typedef struct { 1502 uint16_t con_handle; /* connection handle */ 1503 } __attribute__ ((__packed__)) hci_read_link_quality_cp; 1504 1505 typedef struct { 1506 uint8_t status; /* 0x00 - success */ 1507 uint16_t con_handle; /* connection handle */ 1508 uint8_t quality; /* higher value means better quality */ 1509 } __attribute__ ((__packed__)) hci_read_link_quality_rp; 1510 1511 #define HCI_OCF_READ_RSSI 0x0005 1512 #define HCI_CMD_READ_RSSI 0x1405 1513 typedef struct { 1514 uint16_t con_handle; /* connection handle */ 1515 } __attribute__ ((__packed__)) hci_read_rssi_cp; 1516 1517 typedef struct { 1518 uint8_t status; /* 0x00 - success */ 1519 uint16_t con_handle; /* connection handle */ 1520 char rssi; /* -127 <= rssi <= 127 dB */ 1521 } __attribute__ ((__packed__)) hci_read_rssi_rp; 1522 1523 #define HCI_OCF_READ_AFH_CHANNEL_MAP 0x0006 1524 #define HCI_CMD_READ_AFH_CHANNEL_MAP 0x1406 1525 typedef struct { 1526 uint16_t con_handle; /* connection handle */ 1527 } __attribute__ ((__packed__)) hci_read_afh_channel_map_cp; 1528 1529 typedef struct { 1530 uint8_t status; /* 0x00 - success */ 1531 uint16_t con_handle; /* connection handle */ 1532 uint8_t mode; /* AFH mode */ 1533 uint8_t map[10]; /* AFH Channel Map */ 1534 } __attribute__ ((__packed__)) hci_read_afh_channel_map_rp; 1535 1536 #define HCI_OCF_READ_CLOCK 0x0007 1537 #define HCI_CMD_READ_CLOCK 0x1407 1538 typedef struct { 1539 uint16_t con_handle; /* connection handle */ 1540 uint8_t clock; /* which clock */ 1541 } __attribute__ ((__packed__)) hci_read_clock_cp; 1542 1543 typedef struct { 1544 uint8_t status; /* 0x00 - success */ 1545 uint16_t con_handle; /* connection handle */ 1546 uint32_t clock; /* clock value */ 1547 uint16_t accuracy; /* clock accuracy */ 1548 } __attribute__ ((__packed__)) hci_read_clock_rp; 1549 1550 1551 /************************************************************************** 1552 ************************************************************************** 1553 ** OGF 0x06 Testing commands and return parameters 1554 ************************************************************************** 1555 **************************************************************************/ 1556 1557 #define HCI_OGF_TESTING 0x06 1558 1559 #define HCI_OCF_READ_LOOPBACK_MODE 0x0001 1560 #define HCI_CMD_READ_LOOPBACK_MODE 0x1801 1561 /* No command parameter(s) */ 1562 typedef struct { 1563 uint8_t status; /* 0x00 - success */ 1564 uint8_t lbmode; /* loopback mode */ 1565 } __attribute__ ((__packed__)) hci_read_loopback_mode_rp; 1566 1567 #define HCI_OCF_WRITE_LOOPBACK_MODE 0x0002 1568 #define HCI_CMD_WRITE_LOOPBACK_MODE 0x1802 1569 typedef struct { 1570 uint8_t lbmode; /* loopback mode */ 1571 } __attribute__ ((__packed__)) hci_write_loopback_mode_cp; 1572 1573 typedef hci_status_rp hci_write_loopback_mode_rp; 1574 1575 #define HCI_OCF_ENABLE_UNIT_UNDER_TEST 0x0003 1576 #define HCI_CMD_ENABLE_UNIT_UNDER_TEST 0x1803 1577 /* No command parameter(s) */ 1578 typedef hci_status_rp hci_enable_unit_under_test_rp; 1579 1580 /************************************************************************** 1581 ************************************************************************** 1582 ** OGF 0x3e Bluetooth Logo Testing 1583 ** OGF 0x3f Vendor Specific 1584 ************************************************************************** 1585 **************************************************************************/ 1586 1587 #define HCI_OGF_BT_LOGO 0x3e 1588 #define HCI_OGF_VENDOR 0x3f 1589 1590 /* Ericsson specific FC */ 1591 #define HCI_CMD_ERICSSON_WRITE_PCM_SETTINGS 0xFC07 1592 #define HCI_CMD_ERICSSON_SET_UART_BAUD_RATE 0xFC09 1593 #define HCI_CMD_ERICSSON_SET_SCO_DATA_PATH 0xFC1D 1594 1595 /* Cambridge Silicon Radio specific FC */ 1596 #define HCI_CMD_CSR_EXTN 0xFC00 1597 1598 1599 /************************************************************************** 1600 ************************************************************************** 1601 ** Events and event parameters 1602 ************************************************************************** 1603 **************************************************************************/ 1604 1605 #define HCI_EVENT_INQUIRY_COMPL 0x01 1606 typedef struct { 1607 uint8_t status; /* 0x00 - success */ 1608 } __attribute__ ((__packed__)) hci_inquiry_compl_ep; 1609 1610 #define HCI_EVENT_INQUIRY_RESULT 0x02 1611 typedef struct { 1612 uint8_t num_responses; /* number of responses */ 1613 /* hci_inquiry_response[num_responses] -- see below */ 1614 } __attribute__ ((__packed__)) hci_inquiry_result_ep; 1615 1616 typedef struct { 1617 bdaddr_t bdaddr; /* unit address */ 1618 uint8_t page_scan_rep_mode; /* page scan rep. mode */ 1619 uint8_t page_scan_period_mode; /* page scan period mode */ 1620 uint8_t page_scan_mode; /* page scan mode */ 1621 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 1622 uint16_t clock_offset; /* clock offset */ 1623 } __attribute__ ((__packed__)) hci_inquiry_response; 1624 1625 #define HCI_EVENT_CON_COMPL 0x03 1626 typedef struct { 1627 uint8_t status; /* 0x00 - success */ 1628 uint16_t con_handle; /* Connection handle */ 1629 bdaddr_t bdaddr; /* remote unit address */ 1630 uint8_t link_type; /* Link type */ 1631 uint8_t encryption_mode; /* Encryption mode */ 1632 } __attribute__ ((__packed__)) hci_con_compl_ep; 1633 1634 #define HCI_EVENT_CON_REQ 0x04 1635 typedef struct { 1636 bdaddr_t bdaddr; /* remote unit address */ 1637 uint8_t uclass[HCI_CLASS_SIZE]; /* remote unit class */ 1638 uint8_t link_type; /* link type */ 1639 } __attribute__ ((__packed__)) hci_con_req_ep; 1640 1641 #define HCI_EVENT_DISCON_COMPL 0x05 1642 typedef struct { 1643 uint8_t status; /* 0x00 - success */ 1644 uint16_t con_handle; /* connection handle */ 1645 uint8_t reason; /* reason to disconnect */ 1646 } __attribute__ ((__packed__)) hci_discon_compl_ep; 1647 1648 #define HCI_EVENT_AUTH_COMPL 0x06 1649 typedef struct { 1650 uint8_t status; /* 0x00 - success */ 1651 uint16_t con_handle; /* connection handle */ 1652 } __attribute__ ((__packed__)) hci_auth_compl_ep; 1653 1654 #define HCI_EVENT_REMOTE_NAME_REQ_COMPL 0x07 1655 typedef struct { 1656 uint8_t status; /* 0x00 - success */ 1657 bdaddr_t bdaddr; /* remote unit address */ 1658 char name[HCI_UNIT_NAME_SIZE]; /* remote unit name */ 1659 } __attribute__ ((__packed__)) hci_remote_name_req_compl_ep; 1660 1661 #define HCI_EVENT_ENCRYPTION_CHANGE 0x08 1662 typedef struct { 1663 uint8_t status; /* 0x00 - success */ 1664 uint16_t con_handle; /* Connection handle */ 1665 uint8_t encryption_enable; /* 0x00 - disable */ 1666 } __attribute__ ((__packed__)) hci_encryption_change_ep; 1667 1668 #define HCI_EVENT_CHANGE_CON_LINK_KEY_COMPL 0x09 1669 typedef struct { 1670 uint8_t status; /* 0x00 - success */ 1671 uint16_t con_handle; /* Connection handle */ 1672 } __attribute__ ((__packed__)) hci_change_con_link_key_compl_ep; 1673 1674 #define HCI_EVENT_MASTER_LINK_KEY_COMPL 0x0a 1675 typedef struct { 1676 uint8_t status; /* 0x00 - success */ 1677 uint16_t con_handle; /* Connection handle */ 1678 uint8_t key_flag; /* Key flag */ 1679 } __attribute__ ((__packed__)) hci_master_link_key_compl_ep; 1680 1681 #define HCI_EVENT_READ_REMOTE_FEATURES_COMPL 0x0b 1682 typedef struct { 1683 uint8_t status; /* 0x00 - success */ 1684 uint16_t con_handle; /* Connection handle */ 1685 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 1686 } __attribute__ ((__packed__)) hci_read_remote_features_compl_ep; 1687 1688 #define HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c 1689 typedef struct { 1690 uint8_t status; /* 0x00 - success */ 1691 uint16_t con_handle; /* Connection handle */ 1692 uint8_t lmp_version; /* LMP version */ 1693 uint16_t manufacturer; /* Hardware manufacturer name */ 1694 uint16_t lmp_subversion; /* LMP sub-version */ 1695 } __attribute__ ((__packed__)) hci_read_remote_ver_info_compl_ep; 1696 1697 #define HCI_EVENT_QOS_SETUP_COMPL 0x0d 1698 typedef struct { 1699 uint8_t status; /* 0x00 - success */ 1700 uint16_t con_handle; /* connection handle */ 1701 uint8_t flags; /* reserved for future use */ 1702 uint8_t service_type; /* service type */ 1703 uint32_t token_rate; /* bytes per second */ 1704 uint32_t peak_bandwidth; /* bytes per second */ 1705 uint32_t latency; /* microseconds */ 1706 uint32_t delay_variation; /* microseconds */ 1707 } __attribute__ ((__packed__)) hci_qos_setup_compl_ep; 1708 1709 #define HCI_EVENT_COMMAND_COMPL 0x0e 1710 typedef struct { 1711 uint8_t num_cmd_pkts; /* # of HCI command packets */ 1712 uint16_t opcode; /* command OpCode */ 1713 /* command return parameters (if any) */ 1714 } __attribute__ ((__packed__)) hci_command_compl_ep; 1715 1716 #define HCI_EVENT_COMMAND_STATUS 0x0f 1717 typedef struct { 1718 uint8_t status; /* 0x00 - pending */ 1719 uint8_t num_cmd_pkts; /* # of HCI command packets */ 1720 uint16_t opcode; /* command OpCode */ 1721 } __attribute__ ((__packed__)) hci_command_status_ep; 1722 1723 #define HCI_EVENT_HARDWARE_ERROR 0x10 1724 typedef struct { 1725 uint8_t hardware_code; /* hardware error code */ 1726 } __attribute__ ((__packed__)) hci_hardware_error_ep; 1727 1728 #define HCI_EVENT_FLUSH_OCCUR 0x11 1729 typedef struct { 1730 uint16_t con_handle; /* connection handle */ 1731 } __attribute__ ((__packed__)) hci_flush_occur_ep; 1732 1733 #define HCI_EVENT_ROLE_CHANGE 0x12 1734 typedef struct { 1735 uint8_t status; /* 0x00 - success */ 1736 bdaddr_t bdaddr; /* address of remote unit */ 1737 uint8_t role; /* new connection role */ 1738 } __attribute__ ((__packed__)) hci_role_change_ep; 1739 1740 #define HCI_EVENT_NUM_COMPL_PKTS 0x13 1741 typedef struct { 1742 uint8_t num_con_handles; /* # of connection handles */ 1743 /* these are repeated "num_con_handles" times 1744 uint16_t con_handle; --- connection handle(s) 1745 uint16_t compl_pkts; --- # of completed packets */ 1746 } __attribute__ ((__packed__)) hci_num_compl_pkts_ep; 1747 1748 #define HCI_EVENT_MODE_CHANGE 0x14 1749 typedef struct { 1750 uint8_t status; /* 0x00 - success */ 1751 uint16_t con_handle; /* connection handle */ 1752 uint8_t unit_mode; /* remote unit mode */ 1753 uint16_t interval; /* interval * 0.625 msec */ 1754 } __attribute__ ((__packed__)) hci_mode_change_ep; 1755 1756 #define HCI_EVENT_RETURN_LINK_KEYS 0x15 1757 typedef struct { 1758 uint8_t num_keys; /* # of keys */ 1759 /* these are repeated "num_keys" times 1760 bdaddr_t bdaddr; --- remote address(es) 1761 uint8_t key[HCI_KEY_SIZE]; --- key(s) */ 1762 } __attribute__ ((__packed__)) hci_return_link_keys_ep; 1763 1764 #define HCI_EVENT_PIN_CODE_REQ 0x16 1765 typedef struct { 1766 bdaddr_t bdaddr; /* remote unit address */ 1767 } __attribute__ ((__packed__)) hci_pin_code_req_ep; 1768 1769 #define HCI_EVENT_LINK_KEY_REQ 0x17 1770 typedef struct { 1771 bdaddr_t bdaddr; /* remote unit address */ 1772 } __attribute__ ((__packed__)) hci_link_key_req_ep; 1773 1774 #define HCI_EVENT_LINK_KEY_NOTIFICATION 0x18 1775 typedef struct { 1776 bdaddr_t bdaddr; /* remote unit address */ 1777 uint8_t key[HCI_KEY_SIZE]; /* link key */ 1778 uint8_t key_type; /* type of the key */ 1779 } __attribute__ ((__packed__)) hci_link_key_notification_ep; 1780 1781 #define HCI_EVENT_LOOPBACK_COMMAND 0x19 1782 typedef hci_cmd_hdr_t hci_loopback_command_ep; 1783 1784 #define HCI_EVENT_DATA_BUFFER_OVERFLOW 0x1a 1785 typedef struct { 1786 uint8_t link_type; /* Link type */ 1787 } __attribute__ ((__packed__)) hci_data_buffer_overflow_ep; 1788 1789 #define HCI_EVENT_MAX_SLOT_CHANGE 0x1b 1790 typedef struct { 1791 uint16_t con_handle; /* connection handle */ 1792 uint8_t lmp_max_slots; /* Max. # of slots allowed */ 1793 } __attribute__ ((__packed__)) hci_max_slot_change_ep; 1794 1795 #define HCI_EVENT_READ_CLOCK_OFFSET_COMPL 0x1c 1796 typedef struct { 1797 uint8_t status; /* 0x00 - success */ 1798 uint16_t con_handle; /* Connection handle */ 1799 uint16_t clock_offset; /* Clock offset */ 1800 } __attribute__ ((__packed__)) hci_read_clock_offset_compl_ep; 1801 1802 #define HCI_EVENT_CON_PKT_TYPE_CHANGED 0x1d 1803 typedef struct { 1804 uint8_t status; /* 0x00 - success */ 1805 uint16_t con_handle; /* connection handle */ 1806 uint16_t pkt_type; /* packet type */ 1807 } __attribute__ ((__packed__)) hci_con_pkt_type_changed_ep; 1808 1809 #define HCI_EVENT_QOS_VIOLATION 0x1e 1810 typedef struct { 1811 uint16_t con_handle; /* connection handle */ 1812 } __attribute__ ((__packed__)) hci_qos_violation_ep; 1813 1814 /* Page Scan Mode Change Event is deprecated */ 1815 #define HCI_EVENT_PAGE_SCAN_MODE_CHANGE 0x1f 1816 typedef struct { 1817 bdaddr_t bdaddr; /* destination address */ 1818 uint8_t page_scan_mode; /* page scan mode */ 1819 } __attribute__ ((__packed__)) hci_page_scan_mode_change_ep; 1820 1821 #define HCI_EVENT_PAGE_SCAN_REP_MODE_CHANGE 0x20 1822 typedef struct { 1823 bdaddr_t bdaddr; /* destination address */ 1824 uint8_t page_scan_rep_mode; /* page scan repetition mode */ 1825 } __attribute__ ((__packed__)) hci_page_scan_rep_mode_change_ep; 1826 1827 #define HCI_EVENT_FLOW_SPECIFICATION_COMPL 0x21 1828 typedef struct { 1829 uint8_t status; /* 0x00 - success */ 1830 uint16_t con_handle; /* connection handle */ 1831 uint8_t flags; /* reserved */ 1832 uint8_t direction; /* flow direction */ 1833 uint8_t type; /* service type */ 1834 uint32_t token_rate; /* token rate */ 1835 uint32_t bucket_size; /* token bucket size */ 1836 uint32_t peak_bandwidth; /* peak bandwidth */ 1837 uint32_t latency; /* access latency */ 1838 } __attribute__ ((__packed__)) hci_flow_specification_compl_ep; 1839 1840 #define HCI_EVENT_RSSI_RESULT 0x22 1841 typedef struct { 1842 uint8_t num_responses; /* number of responses */ 1843 /* hci_rssi_response[num_responses] -- see below */ 1844 } __attribute__ ((__packed__)) hci_rssi_result_ep; 1845 1846 typedef struct { 1847 bdaddr_t bdaddr; /* unit address */ 1848 uint8_t page_scan_rep_mode; /* page scan rep. mode */ 1849 uint8_t blank; /* reserved */ 1850 uint8_t uclass[HCI_CLASS_SIZE]; /* unit class */ 1851 uint16_t clock_offset; /* clock offset */ 1852 int8_t rssi; /* rssi */ 1853 } __attribute__ ((__packed__)) hci_rssi_response; 1854 1855 #define HCI_EVENT_READ_REMOTE_EXTENDED_FEATURES 0x23 1856 typedef struct { 1857 uint8_t status; /* 0x00 - success */ 1858 uint16_t con_handle; /* connection handle */ 1859 uint8_t page; /* page number */ 1860 uint8_t max; /* max page number */ 1861 uint8_t features[HCI_FEATURES_SIZE]; /* LMP features bitmsk*/ 1862 } __attribute__ ((__packed__)) hci_read_remote_extended_features_ep; 1863 1864 #define HCI_EVENT_SCO_CON_COMPL 0x2c 1865 typedef struct { 1866 uint8_t status; /* 0x00 - success */ 1867 uint16_t con_handle; /* connection handle */ 1868 bdaddr_t bdaddr; /* unit address */ 1869 uint8_t link_type; /* link type */ 1870 uint8_t interval; /* transmission interval */ 1871 uint8_t window; /* retransmission window */ 1872 uint16_t rxlen; /* rx packet length */ 1873 uint16_t txlen; /* tx packet length */ 1874 uint8_t mode; /* air mode */ 1875 } __attribute__ ((__packed__)) hci_sco_con_compl_ep; 1876 1877 #define HCI_EVENT_SCO_CON_CHANGED 0x2d 1878 typedef struct { 1879 uint8_t status; /* 0x00 - success */ 1880 uint16_t con_handle; /* connection handle */ 1881 uint8_t interval; /* transmission interval */ 1882 uint8_t window; /* retransmission window */ 1883 uint16_t rxlen; /* rx packet length */ 1884 uint16_t txlen; /* tx packet length */ 1885 } __attribute__ ((__packed__)) hci_sco_con_changed_ep; 1886 1887 #define HCI_EVENT_BT_LOGO 0xfe 1888 1889 #define HCI_EVENT_VENDOR 0xff 1890 1891 /************************************************************************** 1892 ************************************************************************** 1893 ** HCI Socket Definitions 1894 ************************************************************************** 1895 **************************************************************************/ 1896 1897 /* HCI socket options */ 1898 #define SO_HCI_EVT_FILTER 1 /* get/set event filter */ 1899 #define SO_HCI_PKT_FILTER 2 /* get/set packet filter */ 1900 #define SO_HCI_DIRECTION 3 /* packet direction indicator */ 1901 1902 /* Control Messages */ 1903 #define SCM_HCI_DIRECTION SO_HCI_DIRECTION 1904 1905 /* 1906 * HCI socket filter and get/set routines 1907 * 1908 * for ease of use, we filter 256 possible events/packets 1909 */ 1910 struct hci_filter { 1911 uint32_t mask[8]; /* 256 bits */ 1912 }; 1913 1914 static __inline void 1915 hci_filter_set(uint8_t bit, struct hci_filter *filter) 1916 { 1917 uint8_t off = bit - 1; 1918 1919 off >>= 5; 1920 filter->mask[off] |= (1 << ((bit - 1) & 0x1f)); 1921 } 1922 1923 static __inline void 1924 hci_filter_clr(uint8_t bit, struct hci_filter *filter) 1925 { 1926 uint8_t off = bit - 1; 1927 1928 off >>= 5; 1929 filter->mask[off] &= ~(1 << ((bit - 1) & 0x1f)); 1930 } 1931 1932 static __inline int 1933 hci_filter_test(uint8_t bit, struct hci_filter *filter) 1934 { 1935 uint8_t off = bit - 1; 1936 1937 off >>= 5; 1938 return (filter->mask[off] & (1 << ((bit - 1) & 0x1f))); 1939 } 1940 1941 /* 1942 * HCI socket ioctl's 1943 * 1944 * Apart from GBTINFOA, these are all indexed on the unit name 1945 */ 1946 1947 #define SIOCGBTINFO _IOWR('b', 5, struct btreq) /* get unit info */ 1948 #define SIOCGBTINFOA _IOWR('b', 6, struct btreq) /* get info by address */ 1949 #define SIOCNBTINFO _IOWR('b', 7, struct btreq) /* next unit info */ 1950 1951 #define SIOCSBTFLAGS _IOWR('b', 8, struct btreq) /* set unit flags */ 1952 #define SIOCSBTPOLICY _IOWR('b', 9, struct btreq) /* set unit link policy */ 1953 #define SIOCSBTPTYPE _IOWR('b', 10, struct btreq) /* set unit packet type */ 1954 1955 #define SIOCGBTSTATS _IOWR('b', 11, struct btreq) /* get unit statistics */ 1956 #define SIOCZBTSTATS _IOWR('b', 12, struct btreq) /* zero unit statistics */ 1957 1958 #define SIOCBTDUMP _IOW('b', 13, struct btreq) /* print debug info */ 1959 #define SIOCSBTSCOMTU _IOWR('b', 17, struct btreq) /* set sco_mtu value */ 1960 1961 struct bt_stats { 1962 uint32_t err_tx; 1963 uint32_t err_rx; 1964 uint32_t cmd_tx; 1965 uint32_t evt_rx; 1966 uint32_t acl_tx; 1967 uint32_t acl_rx; 1968 uint32_t sco_tx; 1969 uint32_t sco_rx; 1970 uint32_t byte_tx; 1971 uint32_t byte_rx; 1972 }; 1973 1974 struct btreq { 1975 char btr_name[HCI_DEVNAME_SIZE]; /* device name */ 1976 1977 union { 1978 struct { 1979 bdaddr_t btri_bdaddr; /* device bdaddr */ 1980 uint16_t btri_flags; /* flags */ 1981 uint16_t btri_num_cmd; /* # of free cmd buffers */ 1982 uint16_t btri_num_acl; /* # of free ACL buffers */ 1983 uint16_t btri_num_sco; /* # of free SCO buffers */ 1984 uint16_t btri_acl_mtu; /* ACL mtu */ 1985 uint16_t btri_sco_mtu; /* SCO mtu */ 1986 uint16_t btri_link_policy; /* Link Policy */ 1987 uint16_t btri_packet_type; /* Packet Type */ 1988 } btri; 1989 struct bt_stats btrs; /* unit stats */ 1990 } btru; 1991 }; 1992 1993 #define btr_flags btru.btri.btri_flags 1994 #define btr_bdaddr btru.btri.btri_bdaddr 1995 #define btr_num_cmd btru.btri.btri_num_cmd 1996 #define btr_num_acl btru.btri.btri_num_acl 1997 #define btr_num_sco btru.btri.btri_num_sco 1998 #define btr_acl_mtu btru.btri.btri_acl_mtu 1999 #define btr_sco_mtu btru.btri.btri_sco_mtu 2000 #define btr_link_policy btru.btri.btri_link_policy 2001 #define btr_packet_type btru.btri.btri_packet_type 2002 #define btr_uclass btru.btri.btri_uclass 2003 #define btr_stats btru.btrs 2004 2005 /* hci_unit & btr_flags */ 2006 #define BTF_UP (1<<0) /* unit is up */ 2007 #define BTF_RUNNING (1<<1) /* unit is running */ 2008 #define BTF_XMIT_CMD (1<<2) /* unit is transmitting CMD packets */ 2009 #define BTF_XMIT_ACL (1<<3) /* unit is transmitting ACL packets */ 2010 #define BTF_XMIT_SCO (1<<4) /* unit is transmitting SCO packets */ 2011 #define BTF_XMIT (BTF_XMIT_CMD | BTF_XMIT_ACL | BTF_XMIT_SCO) 2012 #define BTF_INIT_BDADDR (1<<5) /* waiting for bdaddr */ 2013 #define BTF_INIT_BUFFER_SIZE (1<<6) /* waiting for buffer size */ 2014 #define BTF_INIT_FEATURES (1<<7) /* waiting for features */ 2015 #define BTF_INIT (BTF_INIT_BDADDR | BTF_INIT_BUFFER_SIZE | BTF_INIT_FEATURES) 2016 #define BTF_POWER_UP_NOOP (1<<8) /* should wait for No-op on power up */ 2017 2018 /************************************************************************** 2019 ************************************************************************** 2020 ** HCI Kernel Definitions 2021 ************************************************************************** 2022 **************************************************************************/ 2023 2024 #ifdef _KERNEL 2025 2026 #include <sys/device.h> 2027 2028 struct l2cap_channel; 2029 struct mbuf; 2030 struct sco_pcb; 2031 struct socket; 2032 2033 /* global HCI kernel variables */ 2034 2035 /* sysctl variables */ 2036 extern int hci_memo_expiry; 2037 extern int hci_acl_expiry; 2038 extern int hci_sendspace, hci_recvspace; 2039 extern int hci_eventq_max, hci_aclrxq_max, hci_scorxq_max; 2040 2041 /* 2042 * HCI Connection Information 2043 */ 2044 struct hci_link { 2045 struct hci_unit *hl_unit; /* our unit */ 2046 TAILQ_ENTRY(hci_link) hl_next; /* next link on unit */ 2047 2048 /* common info */ 2049 uint16_t hl_state; /* connection state */ 2050 uint16_t hl_flags; /* link flags */ 2051 bdaddr_t hl_bdaddr; /* dest address */ 2052 uint16_t hl_handle; /* connection handle */ 2053 uint8_t hl_type; /* link type */ 2054 2055 /* ACL link info */ 2056 uint8_t hl_lastid; /* last id used */ 2057 uint16_t hl_refcnt; /* reference count */ 2058 uint16_t hl_mtu; /* signalling mtu for link */ 2059 uint16_t hl_flush; /* flush timeout */ 2060 uint16_t hl_clock; /* remote clock offset */ 2061 2062 TAILQ_HEAD(,l2cap_pdu) hl_txq; /* queue of outgoing PDUs */ 2063 int hl_txqlen; /* number of fragments */ 2064 struct mbuf *hl_rxp; /* incoming PDU (accumulating)*/ 2065 callout_t hl_expire; /* connection expiry timer */ 2066 TAILQ_HEAD(,l2cap_req) hl_reqs; /* pending requests */ 2067 2068 /* SCO link info */ 2069 struct hci_link *hl_link; /* SCO ACL link */ 2070 struct sco_pcb *hl_sco; /* SCO pcb */ 2071 MBUFQ_HEAD() hl_data; /* SCO outgoing data */ 2072 }; 2073 2074 /* hci_link state */ 2075 #define HCI_LINK_CLOSED 0 /* closed */ 2076 #define HCI_LINK_WAIT_CONNECT 1 /* waiting to connect */ 2077 #define HCI_LINK_WAIT_AUTH 2 /* waiting for auth */ 2078 #define HCI_LINK_WAIT_ENCRYPT 3 /* waiting for encrypt */ 2079 #define HCI_LINK_WAIT_SECURE 4 /* waiting for secure */ 2080 #define HCI_LINK_OPEN 5 /* ready and willing */ 2081 #define HCI_LINK_BLOCK 6 /* open but blocking (see hci_acl_start) */ 2082 2083 /* hci_link flags */ 2084 #define HCI_LINK_AUTH_REQ (1<<0) /* authentication requested */ 2085 #define HCI_LINK_ENCRYPT_REQ (1<<1) /* encryption requested */ 2086 #define HCI_LINK_SECURE_REQ (1<<2) /* secure link requested */ 2087 #define HCI_LINK_AUTH (1<<3) /* link is authenticated */ 2088 #define HCI_LINK_ENCRYPT (1<<4) /* link is encrypted */ 2089 #define HCI_LINK_SECURE (1<<5) /* link is secured */ 2090 2091 /* 2092 * Bluetooth Memo 2093 * cached device information for remote devices that this unit has seen 2094 */ 2095 struct hci_memo { 2096 struct timeval time; /* time of last response */ 2097 bdaddr_t bdaddr; 2098 uint8_t page_scan_rep_mode; 2099 uint8_t page_scan_mode; 2100 uint16_t clock_offset; 2101 LIST_ENTRY(hci_memo) next; 2102 }; 2103 2104 /* 2105 * The Bluetooth HCI interface attachment structure 2106 */ 2107 struct hci_if { 2108 int (*enable)(device_t); 2109 void (*disable)(device_t); 2110 void (*output_cmd)(device_t, struct mbuf *); 2111 void (*output_acl)(device_t, struct mbuf *); 2112 void (*output_sco)(device_t, struct mbuf *); 2113 void (*get_stats)(device_t, struct bt_stats *, int); 2114 int ipl; /* for locking */ 2115 }; 2116 2117 /* 2118 * The Bluetooth HCI device unit structure 2119 */ 2120 struct hci_unit { 2121 device_t hci_dev; /* bthci handle */ 2122 device_t hci_bthub; /* bthub(4) handle */ 2123 const struct hci_if *hci_if; /* bthci driver interface */ 2124 2125 /* device info */ 2126 bdaddr_t hci_bdaddr; /* device address */ 2127 uint16_t hci_flags; /* see BTF_ above */ 2128 2129 uint16_t hci_packet_type; /* packet types */ 2130 uint16_t hci_acl_mask; /* ACL packet capabilities */ 2131 uint16_t hci_sco_mask; /* SCO packet capabilities */ 2132 2133 uint16_t hci_link_policy; /* link policy */ 2134 uint16_t hci_lmp_mask; /* link policy capabilities */ 2135 2136 /* flow control */ 2137 uint16_t hci_max_acl_size; /* ACL payload mtu */ 2138 uint16_t hci_num_acl_pkts; /* free ACL packet buffers */ 2139 uint8_t hci_num_cmd_pkts; /* free CMD packet buffers */ 2140 uint8_t hci_max_sco_size; /* SCO payload mtu */ 2141 uint16_t hci_num_sco_pkts; /* free SCO packet buffers */ 2142 2143 TAILQ_HEAD(,hci_link) hci_links; /* list of ACL/SCO links */ 2144 LIST_HEAD(,hci_memo) hci_memos; /* cached memo list */ 2145 2146 /* input queues */ 2147 void *hci_rxint; /* receive interrupt cookie */ 2148 kmutex_t hci_devlock; /* device queue lock */ 2149 MBUFQ_HEAD() hci_eventq; /* Event queue */ 2150 MBUFQ_HEAD() hci_aclrxq; /* ACL rx queue */ 2151 MBUFQ_HEAD() hci_scorxq; /* SCO rx queue */ 2152 uint16_t hci_eventqlen; /* Event queue length */ 2153 uint16_t hci_aclrxqlen; /* ACL rx queue length */ 2154 uint16_t hci_scorxqlen; /* SCO rx queue length */ 2155 2156 /* output queues */ 2157 MBUFQ_HEAD() hci_cmdwait; /* pending commands */ 2158 MBUFQ_HEAD() hci_scodone; /* SCO done queue */ 2159 2160 SIMPLEQ_ENTRY(hci_unit) hci_next; 2161 }; 2162 2163 extern SIMPLEQ_HEAD(hci_unit_list, hci_unit) hci_unit_list; 2164 2165 /* 2166 * HCI layer function prototypes 2167 */ 2168 2169 /* hci_event.c */ 2170 void hci_event(struct mbuf *, struct hci_unit *); 2171 2172 /* hci_ioctl.c */ 2173 int hci_ioctl(unsigned long, void *, struct lwp *); 2174 2175 /* hci_link.c */ 2176 struct hci_link *hci_acl_open(struct hci_unit *, bdaddr_t *); 2177 struct hci_link *hci_acl_newconn(struct hci_unit *, bdaddr_t *); 2178 void hci_acl_close(struct hci_link *, int); 2179 void hci_acl_timeout(void *); 2180 int hci_acl_setmode(struct hci_link *); 2181 void hci_acl_linkmode(struct hci_link *); 2182 void hci_acl_recv(struct mbuf *, struct hci_unit *); 2183 int hci_acl_send(struct mbuf *, struct hci_link *, struct l2cap_channel *); 2184 void hci_acl_start(struct hci_link *); 2185 void hci_acl_complete(struct hci_link *, int); 2186 struct hci_link *hci_sco_newconn(struct hci_unit *, bdaddr_t *); 2187 void hci_sco_recv(struct mbuf *, struct hci_unit *); 2188 void hci_sco_start(struct hci_link *); 2189 void hci_sco_complete(struct hci_link *, int); 2190 struct hci_link *hci_link_alloc(struct hci_unit *); 2191 void hci_link_free(struct hci_link *, int); 2192 struct hci_link *hci_link_lookup_bdaddr(struct hci_unit *, bdaddr_t *, uint16_t); 2193 struct hci_link *hci_link_lookup_handle(struct hci_unit *, uint16_t); 2194 2195 /* hci_misc.c */ 2196 int hci_route_lookup(bdaddr_t *, bdaddr_t *); 2197 struct hci_memo *hci_memo_find(struct hci_unit *, bdaddr_t *); 2198 struct hci_memo *hci_memo_new(struct hci_unit *, bdaddr_t *); 2199 void hci_memo_free(struct hci_memo *); 2200 2201 /* hci_socket.c */ 2202 void hci_drop(void *); 2203 int hci_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct lwp *); 2204 int hci_ctloutput(int, struct socket *, int, int, struct mbuf **); 2205 void hci_mtap(struct mbuf *, struct hci_unit *); 2206 2207 /* hci_unit.c */ 2208 struct hci_unit *hci_attach(const struct hci_if *, device_t, uint16_t); 2209 void hci_detach(struct hci_unit *); 2210 int hci_enable(struct hci_unit *); 2211 void hci_disable(struct hci_unit *); 2212 struct hci_unit *hci_unit_lookup(bdaddr_t *); 2213 int hci_send_cmd(struct hci_unit *, uint16_t, void *, uint8_t); 2214 bool hci_input_event(struct hci_unit *, struct mbuf *); 2215 bool hci_input_acl(struct hci_unit *, struct mbuf *); 2216 bool hci_input_sco(struct hci_unit *, struct mbuf *); 2217 bool hci_complete_sco(struct hci_unit *, struct mbuf *); 2218 void hci_output_cmd(struct hci_unit *, struct mbuf *); 2219 void hci_output_acl(struct hci_unit *, struct mbuf *); 2220 void hci_output_sco(struct hci_unit *, struct mbuf *); 2221 2222 #endif /* _KERNEL */ 2223 2224 #endif /* _NETBT_HCI_H_ */ 2225