GCC Code Coverage Report


Directory: main/
File: zephyr/hci.h
Date: 2025-10-04 14:03:00
Exec Total Coverage
Lines: 0 5 0.0%
Functions: 0 2 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /* hci.h - Bluetooth Host Control Interface definitions */
2
3 /*
4 * Copyright (c) 2015-2016 Intel Corporation
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_
9 #define ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_
10
11 #ifdef BLUERETRO
12 #include <stdbool.h>
13 #include <string.h>
14 #include "types.h"
15 #else
16 #include <toolchain.h>
17 #include <zephyr/types.h>
18 #include <stdbool.h>
19 #include <string.h>
20 #include <sys/util.h>
21 #include <net/buf.h>
22 #endif /* BLUERETRO */
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /* Company Identifiers (see Bluetooth Assigned Numbers) */
29 #define BT_COMP_ID_LF 0x05f1
30
31 #define BT_ADDR_LE_PUBLIC 0x00
32 #define BT_ADDR_LE_RANDOM 0x01
33 #define BT_ADDR_LE_PUBLIC_ID 0x02
34 #define BT_ADDR_LE_RANDOM_ID 0x03
35
36 /* Special own address types for LL privacy (used in adv & scan parameters) */
37 #define BT_HCI_OWN_ADDR_RPA_OR_PUBLIC 0x02
38 #define BT_HCI_OWN_ADDR_RPA_OR_RANDOM 0x03
39 #define BT_HCI_OWN_ADDR_RPA_MASK 0x02
40
41 /** Bluetooth Device Address */
42 typedef struct {
43 u8_t val[6];
44 } bt_addr_t;
45
46 /** Bluetooth LE Device Address */
47 typedef struct {
48 u8_t type;
49 bt_addr_t a;
50 } bt_addr_le_t;
51
52 #define BT_ADDR_ANY (&(bt_addr_t) { { 0, 0, 0, 0, 0, 0 } })
53 #define BT_ADDR_NONE (&(bt_addr_t) { \
54 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } })
55 #define BT_ADDR_LE_ANY (&(bt_addr_le_t) { 0, { { 0, 0, 0, 0, 0, 0 } } })
56 #define BT_ADDR_LE_NONE (&(bt_addr_le_t) { 0, \
57 { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } } })
58
59 static inline int bt_addr_cmp(const bt_addr_t *a, const bt_addr_t *b)
60 {
61 return memcmp(a, b, sizeof(*a));
62 }
63
64 static inline int bt_addr_le_cmp(const bt_addr_le_t *a, const bt_addr_le_t *b)
65 {
66 return memcmp(a, b, sizeof(*a));
67 }
68
69 static inline void bt_addr_copy(bt_addr_t *dst, const bt_addr_t *src)
70 {
71 memcpy(dst, src, sizeof(*dst));
72 }
73
74 static inline void bt_addr_le_copy(bt_addr_le_t *dst, const bt_addr_le_t *src)
75 {
76 memcpy(dst, src, sizeof(*dst));
77 }
78
79 #define BT_ADDR_IS_RPA(a) (((a)->val[5] & 0xc0) == 0x40)
80 #define BT_ADDR_IS_NRPA(a) (((a)->val[5] & 0xc0) == 0x00)
81 #define BT_ADDR_IS_STATIC(a) (((a)->val[5] & 0xc0) == 0xc0)
82
83 #define BT_ADDR_SET_RPA(a) ((a)->val[5] = (((a)->val[5] & 0x3f) | 0x40))
84 #define BT_ADDR_SET_NRPA(a) ((a)->val[5] &= 0x3f)
85 #define BT_ADDR_SET_STATIC(a) ((a)->val[5] |= 0xc0)
86
87 int bt_addr_le_create_nrpa(bt_addr_le_t *addr);
88 int bt_addr_le_create_static(bt_addr_le_t *addr);
89
90 static inline bool bt_addr_le_is_rpa(const bt_addr_le_t *addr)
91 {
92 if (addr->type != BT_ADDR_LE_RANDOM) {
93 return false;
94 }
95
96 return BT_ADDR_IS_RPA(&addr->a);
97 }
98
99 static inline bool bt_addr_le_is_identity(const bt_addr_le_t *addr)
100 {
101 if (addr->type == BT_ADDR_LE_PUBLIC) {
102 return true;
103 }
104
105 return BT_ADDR_IS_STATIC(&addr->a);
106 }
107
108 #define BT_ENC_KEY_SIZE_MIN 0x07
109 #define BT_ENC_KEY_SIZE_MAX 0x10
110
111 /* HCI Error Codes */
112 #define BT_HCI_ERR_SUCCESS 0x00
113 #define BT_HCI_ERR_UNKNOWN_CMD 0x01
114 #define BT_HCI_ERR_UNKNOWN_CONN_ID 0x02
115 #define BT_HCI_ERR_HW_FAILURE 0x03
116 #define BT_HCI_ERR_PAGE_TIMEOUT 0x04
117 #define BT_HCI_ERR_AUTHENTICATION_FAIL 0x05
118 #define BT_HCI_ERR_PIN_OR_KEY_MISSING 0x06
119 #define BT_HCI_ERR_MEM_CAPACITY_EXCEEDED 0x07
120 #define BT_HCI_ERR_CONN_TIMEOUT 0x08
121 #define BT_HCI_ERR_CONN_LIMIT_EXCEEDED 0x09
122 #define BT_HCI_ERR_SYNC_CONN_LIMIT_EXCEEDED 0x0a
123 #define BT_HCI_ERR_CONN_ALREADY_EXISTS 0x0b
124 #define BT_HCI_ERR_CMD_DISALLOWED 0x0c
125 #define BT_HCI_ERR_INSUFFICIENT_RESOURCES 0x0d
126 #define BT_HCI_ERR_INSUFFICIENT_SECURITY 0x0e
127 #define BT_HCI_ERR_BD_ADDR_UNACCEPTABLE 0x0f
128 #define BT_HCI_ERR_CONN_ACCEPT_TIMEOUT 0x10
129 #define BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL 0x11
130 #define BT_HCI_ERR_INVALID_PARAM 0x12
131 #define BT_HCI_ERR_REMOTE_USER_TERM_CONN 0x13
132 #define BT_HCI_ERR_REMOTE_LOW_RESOURCES 0x14
133 #define BT_HCI_ERR_REMOTE_POWER_OFF 0x15
134 #define BT_HCI_ERR_LOCALHOST_TERM_CONN 0x16
135 #define BT_HCI_ERR_PAIRING_NOT_ALLOWED 0x18
136 #define BT_HCI_ERR_UNSUPP_REMOTE_FEATURE 0x1a
137 #define BT_HCI_ERR_INVALID_LL_PARAM 0x1e
138 #define BT_HCI_ERR_UNSPECIFIED 0x1f
139 #define BT_HCI_ERR_UNSUPP_LL_PARAM_VAL 0x20
140 #define BT_HCI_ERR_LL_RESP_TIMEOUT 0x22
141 #define BT_HCI_ERR_LL_PROC_COLLISION 0x23
142 #define BT_HCI_ERR_INSTANT_PASSED 0x28
143 #define BT_HCI_ERR_PAIRING_NOT_SUPPORTED 0x29
144 #define BT_HCI_ERR_DIFF_TRANS_COLLISION 0x2a
145 #define BT_HCI_ERR_UNACCEPT_CONN_PARAM 0x3b
146 #define BT_HCI_ERR_ADV_TIMEOUT 0x3c
147 #define BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL 0x3d
148 #define BT_HCI_ERR_CONN_FAIL_TO_ESTAB 0x3e
149
150 /* EIR/AD data type definitions */
151 #define BT_DATA_FLAGS 0x01 /* AD flags */
152 #define BT_DATA_UUID16_SOME 0x02 /* 16-bit UUID, more available */
153 #define BT_DATA_UUID16_ALL 0x03 /* 16-bit UUID, all listed */
154 #define BT_DATA_UUID32_SOME 0x04 /* 32-bit UUID, more available */
155 #define BT_DATA_UUID32_ALL 0x05 /* 32-bit UUID, all listed */
156 #define BT_DATA_UUID128_SOME 0x06 /* 128-bit UUID, more available */
157 #define BT_DATA_UUID128_ALL 0x07 /* 128-bit UUID, all listed */
158 #define BT_DATA_NAME_SHORTENED 0x08 /* Shortened name */
159 #define BT_DATA_NAME_COMPLETE 0x09 /* Complete name */
160 #define BT_DATA_TX_POWER 0x0a /* Tx Power */
161 #define BT_DATA_SM_TK_VALUE 0x10 /* Security Manager TK Value */
162 #define BT_DATA_SM_OOB_FLAGS 0x11 /* Security Manager OOB Flags */
163 #define BT_DATA_SOLICIT16 0x14 /* Solicit UUIDs, 16-bit */
164 #define BT_DATA_SOLICIT128 0x15 /* Solicit UUIDs, 128-bit */
165 #define BT_DATA_SVC_DATA16 0x16 /* Service data, 16-bit UUID */
166 #define BT_DATA_GAP_APPEARANCE 0x19 /* GAP appearance */
167 #define BT_DATA_LE_BT_DEVICE_ADDRESS 0x1b /* LE Bluetooth Device Address */
168 #define BT_DATA_LE_ROLE 0x1c /* LE Role */
169 #define BT_DATA_SOLICIT32 0x1f /* Solicit UUIDs, 32-bit */
170 #define BT_DATA_SVC_DATA32 0x20 /* Service data, 32-bit UUID */
171 #define BT_DATA_SVC_DATA128 0x21 /* Service data, 128-bit UUID */
172 #define BT_DATA_LE_SC_CONFIRM_VALUE 0x22 /* LE SC Confirmation Value */
173 #define BT_DATA_LE_SC_RANDOM_VALUE 0x23 /* LE SC Random Value */
174 #define BT_DATA_URI 0x24 /* URI */
175 #define BT_DATA_MESH_PROV 0x29 /* Mesh Provisioning PDU */
176 #define BT_DATA_MESH_MESSAGE 0x2a /* Mesh Networking PDU */
177 #define BT_DATA_MESH_BEACON 0x2b /* Mesh Beacon */
178
179 #define BT_DATA_MANUFACTURER_DATA 0xff /* Manufacturer Specific Data */
180
181 #define BT_LE_AD_LIMITED 0x01 /* Limited Discoverable */
182 #define BT_LE_AD_GENERAL 0x02 /* General Discoverable */
183 #define BT_LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
184
185 #ifdef BLUERETRO
186 #define BT_HCI_H4_TYPE_CMD 0x01
187 #define BT_HCI_H4_TYPE_ACL 0x02
188 #define BT_HCI_H4_TYPE_SCO 0x03
189 #define BT_HCI_H4_TYPE_EVT 0x04
190 struct bt_hci_h4_hdr {
191 u8_t type;
192 } __packed;
193 #define BT_HCI_H4_HDR_SIZE 1
194 #endif /* BLUERETRO */
195
196 struct bt_hci_evt_hdr {
197 u8_t evt;
198 u8_t len;
199 } __packed;
200 #define BT_HCI_EVT_HDR_SIZE 2
201
202 #define BT_ACL_START_NO_FLUSH 0x00
203 #define BT_ACL_CONT 0x01
204 #define BT_ACL_START 0x02
205
206 #define bt_acl_handle(h) ((h) & 0x0fff)
207 #define bt_acl_flags(h) ((h) >> 12)
208 #define bt_acl_handle_pack(h, f) ((h) | ((f) << 12))
209
210 struct bt_hci_acl_hdr {
211 u16_t handle;
212 u16_t len;
213 } __packed;
214 #define BT_HCI_ACL_HDR_SIZE 4
215
216 struct bt_hci_cmd_hdr {
217 u16_t opcode;
218 u8_t param_len;
219 } __packed;
220 #define BT_HCI_CMD_HDR_SIZE 3
221
222 /* Supported Commands */
223 #define BT_CMD_TEST(cmd, octet, bit) (cmd[octet] & BIT(bit))
224 #define BT_CMD_LE_STATES(cmd) BT_CMD_TEST(cmd, 28, 3)
225
226 #define BT_FEAT_TEST(feat, page, octet, bit) (feat[page][octet] & BIT(bit))
227
228 #define BT_FEAT_BREDR(feat) !BT_FEAT_TEST(feat, 0, 4, 5)
229 #define BT_FEAT_LE(feat) BT_FEAT_TEST(feat, 0, 4, 6)
230 #define BT_FEAT_EXT_FEATURES(feat) BT_FEAT_TEST(feat, 0, 7, 7)
231 #define BT_FEAT_HOST_SSP(feat) BT_FEAT_TEST(feat, 1, 0, 0)
232 #define BT_FEAT_SC(feat) BT_FEAT_TEST(feat, 2, 1, 0)
233
234 #define BT_FEAT_LMP_ESCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 3, 7)
235 #define BT_FEAT_HV2_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 4)
236 #define BT_FEAT_HV3_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 5)
237 #define BT_FEAT_EV4_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 0)
238 #define BT_FEAT_EV5_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 1)
239 #define BT_FEAT_2EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 5)
240 #define BT_FEAT_3EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 6)
241 #define BT_FEAT_3SLOT_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 7)
242
243 /* LE features */
244 #define BT_LE_FEAT_BIT_ENC 0
245 #define BT_LE_FEAT_BIT_CONN_PARAM_REQ 1
246 #define BT_LE_FEAT_BIT_EXT_REJ_IND 2
247 #define BT_LE_FEAT_BIT_SLAVE_FEAT_REQ 3
248 #define BT_LE_FEAT_BIT_PING 4
249 #define BT_LE_FEAT_BIT_DLE 5
250 #define BT_LE_FEAT_BIT_PRIVACY 6
251 #define BT_LE_FEAT_BIT_EXT_SCAN 7
252 #define BT_LE_FEAT_BIT_PHY_2M 8
253 #define BT_LE_FEAT_BIT_SMI_TX 9
254 #define BT_LE_FEAT_BIT_SMI_RX 10
255 #define BT_LE_FEAT_BIT_PHY_CODED 11
256 #define BT_LE_FEAT_BIT_ADV_EXT 12
257 #define BT_LE_FEAT_BIT_ADV_PER 13
258 #define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14
259 #define BT_LE_FEAT_BIT_PWR_CLASS_1 15
260 #define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC 16
261
262 #define BT_LE_FEAT_TEST(feat, n) (feat[(n) >> 3] & \
263 BIT((n) & 7))
264
265 #define BT_FEAT_LE_ENCR(feat) BT_LE_FEAT_TEST(feat, \
266 BT_LE_FEAT_BIT_ENC)
267 #define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat) BT_LE_FEAT_TEST(feat, \
268 BT_LE_FEAT_BIT_CONN_PARAM_REQ)
269 #define BT_FEAT_LE_SLAVE_FEATURE_XCHG(feat) BT_LE_FEAT_TEST(feat, \
270 BT_LE_FEAT_BIT_SLAVE_FEAT_REQ)
271 #define BT_FEAT_LE_DLE(feat) BT_LE_FEAT_TEST(feat, \
272 BT_LE_FEAT_BIT_DLE)
273 #define BT_FEAT_LE_PHY_2M(feat) BT_LE_FEAT_TEST(feat, \
274 BT_LE_FEAT_BIT_PHY_2M)
275 #define BT_FEAT_LE_PHY_CODED(feat) BT_LE_FEAT_TEST(feat, \
276 BT_LE_FEAT_BIT_PHY_CODED)
277 #define BT_FEAT_LE_PRIVACY(feat) BT_LE_FEAT_TEST(feat, \
278 BT_LE_FEAT_BIT_PRIVACY)
279
280 /* LE States */
281 #define BT_LE_STATES_SLAVE_CONN_ADV(states) (states & 0x0000004000000000)
282
283 /* Bonding/authentication types */
284 #define BT_HCI_NO_BONDING 0x00
285 #define BT_HCI_NO_BONDING_MITM 0x01
286 #define BT_HCI_DEDICATED_BONDING 0x02
287 #define BT_HCI_DEDICATED_BONDING_MITM 0x03
288 #define BT_HCI_GENERAL_BONDING 0x04
289 #define BT_HCI_GENERAL_BONDING_MITM 0x05
290
291 /*
292 * MITM protection is enabled in SSP authentication requirements octet when
293 * LSB bit is set.
294 */
295 #define BT_MITM 0x01
296
297 /* I/O capabilities */
298 #define BT_IO_DISPLAY_ONLY 0x00
299 #define BT_IO_DISPLAY_YESNO 0x01
300 #define BT_IO_KEYBOARD_ONLY 0x02
301 #define BT_IO_NO_INPUT_OUTPUT 0x03
302
303 /* Defined GAP timers */
304 #define BT_GAP_SCAN_FAST_INTERVAL 0x0060 /* 60 ms */
305 #define BT_GAP_SCAN_FAST_WINDOW 0x0030 /* 30 ms */
306 #define BT_GAP_SCAN_SLOW_INTERVAL_1 0x0800 /* 1.28 s */
307 #define BT_GAP_SCAN_SLOW_WINDOW_1 0x0012 /* 11.25 ms */
308 #define BT_GAP_SCAN_SLOW_INTERVAL_2 0x1000 /* 2.56 s */
309 #define BT_GAP_SCAN_SLOW_WINDOW_2 0x0012 /* 11.25 ms */
310 #define BT_GAP_ADV_FAST_INT_MIN_1 0x0030 /* 30 ms */
311 #define BT_GAP_ADV_FAST_INT_MAX_1 0x0060 /* 60 ms */
312 #define BT_GAP_ADV_FAST_INT_MIN_2 0x00a0 /* 100 ms */
313 #define BT_GAP_ADV_FAST_INT_MAX_2 0x00f0 /* 150 ms */
314 #define BT_GAP_ADV_SLOW_INT_MIN 0x0640 /* 1 s */
315 #define BT_GAP_ADV_SLOW_INT_MAX 0x0780 /* 1.2 s */
316 #define BT_GAP_INIT_CONN_INT_MIN 0x0018 /* 30 ms */
317 #define BT_GAP_INIT_CONN_INT_MAX 0x0028 /* 50 ms */
318
319 /* SCO packet types */
320 #define HCI_PKT_TYPE_HV1 0x0020
321 #define HCI_PKT_TYPE_HV2 0x0040
322 #define HCI_PKT_TYPE_HV3 0x0080
323
324 /* eSCO packet types */
325 #define HCI_PKT_TYPE_ESCO_HV1 0x0001
326 #define HCI_PKT_TYPE_ESCO_HV2 0x0002
327 #define HCI_PKT_TYPE_ESCO_HV3 0x0004
328 #define HCI_PKT_TYPE_ESCO_EV3 0x0008
329 #define HCI_PKT_TYPE_ESCO_EV4 0x0010
330 #define HCI_PKT_TYPE_ESCO_EV5 0x0020
331 #define HCI_PKT_TYPE_ESCO_2EV3 0x0040
332 #define HCI_PKT_TYPE_ESCO_3EV3 0x0080
333 #define HCI_PKT_TYPE_ESCO_2EV5 0x0100
334 #define HCI_PKT_TYPE_ESCO_3EV5 0x0200
335
336
337 #define ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_HV1 | \
338 HCI_PKT_TYPE_ESCO_HV2 | \
339 HCI_PKT_TYPE_ESCO_HV3)
340 #define SCO_PKT_MASK (HCI_PKT_TYPE_HV1 | \
341 HCI_PKT_TYPE_HV2 | \
342 HCI_PKT_TYPE_HV3)
343 #define EDR_ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_2EV3 | \
344 HCI_PKT_TYPE_ESCO_3EV3 | \
345 HCI_PKT_TYPE_ESCO_2EV5 | \
346 HCI_PKT_TYPE_ESCO_3EV5)
347
348 /* HCI BR/EDR link types */
349 #define BT_HCI_SCO 0x00
350 #define BT_HCI_ACL 0x01
351 #define BT_HCI_ESCO 0x02
352
353 /* OpCode Group Fields */
354 #define BT_OGF_LINK_CTRL 0x01
355 #ifdef BLUERETRO
356 #define BT_OGF_LINK_POLICY 0x02
357 #endif /* BLUERETRO */
358 #define BT_OGF_BASEBAND 0x03
359 #define BT_OGF_INFO 0x04
360 #define BT_OGF_STATUS 0x05
361 #ifdef BLUERETRO
362 #define BT_OGF_TEST 0x06
363 #endif /* BLUERETRO */
364 #define BT_OGF_LE 0x08
365 #define BT_OGF_VS 0x3f
366
367 /* Construct OpCode from OGF and OCF */
368 #define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
369
370 /* Invalid opcode */
371 #define BT_OP_NOP 0x0000
372
373 /* Obtain OGF from OpCode */
374 #define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
375 /* Obtain OCF from OpCode */
376 #define BT_OCF(opcode) ((opcode) & BIT_MASK(10))
377
378 #define BT_HCI_OP_INQUIRY BT_OP(BT_OGF_LINK_CTRL, 0x0001)
379 #ifdef BLUERETRO
380 struct bt_hci_cp_inquiry {
381 #else
382 struct bt_hci_op_inquiry {
383 #endif /* BLUERETRO */
384 u8_t lap[3];
385 u8_t length;
386 u8_t num_rsp;
387 } __packed;
388
389 #define BT_HCI_OP_INQUIRY_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0002)
390
391 #ifdef BLUERETRO
392 #define BT_HCI_OP_PERIODIC_INQUIRY BT_OP(BT_OGF_LINK_CTRL, 0x0003)
393 struct bt_hci_cp_periodic_inquiry {
394 u16_t max_period_length;
395 u16_t min_period_length;
396 u8_t lap[3];
397 u8_t length;
398 u8_t num_rsp;
399 } __packed;
400
401 #define BT_HCI_OP_EXIT_PERIODIC_INQUIRY BT_OP(BT_OGF_LINK_CTRL, 0x0004)
402 #endif /* BLUERETRO */
403
404 #define BT_HCI_OP_CONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0005)
405 struct bt_hci_cp_connect {
406 bt_addr_t bdaddr;
407 u16_t packet_type;
408 u8_t pscan_rep_mode;
409 u8_t reserved;
410 u16_t clock_offset;
411 u8_t allow_role_switch;
412 } __packed;
413
414 #define BT_HCI_OP_DISCONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0006)
415 struct bt_hci_cp_disconnect {
416 u16_t handle;
417 u8_t reason;
418 } __packed;
419
420 #define BT_HCI_OP_CONNECT_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0008)
421 struct bt_hci_cp_connect_cancel {
422 bt_addr_t bdaddr;
423 } __packed;
424 struct bt_hci_rp_connect_cancel {
425 u8_t status;
426 bt_addr_t bdaddr;
427 } __packed;
428
429 #define BT_HCI_OP_ACCEPT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0009)
430 struct bt_hci_cp_accept_conn_req {
431 bt_addr_t bdaddr;
432 u8_t role;
433 } __packed;
434
435 #define BT_HCI_OP_SETUP_SYNC_CONN BT_OP(BT_OGF_LINK_CTRL, 0x0028)
436 struct bt_hci_cp_setup_sync_conn {
437 u16_t handle;
438 u32_t tx_bandwidth;
439 u32_t rx_bandwidth;
440 u16_t max_latency;
441 u16_t content_format;
442 u8_t retrans_effort;
443 u16_t pkt_type;
444 } __packed;
445
446 #define BT_HCI_OP_ACCEPT_SYNC_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0029)
447 struct bt_hci_cp_accept_sync_conn_req {
448 bt_addr_t bdaddr;
449 u32_t tx_bandwidth;
450 u32_t rx_bandwidth;
451 u16_t max_latency;
452 u16_t content_format;
453 u8_t retrans_effort;
454 u16_t pkt_type;
455 } __packed;
456
457 #define BT_HCI_OP_REJECT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x000a)
458 struct bt_hci_cp_reject_conn_req {
459 bt_addr_t bdaddr;
460 u8_t reason;
461 } __packed;
462
463 #define BT_HCI_OP_LINK_KEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000b)
464 struct bt_hci_cp_link_key_reply {
465 bt_addr_t bdaddr;
466 u8_t link_key[16];
467 } __packed;
468
469 #define BT_HCI_OP_LINK_KEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000c)
470 struct bt_hci_cp_link_key_neg_reply {
471 bt_addr_t bdaddr;
472 } __packed;
473 #ifdef BLUERETRO
474 struct bt_hci_rp_link_key_neg_reply {
475 u8_t status;
476 bt_addr_t bdaddr;
477 } __packed;
478 #endif /* BLUERETRO */
479
480 #define BT_HCI_OP_PIN_CODE_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000d)
481 struct bt_hci_cp_pin_code_reply {
482 bt_addr_t bdaddr;
483 u8_t pin_len;
484 u8_t pin_code[16];
485 } __packed;
486 struct bt_hci_rp_pin_code_reply {
487 u8_t status;
488 bt_addr_t bdaddr;
489 } __packed;
490
491 #define BT_HCI_OP_PIN_CODE_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000e)
492 struct bt_hci_cp_pin_code_neg_reply {
493 bt_addr_t bdaddr;
494 } __packed;
495 struct bt_hci_rp_pin_code_neg_reply {
496 u8_t status;
497 bt_addr_t bdaddr;
498 } __packed;
499
500 #define BT_HCI_OP_AUTH_REQUESTED BT_OP(BT_OGF_LINK_CTRL, 0x0011)
501 struct bt_hci_cp_auth_requested {
502 u16_t handle;
503 } __packed;
504
505 #define BT_HCI_OP_SET_CONN_ENCRYPT BT_OP(BT_OGF_LINK_CTRL, 0x0013)
506 struct bt_hci_cp_set_conn_encrypt {
507 u16_t handle;
508 u8_t encrypt;
509 } __packed;
510
511 #define BT_HCI_OP_REMOTE_NAME_REQUEST BT_OP(BT_OGF_LINK_CTRL, 0x0019)
512 struct bt_hci_cp_remote_name_request {
513 bt_addr_t bdaddr;
514 u8_t pscan_rep_mode;
515 u8_t reserved;
516 u16_t clock_offset;
517 } __packed;
518
519 #define BT_HCI_OP_REMOTE_NAME_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x001a)
520 struct bt_hci_cp_remote_name_cancel {
521 bt_addr_t bdaddr;
522 } __packed;
523 struct bt_hci_rp_remote_name_cancel {
524 u8_t status;
525 bt_addr_t bdaddr;
526 } __packed;
527
528 #define BT_HCI_OP_READ_REMOTE_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001b)
529 struct bt_hci_cp_read_remote_features {
530 u16_t handle;
531 } __packed;
532
533 #define BT_HCI_OP_READ_REMOTE_EXT_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001c)
534 struct bt_hci_cp_read_remote_ext_features {
535 u16_t handle;
536 u8_t page;
537 } __packed;
538
539 #define BT_HCI_OP_READ_REMOTE_VERSION_INFO BT_OP(BT_OGF_LINK_CTRL, 0x001d)
540 struct bt_hci_cp_read_remote_version_info {
541 u16_t handle;
542 } __packed;
543
544 #define BT_HCI_OP_IO_CAPABILITY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002b)
545 struct bt_hci_cp_io_capability_reply {
546 bt_addr_t bdaddr;
547 u8_t capability;
548 u8_t oob_data;
549 u8_t authentication;
550 } __packed;
551 #ifdef BLUERETRO
552 struct bt_hci_rp_io_capability_reply {
553 u8_t status;
554 bt_addr_t bdaddr;
555 } __packed;
556 #endif
557
558 #define BT_HCI_OP_USER_CONFIRM_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002c)
559 #define BT_HCI_OP_USER_CONFIRM_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002d)
560 struct bt_hci_cp_user_confirm_reply {
561 bt_addr_t bdaddr;
562 } __packed;
563 struct bt_hci_rp_user_confirm_reply {
564 u8_t status;
565 bt_addr_t bdaddr;
566 } __packed;
567
568 #define BT_HCI_OP_USER_PASSKEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002e)
569 struct bt_hci_cp_user_passkey_reply {
570 bt_addr_t bdaddr;
571 u32_t passkey;
572 } __packed;
573
574 #define BT_HCI_OP_USER_PASSKEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002f)
575 struct bt_hci_cp_user_passkey_neg_reply {
576 bt_addr_t bdaddr;
577 } __packed;
578
579 #define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x0034)
580 struct bt_hci_cp_io_capability_neg_reply {
581 bt_addr_t bdaddr;
582 u8_t reason;
583 } __packed;
584
585 #ifdef BLUERETRO
586 #define BT_HCI_OP_SNIFF_MODE BT_OP(BT_OGF_LINK_POLICY, 0x0003)
587 struct bt_hci_cp_sniff_mode {
588 u16_t handle;
589 u16_t max_interval;
590 u16_t min_interval;
591 u16_t attempt;
592 u16_t timeout;
593 } __packed;
594
595 #define BT_HCI_OP_EXIT_SNIFF_MODE BT_OP(BT_OGF_LINK_POLICY, 0x0004)
596 struct bt_hci_cp_exit_sniff_mode {
597 u16_t handle;
598 } __packed;
599
600 #define BT_HCI_OP_SWITCH_ROLE BT_OP(BT_OGF_LINK_POLICY, 0x000B)
601 struct bt_hci_cp_switch_role {
602 bt_addr_t bdaddr;
603 u8_t role;
604 } __packed;
605
606 #define BT_HCI_OP_READ_LINK_POLICY BT_OP(BT_OGF_LINK_POLICY, 0x000C)
607 #define BT_BREDR_ENABLE_ROLE_SW BIT(0)
608 #define BT_BREDR_ENABLE_HOLD_MODE BIT(1)
609 #define BT_BREDR_ENABLE_SNIFF_MODE BIT(2)
610 struct bt_hci_cp_read_link_policy {
611 u16_t handle;
612 } __packed;
613
614 struct bt_hci_rp_read_link_policy {
615 u8_t status;
616 u16_t handle;
617 u16_t link_policy;
618 } __packed;
619
620 #define BT_HCI_OP_WRITE_LINK_POLICY BT_OP(BT_OGF_LINK_POLICY, 0x000D)
621 struct bt_hci_cp_write_link_policy {
622 u16_t handle;
623 u16_t link_policy;
624 } __packed;
625
626 struct bt_hci_rp_write_link_policy {
627 u8_t status;
628 u16_t handle;
629 } __packed;
630
631 #define BT_HCI_OP_READ_DEFAULT_LINK_POLICY BT_OP(BT_OGF_LINK_POLICY, 0x000E)
632 struct bt_hci_rp_read_default_link_policy {
633 u8_t status;
634 u16_t link_policy;
635 } __packed;
636
637 #define BT_HCI_OP_WRITE_DEFAULT_LINK_POLICY BT_OP(BT_OGF_LINK_POLICY, 0x000F)
638 struct bt_hci_cp_write_default_link_policy {
639 u16_t link_policy;
640 } __packed;
641 #endif /* BLUERETRO */
642
643 #define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001)
644 struct bt_hci_cp_set_event_mask {
645 u8_t events[8];
646 } __packed;
647
648 #define BT_HCI_OP_RESET BT_OP(BT_OGF_BASEBAND, 0x0003)
649
650 #ifdef BLUERETRO
651 #define BT_HCI_OP_SET_EVENT_FILTER BT_OP(BT_OGF_BASEBAND, 0x0005)
652 #define BT_BREDR_FILTER_TYPE_CLEAR 0x00
653 #define BT_BREDR_FILTER_TYPE_INQUIRY 0x01
654 #define BT_BREDR_FILTER_TYPE_CONN 0x02
655 #define BT_BDEDR_COND_TYPE_NONE 0x00
656 #define BT_BDEDR_COND_TYPE_CLASS 0x01
657 #define BT_BDEDR_COND_TYPE_BDADDR 0x02
658 #define BT_BREDR_AUTO_OFF 0x01
659 #define BT_BREDR_AUTO_ON_SW_OFF 0x02
660 #define BT_BREDR_AUTO_ON_SW_ON 0x03
661 struct bt_hci_cp_set_event_filter {
662 u8_t filter_type;
663 u8_t condition_type;
664 union {
665 struct {
666 u8_t dev_class[3];
667 u8_t dev_class_mask[3];
668 } inquiry_class;
669 bt_addr_t bdaddr;
670 u8_t auto_accept_flag;
671 struct {
672 u8_t dev_class[3];
673 u8_t dev_class_mask[3];
674 u8_t auto_accept_flag;
675 } conn_class;
676 struct {
677 bt_addr_t bdaddr;
678 u8_t auto_accept_flag;
679 } conn_bdaddr;
680 };
681 } __packed;
682
683 #define BT_HCI_OP_READ_STORED_LINK_KEY BT_OP(BT_OGF_BASEBAND, 0x000d)
684 struct bt_hci_cp_read_stored_link_key {
685 bt_addr_t bdaddr;
686 u8_t read_all_flag;
687 } __packed;
688
689 #define BT_HCI_OP_WRITE_STORED_LINK_KEY BT_OP(BT_OGF_BASEBAND, 0x0011)
690
691 #define BT_HCI_OP_DELETE_STORED_LINK_KEY BT_OP(BT_OGF_BASEBAND, 0x0012)
692 struct bt_hci_cp_delete_stored_link_key {
693 bt_addr_t bdaddr;
694 u8_t delete_all_flag;
695 } __packed;
696
697 #endif
698
699 #define BT_HCI_OP_WRITE_LOCAL_NAME BT_OP(BT_OGF_BASEBAND, 0x0013)
700 #ifdef BLUERETRO
701 #define BT_HCI_OP_READ_LOCAL_NAME BT_OP(BT_OGF_BASEBAND, 0x0014)
702 struct bt_hci_cp_write_local_name {
703 #else
704 struct bt_hci_write_local_name {
705 #endif
706 u8_t local_name[248];
707 } __packed;
708
709 #ifdef BLUERETRO
710 #define BT_HCI_OP_WRITE_CONN_ACCEPT_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0016)
711 struct bt_hci_cp_write_conn_accept_timeout {
712 u16_t conn_accept_timeout;
713 } __packed;
714 #endif
715
716 #define BT_HCI_OP_WRITE_PAGE_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0018)
717 #ifdef BLUERETRO
718 struct bt_hci_cp_write_page_scan_timeout {
719 u16_t timeout;
720 } __packed;
721 #endif
722
723
724 #define BT_HCI_OP_WRITE_SCAN_ENABLE BT_OP(BT_OGF_BASEBAND, 0x001a)
725 #define BT_BREDR_SCAN_DISABLED 0x00
726 #define BT_BREDR_SCAN_INQUIRY 0x01
727 #define BT_BREDR_SCAN_PAGE 0x02
728 #ifdef BLUERETRO
729 struct bt_hci_cp_write_scan_enable {
730 u8_t scan_enable;
731 } __packed;
732
733 #define BT_HCI_OP_READ_PAGE_SCAN_ACTIVITY BT_OP(BT_OGF_BASEBAND, 0x001b)
734
735 #define BT_HCI_OP_WRITE_PAGE_SCAN_ACTIVITY BT_OP(BT_OGF_BASEBAND, 0x001c)
736 struct bt_hci_cp_write_page_scan_activity {
737 u16_t interval;
738 u16_t window;
739 } __packed;
740
741 #define BT_HCI_OP_READ_INQUIRY_SCAN_ACTIVITY BT_OP(BT_OGF_BASEBAND, 0x001d)
742
743 #define BT_HCI_OP_WRITE_INQUIRY_SCAN_ACTIVITY BT_OP(BT_OGF_BASEBAND, 0x001e)
744 struct bt_hci_cp_write_inquiry_scan_activity {
745 u16_t interval;
746 u16_t window;
747 } __packed;
748
749 #define BT_HCI_OP_READ_AUTH_ENABLE BT_OP(BT_OGF_BASEBAND, 0x001f)
750
751 #define BT_HCI_OP_WRITE_AUTH_ENABLE BT_OP(BT_OGF_BASEBAND, 0x0020)
752 struct bt_hci_cp_write_auth_enable {
753 u8_t auth_enable;
754 } __packed;
755
756 #define BT_HCI_OP_READ_CLASS_OF_DEVICE BT_OP(BT_OGF_BASEBAND, 0x0023)
757
758 #define BT_HCI_OP_WRITE_CLASS_OF_DEVICE BT_OP(BT_OGF_BASEBAND, 0x0024)
759 struct bt_hci_cp_write_class_of_device {
760 u8_t dev_class[3];
761 } __packed;
762
763 #define BT_HCI_OP_READ_VOICE_SETTING BT_OP(BT_OGF_BASEBAND, 0x0025)
764
765 #define BT_HCI_OP_WRITE_HOLD_MODE_ACT BT_OP(BT_OGF_BASEBAND, 0x002c)
766 struct bt_hci_cp_write_hold_mode_act {
767 u8_t activity;
768 } __packed;
769 #endif /* BLUERETRO */
770
771 #define BT_TX_POWER_LEVEL_CURRENT 0x00
772 #define BT_TX_POWER_LEVEL_MAX 0x01
773 #define BT_HCI_OP_READ_TX_POWER_LEVEL BT_OP(BT_OGF_BASEBAND, 0x002d)
774 struct bt_hci_cp_read_tx_power_level {
775 u16_t handle;
776 u8_t type;
777 } __packed;
778
779 struct bt_hci_rp_read_tx_power_level {
780 u8_t status;
781 u16_t handle;
782 s8_t tx_power_level;
783 } __packed;
784
785 #define BT_HCI_CTL_TO_HOST_FLOW_DISABLE 0x00
786 #define BT_HCI_CTL_TO_HOST_FLOW_ENABLE 0x01
787 #define BT_HCI_OP_SET_CTL_TO_HOST_FLOW BT_OP(BT_OGF_BASEBAND, 0x0031)
788 struct bt_hci_cp_set_ctl_to_host_flow {
789 u8_t flow_enable;
790 } __packed;
791
792 #define BT_HCI_OP_HOST_BUFFER_SIZE BT_OP(BT_OGF_BASEBAND, 0x0033)
793 struct bt_hci_cp_host_buffer_size {
794 u16_t acl_mtu;
795 u8_t sco_mtu;
796 u16_t acl_pkts;
797 u16_t sco_pkts;
798 } __packed;
799
800 struct bt_hci_handle_count {
801 u16_t handle;
802 u16_t count;
803 } __packed;
804
805 #define BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS BT_OP(BT_OGF_BASEBAND, 0x0035)
806 struct bt_hci_cp_host_num_completed_packets {
807 u8_t num_handles;
808 struct bt_hci_handle_count h[0];
809 } __packed;
810
811 #ifdef BLUERETRO
812 #define BT_HCI_OP_WRITE_LINK_SUPERVISION_TO BT_OP(BT_OGF_BASEBAND, 0x0037)
813 struct bt_hci_cp_write_link_supervision_to {
814 u16_t handle;
815 u16_t timeout;
816 } __packed;
817
818 #define BT_HCI_OP_READ_NUM_SUPPORTED_IAC BT_OP(BT_OGF_BASEBAND, 0x0038)
819 #define BT_HCI_OP_READ_CURRENT_IAC_LAP BT_OP(BT_OGF_BASEBAND, 0x0039)
820 #endif
821
822 #define BT_HCI_OP_WRITE_INQUIRY_MODE BT_OP(BT_OGF_BASEBAND, 0x0045)
823 struct bt_hci_cp_write_inquiry_mode {
824 u8_t mode;
825 } __packed;
826
827 #ifdef BLUERETRO
828 #define BT_HCI_OP_READ_PAGE_SCAN_TYPE BT_OP(BT_OGF_BASEBAND, 0x0046)
829
830 #define BT_HCI_OP_WRITE_PAGE_SCAN_TYPE BT_OP(BT_OGF_BASEBAND, 0x0047)
831 struct bt_hci_cp_write_page_scan_type {
832 u8_t type;
833 } __packed;
834 #endif
835
836 #define BT_HCI_OP_WRITE_SSP_MODE BT_OP(BT_OGF_BASEBAND, 0x0056)
837 struct bt_hci_cp_write_ssp_mode {
838 u8_t mode;
839 } __packed;
840
841 #ifdef BLUERETRO
842 #define BT_HCI_OP_READ_INQUIRY_RSP_TX_PWR_LVL BT_OP(BT_OGF_BASEBAND, 0x0058)
843 #endif
844
845 #define BT_HCI_OP_SET_EVENT_MASK_PAGE_2 BT_OP(BT_OGF_BASEBAND, 0x0063)
846 struct bt_hci_cp_set_event_mask_page_2 {
847 u8_t events_page_2[8];
848 } __packed;
849
850 #define BT_HCI_OP_LE_WRITE_LE_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x006d)
851 struct bt_hci_cp_write_le_host_supp {
852 u8_t le;
853 u8_t simul;
854 } __packed;
855
856 #define BT_HCI_OP_WRITE_SC_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x007a)
857 struct bt_hci_cp_write_sc_host_supp {
858 u8_t sc_support;
859 } __packed;
860
861 #define BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007b)
862 struct bt_hci_cp_read_auth_payload_timeout {
863 u16_t handle;
864 } __packed;
865
866 struct bt_hci_rp_read_auth_payload_timeout {
867 u8_t status;
868 u16_t handle;
869 u16_t auth_payload_timeout;
870 } __packed;
871
872 #define BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007c)
873 struct bt_hci_cp_write_auth_payload_timeout {
874 u16_t handle;
875 u16_t auth_payload_timeout;
876 } __packed;
877
878 struct bt_hci_rp_write_auth_payload_timeout {
879 u8_t status;
880 u16_t handle;
881 } __packed;
882
883 /* HCI version from Assigned Numbers */
884 #define BT_HCI_VERSION_1_0B 0
885 #define BT_HCI_VERSION_1_1 1
886 #define BT_HCI_VERSION_1_2 2
887 #define BT_HCI_VERSION_2_0 3
888 #define BT_HCI_VERSION_2_1 4
889 #define BT_HCI_VERSION_3_0 5
890 #define BT_HCI_VERSION_4_0 6
891 #define BT_HCI_VERSION_4_1 7
892 #define BT_HCI_VERSION_4_2 8
893 #define BT_HCI_VERSION_5_0 9
894 #define BT_HCI_VERSION_5_1 10
895
896 #define BT_HCI_OP_READ_LOCAL_VERSION_INFO BT_OP(BT_OGF_INFO, 0x0001)
897 struct bt_hci_rp_read_local_version_info {
898 u8_t status;
899 u8_t hci_version;
900 u16_t hci_revision;
901 u8_t lmp_version;
902 u16_t manufacturer;
903 u16_t lmp_subversion;
904 } __packed;
905
906 #define BT_HCI_OP_READ_SUPPORTED_COMMANDS BT_OP(BT_OGF_INFO, 0x0002)
907 struct bt_hci_rp_read_supported_commands {
908 u8_t status;
909 u8_t commands[64];
910 } __packed;
911
912 #define BT_HCI_OP_READ_LOCAL_EXT_FEATURES BT_OP(BT_OGF_INFO, 0x0004)
913 struct bt_hci_cp_read_local_ext_features {
914 u8_t page;
915 };
916 struct bt_hci_rp_read_local_ext_features {
917 u8_t status;
918 u8_t page;
919 u8_t max_page;
920 u8_t ext_features[8];
921 } __packed;
922
923 #define BT_HCI_OP_READ_LOCAL_FEATURES BT_OP(BT_OGF_INFO, 0x0003)
924 struct bt_hci_rp_read_local_features {
925 u8_t status;
926 u8_t features[8];
927 } __packed;
928
929 #define BT_HCI_OP_READ_BUFFER_SIZE BT_OP(BT_OGF_INFO, 0x0005)
930 struct bt_hci_rp_read_buffer_size {
931 u8_t status;
932 u16_t acl_max_len;
933 u8_t sco_max_len;
934 u16_t acl_max_num;
935 u16_t sco_max_num;
936 } __packed;
937
938 #define BT_HCI_OP_READ_BD_ADDR BT_OP(BT_OGF_INFO, 0x0009)
939 struct bt_hci_rp_read_bd_addr {
940 u8_t status;
941 bt_addr_t bdaddr;
942 } __packed;
943
944 #ifdef BLUERETRO
945 #define BT_HCI_OP_READ_DATA_BLOCK_SIZE BT_OP(BT_OGF_INFO, 0x000A)
946 #define BT_HCI_OP_READ_LOCAL_CODECS BT_OP(BT_OGF_INFO, 0x000B)
947 #define BT_HCI_OP_READ_LOCAL_SP_OPTIONS BT_OP(BT_OGF_INFO, 0x000C)
948 #endif
949
950 #define BT_HCI_OP_READ_RSSI BT_OP(BT_OGF_STATUS, 0x0005)
951 struct bt_hci_cp_read_rssi {
952 u16_t handle;
953 } __packed;
954 struct bt_hci_rp_read_rssi {
955 u8_t status;
956 u16_t handle;
957 s8_t rssi;
958 } __packed;
959
960 #define BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE BT_OP(BT_OGF_STATUS, 0x0008)
961 struct bt_hci_cp_read_encryption_key_size {
962 u16_t handle;
963 } __packed;
964 struct bt_hci_rp_read_encryption_key_size {
965 u8_t status;
966 u16_t handle;
967 u8_t key_size;
968 } __packed;
969
970 #ifdef BLUERETRO
971 #define BT_HCI_OP_WRITE_SSP_DBG_MODE BT_OP(BT_OGF_TEST, 0x0004)
972 struct bt_hci_cp_write_ssp_dbg_mode {
973 u8_t mode;
974 } __packed;
975 #endif
976
977 /* BLE */
978
979 #define BT_HCI_OP_LE_SET_EVENT_MASK BT_OP(BT_OGF_LE, 0x0001)
980 struct bt_hci_cp_le_set_event_mask {
981 u8_t events[8];
982 } __packed;
983
984 #define BT_HCI_OP_LE_READ_BUFFER_SIZE BT_OP(BT_OGF_LE, 0x0002)
985 struct bt_hci_rp_le_read_buffer_size {
986 u8_t status;
987 u16_t le_max_len;
988 u8_t le_max_num;
989 } __packed;
990
991 #define BT_HCI_OP_LE_READ_LOCAL_FEATURES BT_OP(BT_OGF_LE, 0x0003)
992 struct bt_hci_rp_le_read_local_features {
993 u8_t status;
994 u8_t features[8];
995 } __packed;
996
997 #define BT_HCI_OP_LE_SET_RANDOM_ADDRESS BT_OP(BT_OGF_LE, 0x0005)
998 struct bt_hci_cp_le_set_random_address {
999 bt_addr_t bdaddr;
1000 } __packed;
1001
1002 /* Advertising types */
1003 #define BT_LE_ADV_IND 0x00
1004 #define BT_LE_ADV_DIRECT_IND 0x01
1005 #define BT_LE_ADV_SCAN_IND 0x02
1006 #define BT_LE_ADV_NONCONN_IND 0x03
1007 #define BT_LE_ADV_DIRECT_IND_LOW_DUTY 0x04
1008 /* Needed in advertising reports when getting info about */
1009 #define BT_LE_ADV_SCAN_RSP 0x04
1010
1011 #define BT_HCI_OP_LE_SET_ADV_PARAM BT_OP(BT_OGF_LE, 0x0006)
1012 struct bt_hci_cp_le_set_adv_param {
1013 u16_t min_interval;
1014 u16_t max_interval;
1015 u8_t type;
1016 u8_t own_addr_type;
1017 bt_addr_le_t direct_addr;
1018 u8_t channel_map;
1019 u8_t filter_policy;
1020 } __packed;
1021
1022 #define BT_HCI_OP_LE_READ_ADV_CHAN_TX_POWER BT_OP(BT_OGF_LE, 0x0007)
1023 struct bt_hci_rp_le_read_chan_tx_power {
1024 u8_t status;
1025 s8_t tx_power_level;
1026 } __packed;
1027
1028 #define BT_HCI_OP_LE_SET_ADV_DATA BT_OP(BT_OGF_LE, 0x0008)
1029 struct bt_hci_cp_le_set_adv_data {
1030 u8_t len;
1031 u8_t data[31];
1032 } __packed;
1033
1034 #define BT_HCI_OP_LE_SET_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0009)
1035 struct bt_hci_cp_le_set_scan_rsp_data {
1036 u8_t len;
1037 u8_t data[31];
1038 } __packed;
1039
1040 #define BT_HCI_LE_ADV_DISABLE 0x00
1041 #define BT_HCI_LE_ADV_ENABLE 0x01
1042
1043 #define BT_HCI_OP_LE_SET_ADV_ENABLE BT_OP(BT_OGF_LE, 0x000a)
1044 struct bt_hci_cp_le_set_adv_enable {
1045 u8_t enable;
1046 } __packed;
1047
1048 /* Scan types */
1049 #define BT_HCI_OP_LE_SET_SCAN_PARAM BT_OP(BT_OGF_LE, 0x000b)
1050 #define BT_HCI_LE_SCAN_PASSIVE 0x00
1051 #define BT_HCI_LE_SCAN_ACTIVE 0x01
1052
1053 struct bt_hci_cp_le_set_scan_param {
1054 u8_t scan_type;
1055 u16_t interval;
1056 u16_t window;
1057 u8_t addr_type;
1058 u8_t filter_policy;
1059 } __packed;
1060
1061 #define BT_HCI_OP_LE_SET_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x000c)
1062
1063 #define BT_HCI_LE_SCAN_DISABLE 0x00
1064 #define BT_HCI_LE_SCAN_ENABLE 0x01
1065
1066 #define BT_HCI_LE_SCAN_FILTER_DUP_DISABLE 0x00
1067 #define BT_HCI_LE_SCAN_FILTER_DUP_ENABLE 0x01
1068
1069 struct bt_hci_cp_le_set_scan_enable {
1070 u8_t enable;
1071 u8_t filter_dup;
1072 } __packed;
1073
1074 #define BT_HCI_OP_LE_CREATE_CONN BT_OP(BT_OGF_LE, 0x000d)
1075 struct bt_hci_cp_le_create_conn {
1076 u16_t scan_interval;
1077 u16_t scan_window;
1078 u8_t filter_policy;
1079 bt_addr_le_t peer_addr;
1080 u8_t own_addr_type;
1081 u16_t conn_interval_min;
1082 u16_t conn_interval_max;
1083 u16_t conn_latency;
1084 u16_t supervision_timeout;
1085 u16_t min_ce_len;
1086 u16_t max_ce_len;
1087 } __packed;
1088
1089 #define BT_HCI_OP_LE_CREATE_CONN_CANCEL BT_OP(BT_OGF_LE, 0x000e)
1090
1091 #define BT_HCI_OP_LE_READ_WL_SIZE BT_OP(BT_OGF_LE, 0x000f)
1092 struct bt_hci_rp_le_read_wl_size {
1093 u8_t status;
1094 u8_t wl_size;
1095 } __packed;
1096
1097 #define BT_HCI_OP_LE_CLEAR_WL BT_OP(BT_OGF_LE, 0x0010)
1098
1099 #define BT_HCI_OP_LE_ADD_DEV_TO_WL BT_OP(BT_OGF_LE, 0x0011)
1100 struct bt_hci_cp_le_add_dev_to_wl {
1101 bt_addr_le_t addr;
1102 } __packed;
1103
1104 #define BT_HCI_OP_LE_REM_DEV_FROM_WL BT_OP(BT_OGF_LE, 0x0012)
1105 struct bt_hci_cp_le_rem_dev_from_wl {
1106 bt_addr_le_t addr;
1107 } __packed;
1108
1109 #define BT_HCI_OP_LE_CONN_UPDATE BT_OP(BT_OGF_LE, 0x0013)
1110 struct hci_cp_le_conn_update {
1111 u16_t handle;
1112 u16_t conn_interval_min;
1113 u16_t conn_interval_max;
1114 u16_t conn_latency;
1115 u16_t supervision_timeout;
1116 u16_t min_ce_len;
1117 u16_t max_ce_len;
1118 } __packed;
1119
1120 #define BT_HCI_OP_LE_SET_HOST_CHAN_CLASSIF BT_OP(BT_OGF_LE, 0x0014)
1121 struct bt_hci_cp_le_set_host_chan_classif {
1122 u8_t ch_map[5];
1123 } __packed;
1124
1125 #define BT_HCI_OP_LE_READ_CHAN_MAP BT_OP(BT_OGF_LE, 0x0015)
1126 struct bt_hci_cp_le_read_chan_map {
1127 u16_t handle;
1128 } __packed;
1129 struct bt_hci_rp_le_read_chan_map {
1130 u8_t status;
1131 u16_t handle;
1132 u8_t ch_map[5];
1133 } __packed;
1134
1135 #define BT_HCI_OP_LE_READ_REMOTE_FEATURES BT_OP(BT_OGF_LE, 0x0016)
1136 struct bt_hci_cp_le_read_remote_features {
1137 u16_t handle;
1138 } __packed;
1139
1140 #define BT_HCI_OP_LE_ENCRYPT BT_OP(BT_OGF_LE, 0x0017)
1141 struct bt_hci_cp_le_encrypt {
1142 u8_t key[16];
1143 u8_t plaintext[16];
1144 } __packed;
1145 struct bt_hci_rp_le_encrypt {
1146 u8_t status;
1147 u8_t enc_data[16];
1148 } __packed;
1149
1150 #define BT_HCI_OP_LE_RAND BT_OP(BT_OGF_LE, 0x0018)
1151 struct bt_hci_rp_le_rand {
1152 u8_t status;
1153 u8_t rand[8];
1154 } __packed;
1155
1156 #define BT_HCI_OP_LE_START_ENCRYPTION BT_OP(BT_OGF_LE, 0x0019)
1157 struct bt_hci_cp_le_start_encryption {
1158 u16_t handle;
1159 u64_t rand;
1160 u16_t ediv;
1161 u8_t ltk[16];
1162 } __packed;
1163
1164 #define BT_HCI_OP_LE_LTK_REQ_REPLY BT_OP(BT_OGF_LE, 0x001a)
1165 struct bt_hci_cp_le_ltk_req_reply {
1166 u16_t handle;
1167 u8_t ltk[16];
1168 } __packed;
1169 struct bt_hci_rp_le_ltk_req_reply {
1170 u8_t status;
1171 u16_t handle;
1172 } __packed;
1173
1174 #define BT_HCI_OP_LE_LTK_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x001b)
1175 struct bt_hci_cp_le_ltk_req_neg_reply {
1176 u16_t handle;
1177 } __packed;
1178 struct bt_hci_rp_le_ltk_req_neg_reply {
1179 u8_t status;
1180 u16_t handle;
1181 } __packed;
1182
1183 #define BT_HCI_OP_LE_READ_SUPP_STATES BT_OP(BT_OGF_LE, 0x001c)
1184 struct bt_hci_rp_le_read_supp_states {
1185 u8_t status;
1186 u8_t le_states[8];
1187 } __packed;
1188
1189 #define BT_HCI_OP_LE_RX_TEST BT_OP(BT_OGF_LE, 0x001d)
1190 struct bt_hci_cp_le_rx_test {
1191 u8_t rx_ch;
1192 } __packed;
1193
1194 #define BT_HCI_OP_LE_TX_TEST BT_OP(BT_OGF_LE, 0x001e)
1195 struct bt_hci_cp_le_tx_test {
1196 u8_t tx_ch;
1197 u8_t test_data_len;
1198 u8_t pkt_payload;
1199 } __packed;
1200
1201 #define BT_HCI_OP_LE_TEST_END BT_OP(BT_OGF_LE, 0x001f)
1202 struct bt_hci_rp_le_test_end {
1203 u8_t status;
1204 u16_t rx_pkt_count;
1205 } __packed;
1206
1207 #define BT_HCI_OP_LE_CONN_PARAM_REQ_REPLY BT_OP(BT_OGF_LE, 0x0020)
1208 struct bt_hci_cp_le_conn_param_req_reply {
1209 u16_t handle;
1210 u16_t interval_min;
1211 u16_t interval_max;
1212 u16_t latency;
1213 u16_t timeout;
1214 u16_t min_ce_len;
1215 u16_t max_ce_len;
1216 } __packed;
1217 struct bt_hci_rp_le_conn_param_req_reply {
1218 u8_t status;
1219 u16_t handle;
1220 } __packed;
1221
1222 #define BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x0021)
1223 struct bt_hci_cp_le_conn_param_req_neg_reply {
1224 u16_t handle;
1225 u8_t reason;
1226 } __packed;
1227 struct bt_hci_rp_le_conn_param_req_neg_reply {
1228 u8_t status;
1229 u16_t handle;
1230 } __packed;
1231
1232 #define BT_HCI_OP_LE_SET_DATA_LEN BT_OP(BT_OGF_LE, 0x0022)
1233 struct bt_hci_cp_le_set_data_len {
1234 u16_t handle;
1235 u16_t tx_octets;
1236 u16_t tx_time;
1237 } __packed;
1238 struct bt_hci_rp_le_set_data_len {
1239 u8_t status;
1240 u16_t handle;
1241 } __packed;
1242
1243 #define BT_HCI_OP_LE_READ_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0023)
1244 struct bt_hci_rp_le_read_default_data_len {
1245 u8_t status;
1246 u16_t max_tx_octets;
1247 u16_t max_tx_time;
1248 } __packed;
1249
1250 #define BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0024)
1251 struct bt_hci_cp_le_write_default_data_len {
1252 u16_t max_tx_octets;
1253 u16_t max_tx_time;
1254 } __packed;
1255
1256 #define BT_HCI_OP_LE_P256_PUBLIC_KEY BT_OP(BT_OGF_LE, 0x0025)
1257
1258 #define BT_HCI_OP_LE_GENERATE_DHKEY BT_OP(BT_OGF_LE, 0x0026)
1259 struct bt_hci_cp_le_generate_dhkey {
1260 u8_t key[64];
1261 } __packed;
1262
1263 #define BT_HCI_OP_LE_ADD_DEV_TO_RL BT_OP(BT_OGF_LE, 0x0027)
1264 struct bt_hci_cp_le_add_dev_to_rl {
1265 bt_addr_le_t peer_id_addr;
1266 u8_t peer_irk[16];
1267 u8_t local_irk[16];
1268 } __packed;
1269
1270 #define BT_HCI_OP_LE_REM_DEV_FROM_RL BT_OP(BT_OGF_LE, 0x0028)
1271 struct bt_hci_cp_le_rem_dev_from_rl {
1272 bt_addr_le_t peer_id_addr;
1273 } __packed;
1274
1275 #define BT_HCI_OP_LE_CLEAR_RL BT_OP(BT_OGF_LE, 0x0029)
1276
1277 #define BT_HCI_OP_LE_READ_RL_SIZE BT_OP(BT_OGF_LE, 0x002a)
1278 struct bt_hci_rp_le_read_rl_size {
1279 u8_t status;
1280 u8_t rl_size;
1281 } __packed;
1282
1283 #define BT_HCI_OP_LE_READ_PEER_RPA BT_OP(BT_OGF_LE, 0x002b)
1284 struct bt_hci_cp_le_read_peer_rpa {
1285 bt_addr_le_t peer_id_addr;
1286 } __packed;
1287 struct bt_hci_rp_le_read_peer_rpa {
1288 u8_t status;
1289 bt_addr_t peer_rpa;
1290 } __packed;
1291
1292 #define BT_HCI_OP_LE_READ_LOCAL_RPA BT_OP(BT_OGF_LE, 0x002c)
1293 struct bt_hci_cp_le_read_local_rpa {
1294 bt_addr_le_t peer_id_addr;
1295 } __packed;
1296 struct bt_hci_rp_le_read_local_rpa {
1297 u8_t status;
1298 bt_addr_t local_rpa;
1299 } __packed;
1300
1301 #define BT_HCI_ADDR_RES_DISABLE 0x00
1302 #define BT_HCI_ADDR_RES_ENABLE 0x01
1303
1304 #define BT_HCI_OP_LE_SET_ADDR_RES_ENABLE BT_OP(BT_OGF_LE, 0x002d)
1305 struct bt_hci_cp_le_set_addr_res_enable {
1306 u8_t enable;
1307 } __packed;
1308
1309 #define BT_HCI_OP_LE_SET_RPA_TIMEOUT BT_OP(BT_OGF_LE, 0x002e)
1310 struct bt_hci_cp_le_set_rpa_timeout {
1311 u16_t rpa_timeout;
1312 } __packed;
1313
1314 #define BT_HCI_OP_LE_READ_MAX_DATA_LEN BT_OP(BT_OGF_LE, 0x002f)
1315 struct bt_hci_rp_le_read_max_data_len {
1316 u8_t status;
1317 u16_t max_tx_octets;
1318 u16_t max_tx_time;
1319 u16_t max_rx_octets;
1320 u16_t max_rx_time;
1321 } __packed;
1322
1323 #define BT_HCI_LE_PHY_1M 0x01
1324 #define BT_HCI_LE_PHY_2M 0x02
1325 #define BT_HCI_LE_PHY_CODED 0x03
1326
1327 #define BT_HCI_OP_LE_READ_PHY BT_OP(BT_OGF_LE, 0x0030)
1328 struct bt_hci_cp_le_read_phy {
1329 u16_t handle;
1330 } __packed;
1331 struct bt_hci_rp_le_read_phy {
1332 u8_t status;
1333 u16_t handle;
1334 u8_t tx_phy;
1335 u8_t rx_phy;
1336 } __packed;
1337
1338 #define BT_HCI_LE_PHY_TX_ANY BIT(0)
1339 #define BT_HCI_LE_PHY_RX_ANY BIT(1)
1340
1341 #define BT_HCI_LE_PHY_PREFER_1M BIT(0)
1342 #define BT_HCI_LE_PHY_PREFER_2M BIT(1)
1343 #define BT_HCI_LE_PHY_PREFER_CODED BIT(2)
1344
1345 #define BT_HCI_OP_LE_SET_DEFAULT_PHY BT_OP(BT_OGF_LE, 0x0031)
1346 struct bt_hci_cp_le_set_default_phy {
1347 u8_t all_phys;
1348 u8_t tx_phys;
1349 u8_t rx_phys;
1350 } __packed;
1351
1352 #define BT_HCI_LE_PHY_CODED_ANY 0x00
1353 #define BT_HCI_LE_PHY_CODED_S2 0x01
1354 #define BT_HCI_LE_PHY_CODED_S8 0x02
1355
1356 #define BT_HCI_OP_LE_SET_PHY BT_OP(BT_OGF_LE, 0x0032)
1357 struct bt_hci_cp_le_set_phy {
1358 u16_t handle;
1359 u8_t all_phys;
1360 u8_t tx_phys;
1361 u8_t rx_phys;
1362 u16_t phy_opts;
1363 } __packed;
1364
1365 #define BT_HCI_LE_MOD_INDEX_STANDARD 0x00
1366 #define BT_HCI_LE_MOD_INDEX_STABLE 0x01
1367
1368 #define BT_HCI_OP_LE_ENH_RX_TEST BT_OP(BT_OGF_LE, 0x0033)
1369 struct bt_hci_cp_le_enh_rx_test {
1370 u8_t rx_ch;
1371 u8_t phy;
1372 u8_t mod_index;
1373 } __packed;
1374
1375 /* Extends BT_HCI_LE_PHY */
1376 #define BT_HCI_LE_TX_PHY_CODED_S8 0x03
1377 #define BT_HCI_LE_TX_PHY_CODED_S2 0x04
1378
1379 #define BT_HCI_OP_LE_ENH_TX_TEST BT_OP(BT_OGF_LE, 0x0034)
1380 struct bt_hci_cp_le_enh_tx_test {
1381 u8_t tx_ch;
1382 u8_t test_data_len;
1383 u8_t pkt_payload;
1384 u8_t phy;
1385 } __packed;
1386
1387 #define BT_HCI_OP_LE_SET_ADV_SET_RANDOM_ADDR BT_OP(BT_OGF_LE, 0x0035)
1388 struct bt_hci_cp_le_set_adv_set_random_addr {
1389 u8_t handle;
1390 bt_addr_t bdaddr;
1391 } __packed;
1392
1393 #define BT_HCI_LE_ADV_PROP_CONN BIT(0)
1394 #define BT_HCI_LE_ADV_PROP_SCAN BIT(1)
1395 #define BT_HCI_LE_ADV_PROP_DIRECT BIT(2)
1396 #define BT_HCI_LE_ADV_PROP_HI_DC_CONN BIT(3)
1397 #define BT_HCI_LE_ADV_PROP_LEGACY BIT(4)
1398 #define BT_HCI_LE_ADV_PROP_ANON BIT(5)
1399 #define BT_HCI_LE_ADV_PROP_TX_POWER BIT(6)
1400
1401 #define BT_HCI_OP_LE_SET_EXT_ADV_PARAM BT_OP(BT_OGF_LE, 0x0036)
1402 struct bt_hci_cp_le_set_ext_adv_param {
1403 u8_t handle;
1404 u16_t props;
1405 u8_t prim_min_interval[3];
1406 u8_t prim_max_interval[3];
1407 u8_t prim_channel_map;
1408 u8_t own_addr_type;
1409 bt_addr_le_t peer_addr;
1410 u8_t filter_policy;
1411 s8_t tx_power;
1412 u8_t prim_adv_phy;
1413 u8_t sec_adv_max_skip;
1414 u8_t sec_adv_phy;
1415 u8_t sid;
1416 u8_t scan_req_notify_enable;
1417 } __packed;
1418 struct bt_hci_rp_le_set_ext_adv_param {
1419 u8_t status;
1420 s8_t tx_power;
1421 } __packed;
1422
1423 #define BT_HCI_LE_EXT_ADV_OP_INTERM_FRAG 0x00
1424 #define BT_HCI_LE_EXT_ADV_OP_FIRST_FRAG 0x01
1425 #define BT_HCI_LE_EXT_ADV_OP_LAST_FRAG 0x02
1426 #define BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA 0x03
1427 #define BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA 0x04
1428
1429 #define BT_HCI_LE_EXT_ADV_FRAG_ENABLED 0x00
1430 #define BT_HCI_LE_EXT_ADV_FRAG_DISABLED 0x01
1431
1432 #define BT_HCI_OP_LE_SET_EXT_ADV_DATA BT_OP(BT_OGF_LE, 0x0037)
1433 struct bt_hci_cp_le_set_ext_adv_data {
1434 u8_t handle;
1435 u8_t op;
1436 u8_t frag_pref;
1437 u8_t len;
1438 u8_t data[251];
1439 } __packed;
1440
1441 #define BT_HCI_OP_LE_SET_EXT_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0038)
1442 struct bt_hci_cp_le_set_ext_scan_rsp_data {
1443 u8_t handle;
1444 u8_t op;
1445 u8_t frag_pref;
1446 u8_t len;
1447 u8_t data[251];
1448 } __packed;
1449
1450 #define BT_HCI_OP_LE_SET_EXT_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0039)
1451 struct bt_hci_ext_adv_set {
1452 u8_t handle;
1453 u16_t duration;
1454 u8_t max_ext_adv_evts;
1455 } __packed;
1456
1457 struct bt_hci_cp_le_set_ext_adv_enable {
1458 u8_t enable;
1459 u8_t set_num;
1460 struct bt_hci_ext_adv_set s[0];
1461 } __packed;
1462
1463 #define BT_HCI_OP_LE_READ_MAX_ADV_DATA_LEN BT_OP(BT_OGF_LE, 0x003a)
1464 struct bt_hci_rp_le_read_max_adv_data_len {
1465 u8_t status;
1466 u16_t max_adv_data_len;
1467 } __packed;
1468
1469 #define BT_HCI_OP_LE_READ_NUM_ADV_SETS BT_OP(BT_OGF_LE, 0x003b)
1470 struct bt_hci_rp_le_read_num_adv_sets {
1471 u8_t status;
1472 u8_t num_sets;
1473 } __packed;
1474
1475 #define BT_HCI_OP_LE_REMOVE_ADV_SET BT_OP(BT_OGF_LE, 0x003c)
1476 struct bt_hci_cp_le_remove_adv_set {
1477 u8_t handle;
1478 } __packed;
1479
1480 #define BT_HCI_OP_CLEAR_ADV_SETS BT_OP(BT_OGF_LE, 0x003d)
1481
1482 #define BT_HCI_OP_LE_SET_PER_ADV_PARAM BT_OP(BT_OGF_LE, 0x003e)
1483 struct bt_hci_cp_le_set_per_adv_param {
1484 u8_t handle;
1485 u16_t min_interval;
1486 u16_t max_interval;
1487 u16_t props;
1488 } __packed;
1489
1490 #define BT_HCI_OP_LE_SET_PER_ADV_DATA BT_OP(BT_OGF_LE, 0x003f)
1491 struct bt_hci_cp_le_set_per_adv_data {
1492 u8_t handle;
1493 u8_t op;
1494 u8_t len;
1495 u8_t data[251];
1496 } __packed;
1497
1498 #define BT_HCI_OP_LE_SET_PER_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0040)
1499 struct bt_hci_cp_le_set_per_adv_enable {
1500 u8_t enable;
1501 u8_t handle;
1502 } __packed;
1503
1504 #define BT_HCI_OP_LE_SET_EXT_SCAN_PARAM BT_OP(BT_OGF_LE, 0x0041)
1505 struct bt_hci_ext_scan_phy {
1506 u8_t type;
1507 u16_t interval;
1508 u16_t window;
1509 } __packed;
1510
1511 #define BT_HCI_LE_EXT_SCAN_PHY_1M BIT(0)
1512 #define BT_HCI_LE_EXT_SCAN_PHY_2M BIT(1)
1513 #define BT_HCI_LE_EXT_SCAN_PHY_CODED BIT(2)
1514
1515 struct bt_hci_cp_le_set_ext_scan_param {
1516 u8_t own_addr_type;
1517 u8_t filter_policy;
1518 u8_t phys;
1519 struct bt_hci_ext_scan_phy p[0];
1520 } __packed;
1521
1522 /* Extends BT_HCI_LE_SCAN_FILTER_DUP */
1523 #define BT_HCI_LE_EXT_SCAN_FILTER_DUP_ENABLE_RESET 0x02
1524
1525 #define BT_HCI_OP_LE_SET_EXT_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x0042)
1526 struct bt_hci_cp_le_set_ext_scan_enable {
1527 u8_t enable;
1528 u8_t filter_dup;
1529 u16_t duration;
1530 u16_t period;
1531 } __packed;
1532
1533 #define BT_HCI_OP_LE_EXT_CREATE_CONN BT_OP(BT_OGF_LE, 0x0043)
1534 struct bt_hci_ext_conn_phy {
1535 u16_t interval;
1536 u16_t window;
1537 u16_t conn_interval_min;
1538 u16_t conn_interval_max;
1539 u16_t conn_latency;
1540 u16_t supervision_timeout;
1541 u16_t min_ce_len;
1542 u16_t max_ce_len;
1543 } __packed;
1544
1545 struct bt_hci_cp_le_ext_create_conn {
1546 u8_t filter_policy;
1547 u8_t own_addr_type;
1548 bt_addr_le_t peer_addr;
1549 u8_t phys;
1550 struct bt_hci_ext_conn_phy p[0];
1551 } __packed;
1552
1553 #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC BT_OP(BT_OGF_LE, 0x0044)
1554 struct bt_hci_cp_le_per_adv_create_sync {
1555 u8_t filter_policy;
1556 u8_t sid;
1557 bt_addr_le_t addr;
1558 u16_t skip;
1559 u16_t sync_timeout;
1560 u8_t unused;
1561 } __packed;
1562
1563 #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC_CANCEL BT_OP(BT_OGF_LE, 0x0045)
1564
1565 #define BT_HCI_OP_LE_PER_ADV_TERMINATE_SYNC BT_OP(BT_OGF_LE, 0x0046)
1566 struct bt_hci_cp_le_per_adv_terminate_sync {
1567 u16_t handle;
1568 } __packed;
1569
1570 #define BT_HCI_OP_LE_ADD_DEV_TO_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0047)
1571 struct bt_hci_cp_le_add_dev_to_per_adv_list {
1572 bt_addr_le_t addr;
1573 u8_t sid;
1574 } __packed;
1575
1576 #define BT_HCI_OP_LE_REM_DEV_FROM_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0048)
1577 struct bt_hci_cp_le_rem_dev_from_per_adv_list {
1578 bt_addr_le_t addr;
1579 u8_t sid;
1580 } __packed;
1581
1582 #define BT_HCI_OP_LE_CLEAR_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0049)
1583
1584 #define BT_HCI_OP_LE_READ_PER_ADV_LIST_SIZE BT_OP(BT_OGF_LE, 0x004a)
1585 struct bt_hci_rp_le_read_per_adv_list_size {
1586 u8_t status;
1587 u8_t list_size;
1588 } __packed;
1589
1590 #define BT_HCI_OP_LE_READ_TX_POWER BT_OP(BT_OGF_LE, 0x004b)
1591 struct bt_hci_rp_le_read_tx_power {
1592 u8_t status;
1593 s8_t min_tx_power;
1594 s8_t max_tx_power;
1595 } __packed;
1596
1597 #define BT_HCI_OP_LE_READ_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004c)
1598 struct bt_hci_rp_le_read_rf_path_comp {
1599 u8_t status;
1600 s16_t tx_path_comp;
1601 s16_t rx_path_comp;
1602 } __packed;
1603
1604 #define BT_HCI_OP_LE_WRITE_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004d)
1605 struct bt_hci_cp_le_write_rf_path_comp {
1606 s16_t tx_path_comp;
1607 s16_t rx_path_comp;
1608 } __packed;
1609
1610 #define BT_HCI_LE_PRIVACY_MODE_NETWORK 0x00
1611 #define BT_HCI_LE_PRIVACY_MODE_DEVICE 0x01
1612
1613 #define BT_HCI_OP_LE_SET_PRIVACY_MODE BT_OP(BT_OGF_LE, 0x004e)
1614 struct bt_hci_cp_le_set_privacy_mode {
1615 bt_addr_le_t id_addr;
1616 u8_t mode;
1617 } __packed;
1618
1619 /* Event definitions */
1620
1621 #define BT_HCI_EVT_UNKNOWN 0x00
1622 #define BT_HCI_EVT_VENDOR 0xff
1623
1624 #define BT_HCI_EVT_INQUIRY_COMPLETE 0x01
1625 struct bt_hci_evt_inquiry_complete {
1626 u8_t status;
1627 } __packed;
1628
1629 #ifdef BLUERETRO
1630 #define BT_HCI_EVT_INQUIRY_RESULT 0x02
1631 struct bt_hci_evt_inquiry_result {
1632 u8_t num_reports;
1633 bt_addr_t *addr;
1634 u8_t *pscan_rep_mode;
1635 u8_t *reserved;
1636 u8_t **cod;
1637 u16_t *clock_offset;
1638 } __packed;
1639 #endif /* BLUERETRO */
1640
1641 #define BT_HCI_EVT_CONN_COMPLETE 0x03
1642 struct bt_hci_evt_conn_complete {
1643 u8_t status;
1644 u16_t handle;
1645 bt_addr_t bdaddr;
1646 u8_t link_type;
1647 u8_t encr_enabled;
1648 } __packed;
1649
1650 #define BT_HCI_EVT_CONN_REQUEST 0x04
1651 struct bt_hci_evt_conn_request {
1652 bt_addr_t bdaddr;
1653 u8_t dev_class[3];
1654 u8_t link_type;
1655 } __packed;
1656
1657 #define BT_HCI_EVT_DISCONN_COMPLETE 0x05
1658 struct bt_hci_evt_disconn_complete {
1659 u8_t status;
1660 u16_t handle;
1661 u8_t reason;
1662 } __packed;
1663
1664 #define BT_HCI_EVT_AUTH_COMPLETE 0x06
1665 struct bt_hci_evt_auth_complete {
1666 u8_t status;
1667 u16_t handle;
1668 } __packed;
1669
1670 #define BT_HCI_EVT_REMOTE_NAME_REQ_COMPLETE 0x07
1671 struct bt_hci_evt_remote_name_req_complete {
1672 u8_t status;
1673 bt_addr_t bdaddr;
1674 u8_t name[248];
1675 } __packed;
1676
1677 #define BT_HCI_EVT_ENCRYPT_CHANGE 0x08
1678 struct bt_hci_evt_encrypt_change {
1679 u8_t status;
1680 u16_t handle;
1681 u8_t encrypt;
1682 } __packed;
1683
1684 #define BT_HCI_EVT_REMOTE_FEATURES 0x0b
1685 struct bt_hci_evt_remote_features {
1686 u8_t status;
1687 u16_t handle;
1688 u8_t features[8];
1689 } __packed;
1690
1691 #define BT_HCI_EVT_REMOTE_VERSION_INFO 0x0c
1692 struct bt_hci_evt_remote_version_info {
1693 u8_t status;
1694 u16_t handle;
1695 u8_t version;
1696 u16_t manufacturer;
1697 u16_t subversion;
1698 } __packed;
1699
1700 #define BT_HCI_EVT_CMD_COMPLETE 0x0e
1701 struct bt_hci_evt_cmd_complete {
1702 u8_t ncmd;
1703 u16_t opcode;
1704 } __packed;
1705
1706 struct bt_hci_evt_cc_status {
1707 u8_t status;
1708 } __packed;
1709
1710 #define BT_HCI_EVT_CMD_STATUS 0x0f
1711 struct bt_hci_evt_cmd_status {
1712 u8_t status;
1713 u8_t ncmd;
1714 u16_t opcode;
1715 } __packed;
1716
1717 #define BT_HCI_EVT_ROLE_CHANGE 0x12
1718 struct bt_hci_evt_role_change {
1719 u8_t status;
1720 bt_addr_t bdaddr;
1721 u8_t role;
1722 } __packed;
1723
1724 #define BT_HCI_EVT_NUM_COMPLETED_PACKETS 0x13
1725 struct bt_hci_evt_num_completed_packets {
1726 u8_t num_handles;
1727 struct bt_hci_handle_count h[0];
1728 } __packed;
1729
1730 #ifdef BLUERETRO
1731
1732 /* BT Modes */
1733 #define BT_MODE_ACTIVE 0x00
1734 #define BT_MODE_HOLD 0x01
1735 #define BT_MODE_SNIFF 0x02
1736
1737 #define BT_HCI_EVT_MODE_CHANGE 0x14
1738 struct bt_hci_evt_mode_change {
1739 u8_t status;
1740 u16_t handle;
1741 u8_t mode;
1742 u16_t interval;
1743 } __packed;
1744 #endif /* BLUERETRO */
1745
1746 #define BT_HCI_EVT_PIN_CODE_REQ 0x16
1747 struct bt_hci_evt_pin_code_req {
1748 bt_addr_t bdaddr;
1749 } __packed;
1750
1751 #define BT_HCI_EVT_LINK_KEY_REQ 0x17
1752 struct bt_hci_evt_link_key_req {
1753 bt_addr_t bdaddr;
1754 } __packed;
1755
1756 /* Link Key types */
1757 #define BT_LK_COMBINATION 0x00
1758 #define BT_LK_LOCAL_UNIT 0x01
1759 #define BT_LK_REMOTE_UNIT 0x02
1760 #define BT_LK_DEBUG_COMBINATION 0x03
1761 #define BT_LK_UNAUTH_COMBINATION_P192 0x04
1762 #define BT_LK_AUTH_COMBINATION_P192 0x05
1763 #define BT_LK_CHANGED_COMBINATION 0x06
1764 #define BT_LK_UNAUTH_COMBINATION_P256 0x07
1765 #define BT_LK_AUTH_COMBINATION_P256 0x08
1766
1767 #define BT_HCI_EVT_LINK_KEY_NOTIFY 0x18
1768 struct bt_hci_evt_link_key_notify {
1769 bt_addr_t bdaddr;
1770 u8_t link_key[16];
1771 u8_t key_type;
1772 } __packed;
1773
1774 /* Overflow link types */
1775 #define BT_OVERFLOW_LINK_SYNCH 0x00
1776 #define BT_OVERFLOW_LINK_ACL 0x01
1777
1778 #define BT_HCI_EVT_DATA_BUF_OVERFLOW 0x1a
1779 struct bt_hci_evt_data_buf_overflow {
1780 u8_t link_type;
1781 } __packed;
1782
1783 #define BT_HCI_EVT_INQUIRY_RESULT_WITH_RSSI 0x22
1784 struct bt_hci_evt_inquiry_result_with_rssi {
1785 bt_addr_t addr;
1786 u8_t pscan_rep_mode;
1787 u8_t reserved;
1788 u8_t cod[3];
1789 u16_t clock_offset;
1790 s8_t rssi;
1791 } __packed;
1792
1793 #define BT_HCI_EVT_REMOTE_EXT_FEATURES 0x23
1794 struct bt_hci_evt_remote_ext_features {
1795 u8_t status;
1796 u16_t handle;
1797 u8_t page;
1798 u8_t max_page;
1799 u8_t features[8];
1800 } __packed;
1801
1802 #define BT_HCI_EVT_SYNC_CONN_COMPLETE 0x2c
1803 struct bt_hci_evt_sync_conn_complete {
1804 u8_t status;
1805 u16_t handle;
1806 bt_addr_t bdaddr;
1807 u8_t link_type;
1808 u8_t tx_interval;
1809 u8_t retansmission_window;
1810 u16_t rx_pkt_length;
1811 u16_t tx_pkt_length;
1812 u8_t air_mode;
1813 } __packed;
1814
1815 #define BT_HCI_EVT_EXTENDED_INQUIRY_RESULT 0x2f
1816 struct bt_hci_evt_extended_inquiry_result {
1817 u8_t num_reports;
1818 bt_addr_t addr;
1819 u8_t pscan_rep_mode;
1820 u8_t reserved;
1821 u8_t cod[3];
1822 u16_t clock_offset;
1823 s8_t rssi;
1824 u8_t eir[240];
1825 } __packed;
1826
1827 #define BT_HCI_EVT_ENCRYPT_KEY_REFRESH_COMPLETE 0x30
1828 struct bt_hci_evt_encrypt_key_refresh_complete {
1829 u8_t status;
1830 u16_t handle;
1831 } __packed;
1832
1833 #define BT_HCI_EVT_IO_CAPA_REQ 0x31
1834 struct bt_hci_evt_io_capa_req {
1835 bt_addr_t bdaddr;
1836 } __packed;
1837
1838 #define BT_HCI_EVT_IO_CAPA_RESP 0x32
1839 struct bt_hci_evt_io_capa_resp {
1840 bt_addr_t bdaddr;
1841 u8_t capability;
1842 u8_t oob_data;
1843 u8_t authentication;
1844 } __packed;
1845
1846 #define BT_HCI_EVT_USER_CONFIRM_REQ 0x33
1847 struct bt_hci_evt_user_confirm_req {
1848 bt_addr_t bdaddr;
1849 u32_t passkey;
1850 } __packed;
1851
1852 #define BT_HCI_EVT_USER_PASSKEY_REQ 0x34
1853 struct bt_hci_evt_user_passkey_req {
1854 bt_addr_t bdaddr;
1855 } __packed;
1856
1857 #define BT_HCI_EVT_SSP_COMPLETE 0x36
1858 struct bt_hci_evt_ssp_complete {
1859 u8_t status;
1860 bt_addr_t bdaddr;
1861 } __packed;
1862
1863 #define BT_HCI_EVT_USER_PASSKEY_NOTIFY 0x3b
1864 struct bt_hci_evt_user_passkey_notify {
1865 bt_addr_t bdaddr;
1866 u32_t passkey;
1867 } __packed;
1868
1869 #define BT_HCI_EVT_LE_META_EVENT 0x3e
1870 struct bt_hci_evt_le_meta_event {
1871 u8_t subevent;
1872 } __packed;
1873
1874 #define BT_HCI_EVT_AUTH_PAYLOAD_TIMEOUT_EXP 0x57
1875 struct bt_hci_evt_auth_payload_timeout_exp {
1876 u16_t handle;
1877 } __packed;
1878
1879 #define BT_HCI_ROLE_MASTER 0x00
1880 #define BT_HCI_ROLE_SLAVE 0x01
1881
1882 #define BT_HCI_EVT_LE_CONN_COMPLETE 0x01
1883 struct bt_hci_evt_le_conn_complete {
1884 u8_t status;
1885 u16_t handle;
1886 u8_t role;
1887 bt_addr_le_t peer_addr;
1888 u16_t interval;
1889 u16_t latency;
1890 u16_t supv_timeout;
1891 u8_t clock_accuracy;
1892 } __packed;
1893
1894 #define BT_HCI_EVT_LE_ADVERTISING_REPORT 0x02
1895 struct bt_hci_evt_le_advertising_info {
1896 u8_t evt_type;
1897 bt_addr_le_t addr;
1898 u8_t length;
1899 u8_t data[0];
1900 } __packed;
1901 struct bt_hci_evt_le_advertising_report {
1902 u8_t num_reports;
1903 struct bt_hci_evt_le_advertising_info adv_info[0];
1904 } __packed;
1905
1906 #define BT_HCI_EVT_LE_CONN_UPDATE_COMPLETE 0x03
1907 struct bt_hci_evt_le_conn_update_complete {
1908 u8_t status;
1909 u16_t handle;
1910 u16_t interval;
1911 u16_t latency;
1912 u16_t supv_timeout;
1913 } __packed;
1914
1915 #define BT_HCI_EV_LE_REMOTE_FEAT_COMPLETE 0x04
1916 struct bt_hci_evt_le_remote_feat_complete {
1917 u8_t status;
1918 u16_t handle;
1919 u8_t features[8];
1920 } __packed;
1921
1922 #define BT_HCI_EVT_LE_LTK_REQUEST 0x05
1923 struct bt_hci_evt_le_ltk_request {
1924 u16_t handle;
1925 u64_t rand;
1926 u16_t ediv;
1927 } __packed;
1928
1929 #define BT_HCI_EVT_LE_CONN_PARAM_REQ 0x06
1930 struct bt_hci_evt_le_conn_param_req {
1931 u16_t handle;
1932 u16_t interval_min;
1933 u16_t interval_max;
1934 u16_t latency;
1935 u16_t timeout;
1936 } __packed;
1937
1938 #define BT_HCI_EVT_LE_DATA_LEN_CHANGE 0x07
1939 struct bt_hci_evt_le_data_len_change {
1940 u16_t handle;
1941 u16_t max_tx_octets;
1942 u16_t max_tx_time;
1943 u16_t max_rx_octets;
1944 u16_t max_rx_time;
1945 } __packed;
1946
1947 #define BT_HCI_EVT_LE_P256_PUBLIC_KEY_COMPLETE 0x08
1948 struct bt_hci_evt_le_p256_public_key_complete {
1949 u8_t status;
1950 u8_t key[64];
1951 } __packed;
1952
1953 #define BT_HCI_EVT_LE_GENERATE_DHKEY_COMPLETE 0x09
1954 struct bt_hci_evt_le_generate_dhkey_complete {
1955 u8_t status;
1956 u8_t dhkey[32];
1957 } __packed;
1958
1959 #define BT_HCI_EVT_LE_ENH_CONN_COMPLETE 0x0a
1960 struct bt_hci_evt_le_enh_conn_complete {
1961 u8_t status;
1962 u16_t handle;
1963 u8_t role;
1964 bt_addr_le_t peer_addr;
1965 bt_addr_t local_rpa;
1966 bt_addr_t peer_rpa;
1967 u16_t interval;
1968 u16_t latency;
1969 u16_t supv_timeout;
1970 u8_t clock_accuracy;
1971 } __packed;
1972
1973 #define BT_HCI_EVT_LE_DIRECT_ADV_REPORT 0x0b
1974 struct bt_hci_evt_le_direct_adv_info {
1975 u8_t evt_type;
1976 bt_addr_le_t addr;
1977 bt_addr_le_t dir_addr;
1978 s8_t rssi;
1979 } __packed;
1980 struct bt_hci_evt_le_direct_adv_report {
1981 u8_t num_reports;
1982 struct bt_hci_evt_le_direct_adv_info direct_adv_info[0];
1983 } __packed;
1984
1985 #define BT_HCI_EVT_LE_PHY_UPDATE_COMPLETE 0x0c
1986 struct bt_hci_evt_le_phy_update_complete {
1987 u8_t status;
1988 u16_t handle;
1989 u8_t tx_phy;
1990 u8_t rx_phy;
1991 } __packed;
1992
1993 #define BT_HCI_EVT_LE_EXT_ADVERTISING_REPORT 0x0d
1994 struct bt_hci_evt_le_ext_advertising_info {
1995 u8_t evt_type;
1996 bt_addr_le_t addr;
1997 u8_t prim_phy;
1998 u8_t sec_phy;
1999 u8_t sid;
2000 s8_t tx_power;
2001 s8_t rssi;
2002 u16_t interval;
2003 bt_addr_le_t direct_addr;
2004 u8_t length;
2005 u8_t data[0];
2006 } __packed;
2007 struct bt_hci_evt_le_ext_advertising_report {
2008 u8_t num_reports;
2009 struct bt_hci_evt_le_ext_advertising_info adv_info[0];
2010 } __packed;
2011
2012 #define BT_HCI_EVT_LE_PER_ADV_SYNC_ESTABLISHED 0x0e
2013 struct bt_hci_evt_le_per_adv_sync_established {
2014 u8_t status;
2015 u16_t handle;
2016 u8_t sid;
2017 bt_addr_le_t adv_addr;
2018 u8_t phy;
2019 u16_t interval;
2020 u8_t clock_accuracy;
2021 } __packed;
2022
2023 #define BT_HCI_EVT_LE_PER_ADVERTISING_REPORT 0x0f
2024 struct bt_hci_evt_le_per_advertising_report {
2025 u16_t handle;
2026 s8_t tx_power;
2027 s8_t rssi;
2028 u8_t unused;
2029 u8_t data_status;
2030 u8_t length;
2031 u8_t data[0];
2032 } __packed;
2033
2034 #define BT_HCI_EVT_LE_PER_ADV_SYNC_LOST 0x10
2035 struct bt_hci_evt_le_per_adv_sync_lost {
2036 u16_t handle;
2037 } __packed;
2038
2039 #define BT_HCI_EVT_LE_SCAN_TIMEOUT 0x11
2040
2041 #define BT_HCI_EVT_LE_ADV_SET_TERMINATED 0x12
2042 struct bt_hci_evt_le_per_adv_set_terminated {
2043 u8_t status;
2044 u8_t adv_handle;
2045 u16_t conn_handle;
2046 u8_t num_completed_ext_adv_evts;
2047 } __packed;
2048
2049 #define BT_HCI_EVT_LE_SCAN_REQ_RECEIVED 0x13
2050 struct bt_hci_evt_le_scan_req_received {
2051 u8_t handle;
2052 bt_addr_le_t addr;
2053 } __packed;
2054
2055 #define BT_HCI_LE_CHAN_SEL_ALGO_1 0x00
2056 #define BT_HCI_LE_CHAN_SEL_ALGO_2 0x01
2057
2058 #define BT_HCI_EVT_LE_CHAN_SEL_ALGO 0x14
2059 struct bt_hci_evt_le_chan_sel_algo {
2060 u16_t handle;
2061 u8_t chan_sel_algo;
2062 } __packed;
2063
2064 /* Event mask bits */
2065
2066 #define BT_EVT_BIT(n) (1ULL << (n))
2067
2068 #define BT_EVT_MASK_INQUIRY_COMPLETE BT_EVT_BIT(0)
2069 #define BT_EVT_MASK_CONN_COMPLETE BT_EVT_BIT(2)
2070 #define BT_EVT_MASK_CONN_REQUEST BT_EVT_BIT(3)
2071 #define BT_EVT_MASK_DISCONN_COMPLETE BT_EVT_BIT(4)
2072 #define BT_EVT_MASK_AUTH_COMPLETE BT_EVT_BIT(5)
2073 #define BT_EVT_MASK_REMOTE_NAME_REQ_COMPLETE BT_EVT_BIT(6)
2074 #define BT_EVT_MASK_ENCRYPT_CHANGE BT_EVT_BIT(7)
2075 #define BT_EVT_MASK_REMOTE_FEATURES BT_EVT_BIT(10)
2076 #define BT_EVT_MASK_REMOTE_VERSION_INFO BT_EVT_BIT(11)
2077 #define BT_EVT_MASK_HARDWARE_ERROR BT_EVT_BIT(15)
2078 #define BT_EVT_MASK_ROLE_CHANGE BT_EVT_BIT(17)
2079 #define BT_EVT_MASK_PIN_CODE_REQ BT_EVT_BIT(21)
2080 #define BT_EVT_MASK_LINK_KEY_REQ BT_EVT_BIT(22)
2081 #define BT_EVT_MASK_LINK_KEY_NOTIFY BT_EVT_BIT(23)
2082 #define BT_EVT_MASK_DATA_BUFFER_OVERFLOW BT_EVT_BIT(25)
2083 #define BT_EVT_MASK_INQUIRY_RESULT_WITH_RSSI BT_EVT_BIT(33)
2084 #define BT_EVT_MASK_REMOTE_EXT_FEATURES BT_EVT_BIT(34)
2085 #define BT_EVT_MASK_SYNC_CONN_COMPLETE BT_EVT_BIT(43)
2086 #define BT_EVT_MASK_EXTENDED_INQUIRY_RESULT BT_EVT_BIT(46)
2087 #define BT_EVT_MASK_ENCRYPT_KEY_REFRESH_COMPLETE BT_EVT_BIT(47)
2088 #define BT_EVT_MASK_IO_CAPA_REQ BT_EVT_BIT(48)
2089 #define BT_EVT_MASK_IO_CAPA_RESP BT_EVT_BIT(49)
2090 #define BT_EVT_MASK_USER_CONFIRM_REQ BT_EVT_BIT(50)
2091 #define BT_EVT_MASK_USER_PASSKEY_REQ BT_EVT_BIT(51)
2092 #define BT_EVT_MASK_SSP_COMPLETE BT_EVT_BIT(53)
2093 #define BT_EVT_MASK_USER_PASSKEY_NOTIFY BT_EVT_BIT(58)
2094 #define BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61)
2095
2096 /* Page 2 */
2097 #define BT_EVT_MASK_PHY_LINK_COMPLETE BT_EVT_BIT(0)
2098 #define BT_EVT_MASK_CH_SELECTED_COMPLETE BT_EVT_BIT(1)
2099 #define BT_EVT_MASK_DISCONN_PHY_LINK_COMPLETE BT_EVT_BIT(2)
2100 #define BT_EVT_MASK_PHY_LINK_LOSS_EARLY_WARN BT_EVT_BIT(3)
2101 #define BT_EVT_MASK_PHY_LINK_RECOVERY BT_EVT_BIT(4)
2102 #define BT_EVT_MASK_LOG_LINK_COMPLETE BT_EVT_BIT(5)
2103 #define BT_EVT_MASK_DISCONN_LOG_LINK_COMPLETE BT_EVT_BIT(6)
2104 #define BT_EVT_MASK_FLOW_SPEC_MODIFY_COMPLETE BT_EVT_BIT(7)
2105 #define BT_EVT_MASK_NUM_COMPLETE_DATA_BLOCKS BT_EVT_BIT(8)
2106 #define BT_EVT_MASK_AMP_START_TEST BT_EVT_BIT(9)
2107 #define BT_EVT_MASK_AMP_TEST_END BT_EVT_BIT(10)
2108 #define BT_EVT_MASK_AMP_RX_REPORT BT_EVT_BIT(11)
2109 #define BT_EVT_MASK_AMP_SR_MODE_CHANGE_COMPLETE BT_EVT_BIT(12)
2110 #define BT_EVT_MASK_AMP_STATUS_CHANGE BT_EVT_BIT(13)
2111 #define BT_EVT_MASK_TRIGG_CLOCK_CAPTURE BT_EVT_BIT(14)
2112 #define BT_EVT_MASK_SYNCH_TRAIN_COMPLETE BT_EVT_BIT(15)
2113 #define BT_EVT_MASK_SYNCH_TRAIN_RX BT_EVT_BIT(16)
2114 #define BT_EVT_MASK_CL_SLAVE_BC_RX BT_EVT_BIT(17)
2115 #define BT_EVT_MASK_CL_SLAVE_BC_TIMEOUT BT_EVT_BIT(18)
2116 #define BT_EVT_MASK_TRUNC_PAGE_COMPLETE BT_EVT_BIT(19)
2117 #define BT_EVT_MASK_SLAVE_PAGE_RSP_TIMEOUT BT_EVT_BIT(20)
2118 #define BT_EVT_MASK_CL_SLAVE_BC_CH_MAP_CHANGE BT_EVT_BIT(21)
2119 #define BT_EVT_MASK_INQUIRY_RSP_NOT BT_EVT_BIT(22)
2120 #define BT_EVT_MASK_AUTH_PAYLOAD_TIMEOUT_EXP BT_EVT_BIT(23)
2121 #define BT_EVT_MASK_SAM_STATUS_CHANGE BT_EVT_BIT(24)
2122
2123 #define BT_EVT_MASK_LE_CONN_COMPLETE BT_EVT_BIT(0)
2124 #define BT_EVT_MASK_LE_ADVERTISING_REPORT BT_EVT_BIT(1)
2125 #define BT_EVT_MASK_LE_CONN_UPDATE_COMPLETE BT_EVT_BIT(2)
2126 #define BT_EVT_MASK_LE_REMOTE_FEAT_COMPLETE BT_EVT_BIT(3)
2127 #define BT_EVT_MASK_LE_LTK_REQUEST BT_EVT_BIT(4)
2128 #define BT_EVT_MASK_LE_CONN_PARAM_REQ BT_EVT_BIT(5)
2129 #define BT_EVT_MASK_LE_DATA_LEN_CHANGE BT_EVT_BIT(6)
2130 #define BT_EVT_MASK_LE_P256_PUBLIC_KEY_COMPLETE BT_EVT_BIT(7)
2131 #define BT_EVT_MASK_LE_GENERATE_DHKEY_COMPLETE BT_EVT_BIT(8)
2132 #define BT_EVT_MASK_LE_ENH_CONN_COMPLETE BT_EVT_BIT(9)
2133 #define BT_EVT_MASK_LE_DIRECT_ADV_REPORT BT_EVT_BIT(10)
2134 #define BT_EVT_MASK_LE_PHY_UPDATE_COMPLETE BT_EVT_BIT(11)
2135 #define BT_EVT_MASK_LE_EXT_ADVERTISING_REPORT BT_EVT_BIT(12)
2136 #define BT_EVT_MASK_LE_PER_ADV_SYNC_ESTABLISHED BT_EVT_BIT(13)
2137 #define BT_EVT_MASK_LE_PER_ADVERTISING_REPORT BT_EVT_BIT(14)
2138 #define BT_EVT_MASK_LE_PER_ADV_SYNC_LOST BT_EVT_BIT(15)
2139 #define BT_EVT_MASK_LE_SCAN_TIMEOUT BT_EVT_BIT(16)
2140 #define BT_EVT_MASK_LE_ADV_SET_TERMINATED BT_EVT_BIT(17)
2141 #define BT_EVT_MASK_LE_SCAN_REQ_RECEIVED BT_EVT_BIT(18)
2142 #define BT_EVT_MASK_LE_CHAN_SEL_ALGO BT_EVT_BIT(19)
2143
2144 #ifndef BLUERETRO
2145 /** Allocate a HCI command buffer.
2146 *
2147 * This function allocates a new buffer for a HCI command. It is given
2148 * the OpCode (encoded e.g. using the BT_OP macro) and the total length
2149 * of the parameters. Upon successful return the buffer is ready to have
2150 * the parameters encoded into it.
2151 *
2152 * @param opcode Command OpCode.
2153 * @param param_len Length of command parameters.
2154 *
2155 * @return Newly allocated buffer.
2156 */
2157 struct net_buf *bt_hci_cmd_create(u16_t opcode, u8_t param_len);
2158
2159 /** Send a HCI command asynchronously.
2160 *
2161 * This function is used for sending a HCI command asynchronously. It can
2162 * either be called for a buffer created using bt_hci_cmd_create(), or
2163 * if the command has no parameters a NULL can be passed instead. The
2164 * sending of the command will happen asynchronously, i.e. upon successful
2165 * return from this function the caller only knows that it was queued
2166 * successfully.
2167 *
2168 * If synchronous behavior, and retrieval of the Command Complete parameters
2169 * is desired, the bt_hci_cmd_send_sync() API should be used instead.
2170 *
2171 * @param opcode Command OpCode.
2172 * @param buf Command buffer or NULL (if no parameters).
2173 *
2174 * @return 0 on success or negative error value on failure.
2175 */
2176 int bt_hci_cmd_send(u16_t opcode, struct net_buf *buf);
2177
2178 /** Send a HCI command synchronously.
2179 *
2180 * This function is used for sending a HCI command synchronously. It can
2181 * either be called for a buffer created using bt_hci_cmd_create(), or
2182 * if the command has no parameters a NULL can be passed instead.
2183 *
2184 * The function will block until a Command Status or a Command Complete
2185 * event is returned. If either of these have a non-zero status the function
2186 * will return a negative error code and the response reference will not
2187 * be set. If the command completed successfully and a non-NULL rsp parameter
2188 * was given, this parameter will be set to point to a buffer containing
2189 * the response parameters.
2190 *
2191 * @param opcode Command OpCode.
2192 * @param buf Command buffer or NULL (if no parameters).
2193 * @param rsp Place to store a reference to the command response. May
2194 * be NULL if the caller is not interested in the response
2195 * parameters. If non-NULL is passed the caller is responsible
2196 * for calling net_buf_unref() on the buffer when done parsing
2197 * it.
2198 *
2199 * @return 0 on success or negative error value on failure.
2200 */
2201 int bt_hci_cmd_send_sync(u16_t opcode, struct net_buf *buf,
2202 struct net_buf **rsp);
2203
2204 /** @typedef bt_hci_vnd_evt_cb_t
2205 * @brief Callback type for vendor handling of HCI Vendor-Specific Events.
2206 *
2207 * A function of this type is registered with bt_hci_register_vnd_evt_cb()
2208 * and will be called for any HCI Vendor-Specific Event.
2209 *
2210 * @param buf Buffer containing event parameters.
2211 *
2212 * @return true if the function handles the event or false to defer the
2213 * handling of this event back to the stack.
2214 */
2215 typedef bool bt_hci_vnd_evt_cb_t(struct net_buf_simple *buf);
2216
2217 /** Register user callback for HCI Vendor-Specific Events
2218 *
2219 * @param cb Callback to be called when the stack receives a
2220 * HCI Vendor-Specific Event.
2221 *
2222 * @return 0 on success or negative error value on failure.
2223 */
2224 int bt_hci_register_vnd_evt_cb(bt_hci_vnd_evt_cb_t cb);
2225
2226 #endif /* BLUERETRO */
2227
2228 #ifdef __cplusplus
2229 }
2230 #endif
2231
2232 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_ */
2233