forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhci.h
2444 lines (2101 loc) · 71.3 KB
/
hci.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* hci.h - Bluetooth Host Control Interface definitions */
/*
* Copyright (c) 2015-2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_
#include <toolchain.h>
#include <zephyr/types.h>
#include <stdbool.h>
#include <string.h>
#include <sys/util.h>
#include <net/buf.h>
#include <bluetooth/addr.h>
#include <bluetooth/hci_err.h>
#include <bluetooth/conn.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Special own address types for LL privacy (used in adv & scan parameters) */
#define BT_HCI_OWN_ADDR_RPA_OR_PUBLIC 0x02
#define BT_HCI_OWN_ADDR_RPA_OR_RANDOM 0x03
#define BT_HCI_OWN_ADDR_RPA_MASK 0x02
#define BT_HCI_PEER_ADDR_RPA_UNRESOLVED 0xfe
#define BT_HCI_PEER_ADDR_ANONYMOUS 0xff
#define BT_ENC_KEY_SIZE_MIN 0x07
#define BT_ENC_KEY_SIZE_MAX 0x10
struct bt_hci_evt_hdr {
uint8_t evt;
uint8_t len;
} __packed;
#define BT_HCI_EVT_HDR_SIZE 2
#define BT_ACL_START_NO_FLUSH 0x00
#define BT_ACL_CONT 0x01
#define BT_ACL_START 0x02
#define BT_ACL_COMPLETE 0x03
#define BT_ACL_POINT_TO_POINT 0x00
#define BT_ACL_BROADCAST 0x01
#define bt_acl_handle(h) ((h) & BIT_MASK(12))
#define bt_acl_flags(h) ((h) >> 12)
#define bt_acl_flags_pb(f) ((f) & BIT_MASK(2))
#define bt_acl_flags_bc(f) ((f) >> 2)
#define bt_acl_handle_pack(h, f) ((h) | ((f) << 12))
struct bt_hci_acl_hdr {
uint16_t handle;
uint16_t len;
} __packed;
#define BT_HCI_ACL_HDR_SIZE 4
#define BT_ISO_START 0x00
#define BT_ISO_CONT 0x01
#define BT_ISO_SINGLE 0x02
#define BT_ISO_END 0x03
#define bt_iso_handle(h) ((h) & 0x0fff)
#define bt_iso_flags(h) ((h) >> 12)
#define bt_iso_flags_pb(f) ((f) & 0x0003)
#define bt_iso_flags_ts(f) (((f) >> 2) & 0x0001)
#define bt_iso_pack_flags(pb, ts) \
(((pb) & 0x0003) | (((ts) & 0x0001) << 2))
#define bt_iso_handle_pack(h, pb, ts) \
((h) | (bt_iso_pack_flags(pb, ts) << 12))
#define BT_ISO_DATA_VALID 0x00
#define BT_ISO_DATA_INVALID 0x01
#define BT_ISO_DATA_NOP 0x02
#define bt_iso_pkt_len(h) ((h) & 0x3fff)
#define bt_iso_pkt_flags(h) ((h) >> 14)
#define bt_iso_pkt_len_pack(h, f) ((h) | ((f) << 14))
struct bt_hci_iso_data_hdr {
uint16_t sn;
uint16_t slen;
} __packed;
#define BT_HCI_ISO_DATA_HDR_SIZE 4
struct bt_hci_iso_ts_data_hdr {
uint32_t ts;
struct bt_hci_iso_data_hdr data;
} __packed;
#define BT_HCI_ISO_TS_DATA_HDR_SIZE 8
struct bt_hci_iso_hdr {
uint16_t handle;
uint16_t len;
} __packed;
#define BT_HCI_ISO_HDR_SIZE 4
struct bt_hci_cmd_hdr {
uint16_t opcode;
uint8_t param_len;
} __packed;
#define BT_HCI_CMD_HDR_SIZE 3
/* Supported Commands */
#define BT_CMD_TEST(cmd, octet, bit) (cmd[octet] & BIT(bit))
#define BT_CMD_LE_STATES(cmd) BT_CMD_TEST(cmd, 28, 3)
#define BT_FEAT_TEST(feat, page, octet, bit) (feat[page][octet] & BIT(bit))
#define BT_FEAT_BREDR(feat) !BT_FEAT_TEST(feat, 0, 4, 5)
#define BT_FEAT_LE(feat) BT_FEAT_TEST(feat, 0, 4, 6)
#define BT_FEAT_EXT_FEATURES(feat) BT_FEAT_TEST(feat, 0, 7, 7)
#define BT_FEAT_HOST_SSP(feat) BT_FEAT_TEST(feat, 1, 0, 0)
#define BT_FEAT_SC(feat) BT_FEAT_TEST(feat, 2, 1, 0)
#define BT_FEAT_LMP_ESCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 3, 7)
#define BT_FEAT_HV2_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 4)
#define BT_FEAT_HV3_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 5)
#define BT_FEAT_EV4_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 0)
#define BT_FEAT_EV5_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 1)
#define BT_FEAT_2EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 5)
#define BT_FEAT_3EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 6)
#define BT_FEAT_3SLOT_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 7)
/* LE features */
#define BT_LE_FEAT_BIT_ENC 0
#define BT_LE_FEAT_BIT_CONN_PARAM_REQ 1
#define BT_LE_FEAT_BIT_EXT_REJ_IND 2
#define BT_LE_FEAT_BIT_SLAVE_FEAT_REQ 3
#define BT_LE_FEAT_BIT_PING 4
#define BT_LE_FEAT_BIT_DLE 5
#define BT_LE_FEAT_BIT_PRIVACY 6
#define BT_LE_FEAT_BIT_EXT_SCAN 7
#define BT_LE_FEAT_BIT_PHY_2M 8
#define BT_LE_FEAT_BIT_SMI_TX 9
#define BT_LE_FEAT_BIT_SMI_RX 10
#define BT_LE_FEAT_BIT_PHY_CODED 11
#define BT_LE_FEAT_BIT_EXT_ADV 12
#define BT_LE_FEAT_BIT_PER_ADV 13
#define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14
#define BT_LE_FEAT_BIT_PWR_CLASS_1 15
#define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC 16
#define BT_LE_FEAT_BIT_CONN_CTE_REQ 17
#define BT_LE_FEAT_BIT_CONN_CTE_RESP 18
#define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX 19
#define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX 20
#define BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD 21
#define BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA 22
#define BT_LE_FEAT_BIT_RX_CTE 23
#define BT_LE_FEAT_BIT_PAST_SEND 24
#define BT_LE_FEAT_BIT_PAST_RECV 25
#define BT_LE_FEAT_BIT_SCA_UPDATE 26
#define BT_LE_FEAT_BIT_REMOTE_PUB_KEY_VALIDATE 27
#define BT_LE_FEAT_BIT_CIS_MASTER 28
#define BT_LE_FEAT_BIT_CIS_SLAVE 29
#define BT_LE_FEAT_BIT_ISO_BROADCASTER 30
#define BT_LE_FEAT_BIT_SYNC_RECEIVER 31
#define BT_LE_FEAT_BIT_ISO_CHANNELS 32
#define BT_LE_FEAT_BIT_PWR_CTRL_REQ 33
#define BT_LE_FEAT_BIT_PWR_CHG_IND 34
#define BT_LE_FEAT_BIT_PATH_LOSS_MONITOR 35
#define BT_LE_FEAT_TEST(feat, n) (feat[(n) >> 3] & \
BIT((n) & 7))
#define BT_FEAT_LE_ENCR(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ENC)
#define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONN_PARAM_REQ)
#define BT_FEAT_LE_SLAVE_FEATURE_XCHG(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_SLAVE_FEAT_REQ)
#define BT_FEAT_LE_DLE(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_DLE)
#define BT_FEAT_LE_PHY_2M(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PHY_2M)
#define BT_FEAT_LE_PHY_CODED(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PHY_CODED)
#define BT_FEAT_LE_PRIVACY(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PRIVACY)
#define BT_FEAT_LE_EXT_ADV(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_EXT_ADV)
#define BT_FEAT_LE_EXT_PER_ADV(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PER_ADV)
#define BT_FEAT_LE_PAST_SEND(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PAST_SEND)
#define BT_FEAT_LE_PAST_RECV(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PAST_RECV)
#define BT_FEAT_LE_CIS_MASTER(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CIS_MASTER)
#define BT_FEAT_LE_CIS_SLAVE(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CIS_SLAVE)
#define BT_FEAT_LE_ISO_BROADCASTER(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ISO_BROADCASTER)
#define BT_FEAT_LE_SYNC_RECEIVER(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_SYNC_RECEIVER)
#define BT_FEAT_LE_ISO_CHANNELS(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ISO_CHANNELS)
#define BT_FEAT_LE_CIS(feat) (BT_FEAT_LE_CIS_MASTER(feat) | \
BT_FEAT_LE_CIS_SLAVE(feat))
#define BT_FEAT_LE_BIS(feat) (BT_FEAT_LE_ISO_BROADCASTER(feat) | \
BT_FEAT_LE_SYNC_RECEIVER(feat))
#define BT_FEAT_LE_ISO(feat) (BT_FEAT_LE_CIS(feat) | \
BT_FEAT_LE_BIS(feat))
/* LE States */
#define BT_LE_STATES_SLAVE_CONN_ADV(states) (states & 0x0000004000000000)
/* Bonding/authentication types */
#define BT_HCI_NO_BONDING 0x00
#define BT_HCI_NO_BONDING_MITM 0x01
#define BT_HCI_DEDICATED_BONDING 0x02
#define BT_HCI_DEDICATED_BONDING_MITM 0x03
#define BT_HCI_GENERAL_BONDING 0x04
#define BT_HCI_GENERAL_BONDING_MITM 0x05
/*
* MITM protection is enabled in SSP authentication requirements octet when
* LSB bit is set.
*/
#define BT_MITM 0x01
/* I/O capabilities */
#define BT_IO_DISPLAY_ONLY 0x00
#define BT_IO_DISPLAY_YESNO 0x01
#define BT_IO_KEYBOARD_ONLY 0x02
#define BT_IO_NO_INPUT_OUTPUT 0x03
/* SCO packet types */
#define HCI_PKT_TYPE_HV1 0x0020
#define HCI_PKT_TYPE_HV2 0x0040
#define HCI_PKT_TYPE_HV3 0x0080
/* eSCO packet types */
#define HCI_PKT_TYPE_ESCO_HV1 0x0001
#define HCI_PKT_TYPE_ESCO_HV2 0x0002
#define HCI_PKT_TYPE_ESCO_HV3 0x0004
#define HCI_PKT_TYPE_ESCO_EV3 0x0008
#define HCI_PKT_TYPE_ESCO_EV4 0x0010
#define HCI_PKT_TYPE_ESCO_EV5 0x0020
#define HCI_PKT_TYPE_ESCO_2EV3 0x0040
#define HCI_PKT_TYPE_ESCO_3EV3 0x0080
#define HCI_PKT_TYPE_ESCO_2EV5 0x0100
#define HCI_PKT_TYPE_ESCO_3EV5 0x0200
#define ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_HV1 | \
HCI_PKT_TYPE_ESCO_HV2 | \
HCI_PKT_TYPE_ESCO_HV3)
#define SCO_PKT_MASK (HCI_PKT_TYPE_HV1 | \
HCI_PKT_TYPE_HV2 | \
HCI_PKT_TYPE_HV3)
#define EDR_ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_2EV3 | \
HCI_PKT_TYPE_ESCO_3EV3 | \
HCI_PKT_TYPE_ESCO_2EV5 | \
HCI_PKT_TYPE_ESCO_3EV5)
/* HCI BR/EDR link types */
#define BT_HCI_SCO 0x00
#define BT_HCI_ACL 0x01
#define BT_HCI_ESCO 0x02
/* OpCode Group Fields */
#define BT_OGF_LINK_CTRL 0x01
#define BT_OGF_BASEBAND 0x03
#define BT_OGF_INFO 0x04
#define BT_OGF_STATUS 0x05
#define BT_OGF_LE 0x08
#define BT_OGF_VS 0x3f
/* Construct OpCode from OGF and OCF */
#define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
/* Invalid opcode */
#define BT_OP_NOP 0x0000
/* Obtain OGF from OpCode */
#define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
/* Obtain OCF from OpCode */
#define BT_OCF(opcode) ((opcode) & BIT_MASK(10))
#define BT_HCI_OP_INQUIRY BT_OP(BT_OGF_LINK_CTRL, 0x0001)
struct bt_hci_op_inquiry {
uint8_t lap[3];
uint8_t length;
uint8_t num_rsp;
} __packed;
#define BT_HCI_OP_INQUIRY_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0002)
#define BT_HCI_OP_CONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0005)
struct bt_hci_cp_connect {
bt_addr_t bdaddr;
uint16_t packet_type;
uint8_t pscan_rep_mode;
uint8_t reserved;
uint16_t clock_offset;
uint8_t allow_role_switch;
} __packed;
#define BT_HCI_OP_DISCONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0006)
struct bt_hci_cp_disconnect {
uint16_t handle;
uint8_t reason;
} __packed;
#define BT_HCI_OP_CONNECT_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0008)
struct bt_hci_cp_connect_cancel {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_connect_cancel {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_ACCEPT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0009)
struct bt_hci_cp_accept_conn_req {
bt_addr_t bdaddr;
uint8_t role;
} __packed;
#define BT_HCI_OP_SETUP_SYNC_CONN BT_OP(BT_OGF_LINK_CTRL, 0x0028)
struct bt_hci_cp_setup_sync_conn {
uint16_t handle;
uint32_t tx_bandwidth;
uint32_t rx_bandwidth;
uint16_t max_latency;
uint16_t content_format;
uint8_t retrans_effort;
uint16_t pkt_type;
} __packed;
#define BT_HCI_OP_ACCEPT_SYNC_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0029)
struct bt_hci_cp_accept_sync_conn_req {
bt_addr_t bdaddr;
uint32_t tx_bandwidth;
uint32_t rx_bandwidth;
uint16_t max_latency;
uint16_t content_format;
uint8_t retrans_effort;
uint16_t pkt_type;
} __packed;
#define BT_HCI_OP_REJECT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x000a)
struct bt_hci_cp_reject_conn_req {
bt_addr_t bdaddr;
uint8_t reason;
} __packed;
#define BT_HCI_OP_LINK_KEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000b)
struct bt_hci_cp_link_key_reply {
bt_addr_t bdaddr;
uint8_t link_key[16];
} __packed;
#define BT_HCI_OP_LINK_KEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000c)
struct bt_hci_cp_link_key_neg_reply {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_PIN_CODE_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000d)
struct bt_hci_cp_pin_code_reply {
bt_addr_t bdaddr;
uint8_t pin_len;
uint8_t pin_code[16];
} __packed;
struct bt_hci_rp_pin_code_reply {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_PIN_CODE_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000e)
struct bt_hci_cp_pin_code_neg_reply {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_pin_code_neg_reply {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_AUTH_REQUESTED BT_OP(BT_OGF_LINK_CTRL, 0x0011)
struct bt_hci_cp_auth_requested {
uint16_t handle;
} __packed;
#define BT_HCI_OP_SET_CONN_ENCRYPT BT_OP(BT_OGF_LINK_CTRL, 0x0013)
struct bt_hci_cp_set_conn_encrypt {
uint16_t handle;
uint8_t encrypt;
} __packed;
#define BT_HCI_OP_REMOTE_NAME_REQUEST BT_OP(BT_OGF_LINK_CTRL, 0x0019)
struct bt_hci_cp_remote_name_request {
bt_addr_t bdaddr;
uint8_t pscan_rep_mode;
uint8_t reserved;
uint16_t clock_offset;
} __packed;
#define BT_HCI_OP_REMOTE_NAME_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x001a)
struct bt_hci_cp_remote_name_cancel {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_remote_name_cancel {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_READ_REMOTE_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001b)
struct bt_hci_cp_read_remote_features {
uint16_t handle;
} __packed;
#define BT_HCI_OP_READ_REMOTE_EXT_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001c)
struct bt_hci_cp_read_remote_ext_features {
uint16_t handle;
uint8_t page;
} __packed;
#define BT_HCI_OP_READ_REMOTE_VERSION_INFO BT_OP(BT_OGF_LINK_CTRL, 0x001d)
struct bt_hci_cp_read_remote_version_info {
uint16_t handle;
} __packed;
#define BT_HCI_OP_IO_CAPABILITY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002b)
struct bt_hci_cp_io_capability_reply {
bt_addr_t bdaddr;
uint8_t capability;
uint8_t oob_data;
uint8_t authentication;
} __packed;
#define BT_HCI_OP_USER_CONFIRM_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002c)
#define BT_HCI_OP_USER_CONFIRM_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002d)
struct bt_hci_cp_user_confirm_reply {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_user_confirm_reply {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_USER_PASSKEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002e)
struct bt_hci_cp_user_passkey_reply {
bt_addr_t bdaddr;
uint32_t passkey;
} __packed;
#define BT_HCI_OP_USER_PASSKEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002f)
struct bt_hci_cp_user_passkey_neg_reply {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x0034)
struct bt_hci_cp_io_capability_neg_reply {
bt_addr_t bdaddr;
uint8_t reason;
} __packed;
#define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001)
struct bt_hci_cp_set_event_mask {
uint8_t events[8];
} __packed;
#define BT_HCI_OP_RESET BT_OP(BT_OGF_BASEBAND, 0x0003)
#define BT_HCI_OP_WRITE_LOCAL_NAME BT_OP(BT_OGF_BASEBAND, 0x0013)
struct bt_hci_write_local_name {
uint8_t local_name[248];
} __packed;
#define BT_HCI_OP_WRITE_PAGE_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0018)
#define BT_HCI_OP_WRITE_SCAN_ENABLE BT_OP(BT_OGF_BASEBAND, 0x001a)
#define BT_BREDR_SCAN_DISABLED 0x00
#define BT_BREDR_SCAN_INQUIRY 0x01
#define BT_BREDR_SCAN_PAGE 0x02
#define BT_TX_POWER_LEVEL_CURRENT 0x00
#define BT_TX_POWER_LEVEL_MAX 0x01
#define BT_HCI_OP_READ_TX_POWER_LEVEL BT_OP(BT_OGF_BASEBAND, 0x002d)
struct bt_hci_cp_read_tx_power_level {
uint16_t handle;
uint8_t type;
} __packed;
struct bt_hci_rp_read_tx_power_level {
uint8_t status;
uint16_t handle;
int8_t tx_power_level;
} __packed;
#define BT_HCI_CTL_TO_HOST_FLOW_DISABLE 0x00
#define BT_HCI_CTL_TO_HOST_FLOW_ENABLE 0x01
#define BT_HCI_OP_SET_CTL_TO_HOST_FLOW BT_OP(BT_OGF_BASEBAND, 0x0031)
struct bt_hci_cp_set_ctl_to_host_flow {
uint8_t flow_enable;
} __packed;
#define BT_HCI_OP_HOST_BUFFER_SIZE BT_OP(BT_OGF_BASEBAND, 0x0033)
struct bt_hci_cp_host_buffer_size {
uint16_t acl_mtu;
uint8_t sco_mtu;
uint16_t acl_pkts;
uint16_t sco_pkts;
} __packed;
struct bt_hci_handle_count {
uint16_t handle;
uint16_t count;
} __packed;
#define BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS BT_OP(BT_OGF_BASEBAND, 0x0035)
struct bt_hci_cp_host_num_completed_packets {
uint8_t num_handles;
struct bt_hci_handle_count h[0];
} __packed;
#define BT_HCI_OP_WRITE_INQUIRY_MODE BT_OP(BT_OGF_BASEBAND, 0x0045)
struct bt_hci_cp_write_inquiry_mode {
uint8_t mode;
} __packed;
#define BT_HCI_OP_WRITE_SSP_MODE BT_OP(BT_OGF_BASEBAND, 0x0056)
struct bt_hci_cp_write_ssp_mode {
uint8_t mode;
} __packed;
#define BT_HCI_OP_SET_EVENT_MASK_PAGE_2 BT_OP(BT_OGF_BASEBAND, 0x0063)
struct bt_hci_cp_set_event_mask_page_2 {
uint8_t events_page_2[8];
} __packed;
#define BT_HCI_OP_LE_WRITE_LE_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x006d)
struct bt_hci_cp_write_le_host_supp {
uint8_t le;
uint8_t simul;
} __packed;
#define BT_HCI_OP_WRITE_SC_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x007a)
struct bt_hci_cp_write_sc_host_supp {
uint8_t sc_support;
} __packed;
#define BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007b)
struct bt_hci_cp_read_auth_payload_timeout {
uint16_t handle;
} __packed;
struct bt_hci_rp_read_auth_payload_timeout {
uint8_t status;
uint16_t handle;
uint16_t auth_payload_timeout;
} __packed;
#define BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007c)
struct bt_hci_cp_write_auth_payload_timeout {
uint16_t handle;
uint16_t auth_payload_timeout;
} __packed;
struct bt_hci_rp_write_auth_payload_timeout {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_CONFIGURE_DATA_PATH BT_OP(BT_OGF_BASEBAND, 0x0083)
struct bt_hci_cp_configure_data_path {
uint8_t data_path_dir;
uint8_t data_path_id;
uint8_t vs_config_len;
uint8_t vs_config[0];
} __packed;
struct bt_hci_rp_configure_data_path {
uint8_t status;
} __packed;
/* HCI version from Assigned Numbers */
#define BT_HCI_VERSION_1_0B 0
#define BT_HCI_VERSION_1_1 1
#define BT_HCI_VERSION_1_2 2
#define BT_HCI_VERSION_2_0 3
#define BT_HCI_VERSION_2_1 4
#define BT_HCI_VERSION_3_0 5
#define BT_HCI_VERSION_4_0 6
#define BT_HCI_VERSION_4_1 7
#define BT_HCI_VERSION_4_2 8
#define BT_HCI_VERSION_5_0 9
#define BT_HCI_VERSION_5_1 10
#define BT_HCI_VERSION_5_2 11
#define BT_HCI_OP_READ_LOCAL_VERSION_INFO BT_OP(BT_OGF_INFO, 0x0001)
struct bt_hci_rp_read_local_version_info {
uint8_t status;
uint8_t hci_version;
uint16_t hci_revision;
uint8_t lmp_version;
uint16_t manufacturer;
uint16_t lmp_subversion;
} __packed;
#define BT_HCI_OP_READ_SUPPORTED_COMMANDS BT_OP(BT_OGF_INFO, 0x0002)
struct bt_hci_rp_read_supported_commands {
uint8_t status;
uint8_t commands[64];
} __packed;
#define BT_HCI_OP_READ_LOCAL_EXT_FEATURES BT_OP(BT_OGF_INFO, 0x0004)
struct bt_hci_cp_read_local_ext_features {
uint8_t page;
};
struct bt_hci_rp_read_local_ext_features {
uint8_t status;
uint8_t page;
uint8_t max_page;
uint8_t ext_features[8];
} __packed;
#define BT_HCI_OP_READ_LOCAL_FEATURES BT_OP(BT_OGF_INFO, 0x0003)
struct bt_hci_rp_read_local_features {
uint8_t status;
uint8_t features[8];
} __packed;
#define BT_HCI_OP_READ_BUFFER_SIZE BT_OP(BT_OGF_INFO, 0x0005)
struct bt_hci_rp_read_buffer_size {
uint8_t status;
uint16_t acl_max_len;
uint8_t sco_max_len;
uint16_t acl_max_num;
uint16_t sco_max_num;
} __packed;
#define BT_HCI_OP_READ_BD_ADDR BT_OP(BT_OGF_INFO, 0x0009)
struct bt_hci_rp_read_bd_addr {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_READ_RSSI BT_OP(BT_OGF_STATUS, 0x0005)
struct bt_hci_cp_read_rssi {
uint16_t handle;
} __packed;
struct bt_hci_rp_read_rssi {
uint8_t status;
uint16_t handle;
int8_t rssi;
} __packed;
#define BT_HCI_ENCRYPTION_KEY_SIZE_MIN 7
#define BT_HCI_ENCRYPTION_KEY_SIZE_MAX 16
#define BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE BT_OP(BT_OGF_STATUS, 0x0008)
struct bt_hci_cp_read_encryption_key_size {
uint16_t handle;
} __packed;
struct bt_hci_rp_read_encryption_key_size {
uint8_t status;
uint16_t handle;
uint8_t key_size;
} __packed;
/* BLE */
#define BT_HCI_OP_LE_SET_EVENT_MASK BT_OP(BT_OGF_LE, 0x0001)
struct bt_hci_cp_le_set_event_mask {
uint8_t events[8];
} __packed;
#define BT_HCI_OP_LE_READ_BUFFER_SIZE BT_OP(BT_OGF_LE, 0x0002)
struct bt_hci_rp_le_read_buffer_size {
uint8_t status;
uint16_t le_max_len;
uint8_t le_max_num;
} __packed;
#define BT_HCI_OP_LE_READ_LOCAL_FEATURES BT_OP(BT_OGF_LE, 0x0003)
struct bt_hci_rp_le_read_local_features {
uint8_t status;
uint8_t features[8];
} __packed;
#define BT_HCI_OP_LE_SET_RANDOM_ADDRESS BT_OP(BT_OGF_LE, 0x0005)
struct bt_hci_cp_le_set_random_address {
bt_addr_t bdaddr;
} __packed;
/* LE Advertising Types (LE Advertising Parameters Set)*/
#define BT_LE_ADV_IND (__DEPRECATED_MACRO 0x00)
#define BT_LE_ADV_DIRECT_IND (__DEPRECATED_MACRO 0x01)
#define BT_LE_ADV_SCAN_IND (__DEPRECATED_MACRO 0x02)
#define BT_LE_ADV_NONCONN_IND (__DEPRECATED_MACRO 0x03)
#define BT_LE_ADV_DIRECT_IND_LOW_DUTY (__DEPRECATED_MACRO 0x04)
/* LE Advertising PDU Types. */
#define BT_LE_ADV_SCAN_RSP (__DEPRECATED_MACRO 0x04)
#define BT_HCI_ADV_IND 0x00
#define BT_HCI_ADV_DIRECT_IND 0x01
#define BT_HCI_ADV_SCAN_IND 0x02
#define BT_HCI_ADV_NONCONN_IND 0x03
#define BT_HCI_ADV_DIRECT_IND_LOW_DUTY 0x04
#define BT_HCI_ADV_SCAN_RSP 0x04
#define BT_LE_ADV_FP_NO_WHITELIST 0x00
#define BT_LE_ADV_FP_WHITELIST_SCAN_REQ 0x01
#define BT_LE_ADV_FP_WHITELIST_CONN_IND 0x02
#define BT_LE_ADV_FP_WHITELIST_BOTH 0x03
#define BT_HCI_OP_LE_SET_ADV_PARAM BT_OP(BT_OGF_LE, 0x0006)
struct bt_hci_cp_le_set_adv_param {
uint16_t min_interval;
uint16_t max_interval;
uint8_t type;
uint8_t own_addr_type;
bt_addr_le_t direct_addr;
uint8_t channel_map;
uint8_t filter_policy;
} __packed;
#define BT_HCI_OP_LE_READ_ADV_CHAN_TX_POWER BT_OP(BT_OGF_LE, 0x0007)
struct bt_hci_rp_le_read_chan_tx_power {
uint8_t status;
int8_t tx_power_level;
} __packed;
#define BT_HCI_OP_LE_SET_ADV_DATA BT_OP(BT_OGF_LE, 0x0008)
struct bt_hci_cp_le_set_adv_data {
uint8_t len;
uint8_t data[31];
} __packed;
#define BT_HCI_OP_LE_SET_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0009)
struct bt_hci_cp_le_set_scan_rsp_data {
uint8_t len;
uint8_t data[31];
} __packed;
#define BT_HCI_LE_ADV_DISABLE 0x00
#define BT_HCI_LE_ADV_ENABLE 0x01
#define BT_HCI_OP_LE_SET_ADV_ENABLE BT_OP(BT_OGF_LE, 0x000a)
struct bt_hci_cp_le_set_adv_enable {
uint8_t enable;
} __packed;
/* Scan types */
#define BT_HCI_OP_LE_SET_SCAN_PARAM BT_OP(BT_OGF_LE, 0x000b)
#define BT_HCI_LE_SCAN_PASSIVE 0x00
#define BT_HCI_LE_SCAN_ACTIVE 0x01
#define BT_HCI_LE_SCAN_FP_NO_WHITELIST 0x00
#define BT_HCI_LE_SCAN_FP_USE_WHITELIST 0x01
struct bt_hci_cp_le_set_scan_param {
uint8_t scan_type;
uint16_t interval;
uint16_t window;
uint8_t addr_type;
uint8_t filter_policy;
} __packed;
#define BT_HCI_OP_LE_SET_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x000c)
#define BT_HCI_LE_SCAN_DISABLE 0x00
#define BT_HCI_LE_SCAN_ENABLE 0x01
#define BT_HCI_LE_SCAN_FILTER_DUP_DISABLE 0x00
#define BT_HCI_LE_SCAN_FILTER_DUP_ENABLE 0x01
struct bt_hci_cp_le_set_scan_enable {
uint8_t enable;
uint8_t filter_dup;
} __packed;
#define BT_HCI_OP_LE_CREATE_CONN BT_OP(BT_OGF_LE, 0x000d)
#define BT_HCI_LE_CREATE_CONN_FP_DIRECT 0x00
#define BT_HCI_LE_CREATE_CONN_FP_WHITELIST 0x01
struct bt_hci_cp_le_create_conn {
uint16_t scan_interval;
uint16_t scan_window;
uint8_t filter_policy;
bt_addr_le_t peer_addr;
uint8_t own_addr_type;
uint16_t conn_interval_min;
uint16_t conn_interval_max;
uint16_t conn_latency;
uint16_t supervision_timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} __packed;
#define BT_HCI_OP_LE_CREATE_CONN_CANCEL BT_OP(BT_OGF_LE, 0x000e)
#define BT_HCI_OP_LE_READ_WL_SIZE BT_OP(BT_OGF_LE, 0x000f)
struct bt_hci_rp_le_read_wl_size {
uint8_t status;
uint8_t wl_size;
} __packed;
#define BT_HCI_OP_LE_CLEAR_WL BT_OP(BT_OGF_LE, 0x0010)
#define BT_HCI_OP_LE_ADD_DEV_TO_WL BT_OP(BT_OGF_LE, 0x0011)
struct bt_hci_cp_le_add_dev_to_wl {
bt_addr_le_t addr;
} __packed;
#define BT_HCI_OP_LE_REM_DEV_FROM_WL BT_OP(BT_OGF_LE, 0x0012)
struct bt_hci_cp_le_rem_dev_from_wl {
bt_addr_le_t addr;
} __packed;
#define BT_HCI_OP_LE_CONN_UPDATE BT_OP(BT_OGF_LE, 0x0013)
struct hci_cp_le_conn_update {
uint16_t handle;
uint16_t conn_interval_min;
uint16_t conn_interval_max;
uint16_t conn_latency;
uint16_t supervision_timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} __packed;
#define BT_HCI_OP_LE_SET_HOST_CHAN_CLASSIF BT_OP(BT_OGF_LE, 0x0014)
struct bt_hci_cp_le_set_host_chan_classif {
uint8_t ch_map[5];
} __packed;
#define BT_HCI_OP_LE_READ_CHAN_MAP BT_OP(BT_OGF_LE, 0x0015)
struct bt_hci_cp_le_read_chan_map {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_read_chan_map {
uint8_t status;
uint16_t handle;
uint8_t ch_map[5];
} __packed;
#define BT_HCI_OP_LE_READ_REMOTE_FEATURES BT_OP(BT_OGF_LE, 0x0016)
struct bt_hci_cp_le_read_remote_features {
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_ENCRYPT BT_OP(BT_OGF_LE, 0x0017)
struct bt_hci_cp_le_encrypt {
uint8_t key[16];
uint8_t plaintext[16];
} __packed;
struct bt_hci_rp_le_encrypt {
uint8_t status;
uint8_t enc_data[16];
} __packed;
#define BT_HCI_OP_LE_RAND BT_OP(BT_OGF_LE, 0x0018)
struct bt_hci_rp_le_rand {
uint8_t status;
uint8_t rand[8];
} __packed;
#define BT_HCI_OP_LE_START_ENCRYPTION BT_OP(BT_OGF_LE, 0x0019)
struct bt_hci_cp_le_start_encryption {
uint16_t handle;
uint64_t rand;
uint16_t ediv;
uint8_t ltk[16];
} __packed;
#define BT_HCI_OP_LE_LTK_REQ_REPLY BT_OP(BT_OGF_LE, 0x001a)
struct bt_hci_cp_le_ltk_req_reply {
uint16_t handle;
uint8_t ltk[16];
} __packed;
struct bt_hci_rp_le_ltk_req_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_LTK_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x001b)
struct bt_hci_cp_le_ltk_req_neg_reply {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_ltk_req_neg_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_READ_SUPP_STATES BT_OP(BT_OGF_LE, 0x001c)
struct bt_hci_rp_le_read_supp_states {
uint8_t status;
uint8_t le_states[8];
} __packed;
#define BT_HCI_OP_LE_RX_TEST BT_OP(BT_OGF_LE, 0x001d)
struct bt_hci_cp_le_rx_test {
uint8_t rx_ch;
} __packed;
#define BT_HCI_OP_LE_TX_TEST BT_OP(BT_OGF_LE, 0x001e)
struct bt_hci_cp_le_tx_test {
uint8_t tx_ch;
uint8_t test_data_len;
uint8_t pkt_payload;
} __packed;
#define BT_HCI_OP_LE_TEST_END BT_OP(BT_OGF_LE, 0x001f)
struct bt_hci_rp_le_test_end {
uint8_t status;
uint16_t rx_pkt_count;
} __packed;
#define BT_HCI_OP_LE_CONN_PARAM_REQ_REPLY BT_OP(BT_OGF_LE, 0x0020)
struct bt_hci_cp_le_conn_param_req_reply {
uint16_t handle;
uint16_t interval_min;
uint16_t interval_max;
uint16_t latency;
uint16_t timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} __packed;
struct bt_hci_rp_le_conn_param_req_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x0021)
struct bt_hci_cp_le_conn_param_req_neg_reply {
uint16_t handle;
uint8_t reason;
} __packed;
struct bt_hci_rp_le_conn_param_req_neg_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_SET_DATA_LEN BT_OP(BT_OGF_LE, 0x0022)
struct bt_hci_cp_le_set_data_len {
uint16_t handle;
uint16_t tx_octets;
uint16_t tx_time;
} __packed;
struct bt_hci_rp_le_set_data_len {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_READ_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0023)
struct bt_hci_rp_le_read_default_data_len {
uint8_t status;
uint16_t max_tx_octets;
uint16_t max_tx_time;
} __packed;
#define BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0024)
struct bt_hci_cp_le_write_default_data_len {
uint16_t max_tx_octets;
uint16_t max_tx_time;
} __packed;
#define BT_HCI_OP_LE_P256_PUBLIC_KEY BT_OP(BT_OGF_LE, 0x0025)
#define BT_HCI_OP_LE_GENERATE_DHKEY BT_OP(BT_OGF_LE, 0x0026)
struct bt_hci_cp_le_generate_dhkey {
uint8_t key[64];
} __packed;
#define BT_HCI_OP_LE_ADD_DEV_TO_RL BT_OP(BT_OGF_LE, 0x0027)
struct bt_hci_cp_le_add_dev_to_rl {
bt_addr_le_t peer_id_addr;
uint8_t peer_irk[16];
uint8_t local_irk[16];
} __packed;
#define BT_HCI_OP_LE_REM_DEV_FROM_RL BT_OP(BT_OGF_LE, 0x0028)
struct bt_hci_cp_le_rem_dev_from_rl {
bt_addr_le_t peer_id_addr;
} __packed;
#define BT_HCI_OP_LE_CLEAR_RL BT_OP(BT_OGF_LE, 0x0029)
#define BT_HCI_OP_LE_READ_RL_SIZE BT_OP(BT_OGF_LE, 0x002a)
struct bt_hci_rp_le_read_rl_size {
uint8_t status;
uint8_t rl_size;
} __packed;
#define BT_HCI_OP_LE_READ_PEER_RPA BT_OP(BT_OGF_LE, 0x002b)
struct bt_hci_cp_le_read_peer_rpa {
bt_addr_le_t peer_id_addr;
} __packed;
struct bt_hci_rp_le_read_peer_rpa {
uint8_t status;
bt_addr_t peer_rpa;
} __packed;