2 * QEMU Bluetooth HCI helpers.
4 * Copyright (C) 2007 OpenMoko, Inc.
5 * Written by Andrzej Zaborowski <andrew@openedhand.com>
7 * Useful definitions taken from BlueZ project's headers.
8 * Copyright (C) 2000-2001 Qualcomm Incorporated
9 * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com>
10 * Copyright (C) 2002-2006 Marcel Holtmann <marcel@holtmann.org>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
31 } __attribute__((packed)) bdaddr_t;
33 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
34 #define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
35 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
37 /* Copy, swap, convert BD Address */
38 static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
40 return memcmp(ba1, ba2, sizeof(bdaddr_t));
42 static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
44 memcpy(dst, src, sizeof(bdaddr_t));
47 #define BAINIT(orig) { .b = { \
48 (orig)->b[0], (orig)->b[1], (orig)->b[2], \
49 (orig)->b[3], (orig)->b[4], (orig)->b[5], \
52 /* The twisted structures of a bluetooth environment */
54 struct bt_scatternet_s;
58 struct bt_scatternet_s {
59 struct bt_device_s *slave;
63 struct bt_device_s *slave, *host;
64 uint16_t handle; /* Master (host) side handle */
65 uint16_t acl_interval;
79 struct bt_scatternet_s *net;
85 uint8_t reject_reason;
89 void (*lmp_connection_request)(struct bt_link_s *link);
90 void (*lmp_connection_complete)(struct bt_link_s *link);
91 void (*lmp_disconnect_master)(struct bt_link_s *link);
92 void (*lmp_disconnect_slave)(struct bt_link_s *link);
93 void (*lmp_acl_data)(struct bt_link_s *link, const uint8_t *data,
95 void (*lmp_acl_resp)(struct bt_link_s *link, const uint8_t *data,
97 void (*lmp_mode_change)(struct bt_link_s *link);
99 void (*handle_destroy)(struct bt_device_s *device);
100 struct bt_device_s *next; /* Next in the piconet/scatternet */
105 uint16_t clkoff; /* Note: Always little-endian */
109 void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net);
110 void bt_device_done(struct bt_device_s *dev);
113 struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net);
116 struct HCIInfo *bt_host_hci(const char *id);
124 qemu_irq *csrhci_pins_get(CharDriverState *chr);
125 CharDriverState *uart_hci_init(qemu_irq wakeup);
127 /* Link Management Protocol layer defines */
129 #define LLID_ACLU_CONT 0x1
130 #define LLID_ACLU_START 0x2
131 #define LLID_ACLC 0x3
134 LMP_NAME_REQ = 0x0001,
135 LMP_NAME_RES = 0x0002,
136 LMP_ACCEPTED = 0x0003,
137 LMP_NOT_ACCEPTED = 0x0004,
138 LMP_CLKOFFSET_REQ = 0x0005,
139 LMP_CLKOFFSET_RES = 0x0006,
141 LMP_IN_RAND = 0x0008,
142 LMP_COMB_KEY = 0x0009,
143 LMP_UNIT_KEY = 0x000a,
144 LMP_AU_RAND = 0x000b,
146 LMP_TEMP_RAND = 0x000d,
147 LMP_TEMP_KEY = 0x000e,
148 LMP_CRYPT_MODE_REQ = 0x000f,
149 LMP_CRYPT_KEY_SIZE_REQ = 0x0010,
150 LMP_START_ENCRYPT_REQ = 0x0011,
151 LMP_STOP_ENCRYPT_REQ = 0x0012,
152 LMP_SWITCH_REQ = 0x0013,
154 LMP_HOLD_REQ = 0x0015,
155 LMP_SNIFF_REQ = 0x0017,
156 LMP_UNSNIFF_REQ = 0x0018,
157 LMP_LMP_PARK_REQ = 0x0019,
158 LMP_SET_BCAST_SCAN_WND = 0x001b,
159 LMP_MODIFY_BEACON = 0x001c,
160 LMP_UNPARK_BD_ADDR_REQ = 0x001d,
161 LMP_UNPARK_PM_ADDR_REQ = 0x001e,
162 LMP_INCR_POWER_REQ = 0x001f,
163 LMP_DECR_POWER_REQ = 0x0020,
164 LMP_MAX_POWER = 0x0021,
165 LMP_MIN_POWER = 0x0022,
166 LMP_AUTO_RATE = 0x0023,
167 LMP_PREFERRED_RATE = 0x0024,
168 LMP_VERSION_REQ = 0x0025,
169 LMP_VERSION_RES = 0x0026,
170 LMP_FEATURES_REQ = 0x0027,
171 LMP_FEATURES_RES = 0x0028,
172 LMP_QUALITY_OF_SERVICE = 0x0029,
173 LMP_QOS_REQ = 0x002a,
174 LMP_RM_SCO_LINK_REQ = 0x002b,
175 LMP_SCO_LINK_REQ = 0x002c,
176 LMP_MAX_SLOT = 0x002d,
177 LMP_MAX_SLOT_REQ = 0x002e,
178 LMP_TIMING_ACCURACY_REQ = 0x002f,
179 LMP_TIMING_ACCURACY_RES = 0x0030,
180 LMP_SETUP_COMPLETE = 0x0031,
181 LMP_USE_SEMIPERM_KEY = 0x0032,
182 LMP_HOST_CONNECTION_REQ = 0x0033,
183 LMP_SLOT_OFFSET = 0x0034,
184 LMP_PAGE_MODE_REQ = 0x0035,
185 LMP_PAGE_SCAN_MODE_REQ = 0x0036,
186 LMP_SUPERVISION_TIMEOUT = 0x0037,
187 LMP_TEST_ACTIVATE = 0x0038,
188 LMP_TEST_CONTROL = 0x0039,
189 LMP_CRYPT_KEY_MASK_REQ = 0x003a,
190 LMP_CRYPT_KEY_MASK_RES = 0x003b,
191 LMP_SET_AFH = 0x003c,
192 LMP_ACCEPTED_EXT = 0x7f01,
193 LMP_NOT_ACCEPTED_EXT = 0x7f02,
194 LMP_FEATURES_REQ_EXT = 0x7f03,
195 LMP_FEATURES_RES_EXT = 0x7f04,
196 LMP_PACKET_TYPE_TBL_REQ = 0x7f0b,
197 LMP_ESCO_LINK_REQ = 0x7f0c,
198 LMP_RM_ESCO_LINK_REQ = 0x7f0d,
199 LMP_CHANNEL_CLASS_REQ = 0x7f10,
200 LMP_CHANNEL_CLASS = 0x7f11,
203 /* Host Controller Interface layer defines */
205 enum hci_packet_type {
206 HCI_COMMAND_PKT = 0x01,
207 HCI_ACLDATA_PKT = 0x02,
208 HCI_SCODATA_PKT = 0x03,
209 HCI_EVENT_PKT = 0x04,
210 HCI_VENDOR_PKT = 0xff,
213 enum bt_packet_type {
228 enum sco_packet_type {
234 enum ev_packet_type {
244 enum hci_error_code {
246 HCI_UNKNOWN_COMMAND = 0x01,
247 HCI_NO_CONNECTION = 0x02,
248 HCI_HARDWARE_FAILURE = 0x03,
249 HCI_PAGE_TIMEOUT = 0x04,
250 HCI_AUTHENTICATION_FAILURE = 0x05,
251 HCI_PIN_OR_KEY_MISSING = 0x06,
252 HCI_MEMORY_FULL = 0x07,
253 HCI_CONNECTION_TIMEOUT = 0x08,
254 HCI_MAX_NUMBER_OF_CONNECTIONS = 0x09,
255 HCI_MAX_NUMBER_OF_SCO_CONNECTIONS = 0x0a,
256 HCI_ACL_CONNECTION_EXISTS = 0x0b,
257 HCI_COMMAND_DISALLOWED = 0x0c,
258 HCI_REJECTED_LIMITED_RESOURCES = 0x0d,
259 HCI_REJECTED_SECURITY = 0x0e,
260 HCI_REJECTED_PERSONAL = 0x0f,
261 HCI_HOST_TIMEOUT = 0x10,
262 HCI_UNSUPPORTED_FEATURE = 0x11,
263 HCI_INVALID_PARAMETERS = 0x12,
264 HCI_OE_USER_ENDED_CONNECTION = 0x13,
265 HCI_OE_LOW_RESOURCES = 0x14,
266 HCI_OE_POWER_OFF = 0x15,
267 HCI_CONNECTION_TERMINATED = 0x16,
268 HCI_REPEATED_ATTEMPTS = 0x17,
269 HCI_PAIRING_NOT_ALLOWED = 0x18,
270 HCI_UNKNOWN_LMP_PDU = 0x19,
271 HCI_UNSUPPORTED_REMOTE_FEATURE = 0x1a,
272 HCI_SCO_OFFSET_REJECTED = 0x1b,
273 HCI_SCO_INTERVAL_REJECTED = 0x1c,
274 HCI_AIR_MODE_REJECTED = 0x1d,
275 HCI_INVALID_LMP_PARAMETERS = 0x1e,
276 HCI_UNSPECIFIED_ERROR = 0x1f,
277 HCI_UNSUPPORTED_LMP_PARAMETER_VALUE = 0x20,
278 HCI_ROLE_CHANGE_NOT_ALLOWED = 0x21,
279 HCI_LMP_RESPONSE_TIMEOUT = 0x22,
280 HCI_LMP_ERROR_TRANSACTION_COLLISION = 0x23,
281 HCI_LMP_PDU_NOT_ALLOWED = 0x24,
282 HCI_ENCRYPTION_MODE_NOT_ACCEPTED = 0x25,
283 HCI_UNIT_LINK_KEY_USED = 0x26,
284 HCI_QOS_NOT_SUPPORTED = 0x27,
285 HCI_INSTANT_PASSED = 0x28,
286 HCI_PAIRING_NOT_SUPPORTED = 0x29,
287 HCI_TRANSACTION_COLLISION = 0x2a,
288 HCI_QOS_UNACCEPTABLE_PARAMETER = 0x2c,
289 HCI_QOS_REJECTED = 0x2d,
290 HCI_CLASSIFICATION_NOT_SUPPORTED = 0x2e,
291 HCI_INSUFFICIENT_SECURITY = 0x2f,
292 HCI_PARAMETER_OUT_OF_RANGE = 0x30,
293 HCI_ROLE_SWITCH_PENDING = 0x32,
294 HCI_SLOT_VIOLATION = 0x34,
295 HCI_ROLE_SWITCH_FAILED = 0x35,
301 ACL_ACTIVE_BCAST = 1 << 2,
302 ACL_PICO_BCAST = 1 << 3,
305 enum baseband_link_type {
310 enum lmp_feature_bits0 {
313 LMP_ENCRYPT = 1 << 2,
314 LMP_SOFFSET = 1 << 3,
315 LMP_TACCURACY = 1 << 4,
316 LMP_RSWITCH = 1 << 5,
317 LMP_HOLD_MODE = 1 << 6,
318 LMP_SNIFF_MODE = 1 << 7,
321 enum lmp_feature_bits1 {
324 LMP_QUALITY = 1 << 2,
332 enum lmp_feature_bits2 {
334 LMP_PSCHEME = 1 << 1,
335 LMP_PCONTROL = 1 << 2,
336 LMP_TRSP_SCO = 1 << 3,
337 LMP_BCAST_ENC = 1 << 7,
340 enum lmp_feature_bits3 {
341 LMP_EDR_ACL_2M = 1 << 1,
342 LMP_EDR_ACL_3M = 1 << 2,
343 LMP_ENH_ISCAN = 1 << 3,
344 LMP_ILACE_ISCAN = 1 << 4,
345 LMP_ILACE_PSCAN = 1 << 5,
346 LMP_RSSI_INQ = 1 << 6,
350 enum lmp_feature_bits4 {
353 LMP_AFH_CAP_SLV = 1 << 3,
354 LMP_AFH_CLS_SLV = 1 << 4,
355 LMP_EDR_3SLOT = 1 << 7,
358 enum lmp_feature_bits5 {
359 LMP_EDR_5SLOT = 1 << 0,
360 LMP_SNIFF_SUBR = 1 << 1,
361 LMP_AFH_CAP_MST = 1 << 3,
362 LMP_AFH_CLS_MST = 1 << 4,
363 LMP_EDR_ESCO_2M = 1 << 5,
364 LMP_EDR_ESCO_3M = 1 << 6,
365 LMP_EDR_3S_ESCO = 1 << 7,
368 enum lmp_feature_bits6 {
369 LMP_EXT_INQ = 1 << 0,
372 enum lmp_feature_bits7 {
373 LMP_EXT_FEAT = 1 << 7,
376 enum hci_link_policy {
377 HCI_LP_RSWITCH = 1 << 0,
378 HCI_LP_HOLD = 1 << 1,
379 HCI_LP_SNIFF = 1 << 2,
380 HCI_LP_PARK = 1 << 3,
384 HCI_LM_ACCEPT = 1 << 15,
385 HCI_LM_MASTER = 1 << 0,
386 HCI_LM_AUTH = 1 << 1,
387 HCI_LM_ENCRYPT = 1 << 2,
388 HCI_LM_TRUSTED = 1 << 3,
389 HCI_LM_RELIABLE = 1 << 4,
390 HCI_LM_SECURE = 1 << 5,
396 #define OGF_LINK_CTL 0x01
398 #define OCF_INQUIRY 0x0001
401 uint8_t length; /* 1.28s units */
403 } __attribute__ ((packed)) inquiry_cp;
404 #define INQUIRY_CP_SIZE 5
409 } __attribute__ ((packed)) status_bdaddr_rp;
410 #define STATUS_BDADDR_RP_SIZE 7
412 #define OCF_INQUIRY_CANCEL 0x0002
414 #define OCF_PERIODIC_INQUIRY 0x0003
416 uint16_t max_period; /* 1.28s units */
417 uint16_t min_period; /* 1.28s units */
419 uint8_t length; /* 1.28s units */
421 } __attribute__ ((packed)) periodic_inquiry_cp;
422 #define PERIODIC_INQUIRY_CP_SIZE 9
424 #define OCF_EXIT_PERIODIC_INQUIRY 0x0004
426 #define OCF_CREATE_CONN 0x0005
430 uint8_t pscan_rep_mode;
432 uint16_t clock_offset;
434 } __attribute__ ((packed)) create_conn_cp;
435 #define CREATE_CONN_CP_SIZE 13
437 #define OCF_DISCONNECT 0x0006
441 } __attribute__ ((packed)) disconnect_cp;
442 #define DISCONNECT_CP_SIZE 3
444 #define OCF_ADD_SCO 0x0007
448 } __attribute__ ((packed)) add_sco_cp;
449 #define ADD_SCO_CP_SIZE 4
451 #define OCF_CREATE_CONN_CANCEL 0x0008
455 } __attribute__ ((packed)) create_conn_cancel_cp;
456 #define CREATE_CONN_CANCEL_CP_SIZE 6
461 } __attribute__ ((packed)) create_conn_cancel_rp;
462 #define CREATE_CONN_CANCEL_RP_SIZE 7
464 #define OCF_ACCEPT_CONN_REQ 0x0009
468 } __attribute__ ((packed)) accept_conn_req_cp;
469 #define ACCEPT_CONN_REQ_CP_SIZE 7
471 #define OCF_REJECT_CONN_REQ 0x000A
475 } __attribute__ ((packed)) reject_conn_req_cp;
476 #define REJECT_CONN_REQ_CP_SIZE 7
478 #define OCF_LINK_KEY_REPLY 0x000B
481 uint8_t link_key[16];
482 } __attribute__ ((packed)) link_key_reply_cp;
483 #define LINK_KEY_REPLY_CP_SIZE 22
485 #define OCF_LINK_KEY_NEG_REPLY 0x000C
487 #define OCF_PIN_CODE_REPLY 0x000D
491 uint8_t pin_code[16];
492 } __attribute__ ((packed)) pin_code_reply_cp;
493 #define PIN_CODE_REPLY_CP_SIZE 23
495 #define OCF_PIN_CODE_NEG_REPLY 0x000E
497 #define OCF_SET_CONN_PTYPE 0x000F
501 } __attribute__ ((packed)) set_conn_ptype_cp;
502 #define SET_CONN_PTYPE_CP_SIZE 4
504 #define OCF_AUTH_REQUESTED 0x0011
507 } __attribute__ ((packed)) auth_requested_cp;
508 #define AUTH_REQUESTED_CP_SIZE 2
510 #define OCF_SET_CONN_ENCRYPT 0x0013
514 } __attribute__ ((packed)) set_conn_encrypt_cp;
515 #define SET_CONN_ENCRYPT_CP_SIZE 3
517 #define OCF_CHANGE_CONN_LINK_KEY 0x0015
520 } __attribute__ ((packed)) change_conn_link_key_cp;
521 #define CHANGE_CONN_LINK_KEY_CP_SIZE 2
523 #define OCF_MASTER_LINK_KEY 0x0017
526 } __attribute__ ((packed)) master_link_key_cp;
527 #define MASTER_LINK_KEY_CP_SIZE 1
529 #define OCF_REMOTE_NAME_REQ 0x0019
532 uint8_t pscan_rep_mode;
534 uint16_t clock_offset;
535 } __attribute__ ((packed)) remote_name_req_cp;
536 #define REMOTE_NAME_REQ_CP_SIZE 10
538 #define OCF_REMOTE_NAME_REQ_CANCEL 0x001A
541 } __attribute__ ((packed)) remote_name_req_cancel_cp;
542 #define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
547 } __attribute__ ((packed)) remote_name_req_cancel_rp;
548 #define REMOTE_NAME_REQ_CANCEL_RP_SIZE 7
550 #define OCF_READ_REMOTE_FEATURES 0x001B
553 } __attribute__ ((packed)) read_remote_features_cp;
554 #define READ_REMOTE_FEATURES_CP_SIZE 2
556 #define OCF_READ_REMOTE_EXT_FEATURES 0x001C
560 } __attribute__ ((packed)) read_remote_ext_features_cp;
561 #define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
563 #define OCF_READ_REMOTE_VERSION 0x001D
566 } __attribute__ ((packed)) read_remote_version_cp;
567 #define READ_REMOTE_VERSION_CP_SIZE 2
569 #define OCF_READ_CLOCK_OFFSET 0x001F
572 } __attribute__ ((packed)) read_clock_offset_cp;
573 #define READ_CLOCK_OFFSET_CP_SIZE 2
575 #define OCF_READ_LMP_HANDLE 0x0020
578 } __attribute__ ((packed)) read_lmp_handle_cp;
579 #define READ_LMP_HANDLE_CP_SIZE 2
586 } __attribute__ ((packed)) read_lmp_handle_rp;
587 #define READ_LMP_HANDLE_RP_SIZE 8
589 #define OCF_SETUP_SYNC_CONN 0x0028
592 uint32_t tx_bandwith;
593 uint32_t rx_bandwith;
594 uint16_t max_latency;
595 uint16_t voice_setting;
596 uint8_t retrans_effort;
598 } __attribute__ ((packed)) setup_sync_conn_cp;
599 #define SETUP_SYNC_CONN_CP_SIZE 17
601 #define OCF_ACCEPT_SYNC_CONN_REQ 0x0029
604 uint32_t tx_bandwith;
605 uint32_t rx_bandwith;
606 uint16_t max_latency;
607 uint16_t voice_setting;
608 uint8_t retrans_effort;
610 } __attribute__ ((packed)) accept_sync_conn_req_cp;
611 #define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
613 #define OCF_REJECT_SYNC_CONN_REQ 0x002A
617 } __attribute__ ((packed)) reject_sync_conn_req_cp;
618 #define REJECT_SYNC_CONN_REQ_CP_SIZE 7
621 #define OGF_LINK_POLICY 0x02
623 #define OCF_HOLD_MODE 0x0001
626 uint16_t max_interval;
627 uint16_t min_interval;
628 } __attribute__ ((packed)) hold_mode_cp;
629 #define HOLD_MODE_CP_SIZE 6
631 #define OCF_SNIFF_MODE 0x0003
634 uint16_t max_interval;
635 uint16_t min_interval;
638 } __attribute__ ((packed)) sniff_mode_cp;
639 #define SNIFF_MODE_CP_SIZE 10
641 #define OCF_EXIT_SNIFF_MODE 0x0004
644 } __attribute__ ((packed)) exit_sniff_mode_cp;
645 #define EXIT_SNIFF_MODE_CP_SIZE 2
647 #define OCF_PARK_MODE 0x0005
650 uint16_t max_interval;
651 uint16_t min_interval;
652 } __attribute__ ((packed)) park_mode_cp;
653 #define PARK_MODE_CP_SIZE 6
655 #define OCF_EXIT_PARK_MODE 0x0006
658 } __attribute__ ((packed)) exit_park_mode_cp;
659 #define EXIT_PARK_MODE_CP_SIZE 2
661 #define OCF_QOS_SETUP 0x0007
663 uint8_t service_type; /* 1 = best effort */
664 uint32_t token_rate; /* Byte per seconds */
665 uint32_t peak_bandwidth; /* Byte per seconds */
666 uint32_t latency; /* Microseconds */
667 uint32_t delay_variation; /* Microseconds */
668 } __attribute__ ((packed)) hci_qos;
669 #define HCI_QOS_CP_SIZE 17
672 uint8_t flags; /* Reserved */
674 } __attribute__ ((packed)) qos_setup_cp;
675 #define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
677 #define OCF_ROLE_DISCOVERY 0x0009
680 } __attribute__ ((packed)) role_discovery_cp;
681 #define ROLE_DISCOVERY_CP_SIZE 2
686 } __attribute__ ((packed)) role_discovery_rp;
687 #define ROLE_DISCOVERY_RP_SIZE 4
689 #define OCF_SWITCH_ROLE 0x000B
693 } __attribute__ ((packed)) switch_role_cp;
694 #define SWITCH_ROLE_CP_SIZE 7
696 #define OCF_READ_LINK_POLICY 0x000C
699 } __attribute__ ((packed)) read_link_policy_cp;
700 #define READ_LINK_POLICY_CP_SIZE 2
705 } __attribute__ ((packed)) read_link_policy_rp;
706 #define READ_LINK_POLICY_RP_SIZE 5
708 #define OCF_WRITE_LINK_POLICY 0x000D
712 } __attribute__ ((packed)) write_link_policy_cp;
713 #define WRITE_LINK_POLICY_CP_SIZE 4
717 } __attribute__ ((packed)) write_link_policy_rp;
718 #define WRITE_LINK_POLICY_RP_SIZE 3
720 #define OCF_READ_DEFAULT_LINK_POLICY 0x000E
722 #define OCF_WRITE_DEFAULT_LINK_POLICY 0x000F
724 #define OCF_FLOW_SPECIFICATION 0x0010
726 #define OCF_SNIFF_SUBRATE 0x0011
729 uint16_t max_remote_latency;
730 uint16_t max_local_latency;
731 uint16_t min_remote_timeout;
732 uint16_t min_local_timeout;
733 } __attribute__ ((packed)) sniff_subrate_cp;
734 #define SNIFF_SUBRATE_CP_SIZE 10
736 /* Host Controller and Baseband */
737 #define OGF_HOST_CTL 0x03
739 #define OCF_SET_EVENT_MASK 0x0001
742 } __attribute__ ((packed)) set_event_mask_cp;
743 #define SET_EVENT_MASK_CP_SIZE 8
745 #define OCF_RESET 0x0003
747 #define OCF_SET_EVENT_FLT 0x0005
751 uint8_t condition[0];
752 } __attribute__ ((packed)) set_event_flt_cp;
753 #define SET_EVENT_FLT_CP_SIZE 2
755 enum bt_filter_type {
756 FLT_CLEAR_ALL = 0x00,
757 FLT_INQ_RESULT = 0x01,
758 FLT_CONN_SETUP = 0x02,
760 enum inq_result_cond_type {
761 INQ_RESULT_RETURN_ALL = 0x00,
762 INQ_RESULT_RETURN_CLASS = 0x01,
763 INQ_RESULT_RETURN_BDADDR = 0x02,
765 enum conn_setup_cond_type {
766 CONN_SETUP_ALLOW_ALL = 0x00,
767 CONN_SETUP_ALLOW_CLASS = 0x01,
768 CONN_SETUP_ALLOW_BDADDR = 0x02,
770 enum conn_setup_cond {
771 CONN_SETUP_AUTO_OFF = 0x01,
772 CONN_SETUP_AUTO_ON = 0x02,
775 #define OCF_FLUSH 0x0008
778 } __attribute__ ((packed)) flush_cp;
779 #define FLUSH_CP_SIZE 2
784 } __attribute__ ((packed)) flush_rp;
785 #define FLUSH_RP_SIZE 3
787 #define OCF_READ_PIN_TYPE 0x0009
791 } __attribute__ ((packed)) read_pin_type_rp;
792 #define READ_PIN_TYPE_RP_SIZE 2
794 #define OCF_WRITE_PIN_TYPE 0x000A
797 } __attribute__ ((packed)) write_pin_type_cp;
798 #define WRITE_PIN_TYPE_CP_SIZE 1
800 #define OCF_CREATE_NEW_UNIT_KEY 0x000B
802 #define OCF_READ_STORED_LINK_KEY 0x000D
806 } __attribute__ ((packed)) read_stored_link_key_cp;
807 #define READ_STORED_LINK_KEY_CP_SIZE 7
812 } __attribute__ ((packed)) read_stored_link_key_rp;
813 #define READ_STORED_LINK_KEY_RP_SIZE 5
815 #define OCF_WRITE_STORED_LINK_KEY 0x0011
818 /* variable length part */
819 } __attribute__ ((packed)) write_stored_link_key_cp;
820 #define WRITE_STORED_LINK_KEY_CP_SIZE 1
824 } __attribute__ ((packed)) write_stored_link_key_rp;
825 #define READ_WRITE_LINK_KEY_RP_SIZE 2
827 #define OCF_DELETE_STORED_LINK_KEY 0x0012
831 } __attribute__ ((packed)) delete_stored_link_key_cp;
832 #define DELETE_STORED_LINK_KEY_CP_SIZE 7
836 } __attribute__ ((packed)) delete_stored_link_key_rp;
837 #define DELETE_STORED_LINK_KEY_RP_SIZE 3
839 #define OCF_CHANGE_LOCAL_NAME 0x0013
842 } __attribute__ ((packed)) change_local_name_cp;
843 #define CHANGE_LOCAL_NAME_CP_SIZE 248
845 #define OCF_READ_LOCAL_NAME 0x0014
849 } __attribute__ ((packed)) read_local_name_rp;
850 #define READ_LOCAL_NAME_RP_SIZE 249
852 #define OCF_READ_CONN_ACCEPT_TIMEOUT 0x0015
856 } __attribute__ ((packed)) read_conn_accept_timeout_rp;
857 #define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
859 #define OCF_WRITE_CONN_ACCEPT_TIMEOUT 0x0016
862 } __attribute__ ((packed)) write_conn_accept_timeout_cp;
863 #define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
865 #define OCF_READ_PAGE_TIMEOUT 0x0017
869 } __attribute__ ((packed)) read_page_timeout_rp;
870 #define READ_PAGE_TIMEOUT_RP_SIZE 3
872 #define OCF_WRITE_PAGE_TIMEOUT 0x0018
875 } __attribute__ ((packed)) write_page_timeout_cp;
876 #define WRITE_PAGE_TIMEOUT_CP_SIZE 2
878 #define OCF_READ_SCAN_ENABLE 0x0019
882 } __attribute__ ((packed)) read_scan_enable_rp;
883 #define READ_SCAN_ENABLE_RP_SIZE 2
885 #define OCF_WRITE_SCAN_ENABLE 0x001A
888 } __attribute__ ((packed)) write_scan_enable_cp;
889 #define WRITE_SCAN_ENABLE_CP_SIZE 1
891 enum scan_enable_bits {
893 SCAN_INQUIRY = 1 << 0,
897 #define OCF_READ_PAGE_ACTIVITY 0x001B
902 } __attribute__ ((packed)) read_page_activity_rp;
903 #define READ_PAGE_ACTIVITY_RP_SIZE 5
905 #define OCF_WRITE_PAGE_ACTIVITY 0x001C
909 } __attribute__ ((packed)) write_page_activity_cp;
910 #define WRITE_PAGE_ACTIVITY_CP_SIZE 4
912 #define OCF_READ_INQ_ACTIVITY 0x001D
917 } __attribute__ ((packed)) read_inq_activity_rp;
918 #define READ_INQ_ACTIVITY_RP_SIZE 5
920 #define OCF_WRITE_INQ_ACTIVITY 0x001E
924 } __attribute__ ((packed)) write_inq_activity_cp;
925 #define WRITE_INQ_ACTIVITY_CP_SIZE 4
927 #define OCF_READ_AUTH_ENABLE 0x001F
929 #define OCF_WRITE_AUTH_ENABLE 0x0020
931 #define AUTH_DISABLED 0x00
932 #define AUTH_ENABLED 0x01
934 #define OCF_READ_ENCRYPT_MODE 0x0021
936 #define OCF_WRITE_ENCRYPT_MODE 0x0022
938 #define ENCRYPT_DISABLED 0x00
939 #define ENCRYPT_P2P 0x01
940 #define ENCRYPT_BOTH 0x02
942 #define OCF_READ_CLASS_OF_DEV 0x0023
945 uint8_t dev_class[3];
946 } __attribute__ ((packed)) read_class_of_dev_rp;
947 #define READ_CLASS_OF_DEV_RP_SIZE 4
949 #define OCF_WRITE_CLASS_OF_DEV 0x0024
951 uint8_t dev_class[3];
952 } __attribute__ ((packed)) write_class_of_dev_cp;
953 #define WRITE_CLASS_OF_DEV_CP_SIZE 3
955 #define OCF_READ_VOICE_SETTING 0x0025
958 uint16_t voice_setting;
959 } __attribute__ ((packed)) read_voice_setting_rp;
960 #define READ_VOICE_SETTING_RP_SIZE 3
962 #define OCF_WRITE_VOICE_SETTING 0x0026
964 uint16_t voice_setting;
965 } __attribute__ ((packed)) write_voice_setting_cp;
966 #define WRITE_VOICE_SETTING_CP_SIZE 2
968 #define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT 0x0027
970 #define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT 0x0028
972 #define OCF_READ_NUM_BROADCAST_RETRANS 0x0029
974 #define OCF_WRITE_NUM_BROADCAST_RETRANS 0x002A
976 #define OCF_READ_HOLD_MODE_ACTIVITY 0x002B
978 #define OCF_WRITE_HOLD_MODE_ACTIVITY 0x002C
980 #define OCF_READ_TRANSMIT_POWER_LEVEL 0x002D
984 } __attribute__ ((packed)) read_transmit_power_level_cp;
985 #define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
990 } __attribute__ ((packed)) read_transmit_power_level_rp;
991 #define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
993 #define OCF_HOST_BUFFER_SIZE 0x0033
997 uint16_t acl_max_pkt;
998 uint16_t sco_max_pkt;
999 } __attribute__ ((packed)) host_buffer_size_cp;
1000 #define HOST_BUFFER_SIZE_CP_SIZE 7
1002 #define OCF_HOST_NUMBER_OF_COMPLETED_PACKETS 0x0035
1004 #define OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036
1008 uint16_t link_sup_to;
1009 } __attribute__ ((packed)) read_link_supervision_timeout_rp;
1010 #define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
1012 #define OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037
1015 uint16_t link_sup_to;
1016 } __attribute__ ((packed)) write_link_supervision_timeout_cp;
1017 #define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
1021 } __attribute__ ((packed)) write_link_supervision_timeout_rp;
1022 #define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
1024 #define OCF_READ_NUM_SUPPORTED_IAC 0x0038
1026 #define MAX_IAC_LAP 0x40
1027 #define OCF_READ_CURRENT_IAC_LAP 0x0039
1030 uint8_t num_current_iac;
1031 uint8_t lap[MAX_IAC_LAP][3];
1032 } __attribute__ ((packed)) read_current_iac_lap_rp;
1033 #define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
1035 #define OCF_WRITE_CURRENT_IAC_LAP 0x003A
1037 uint8_t num_current_iac;
1038 uint8_t lap[MAX_IAC_LAP][3];
1039 } __attribute__ ((packed)) write_current_iac_lap_cp;
1040 #define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
1042 #define OCF_READ_PAGE_SCAN_PERIOD_MODE 0x003B
1044 #define OCF_WRITE_PAGE_SCAN_PERIOD_MODE 0x003C
1046 #define OCF_READ_PAGE_SCAN_MODE 0x003D
1048 #define OCF_WRITE_PAGE_SCAN_MODE 0x003E
1050 #define OCF_SET_AFH_CLASSIFICATION 0x003F
1053 } __attribute__ ((packed)) set_afh_classification_cp;
1054 #define SET_AFH_CLASSIFICATION_CP_SIZE 10
1057 } __attribute__ ((packed)) set_afh_classification_rp;
1058 #define SET_AFH_CLASSIFICATION_RP_SIZE 1
1060 #define OCF_READ_INQUIRY_SCAN_TYPE 0x0042
1064 } __attribute__ ((packed)) read_inquiry_scan_type_rp;
1065 #define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
1067 #define OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043
1070 } __attribute__ ((packed)) write_inquiry_scan_type_cp;
1071 #define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
1074 } __attribute__ ((packed)) write_inquiry_scan_type_rp;
1075 #define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
1077 #define OCF_READ_INQUIRY_MODE 0x0044
1081 } __attribute__ ((packed)) read_inquiry_mode_rp;
1082 #define READ_INQUIRY_MODE_RP_SIZE 2
1084 #define OCF_WRITE_INQUIRY_MODE 0x0045
1087 } __attribute__ ((packed)) write_inquiry_mode_cp;
1088 #define WRITE_INQUIRY_MODE_CP_SIZE 1
1091 } __attribute__ ((packed)) write_inquiry_mode_rp;
1092 #define WRITE_INQUIRY_MODE_RP_SIZE 1
1094 #define OCF_READ_PAGE_SCAN_TYPE 0x0046
1096 #define OCF_WRITE_PAGE_SCAN_TYPE 0x0047
1098 #define OCF_READ_AFH_MODE 0x0048
1102 } __attribute__ ((packed)) read_afh_mode_rp;
1103 #define READ_AFH_MODE_RP_SIZE 2
1105 #define OCF_WRITE_AFH_MODE 0x0049
1108 } __attribute__ ((packed)) write_afh_mode_cp;
1109 #define WRITE_AFH_MODE_CP_SIZE 1
1112 } __attribute__ ((packed)) write_afh_mode_rp;
1113 #define WRITE_AFH_MODE_RP_SIZE 1
1115 #define OCF_READ_EXT_INQUIRY_RESPONSE 0x0051
1120 } __attribute__ ((packed)) read_ext_inquiry_response_rp;
1121 #define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
1123 #define OCF_WRITE_EXT_INQUIRY_RESPONSE 0x0052
1127 } __attribute__ ((packed)) write_ext_inquiry_response_cp;
1128 #define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
1131 } __attribute__ ((packed)) write_ext_inquiry_response_rp;
1132 #define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
1134 /* Informational Parameters */
1135 #define OGF_INFO_PARAM 0x04
1137 #define OCF_READ_LOCAL_VERSION 0x0001
1143 uint16_t manufacturer;
1144 uint16_t lmp_subver;
1145 } __attribute__ ((packed)) read_local_version_rp;
1146 #define READ_LOCAL_VERSION_RP_SIZE 9
1148 #define OCF_READ_LOCAL_COMMANDS 0x0002
1151 uint8_t commands[64];
1152 } __attribute__ ((packed)) read_local_commands_rp;
1153 #define READ_LOCAL_COMMANDS_RP_SIZE 65
1155 #define OCF_READ_LOCAL_FEATURES 0x0003
1158 uint8_t features[8];
1159 } __attribute__ ((packed)) read_local_features_rp;
1160 #define READ_LOCAL_FEATURES_RP_SIZE 9
1162 #define OCF_READ_LOCAL_EXT_FEATURES 0x0004
1165 } __attribute__ ((packed)) read_local_ext_features_cp;
1166 #define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
1170 uint8_t max_page_num;
1171 uint8_t features[8];
1172 } __attribute__ ((packed)) read_local_ext_features_rp;
1173 #define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
1175 #define OCF_READ_BUFFER_SIZE 0x0005
1180 uint16_t acl_max_pkt;
1181 uint16_t sco_max_pkt;
1182 } __attribute__ ((packed)) read_buffer_size_rp;
1183 #define READ_BUFFER_SIZE_RP_SIZE 8
1185 #define OCF_READ_COUNTRY_CODE 0x0007
1188 uint8_t country_code;
1189 } __attribute__ ((packed)) read_country_code_rp;
1190 #define READ_COUNTRY_CODE_RP_SIZE 2
1192 #define OCF_READ_BD_ADDR 0x0009
1196 } __attribute__ ((packed)) read_bd_addr_rp;
1197 #define READ_BD_ADDR_RP_SIZE 7
1200 #define OGF_STATUS_PARAM 0x05
1202 #define OCF_READ_FAILED_CONTACT_COUNTER 0x0001
1207 } __attribute__ ((packed)) read_failed_contact_counter_rp;
1208 #define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
1210 #define OCF_RESET_FAILED_CONTACT_COUNTER 0x0002
1214 } __attribute__ ((packed)) reset_failed_contact_counter_rp;
1215 #define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
1217 #define OCF_READ_LINK_QUALITY 0x0003
1220 } __attribute__ ((packed)) read_link_quality_cp;
1221 #define READ_LINK_QUALITY_CP_SIZE 4
1226 uint8_t link_quality;
1227 } __attribute__ ((packed)) read_link_quality_rp;
1228 #define READ_LINK_QUALITY_RP_SIZE 4
1230 #define OCF_READ_RSSI 0x0005
1235 } __attribute__ ((packed)) read_rssi_rp;
1236 #define READ_RSSI_RP_SIZE 4
1238 #define OCF_READ_AFH_MAP 0x0006
1244 } __attribute__ ((packed)) read_afh_map_rp;
1245 #define READ_AFH_MAP_RP_SIZE 14
1247 #define OCF_READ_CLOCK 0x0007
1250 uint8_t which_clock;
1251 } __attribute__ ((packed)) read_clock_cp;
1252 #define READ_CLOCK_CP_SIZE 3
1258 } __attribute__ ((packed)) read_clock_rp;
1259 #define READ_CLOCK_RP_SIZE 9
1261 /* Testing commands */
1262 #define OGF_TESTING_CMD 0x3e
1264 /* Vendor specific commands */
1265 #define OGF_VENDOR_CMD 0x3f
1269 #define EVT_INQUIRY_COMPLETE 0x01
1271 #define EVT_INQUIRY_RESULT 0x02
1273 uint8_t num_responses;
1275 uint8_t pscan_rep_mode;
1276 uint8_t pscan_period_mode;
1278 uint8_t dev_class[3];
1279 uint16_t clock_offset;
1280 } __attribute__ ((packed)) inquiry_info;
1281 #define INQUIRY_INFO_SIZE 14
1283 #define EVT_CONN_COMPLETE 0x03
1290 } __attribute__ ((packed)) evt_conn_complete;
1291 #define EVT_CONN_COMPLETE_SIZE 11
1293 #define EVT_CONN_REQUEST 0x04
1296 uint8_t dev_class[3];
1298 } __attribute__ ((packed)) evt_conn_request;
1299 #define EVT_CONN_REQUEST_SIZE 10
1301 #define EVT_DISCONN_COMPLETE 0x05
1306 } __attribute__ ((packed)) evt_disconn_complete;
1307 #define EVT_DISCONN_COMPLETE_SIZE 4
1309 #define EVT_AUTH_COMPLETE 0x06
1313 } __attribute__ ((packed)) evt_auth_complete;
1314 #define EVT_AUTH_COMPLETE_SIZE 3
1316 #define EVT_REMOTE_NAME_REQ_COMPLETE 0x07
1321 } __attribute__ ((packed)) evt_remote_name_req_complete;
1322 #define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
1324 #define EVT_ENCRYPT_CHANGE 0x08
1329 } __attribute__ ((packed)) evt_encrypt_change;
1330 #define EVT_ENCRYPT_CHANGE_SIZE 5
1332 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
1336 } __attribute__ ((packed)) evt_change_conn_link_key_complete;
1337 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
1339 #define EVT_MASTER_LINK_KEY_COMPLETE 0x0A
1344 } __attribute__ ((packed)) evt_master_link_key_complete;
1345 #define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
1347 #define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
1351 uint8_t features[8];
1352 } __attribute__ ((packed)) evt_read_remote_features_complete;
1353 #define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
1355 #define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
1360 uint16_t manufacturer;
1361 uint16_t lmp_subver;
1362 } __attribute__ ((packed)) evt_read_remote_version_complete;
1363 #define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
1365 #define EVT_QOS_SETUP_COMPLETE 0x0D
1369 uint8_t flags; /* Reserved */
1371 } __attribute__ ((packed)) evt_qos_setup_complete;
1372 #define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
1374 #define EVT_CMD_COMPLETE 0x0E
1378 } __attribute__ ((packed)) evt_cmd_complete;
1379 #define EVT_CMD_COMPLETE_SIZE 3
1381 #define EVT_CMD_STATUS 0x0F
1386 } __attribute__ ((packed)) evt_cmd_status;
1387 #define EVT_CMD_STATUS_SIZE 4
1389 #define EVT_HARDWARE_ERROR 0x10
1392 } __attribute__ ((packed)) evt_hardware_error;
1393 #define EVT_HARDWARE_ERROR_SIZE 1
1395 #define EVT_FLUSH_OCCURRED 0x11
1398 } __attribute__ ((packed)) evt_flush_occured;
1399 #define EVT_FLUSH_OCCURRED_SIZE 2
1401 #define EVT_ROLE_CHANGE 0x12
1406 } __attribute__ ((packed)) evt_role_change;
1407 #define EVT_ROLE_CHANGE_SIZE 8
1409 #define EVT_NUM_COMP_PKTS 0x13
1414 uint16_t num_packets;
1416 } __attribute__ ((packed)) evt_num_comp_pkts;
1417 #define EVT_NUM_COMP_PKTS_SIZE(num_hndl) (1 + 4 * (num_hndl))
1419 #define EVT_MODE_CHANGE 0x14
1425 } __attribute__ ((packed)) evt_mode_change;
1426 #define EVT_MODE_CHANGE_SIZE 6
1428 #define EVT_RETURN_LINK_KEYS 0x15
1431 /* variable length part */
1432 } __attribute__ ((packed)) evt_return_link_keys;
1433 #define EVT_RETURN_LINK_KEYS_SIZE 1
1435 #define EVT_PIN_CODE_REQ 0x16
1438 } __attribute__ ((packed)) evt_pin_code_req;
1439 #define EVT_PIN_CODE_REQ_SIZE 6
1441 #define EVT_LINK_KEY_REQ 0x17
1444 } __attribute__ ((packed)) evt_link_key_req;
1445 #define EVT_LINK_KEY_REQ_SIZE 6
1447 #define EVT_LINK_KEY_NOTIFY 0x18
1450 uint8_t link_key[16];
1452 } __attribute__ ((packed)) evt_link_key_notify;
1453 #define EVT_LINK_KEY_NOTIFY_SIZE 23
1455 #define EVT_LOOPBACK_COMMAND 0x19
1457 #define EVT_DATA_BUFFER_OVERFLOW 0x1A
1460 } __attribute__ ((packed)) evt_data_buffer_overflow;
1461 #define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
1463 #define EVT_MAX_SLOTS_CHANGE 0x1B
1467 } __attribute__ ((packed)) evt_max_slots_change;
1468 #define EVT_MAX_SLOTS_CHANGE_SIZE 3
1470 #define EVT_READ_CLOCK_OFFSET_COMPLETE 0x1C
1474 uint16_t clock_offset;
1475 } __attribute__ ((packed)) evt_read_clock_offset_complete;
1476 #define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
1478 #define EVT_CONN_PTYPE_CHANGED 0x1D
1483 } __attribute__ ((packed)) evt_conn_ptype_changed;
1484 #define EVT_CONN_PTYPE_CHANGED_SIZE 5
1486 #define EVT_QOS_VIOLATION 0x1E
1489 } __attribute__ ((packed)) evt_qos_violation;
1490 #define EVT_QOS_VIOLATION_SIZE 2
1492 #define EVT_PSCAN_REP_MODE_CHANGE 0x20
1495 uint8_t pscan_rep_mode;
1496 } __attribute__ ((packed)) evt_pscan_rep_mode_change;
1497 #define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
1499 #define EVT_FLOW_SPEC_COMPLETE 0x21
1506 } __attribute__ ((packed)) evt_flow_spec_complete;
1507 #define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
1509 #define EVT_INQUIRY_RESULT_WITH_RSSI 0x22
1511 uint8_t num_responses;
1513 uint8_t pscan_rep_mode;
1514 uint8_t pscan_period_mode;
1515 uint8_t dev_class[3];
1516 uint16_t clock_offset;
1518 } __attribute__ ((packed)) inquiry_info_with_rssi;
1519 #define INQUIRY_INFO_WITH_RSSI_SIZE 15
1521 uint8_t num_responses;
1523 uint8_t pscan_rep_mode;
1524 uint8_t pscan_period_mode;
1526 uint8_t dev_class[3];
1527 uint16_t clock_offset;
1529 } __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
1530 #define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 16
1532 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE 0x23
1537 uint8_t max_page_num;
1538 uint8_t features[8];
1539 } __attribute__ ((packed)) evt_read_remote_ext_features_complete;
1540 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
1542 #define EVT_SYNC_CONN_COMPLETE 0x2C
1548 uint8_t trans_interval;
1549 uint8_t retrans_window;
1550 uint16_t rx_pkt_len;
1551 uint16_t tx_pkt_len;
1553 } __attribute__ ((packed)) evt_sync_conn_complete;
1554 #define EVT_SYNC_CONN_COMPLETE_SIZE 17
1556 #define EVT_SYNC_CONN_CHANGED 0x2D
1560 uint8_t trans_interval;
1561 uint8_t retrans_window;
1562 uint16_t rx_pkt_len;
1563 uint16_t tx_pkt_len;
1564 } __attribute__ ((packed)) evt_sync_conn_changed;
1565 #define EVT_SYNC_CONN_CHANGED_SIZE 9
1567 #define EVT_SNIFF_SUBRATE 0x2E
1571 uint16_t max_remote_latency;
1572 uint16_t max_local_latency;
1573 uint16_t min_remote_timeout;
1574 uint16_t min_local_timeout;
1575 } __attribute__ ((packed)) evt_sniff_subrate;
1576 #define EVT_SNIFF_SUBRATE_SIZE 11
1578 #define EVT_EXTENDED_INQUIRY_RESULT 0x2F
1581 uint8_t pscan_rep_mode;
1582 uint8_t pscan_period_mode;
1583 uint8_t dev_class[3];
1584 uint16_t clock_offset;
1587 } __attribute__ ((packed)) extended_inquiry_info;
1588 #define EXTENDED_INQUIRY_INFO_SIZE 254
1590 #define EVT_TESTING 0xFE
1592 #define EVT_VENDOR 0xFF
1594 /* Command opcode pack/unpack */
1595 #define cmd_opcode_pack(ogf, ocf) (uint16_t)((ocf & 0x03ff)|(ogf << 10))
1596 #define cmd_opcode_ogf(op) (op >> 10)
1597 #define cmd_opcode_ocf(op) (op & 0x03ff)
1599 /* ACL handle and flags pack/unpack */
1600 #define acl_handle_pack(h, f) (uint16_t)(((h) & 0x0fff)|((f) << 12))
1601 #define acl_handle(h) ((h) & 0x0fff)
1602 #define acl_flags(h) ((h) >> 12)
1604 /* HCI Packet structures */
1605 #define HCI_COMMAND_HDR_SIZE 3
1606 #define HCI_EVENT_HDR_SIZE 2
1607 #define HCI_ACL_HDR_SIZE 4
1608 #define HCI_SCO_HDR_SIZE 3
1610 struct hci_command_hdr {
1611 uint16_t opcode; /* OCF & OGF */
1613 } __attribute__ ((packed));
1615 struct hci_event_hdr {
1618 } __attribute__ ((packed));
1620 struct hci_acl_hdr {
1621 uint16_t handle; /* Handle & Flags(PB, BC) */
1623 } __attribute__ ((packed));
1625 struct hci_sco_hdr {
1628 } __attribute__ ((packed));