xref: /haiku/headers/os/bluetooth/HCI/btHCI.h (revision 71452e98334eaac603bf542d159e24788a46bebb)
1 /*
2  * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef _BTHCI_H_
6 #define _BTHCI_H_
7 
8 /* typedefs */
9 typedef int32 hci_id;
10 #define HCI_DEVICE_INDEX_OFFSET 0x7c
11 
12 typedef enum { H2 = 2, H3, H4, H5 } transport_type;
13 
14 typedef enum { 	BT_COMMAND = 0,
15 				BT_EVENT,
16 				BT_ACL,
17 				BT_SCO,
18 				BT_ESCO,
19 				// more packets here
20 				HCI_NUM_PACKET_TYPES
21 } bt_packet_t;
22 
23 const char* BluetoothCommandOpcode(uint16 opcode);
24 const char* BluetoothEvent(uint8 event);
25 const char* BluetoothManufacturer(uint16 manufacturer);
26 const char* BluetoothHciVersion(uint16 ver);
27 const char* BluetoothLmpVersion(uint16 ver);
28 const char* BluetoothError(uint8 error);
29 
30 /* packets sizes */
31 #define HCI_MAX_ACL_SIZE		1024
32 #define HCI_MAX_SCO_SIZE		255
33 #define HCI_MAX_EVENT_SIZE		260
34 #define HCI_MAX_FRAME_SIZE		(HCI_MAX_ACL_SIZE + 4)
35 
36 /* fields sizes */
37 #define HCI_LAP_SIZE			3	/* LAP */
38 #define HCI_LINK_KEY_SIZE		16	/* link key */
39 #define HCI_PIN_SIZE			16	/* PIN */
40 #define HCI_EVENT_MASK_SIZE		8	/* event mask */
41 #define HCI_CLASS_SIZE			3	/* class */
42 #define HCI_FEATURES_SIZE		8	/* LMP features */
43 #define HCI_DEVICE_NAME_SIZE	248	/* unit name size */
44 
45 /* Device drivers need to take this into account
46  * when receiving ioctls. Only applies to R5 builds
47  * in deprecation process
48  */
49 #define BT_IOCTLS_PASS_SIZE
50 
51 
52 // HCI Packet types
53 #define HCI_2DH1        0x0002
54 #define HCI_3DH1        0x0004
55 #define HCI_DM1         0x0008
56 #define HCI_DH1         0x0010
57 #define HCI_2DH3        0x0100
58 #define HCI_3DH3        0x0200
59 #define HCI_DM3         0x0400
60 #define HCI_DH3         0x0800
61 #define HCI_2DH5        0x1000
62 #define HCI_3DH5        0x2000
63 #define HCI_DM5         0x4000
64 #define HCI_DH5         0x8000
65 
66 #define HCI_HV1         0x0020
67 #define HCI_HV2         0x0040
68 #define HCI_HV3         0x0080
69 
70 #define HCI_EV3         0x0008
71 #define HCI_EV4         0x0010
72 #define HCI_EV5         0x0020
73 #define HCI_2EV3        0x0040
74 #define HCI_3EV3        0x0080
75 #define HCI_2EV5        0x0100
76 #define HCI_3EV5        0x0200
77 
78 #define SCO_PTYPE_MASK  (HCI_HV1 | HCI_HV2 | HCI_HV3)
79 #define ACL_PTYPE_MASK  (HCI_DM1 | HCI_DH1 | HCI_DM3 | HCI_DH3 | HCI_DM5 | HCI_DH5)
80 
81 
82 // LMP features
83 #define LMP_3SLOT       0x01
84 #define LMP_5SLOT       0x02
85 #define LMP_ENCRYPT     0x04
86 #define LMP_SOFFSET     0x08
87 #define LMP_TACCURACY   0x10
88 #define LMP_RSWITCH     0x20
89 #define LMP_HOLD        0x40
90 #define LMP_SNIFF       0x80
91 
92 #define LMP_PARK        0x01
93 #define LMP_RSSI        0x02
94 #define LMP_QUALITY     0x04
95 #define LMP_SCO         0x08
96 #define LMP_HV2         0x10
97 #define LMP_HV3         0x20
98 #define LMP_ULAW        0x40
99 #define LMP_ALAW        0x80
100 
101 #define LMP_CVSD        0x01
102 #define LMP_PSCHEME     0x02
103 #define LMP_PCONTROL    0x04
104 #define LMP_TRSP_SCO    0x08
105 #define LMP_BCAST_ENC   0x80
106 
107 #define LMP_EDR_ACL_2M  0x02
108 #define LMP_EDR_ACL_3M  0x04
109 #define LMP_ENH_ISCAN   0x08
110 #define LMP_ILACE_ISCAN 0x10
111 #define LMP_ILACE_PSCAN 0x20
112 #define LMP_RSSI_INQ    0x40
113 #define LMP_ESCO        0x80
114 
115 #define LMP_EV4         0x01
116 #define LMP_EV5         0x02
117 #define LMP_AFH_CAP_SLV 0x08
118 #define LMP_AFH_CLS_SLV 0x10
119 #define LMP_EDR_3SLOT   0x80
120 
121 #define LMP_EDR_5SLOT   0x01
122 #define LMP_SNIFF_SUBR  0x02
123 #define LMP_PAUSE_ENC   0x04
124 #define LMP_AFH_CAP_MST 0x08
125 #define LMP_AFH_CLS_MST 0x10
126 #define LMP_EDR_ESCO_2M 0x20
127 #define LMP_EDR_ESCO_3M 0x40
128 #define LMP_EDR_3S_ESCO 0x80
129 
130 #define LMP_EXT_INQ     0x01
131 #define LMP_SIMPLE_PAIR 0x08
132 #define LMP_ENCAPS_PDU  0x10
133 #define LMP_ERR_DAT_REP 0x20
134 #define LMP_NFLUSH_PKTS 0x40
135 
136 #define LMP_LSTO        0x01
137 #define LMP_INQ_TX_PWR  0x02
138 #define LMP_EXT_FEAT    0x80
139 
140 // Link policies
141 #define HCI_LP_RSWITCH  0x0001
142 #define HCI_LP_HOLD     0x0002
143 #define HCI_LP_SNIFF    0x0004
144 #define HCI_LP_PARK     0x0008
145 
146 // Link mode
147 #define HCI_LM_ACCEPT   0x8000
148 #define HCI_LM_MASTER   0x0001
149 #define HCI_LM_AUTH     0x0002
150 #define HCI_LM_ENCRYPT  0x0004
151 #define HCI_LM_TRUSTED  0x0008
152 #define HCI_LM_RELIABLE 0x0010
153 #define HCI_LM_SECURE   0x0020
154 
155 
156 #endif // _BTHCI_H_
157 
158