2 * QEMU Bluetooth HCI helpers.
4 * Copyright (C) 2007 OpenMoko, Inc.
5 * Written by Andrzej Zaborowski <andrew@openedhand.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
26 } __attribute__((packed)) bdaddr_t;
28 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
29 #define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}})
30 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
32 /* Copy, swap, convert BD Address */
33 static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2)
35 return memcmp(ba1, ba2, sizeof(bdaddr_t));
37 static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src)
39 memcpy(dst, src, sizeof(bdaddr_t));
42 #define BAINIT(orig) { .b = { \
43 (orig)->b[0], (orig)->b[1], (orig)->b[2], \
44 (orig)->b[3], (orig)->b[4], (orig)->b[5], \
47 /* The twisted structures of a bluetooth environment */
49 struct bt_scatternet_s;
53 struct bt_scatternet_s {
54 struct bt_device_s *slave;
58 struct bt_device_s *slave, *host;
59 uint16_t handle; /* Master (host) side handle */
60 uint16_t acl_interval;
74 struct bt_scatternet_s *net;
80 uint8_t reject_reason;
84 void (*lmp_connection_request)(struct bt_link_s *link);
85 void (*lmp_connection_complete)(struct bt_link_s *link);
86 void (*lmp_disconnect_master)(struct bt_link_s *link);
87 void (*lmp_disconnect_slave)(struct bt_link_s *link);
88 void (*lmp_acl_data)(struct bt_link_s *link, const uint8_t *data,
90 void (*lmp_acl_resp)(struct bt_link_s *link, const uint8_t *data,
92 void (*lmp_mode_change)(struct bt_link_s *link);
94 void (*handle_destroy)(struct bt_device_s *device);
95 struct bt_device_s *next; /* Next in the piconet/scatternet */
100 uint16_t clkoff; /* Note: Always little-endian */
104 void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net);
105 void bt_device_done(struct bt_device_s *dev);
113 qemu_irq *csrhci_pins_get(CharDriverState *chr);
114 CharDriverState *uart_hci_init(qemu_irq wakeup);
116 /* Link Management Protocol layer defines */
118 #define LLID_ACLU_CONT 0x1
119 #define LLID_ACLU_START 0x2
120 #define LLID_ACLC 0x3
123 LMP_NAME_REQ = 0x0001,
124 LMP_NAME_RES = 0x0002,
125 LMP_ACCEPTED = 0x0003,
126 LMP_NOT_ACCEPTED = 0x0004,
127 LMP_CLKOFFSET_REQ = 0x0005,
128 LMP_CLKOFFSET_RES = 0x0006,
130 LMP_IN_RAND = 0x0008,
131 LMP_COMB_KEY = 0x0009,
132 LMP_UNIT_KEY = 0x000a,
133 LMP_AU_RAND = 0x000b,
135 LMP_TEMP_RAND = 0x000d,
136 LMP_TEMP_KEY = 0x000e,
137 LMP_CRYPT_MODE_REQ = 0x000f,
138 LMP_CRYPT_KEY_SIZE_REQ = 0x0010,
139 LMP_START_ENCRYPT_REQ = 0x0011,
140 LMP_STOP_ENCRYPT_REQ = 0x0012,
141 LMP_SWITCH_REQ = 0x0013,
143 LMP_HOLD_REQ = 0x0015,
144 LMP_SNIFF_REQ = 0x0017,
145 LMP_UNSNIFF_REQ = 0x0018,
146 LMP_LMP_PARK_REQ = 0x0019,
147 LMP_SET_BCAST_SCAN_WND = 0x001b,
148 LMP_MODIFY_BEACON = 0x001c,
149 LMP_UNPARK_BD_ADDR_REQ = 0x001d,
150 LMP_UNPARK_PM_ADDR_REQ = 0x001e,
151 LMP_INCR_POWER_REQ = 0x001f,
152 LMP_DECR_POWER_REQ = 0x0020,
153 LMP_MAX_POWER = 0x0021,
154 LMP_MIN_POWER = 0x0022,
155 LMP_AUTO_RATE = 0x0023,
156 LMP_PREFERRED_RATE = 0x0024,
157 LMP_VERSION_REQ = 0x0025,
158 LMP_VERSION_RES = 0x0026,
159 LMP_FEATURES_REQ = 0x0027,
160 LMP_FEATURES_RES = 0x0028,
161 LMP_QUALITY_OF_SERVICE = 0x0029,
162 LMP_QOS_REQ = 0x002a,
163 LMP_RM_SCO_LINK_REQ = 0x002b,
164 LMP_SCO_LINK_REQ = 0x002c,
165 LMP_MAX_SLOT = 0x002d,
166 LMP_MAX_SLOT_REQ = 0x002e,
167 LMP_TIMING_ACCURACY_REQ = 0x002f,
168 LMP_TIMING_ACCURACY_RES = 0x0030,
169 LMP_SETUP_COMPLETE = 0x0031,
170 LMP_USE_SEMIPERM_KEY = 0x0032,
171 LMP_HOST_CONNECTION_REQ = 0x0033,
172 LMP_SLOT_OFFSET = 0x0034,
173 LMP_PAGE_MODE_REQ = 0x0035,
174 LMP_PAGE_SCAN_MODE_REQ = 0x0036,
175 LMP_SUPERVISION_TIMEOUT = 0x0037,
176 LMP_TEST_ACTIVATE = 0x0038,
177 LMP_TEST_CONTROL = 0x0039,
178 LMP_CRYPT_KEY_MASK_REQ = 0x003a,
179 LMP_CRYPT_KEY_MASK_RES = 0x003b,
180 LMP_SET_AFH = 0x003c,
181 LMP_ACCEPTED_EXT = 0x7f01,
182 LMP_NOT_ACCEPTED_EXT = 0x7f02,
183 LMP_FEATURES_REQ_EXT = 0x7f03,
184 LMP_FEATURES_RES_EXT = 0x7f04,
185 LMP_PACKET_TYPE_TBL_REQ = 0x7f0b,
186 LMP_ESCO_LINK_REQ = 0x7f0c,
187 LMP_RM_ESCO_LINK_REQ = 0x7f0d,
188 LMP_CHANNEL_CLASS_REQ = 0x7f10,
189 LMP_CHANNEL_CLASS = 0x7f11,
192 /* Host Controller Interface layer defines */
194 enum hci_packet_type {
195 HCI_COMMAND_PKT = 0x01,
196 HCI_ACLDATA_PKT = 0x02,
197 HCI_SCODATA_PKT = 0x03,
198 HCI_EVENT_PKT = 0x04,
199 HCI_VENDOR_PKT = 0xff,
202 enum bt_packet_type {
217 enum sco_packet_type {
223 enum ev_packet_type {
233 enum hci_error_code {
235 HCI_UNKNOWN_COMMAND = 0x01,
236 HCI_NO_CONNECTION = 0x02,
237 HCI_HARDWARE_FAILURE = 0x03,
238 HCI_PAGE_TIMEOUT = 0x04,
239 HCI_AUTHENTICATION_FAILURE = 0x05,
240 HCI_PIN_OR_KEY_MISSING = 0x06,
241 HCI_MEMORY_FULL = 0x07,
242 HCI_CONNECTION_TIMEOUT = 0x08,
243 HCI_MAX_NUMBER_OF_CONNECTIONS = 0x09,
244 HCI_MAX_NUMBER_OF_SCO_CONNECTIONS = 0x0a,
245 HCI_ACL_CONNECTION_EXISTS = 0x0b,
246 HCI_COMMAND_DISALLOWED = 0x0c,
247 HCI_REJECTED_LIMITED_RESOURCES = 0x0d,
248 HCI_REJECTED_SECURITY = 0x0e,
249 HCI_REJECTED_PERSONAL = 0x0f,
250 HCI_HOST_TIMEOUT = 0x10,
251 HCI_UNSUPPORTED_FEATURE = 0x11,
252 HCI_INVALID_PARAMETERS = 0x12,
253 HCI_OE_USER_ENDED_CONNECTION = 0x13,
254 HCI_OE_LOW_RESOURCES = 0x14,
255 HCI_OE_POWER_OFF = 0x15,
256 HCI_CONNECTION_TERMINATED = 0x16,
257 HCI_REPEATED_ATTEMPTS = 0x17,
258 HCI_PAIRING_NOT_ALLOWED = 0x18,
259 HCI_UNKNOWN_LMP_PDU = 0x19,
260 HCI_UNSUPPORTED_REMOTE_FEATURE = 0x1a,
261 HCI_SCO_OFFSET_REJECTED = 0x1b,
262 HCI_SCO_INTERVAL_REJECTED = 0x1c,
263 HCI_AIR_MODE_REJECTED = 0x1d,
264 HCI_INVALID_LMP_PARAMETERS = 0x1e,
265 HCI_UNSPECIFIED_ERROR = 0x1f,
266 HCI_UNSUPPORTED_LMP_PARAMETER_VALUE = 0x20,
267 HCI_ROLE_CHANGE_NOT_ALLOWED = 0x21,
268 HCI_LMP_RESPONSE_TIMEOUT = 0x22,
269 HCI_LMP_ERROR_TRANSACTION_COLLISION = 0x23,
270 HCI_LMP_PDU_NOT_ALLOWED = 0x24,
271 HCI_ENCRYPTION_MODE_NOT_ACCEPTED = 0x25,
272 HCI_UNIT_LINK_KEY_USED = 0x26,
273 HCI_QOS_NOT_SUPPORTED = 0x27,
274 HCI_INSTANT_PASSED = 0x28,
275 HCI_PAIRING_NOT_SUPPORTED = 0x29,
276 HCI_TRANSACTION_COLLISION = 0x2a,
277 HCI_QOS_UNACCEPTABLE_PARAMETER = 0x2c,
278 HCI_QOS_REJECTED = 0x2d,
279 HCI_CLASSIFICATION_NOT_SUPPORTED = 0x2e,
280 HCI_INSUFFICIENT_SECURITY = 0x2f,
281 HCI_PARAMETER_OUT_OF_RANGE = 0x30,
282 HCI_ROLE_SWITCH_PENDING = 0x32,
283 HCI_SLOT_VIOLATION = 0x34,
284 HCI_ROLE_SWITCH_FAILED = 0x35,
290 ACL_ACTIVE_BCAST = 1 << 2,
291 ACL_PICO_BCAST = 1 << 3,
294 enum baseband_link_type {
299 enum lmp_feature_bits0 {
302 LMP_ENCRYPT = 1 << 2,
303 LMP_SOFFSET = 1 << 3,
304 LMP_TACCURACY = 1 << 4,
305 LMP_RSWITCH = 1 << 5,
306 LMP_HOLD_MODE = 1 << 6,
307 LMP_SNIFF_MODE = 1 << 7,
310 enum lmp_feature_bits1 {
313 LMP_QUALITY = 1 << 2,
321 enum lmp_feature_bits2 {
323 LMP_PSCHEME = 1 << 1,
324 LMP_PCONTROL = 1 << 2,
325 LMP_TRSP_SCO = 1 << 3,
326 LMP_BCAST_ENC = 1 << 7,
329 enum lmp_feature_bits3 {
330 LMP_EDR_ACL_2M = 1 << 1,
331 LMP_EDR_ACL_3M = 1 << 2,
332 LMP_ENH_ISCAN = 1 << 3,
333 LMP_ILACE_ISCAN = 1 << 4,
334 LMP_ILACE_PSCAN = 1 << 5,
335 LMP_RSSI_INQ = 1 << 6,
339 enum lmp_feature_bits4 {
342 LMP_AFH_CAP_SLV = 1 << 3,
343 LMP_AFH_CLS_SLV = 1 << 4,
344 LMP_EDR_3SLOT = 1 << 7,
347 enum lmp_feature_bits5 {
348 LMP_EDR_5SLOT = 1 << 0,
349 LMP_SNIFF_SUBR = 1 << 1,
350 LMP_AFH_CAP_MST = 1 << 3,
351 LMP_AFH_CLS_MST = 1 << 4,
352 LMP_EDR_ESCO_2M = 1 << 5,
353 LMP_EDR_ESCO_3M = 1 << 6,
354 LMP_EDR_3S_ESCO = 1 << 7,
357 enum lmp_feature_bits6 {
358 LMP_EXT_INQ = 1 << 0,
361 enum lmp_feature_bits7 {
362 LMP_EXT_FEAT = 1 << 7,
365 enum hci_link_policy {
366 HCI_LP_RSWITCH = 1 << 0,
367 HCI_LP_HOLD = 1 << 1,
368 HCI_LP_SNIFF = 1 << 2,
369 HCI_LP_PARK = 1 << 3,
373 HCI_LM_ACCEPT = 1 << 15,
374 HCI_LM_MASTER = 1 << 0,
375 HCI_LM_AUTH = 1 << 1,
376 HCI_LM_ENCRYPT = 1 << 2,
377 HCI_LM_TRUSTED = 1 << 3,
378 HCI_LM_RELIABLE = 1 << 4,
379 HCI_LM_SECURE = 1 << 5,
385 #define OGF_LINK_CTL 0x01
387 #define OCF_INQUIRY 0x0001
390 uint8_t length; /* 1.28s units */
392 } __attribute__ ((packed)) inquiry_cp;
393 #define INQUIRY_CP_SIZE 5
398 } __attribute__ ((packed)) status_bdaddr_rp;
399 #define STATUS_BDADDR_RP_SIZE 7
401 #define OCF_INQUIRY_CANCEL 0x0002
403 #define OCF_PERIODIC_INQUIRY 0x0003
405 uint16_t max_period; /* 1.28s units */
406 uint16_t min_period; /* 1.28s units */
408 uint8_t length; /* 1.28s units */
410 } __attribute__ ((packed)) periodic_inquiry_cp;
411 #define PERIODIC_INQUIRY_CP_SIZE 9
413 #define OCF_EXIT_PERIODIC_INQUIRY 0x0004
415 #define OCF_CREATE_CONN 0x0005
419 uint8_t pscan_rep_mode;
421 uint16_t clock_offset;
423 } __attribute__ ((packed)) create_conn_cp;
424 #define CREATE_CONN_CP_SIZE 13
426 #define OCF_DISCONNECT 0x0006
430 } __attribute__ ((packed)) disconnect_cp;
431 #define DISCONNECT_CP_SIZE 3
433 #define OCF_ADD_SCO 0x0007
437 } __attribute__ ((packed)) add_sco_cp;
438 #define ADD_SCO_CP_SIZE 4
440 #define OCF_CREATE_CONN_CANCEL 0x0008
444 } __attribute__ ((packed)) create_conn_cancel_cp;
445 #define CREATE_CONN_CANCEL_CP_SIZE 6
450 } __attribute__ ((packed)) create_conn_cancel_rp;
451 #define CREATE_CONN_CANCEL_RP_SIZE 7
453 #define OCF_ACCEPT_CONN_REQ 0x0009
457 } __attribute__ ((packed)) accept_conn_req_cp;
458 #define ACCEPT_CONN_REQ_CP_SIZE 7
460 #define OCF_REJECT_CONN_REQ 0x000A
464 } __attribute__ ((packed)) reject_conn_req_cp;
465 #define REJECT_CONN_REQ_CP_SIZE 7
467 #define OCF_LINK_KEY_REPLY 0x000B
470 uint8_t link_key[16];
471 } __attribute__ ((packed)) link_key_reply_cp;
472 #define LINK_KEY_REPLY_CP_SIZE 22
474 #define OCF_LINK_KEY_NEG_REPLY 0x000C
476 #define OCF_PIN_CODE_REPLY 0x000D
480 uint8_t pin_code[16];
481 } __attribute__ ((packed)) pin_code_reply_cp;
482 #define PIN_CODE_REPLY_CP_SIZE 23
484 #define OCF_PIN_CODE_NEG_REPLY 0x000E
486 #define OCF_SET_CONN_PTYPE 0x000F
490 } __attribute__ ((packed)) set_conn_ptype_cp;
491 #define SET_CONN_PTYPE_CP_SIZE 4
493 #define OCF_AUTH_REQUESTED 0x0011
496 } __attribute__ ((packed)) auth_requested_cp;
497 #define AUTH_REQUESTED_CP_SIZE 2
499 #define OCF_SET_CONN_ENCRYPT 0x0013
503 } __attribute__ ((packed)) set_conn_encrypt_cp;
504 #define SET_CONN_ENCRYPT_CP_SIZE 3
506 #define OCF_CHANGE_CONN_LINK_KEY 0x0015
509 } __attribute__ ((packed)) change_conn_link_key_cp;
510 #define CHANGE_CONN_LINK_KEY_CP_SIZE 2
512 #define OCF_MASTER_LINK_KEY 0x0017
515 } __attribute__ ((packed)) master_link_key_cp;
516 #define MASTER_LINK_KEY_CP_SIZE 1
518 #define OCF_REMOTE_NAME_REQ 0x0019
521 uint8_t pscan_rep_mode;
523 uint16_t clock_offset;
524 } __attribute__ ((packed)) remote_name_req_cp;
525 #define REMOTE_NAME_REQ_CP_SIZE 10
527 #define OCF_REMOTE_NAME_REQ_CANCEL 0x001A
530 } __attribute__ ((packed)) remote_name_req_cancel_cp;
531 #define REMOTE_NAME_REQ_CANCEL_CP_SIZE 6
536 } __attribute__ ((packed)) remote_name_req_cancel_rp;
537 #define REMOTE_NAME_REQ_CANCEL_RP_SIZE 7
539 #define OCF_READ_REMOTE_FEATURES 0x001B
542 } __attribute__ ((packed)) read_remote_features_cp;
543 #define READ_REMOTE_FEATURES_CP_SIZE 2
545 #define OCF_READ_REMOTE_EXT_FEATURES 0x001C
549 } __attribute__ ((packed)) read_remote_ext_features_cp;
550 #define READ_REMOTE_EXT_FEATURES_CP_SIZE 3
552 #define OCF_READ_REMOTE_VERSION 0x001D
555 } __attribute__ ((packed)) read_remote_version_cp;
556 #define READ_REMOTE_VERSION_CP_SIZE 2
558 #define OCF_READ_CLOCK_OFFSET 0x001F
561 } __attribute__ ((packed)) read_clock_offset_cp;
562 #define READ_CLOCK_OFFSET_CP_SIZE 2
564 #define OCF_READ_LMP_HANDLE 0x0020
567 } __attribute__ ((packed)) read_lmp_handle_cp;
568 #define READ_LMP_HANDLE_CP_SIZE 2
575 } __attribute__ ((packed)) read_lmp_handle_rp;
576 #define READ_LMP_HANDLE_RP_SIZE 8
578 #define OCF_SETUP_SYNC_CONN 0x0028
581 uint32_t tx_bandwith;
582 uint32_t rx_bandwith;
583 uint16_t max_latency;
584 uint16_t voice_setting;
585 uint8_t retrans_effort;
587 } __attribute__ ((packed)) setup_sync_conn_cp;
588 #define SETUP_SYNC_CONN_CP_SIZE 17
590 #define OCF_ACCEPT_SYNC_CONN_REQ 0x0029
593 uint32_t tx_bandwith;
594 uint32_t rx_bandwith;
595 uint16_t max_latency;
596 uint16_t voice_setting;
597 uint8_t retrans_effort;
599 } __attribute__ ((packed)) accept_sync_conn_req_cp;
600 #define ACCEPT_SYNC_CONN_REQ_CP_SIZE 21
602 #define OCF_REJECT_SYNC_CONN_REQ 0x002A
606 } __attribute__ ((packed)) reject_sync_conn_req_cp;
607 #define REJECT_SYNC_CONN_REQ_CP_SIZE 7
610 #define OGF_LINK_POLICY 0x02
612 #define OCF_HOLD_MODE 0x0001
615 uint16_t max_interval;
616 uint16_t min_interval;
617 } __attribute__ ((packed)) hold_mode_cp;
618 #define HOLD_MODE_CP_SIZE 6
620 #define OCF_SNIFF_MODE 0x0003
623 uint16_t max_interval;
624 uint16_t min_interval;
627 } __attribute__ ((packed)) sniff_mode_cp;
628 #define SNIFF_MODE_CP_SIZE 10
630 #define OCF_EXIT_SNIFF_MODE 0x0004
633 } __attribute__ ((packed)) exit_sniff_mode_cp;
634 #define EXIT_SNIFF_MODE_CP_SIZE 2
636 #define OCF_PARK_MODE 0x0005
639 uint16_t max_interval;
640 uint16_t min_interval;
641 } __attribute__ ((packed)) park_mode_cp;
642 #define PARK_MODE_CP_SIZE 6
644 #define OCF_EXIT_PARK_MODE 0x0006
647 } __attribute__ ((packed)) exit_park_mode_cp;
648 #define EXIT_PARK_MODE_CP_SIZE 2
650 #define OCF_QOS_SETUP 0x0007
652 uint8_t service_type; /* 1 = best effort */
653 uint32_t token_rate; /* Byte per seconds */
654 uint32_t peak_bandwidth; /* Byte per seconds */
655 uint32_t latency; /* Microseconds */
656 uint32_t delay_variation; /* Microseconds */
657 } __attribute__ ((packed)) hci_qos;
658 #define HCI_QOS_CP_SIZE 17
661 uint8_t flags; /* Reserved */
663 } __attribute__ ((packed)) qos_setup_cp;
664 #define QOS_SETUP_CP_SIZE (3 + HCI_QOS_CP_SIZE)
666 #define OCF_ROLE_DISCOVERY 0x0009
669 } __attribute__ ((packed)) role_discovery_cp;
670 #define ROLE_DISCOVERY_CP_SIZE 2
675 } __attribute__ ((packed)) role_discovery_rp;
676 #define ROLE_DISCOVERY_RP_SIZE 4
678 #define OCF_SWITCH_ROLE 0x000B
682 } __attribute__ ((packed)) switch_role_cp;
683 #define SWITCH_ROLE_CP_SIZE 7
685 #define OCF_READ_LINK_POLICY 0x000C
688 } __attribute__ ((packed)) read_link_policy_cp;
689 #define READ_LINK_POLICY_CP_SIZE 2
694 } __attribute__ ((packed)) read_link_policy_rp;
695 #define READ_LINK_POLICY_RP_SIZE 5
697 #define OCF_WRITE_LINK_POLICY 0x000D
701 } __attribute__ ((packed)) write_link_policy_cp;
702 #define WRITE_LINK_POLICY_CP_SIZE 4
706 } __attribute__ ((packed)) write_link_policy_rp;
707 #define WRITE_LINK_POLICY_RP_SIZE 3
709 #define OCF_READ_DEFAULT_LINK_POLICY 0x000E
711 #define OCF_WRITE_DEFAULT_LINK_POLICY 0x000F
713 #define OCF_FLOW_SPECIFICATION 0x0010
715 #define OCF_SNIFF_SUBRATE 0x0011
718 uint16_t max_remote_latency;
719 uint16_t max_local_latency;
720 uint16_t min_remote_timeout;
721 uint16_t min_local_timeout;
722 } __attribute__ ((packed)) sniff_subrate_cp;
723 #define SNIFF_SUBRATE_CP_SIZE 10
725 /* Host Controller and Baseband */
726 #define OGF_HOST_CTL 0x03
728 #define OCF_SET_EVENT_MASK 0x0001
731 } __attribute__ ((packed)) set_event_mask_cp;
732 #define SET_EVENT_MASK_CP_SIZE 8
734 #define OCF_RESET 0x0003
736 #define OCF_SET_EVENT_FLT 0x0005
740 uint8_t condition[0];
741 } __attribute__ ((packed)) set_event_flt_cp;
742 #define SET_EVENT_FLT_CP_SIZE 2
744 enum bt_filter_type {
745 FLT_CLEAR_ALL = 0x00,
746 FLT_INQ_RESULT = 0x01,
747 FLT_CONN_SETUP = 0x02,
749 enum inq_result_cond_type {
750 INQ_RESULT_RETURN_ALL = 0x00,
751 INQ_RESULT_RETURN_CLASS = 0x01,
752 INQ_RESULT_RETURN_BDADDR = 0x02,
754 enum conn_setup_cond_type {
755 CONN_SETUP_ALLOW_ALL = 0x00,
756 CONN_SETUP_ALLOW_CLASS = 0x01,
757 CONN_SETUP_ALLOW_BDADDR = 0x02,
759 enum conn_setup_cond {
760 CONN_SETUP_AUTO_OFF = 0x01,
761 CONN_SETUP_AUTO_ON = 0x02,
764 #define OCF_FLUSH 0x0008
767 } __attribute__ ((packed)) flush_cp;
768 #define FLUSH_CP_SIZE 2
773 } __attribute__ ((packed)) flush_rp;
774 #define FLUSH_RP_SIZE 3
776 #define OCF_READ_PIN_TYPE 0x0009
780 } __attribute__ ((packed)) read_pin_type_rp;
781 #define READ_PIN_TYPE_RP_SIZE 2
783 #define OCF_WRITE_PIN_TYPE 0x000A
786 } __attribute__ ((packed)) write_pin_type_cp;
787 #define WRITE_PIN_TYPE_CP_SIZE 1
789 #define OCF_CREATE_NEW_UNIT_KEY 0x000B
791 #define OCF_READ_STORED_LINK_KEY 0x000D
795 } __attribute__ ((packed)) read_stored_link_key_cp;
796 #define READ_STORED_LINK_KEY_CP_SIZE 7
801 } __attribute__ ((packed)) read_stored_link_key_rp;
802 #define READ_STORED_LINK_KEY_RP_SIZE 5
804 #define OCF_WRITE_STORED_LINK_KEY 0x0011
807 /* variable length part */
808 } __attribute__ ((packed)) write_stored_link_key_cp;
809 #define WRITE_STORED_LINK_KEY_CP_SIZE 1
813 } __attribute__ ((packed)) write_stored_link_key_rp;
814 #define READ_WRITE_LINK_KEY_RP_SIZE 2
816 #define OCF_DELETE_STORED_LINK_KEY 0x0012
820 } __attribute__ ((packed)) delete_stored_link_key_cp;
821 #define DELETE_STORED_LINK_KEY_CP_SIZE 7
825 } __attribute__ ((packed)) delete_stored_link_key_rp;
826 #define DELETE_STORED_LINK_KEY_RP_SIZE 3
828 #define OCF_CHANGE_LOCAL_NAME 0x0013
831 } __attribute__ ((packed)) change_local_name_cp;
832 #define CHANGE_LOCAL_NAME_CP_SIZE 248
834 #define OCF_READ_LOCAL_NAME 0x0014
838 } __attribute__ ((packed)) read_local_name_rp;
839 #define READ_LOCAL_NAME_RP_SIZE 249
841 #define OCF_READ_CONN_ACCEPT_TIMEOUT 0x0015
845 } __attribute__ ((packed)) read_conn_accept_timeout_rp;
846 #define READ_CONN_ACCEPT_TIMEOUT_RP_SIZE 3
848 #define OCF_WRITE_CONN_ACCEPT_TIMEOUT 0x0016
851 } __attribute__ ((packed)) write_conn_accept_timeout_cp;
852 #define WRITE_CONN_ACCEPT_TIMEOUT_CP_SIZE 2
854 #define OCF_READ_PAGE_TIMEOUT 0x0017
858 } __attribute__ ((packed)) read_page_timeout_rp;
859 #define READ_PAGE_TIMEOUT_RP_SIZE 3
861 #define OCF_WRITE_PAGE_TIMEOUT 0x0018
864 } __attribute__ ((packed)) write_page_timeout_cp;
865 #define WRITE_PAGE_TIMEOUT_CP_SIZE 2
867 #define OCF_READ_SCAN_ENABLE 0x0019
871 } __attribute__ ((packed)) read_scan_enable_rp;
872 #define READ_SCAN_ENABLE_RP_SIZE 2
874 #define OCF_WRITE_SCAN_ENABLE 0x001A
877 } __attribute__ ((packed)) write_scan_enable_cp;
878 #define WRITE_SCAN_ENABLE_CP_SIZE 1
880 enum scan_enable_bits {
882 SCAN_INQUIRY = 1 << 0,
886 #define OCF_READ_PAGE_ACTIVITY 0x001B
891 } __attribute__ ((packed)) read_page_activity_rp;
892 #define READ_PAGE_ACTIVITY_RP_SIZE 5
894 #define OCF_WRITE_PAGE_ACTIVITY 0x001C
898 } __attribute__ ((packed)) write_page_activity_cp;
899 #define WRITE_PAGE_ACTIVITY_CP_SIZE 4
901 #define OCF_READ_INQ_ACTIVITY 0x001D
906 } __attribute__ ((packed)) read_inq_activity_rp;
907 #define READ_INQ_ACTIVITY_RP_SIZE 5
909 #define OCF_WRITE_INQ_ACTIVITY 0x001E
913 } __attribute__ ((packed)) write_inq_activity_cp;
914 #define WRITE_INQ_ACTIVITY_CP_SIZE 4
916 #define OCF_READ_AUTH_ENABLE 0x001F
918 #define OCF_WRITE_AUTH_ENABLE 0x0020
920 #define AUTH_DISABLED 0x00
921 #define AUTH_ENABLED 0x01
923 #define OCF_READ_ENCRYPT_MODE 0x0021
925 #define OCF_WRITE_ENCRYPT_MODE 0x0022
927 #define ENCRYPT_DISABLED 0x00
928 #define ENCRYPT_P2P 0x01
929 #define ENCRYPT_BOTH 0x02
931 #define OCF_READ_CLASS_OF_DEV 0x0023
934 uint8_t dev_class[3];
935 } __attribute__ ((packed)) read_class_of_dev_rp;
936 #define READ_CLASS_OF_DEV_RP_SIZE 4
938 #define OCF_WRITE_CLASS_OF_DEV 0x0024
940 uint8_t dev_class[3];
941 } __attribute__ ((packed)) write_class_of_dev_cp;
942 #define WRITE_CLASS_OF_DEV_CP_SIZE 3
944 #define OCF_READ_VOICE_SETTING 0x0025
947 uint16_t voice_setting;
948 } __attribute__ ((packed)) read_voice_setting_rp;
949 #define READ_VOICE_SETTING_RP_SIZE 3
951 #define OCF_WRITE_VOICE_SETTING 0x0026
953 uint16_t voice_setting;
954 } __attribute__ ((packed)) write_voice_setting_cp;
955 #define WRITE_VOICE_SETTING_CP_SIZE 2
957 #define OCF_READ_AUTOMATIC_FLUSH_TIMEOUT 0x0027
959 #define OCF_WRITE_AUTOMATIC_FLUSH_TIMEOUT 0x0028
961 #define OCF_READ_NUM_BROADCAST_RETRANS 0x0029
963 #define OCF_WRITE_NUM_BROADCAST_RETRANS 0x002A
965 #define OCF_READ_HOLD_MODE_ACTIVITY 0x002B
967 #define OCF_WRITE_HOLD_MODE_ACTIVITY 0x002C
969 #define OCF_READ_TRANSMIT_POWER_LEVEL 0x002D
973 } __attribute__ ((packed)) read_transmit_power_level_cp;
974 #define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
979 } __attribute__ ((packed)) read_transmit_power_level_rp;
980 #define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
982 #define OCF_HOST_BUFFER_SIZE 0x0033
986 uint16_t acl_max_pkt;
987 uint16_t sco_max_pkt;
988 } __attribute__ ((packed)) host_buffer_size_cp;
989 #define HOST_BUFFER_SIZE_CP_SIZE 7
991 #define OCF_HOST_NUMBER_OF_COMPLETED_PACKETS 0x0035
993 #define OCF_READ_LINK_SUPERVISION_TIMEOUT 0x0036
997 uint16_t link_sup_to;
998 } __attribute__ ((packed)) read_link_supervision_timeout_rp;
999 #define READ_LINK_SUPERVISION_TIMEOUT_RP_SIZE 5
1001 #define OCF_WRITE_LINK_SUPERVISION_TIMEOUT 0x0037
1004 uint16_t link_sup_to;
1005 } __attribute__ ((packed)) write_link_supervision_timeout_cp;
1006 #define WRITE_LINK_SUPERVISION_TIMEOUT_CP_SIZE 4
1010 } __attribute__ ((packed)) write_link_supervision_timeout_rp;
1011 #define WRITE_LINK_SUPERVISION_TIMEOUT_RP_SIZE 3
1013 #define OCF_READ_NUM_SUPPORTED_IAC 0x0038
1015 #define MAX_IAC_LAP 0x40
1016 #define OCF_READ_CURRENT_IAC_LAP 0x0039
1019 uint8_t num_current_iac;
1020 uint8_t lap[MAX_IAC_LAP][3];
1021 } __attribute__ ((packed)) read_current_iac_lap_rp;
1022 #define READ_CURRENT_IAC_LAP_RP_SIZE 2+3*MAX_IAC_LAP
1024 #define OCF_WRITE_CURRENT_IAC_LAP 0x003A
1026 uint8_t num_current_iac;
1027 uint8_t lap[MAX_IAC_LAP][3];
1028 } __attribute__ ((packed)) write_current_iac_lap_cp;
1029 #define WRITE_CURRENT_IAC_LAP_CP_SIZE 1+3*MAX_IAC_LAP
1031 #define OCF_READ_PAGE_SCAN_PERIOD_MODE 0x003B
1033 #define OCF_WRITE_PAGE_SCAN_PERIOD_MODE 0x003C
1035 #define OCF_READ_PAGE_SCAN_MODE 0x003D
1037 #define OCF_WRITE_PAGE_SCAN_MODE 0x003E
1039 #define OCF_SET_AFH_CLASSIFICATION 0x003F
1042 } __attribute__ ((packed)) set_afh_classification_cp;
1043 #define SET_AFH_CLASSIFICATION_CP_SIZE 10
1046 } __attribute__ ((packed)) set_afh_classification_rp;
1047 #define SET_AFH_CLASSIFICATION_RP_SIZE 1
1049 #define OCF_READ_INQUIRY_SCAN_TYPE 0x0042
1053 } __attribute__ ((packed)) read_inquiry_scan_type_rp;
1054 #define READ_INQUIRY_SCAN_TYPE_RP_SIZE 2
1056 #define OCF_WRITE_INQUIRY_SCAN_TYPE 0x0043
1059 } __attribute__ ((packed)) write_inquiry_scan_type_cp;
1060 #define WRITE_INQUIRY_SCAN_TYPE_CP_SIZE 1
1063 } __attribute__ ((packed)) write_inquiry_scan_type_rp;
1064 #define WRITE_INQUIRY_SCAN_TYPE_RP_SIZE 1
1066 #define OCF_READ_INQUIRY_MODE 0x0044
1070 } __attribute__ ((packed)) read_inquiry_mode_rp;
1071 #define READ_INQUIRY_MODE_RP_SIZE 2
1073 #define OCF_WRITE_INQUIRY_MODE 0x0045
1076 } __attribute__ ((packed)) write_inquiry_mode_cp;
1077 #define WRITE_INQUIRY_MODE_CP_SIZE 1
1080 } __attribute__ ((packed)) write_inquiry_mode_rp;
1081 #define WRITE_INQUIRY_MODE_RP_SIZE 1
1083 #define OCF_READ_PAGE_SCAN_TYPE 0x0046
1085 #define OCF_WRITE_PAGE_SCAN_TYPE 0x0047
1087 #define OCF_READ_AFH_MODE 0x0048
1091 } __attribute__ ((packed)) read_afh_mode_rp;
1092 #define READ_AFH_MODE_RP_SIZE 2
1094 #define OCF_WRITE_AFH_MODE 0x0049
1097 } __attribute__ ((packed)) write_afh_mode_cp;
1098 #define WRITE_AFH_MODE_CP_SIZE 1
1101 } __attribute__ ((packed)) write_afh_mode_rp;
1102 #define WRITE_AFH_MODE_RP_SIZE 1
1104 #define OCF_READ_EXT_INQUIRY_RESPONSE 0x0051
1109 } __attribute__ ((packed)) read_ext_inquiry_response_rp;
1110 #define READ_EXT_INQUIRY_RESPONSE_RP_SIZE 242
1112 #define OCF_WRITE_EXT_INQUIRY_RESPONSE 0x0052
1116 } __attribute__ ((packed)) write_ext_inquiry_response_cp;
1117 #define WRITE_EXT_INQUIRY_RESPONSE_CP_SIZE 241
1120 } __attribute__ ((packed)) write_ext_inquiry_response_rp;
1121 #define WRITE_EXT_INQUIRY_RESPONSE_RP_SIZE 1
1123 /* Informational Parameters */
1124 #define OGF_INFO_PARAM 0x04
1126 #define OCF_READ_LOCAL_VERSION 0x0001
1132 uint16_t manufacturer;
1133 uint16_t lmp_subver;
1134 } __attribute__ ((packed)) read_local_version_rp;
1135 #define READ_LOCAL_VERSION_RP_SIZE 9
1137 #define OCF_READ_LOCAL_COMMANDS 0x0002
1140 uint8_t commands[64];
1141 } __attribute__ ((packed)) read_local_commands_rp;
1142 #define READ_LOCAL_COMMANDS_RP_SIZE 65
1144 #define OCF_READ_LOCAL_FEATURES 0x0003
1147 uint8_t features[8];
1148 } __attribute__ ((packed)) read_local_features_rp;
1149 #define READ_LOCAL_FEATURES_RP_SIZE 9
1151 #define OCF_READ_LOCAL_EXT_FEATURES 0x0004
1154 } __attribute__ ((packed)) read_local_ext_features_cp;
1155 #define READ_LOCAL_EXT_FEATURES_CP_SIZE 1
1159 uint8_t max_page_num;
1160 uint8_t features[8];
1161 } __attribute__ ((packed)) read_local_ext_features_rp;
1162 #define READ_LOCAL_EXT_FEATURES_RP_SIZE 11
1164 #define OCF_READ_BUFFER_SIZE 0x0005
1169 uint16_t acl_max_pkt;
1170 uint16_t sco_max_pkt;
1171 } __attribute__ ((packed)) read_buffer_size_rp;
1172 #define READ_BUFFER_SIZE_RP_SIZE 8
1174 #define OCF_READ_COUNTRY_CODE 0x0007
1177 uint8_t country_code;
1178 } __attribute__ ((packed)) read_country_code_rp;
1179 #define READ_COUNTRY_CODE_RP_SIZE 2
1181 #define OCF_READ_BD_ADDR 0x0009
1185 } __attribute__ ((packed)) read_bd_addr_rp;
1186 #define READ_BD_ADDR_RP_SIZE 7
1189 #define OGF_STATUS_PARAM 0x05
1191 #define OCF_READ_FAILED_CONTACT_COUNTER 0x0001
1196 } __attribute__ ((packed)) read_failed_contact_counter_rp;
1197 #define READ_FAILED_CONTACT_COUNTER_RP_SIZE 4
1199 #define OCF_RESET_FAILED_CONTACT_COUNTER 0x0002
1203 } __attribute__ ((packed)) reset_failed_contact_counter_rp;
1204 #define RESET_FAILED_CONTACT_COUNTER_RP_SIZE 4
1206 #define OCF_READ_LINK_QUALITY 0x0003
1209 } __attribute__ ((packed)) read_link_quality_cp;
1210 #define READ_LINK_QUALITY_CP_SIZE 4
1215 uint8_t link_quality;
1216 } __attribute__ ((packed)) read_link_quality_rp;
1217 #define READ_LINK_QUALITY_RP_SIZE 4
1219 #define OCF_READ_RSSI 0x0005
1224 } __attribute__ ((packed)) read_rssi_rp;
1225 #define READ_RSSI_RP_SIZE 4
1227 #define OCF_READ_AFH_MAP 0x0006
1233 } __attribute__ ((packed)) read_afh_map_rp;
1234 #define READ_AFH_MAP_RP_SIZE 14
1236 #define OCF_READ_CLOCK 0x0007
1239 uint8_t which_clock;
1240 } __attribute__ ((packed)) read_clock_cp;
1241 #define READ_CLOCK_CP_SIZE 3
1247 } __attribute__ ((packed)) read_clock_rp;
1248 #define READ_CLOCK_RP_SIZE 9
1250 /* Testing commands */
1251 #define OGF_TESTING_CMD 0x3e
1253 /* Vendor specific commands */
1254 #define OGF_VENDOR_CMD 0x3f
1258 #define EVT_INQUIRY_COMPLETE 0x01
1260 #define EVT_INQUIRY_RESULT 0x02
1262 uint8_t num_responses;
1264 uint8_t pscan_rep_mode;
1265 uint8_t pscan_period_mode;
1267 uint8_t dev_class[3];
1268 uint16_t clock_offset;
1269 } __attribute__ ((packed)) inquiry_info;
1270 #define INQUIRY_INFO_SIZE 14
1272 #define EVT_CONN_COMPLETE 0x03
1279 } __attribute__ ((packed)) evt_conn_complete;
1280 #define EVT_CONN_COMPLETE_SIZE 11
1282 #define EVT_CONN_REQUEST 0x04
1285 uint8_t dev_class[3];
1287 } __attribute__ ((packed)) evt_conn_request;
1288 #define EVT_CONN_REQUEST_SIZE 10
1290 #define EVT_DISCONN_COMPLETE 0x05
1295 } __attribute__ ((packed)) evt_disconn_complete;
1296 #define EVT_DISCONN_COMPLETE_SIZE 4
1298 #define EVT_AUTH_COMPLETE 0x06
1302 } __attribute__ ((packed)) evt_auth_complete;
1303 #define EVT_AUTH_COMPLETE_SIZE 3
1305 #define EVT_REMOTE_NAME_REQ_COMPLETE 0x07
1310 } __attribute__ ((packed)) evt_remote_name_req_complete;
1311 #define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
1313 #define EVT_ENCRYPT_CHANGE 0x08
1318 } __attribute__ ((packed)) evt_encrypt_change;
1319 #define EVT_ENCRYPT_CHANGE_SIZE 5
1321 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
1325 } __attribute__ ((packed)) evt_change_conn_link_key_complete;
1326 #define EVT_CHANGE_CONN_LINK_KEY_COMPLETE_SIZE 3
1328 #define EVT_MASTER_LINK_KEY_COMPLETE 0x0A
1333 } __attribute__ ((packed)) evt_master_link_key_complete;
1334 #define EVT_MASTER_LINK_KEY_COMPLETE_SIZE 4
1336 #define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
1340 uint8_t features[8];
1341 } __attribute__ ((packed)) evt_read_remote_features_complete;
1342 #define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
1344 #define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
1349 uint16_t manufacturer;
1350 uint16_t lmp_subver;
1351 } __attribute__ ((packed)) evt_read_remote_version_complete;
1352 #define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
1354 #define EVT_QOS_SETUP_COMPLETE 0x0D
1358 uint8_t flags; /* Reserved */
1360 } __attribute__ ((packed)) evt_qos_setup_complete;
1361 #define EVT_QOS_SETUP_COMPLETE_SIZE (4 + HCI_QOS_CP_SIZE)
1363 #define EVT_CMD_COMPLETE 0x0E
1367 } __attribute__ ((packed)) evt_cmd_complete;
1368 #define EVT_CMD_COMPLETE_SIZE 3
1370 #define EVT_CMD_STATUS 0x0F
1375 } __attribute__ ((packed)) evt_cmd_status;
1376 #define EVT_CMD_STATUS_SIZE 4
1378 #define EVT_HARDWARE_ERROR 0x10
1381 } __attribute__ ((packed)) evt_hardware_error;
1382 #define EVT_HARDWARE_ERROR_SIZE 1
1384 #define EVT_FLUSH_OCCURRED 0x11
1387 } __attribute__ ((packed)) evt_flush_occured;
1388 #define EVT_FLUSH_OCCURRED_SIZE 2
1390 #define EVT_ROLE_CHANGE 0x12
1395 } __attribute__ ((packed)) evt_role_change;
1396 #define EVT_ROLE_CHANGE_SIZE 8
1398 #define EVT_NUM_COMP_PKTS 0x13
1403 uint16_t num_packets;
1405 } __attribute__ ((packed)) evt_num_comp_pkts;
1406 #define EVT_NUM_COMP_PKTS_SIZE(num_hndl) (1 + 4 * (num_hndl))
1408 #define EVT_MODE_CHANGE 0x14
1414 } __attribute__ ((packed)) evt_mode_change;
1415 #define EVT_MODE_CHANGE_SIZE 6
1417 #define EVT_RETURN_LINK_KEYS 0x15
1420 /* variable length part */
1421 } __attribute__ ((packed)) evt_return_link_keys;
1422 #define EVT_RETURN_LINK_KEYS_SIZE 1
1424 #define EVT_PIN_CODE_REQ 0x16
1427 } __attribute__ ((packed)) evt_pin_code_req;
1428 #define EVT_PIN_CODE_REQ_SIZE 6
1430 #define EVT_LINK_KEY_REQ 0x17
1433 } __attribute__ ((packed)) evt_link_key_req;
1434 #define EVT_LINK_KEY_REQ_SIZE 6
1436 #define EVT_LINK_KEY_NOTIFY 0x18
1439 uint8_t link_key[16];
1441 } __attribute__ ((packed)) evt_link_key_notify;
1442 #define EVT_LINK_KEY_NOTIFY_SIZE 23
1444 #define EVT_LOOPBACK_COMMAND 0x19
1446 #define EVT_DATA_BUFFER_OVERFLOW 0x1A
1449 } __attribute__ ((packed)) evt_data_buffer_overflow;
1450 #define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
1452 #define EVT_MAX_SLOTS_CHANGE 0x1B
1456 } __attribute__ ((packed)) evt_max_slots_change;
1457 #define EVT_MAX_SLOTS_CHANGE_SIZE 3
1459 #define EVT_READ_CLOCK_OFFSET_COMPLETE 0x1C
1463 uint16_t clock_offset;
1464 } __attribute__ ((packed)) evt_read_clock_offset_complete;
1465 #define EVT_READ_CLOCK_OFFSET_COMPLETE_SIZE 5
1467 #define EVT_CONN_PTYPE_CHANGED 0x1D
1472 } __attribute__ ((packed)) evt_conn_ptype_changed;
1473 #define EVT_CONN_PTYPE_CHANGED_SIZE 5
1475 #define EVT_QOS_VIOLATION 0x1E
1478 } __attribute__ ((packed)) evt_qos_violation;
1479 #define EVT_QOS_VIOLATION_SIZE 2
1481 #define EVT_PSCAN_REP_MODE_CHANGE 0x20
1484 uint8_t pscan_rep_mode;
1485 } __attribute__ ((packed)) evt_pscan_rep_mode_change;
1486 #define EVT_PSCAN_REP_MODE_CHANGE_SIZE 7
1488 #define EVT_FLOW_SPEC_COMPLETE 0x21
1495 } __attribute__ ((packed)) evt_flow_spec_complete;
1496 #define EVT_FLOW_SPEC_COMPLETE_SIZE (5 + HCI_QOS_CP_SIZE)
1498 #define EVT_INQUIRY_RESULT_WITH_RSSI 0x22
1500 uint8_t num_responses;
1502 uint8_t pscan_rep_mode;
1503 uint8_t pscan_period_mode;
1504 uint8_t dev_class[3];
1505 uint16_t clock_offset;
1507 } __attribute__ ((packed)) inquiry_info_with_rssi;
1508 #define INQUIRY_INFO_WITH_RSSI_SIZE 15
1510 uint8_t num_responses;
1512 uint8_t pscan_rep_mode;
1513 uint8_t pscan_period_mode;
1515 uint8_t dev_class[3];
1516 uint16_t clock_offset;
1518 } __attribute__ ((packed)) inquiry_info_with_rssi_and_pscan_mode;
1519 #define INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE 16
1521 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE 0x23
1526 uint8_t max_page_num;
1527 uint8_t features[8];
1528 } __attribute__ ((packed)) evt_read_remote_ext_features_complete;
1529 #define EVT_READ_REMOTE_EXT_FEATURES_COMPLETE_SIZE 13
1531 #define EVT_SYNC_CONN_COMPLETE 0x2C
1537 uint8_t trans_interval;
1538 uint8_t retrans_window;
1539 uint16_t rx_pkt_len;
1540 uint16_t tx_pkt_len;
1542 } __attribute__ ((packed)) evt_sync_conn_complete;
1543 #define EVT_SYNC_CONN_COMPLETE_SIZE 17
1545 #define EVT_SYNC_CONN_CHANGED 0x2D
1549 uint8_t trans_interval;
1550 uint8_t retrans_window;
1551 uint16_t rx_pkt_len;
1552 uint16_t tx_pkt_len;
1553 } __attribute__ ((packed)) evt_sync_conn_changed;
1554 #define EVT_SYNC_CONN_CHANGED_SIZE 9
1556 #define EVT_SNIFF_SUBRATE 0x2E
1560 uint16_t max_remote_latency;
1561 uint16_t max_local_latency;
1562 uint16_t min_remote_timeout;
1563 uint16_t min_local_timeout;
1564 } __attribute__ ((packed)) evt_sniff_subrate;
1565 #define EVT_SNIFF_SUBRATE_SIZE 11
1567 #define EVT_EXTENDED_INQUIRY_RESULT 0x2F
1570 uint8_t pscan_rep_mode;
1571 uint8_t pscan_period_mode;
1572 uint8_t dev_class[3];
1573 uint16_t clock_offset;
1576 } __attribute__ ((packed)) extended_inquiry_info;
1577 #define EXTENDED_INQUIRY_INFO_SIZE 254
1579 #define EVT_TESTING 0xFE
1581 #define EVT_VENDOR 0xFF
1583 /* Command opcode pack/unpack */
1584 #define cmd_opcode_pack(ogf, ocf) (uint16_t)((ocf & 0x03ff)|(ogf << 10))
1585 #define cmd_opcode_ogf(op) (op >> 10)
1586 #define cmd_opcode_ocf(op) (op & 0x03ff)
1588 /* ACL handle and flags pack/unpack */
1589 #define acl_handle_pack(h, f) (uint16_t)(((h) & 0x0fff)|((f) << 12))
1590 #define acl_handle(h) ((h) & 0x0fff)
1591 #define acl_flags(h) ((h) >> 12)
1593 /* HCI Packet structures */
1594 #define HCI_COMMAND_HDR_SIZE 3
1595 #define HCI_EVENT_HDR_SIZE 2
1596 #define HCI_ACL_HDR_SIZE 4
1597 #define HCI_SCO_HDR_SIZE 3
1599 struct hci_command_hdr {
1600 uint16_t opcode; /* OCF & OGF */
1602 } __attribute__ ((packed));
1604 struct hci_event_hdr {
1607 } __attribute__ ((packed));
1609 struct hci_acl_hdr {
1610 uint16_t handle; /* Handle & Flags(PB, BC) */
1612 } __attribute__ ((packed));
1614 struct hci_sco_hdr {
1617 } __attribute__ ((packed));