NimBLE-Arduino 2.1.3
Loading...
Searching...
No Matches
hci_common.h
1/*
2 * SPDX-FileCopyrightText: 2015-2023 The Apache Software Foundation (ASF)
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * SPDX-FileContributor: 2019-2022 Espressif Systems (Shanghai) CO LTD
7 */
8/*
9 * Licensed to the Apache Software Foundation (ASF) under one
10 * or more contributor license agreements. See the NOTICE file
11 * distributed with this work for additional information
12 * regarding copyright ownership. The ASF licenses this file
13 * to you under the Apache License, Version 2.0 (the
14 * "License"); you may not use this file except in compliance
15 * with the License. You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing,
20 * software distributed under the License is distributed on an
21 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 * KIND, either express or implied. See the License for the
23 * specific language governing permissions and limitations
24 * under the License.
25 */
26
27#ifndef H_BLE_HCI_COMMON_
28#define H_BLE_HCI_COMMON_
29
30#include "nimble/nimble/include/nimble/ble.h"
31#include "nimble/nimble/transport/include/nimble/transport.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#define BLE_HCI_MAX_DATA_LEN (MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE) - \
38 sizeof(struct ble_hci_ev))
39
40/* Generic command header */
41struct ble_hci_cmd {
42 uint16_t opcode;
43 uint8_t length;
44 uint8_t data[0];
45} __attribute__((packed));
46
47/* Generic event header */
48struct ble_hci_ev {
49 uint8_t opcode;
50 uint8_t length;
51 uint8_t data[0];
52} __attribute__((packed));
53
54#define BLE_HCI_OPCODE_NOP (0)
55
56/* Set opcode based on OCF and OGF */
57#define BLE_HCI_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
58
59/* Get the OGF and OCF from the opcode in the command */
60#define BLE_HCI_OGF(opcode) (((opcode) >> 10) & 0x003F)
61#define BLE_HCI_OCF(opcode) ((opcode) & 0x03FF)
62
63/* Opcode Group definitions (note: 0x07 not defined in spec) */
64#define BLE_HCI_OGF_LINK_CTRL (0x01)
65#define BLE_HCI_OGF_LINK_POLICY (0x02)
66#define BLE_HCI_OGF_CTLR_BASEBAND (0x03)
67#define BLE_HCI_OGF_INFO_PARAMS (0x04)
68#define BLE_HCI_OGF_STATUS_PARAMS (0x05)
69#define BLE_HCI_OGF_TESTING (0x06)
70#define BLE_HCI_OGF_LE (0x08)
71#define BLE_HCI_OGF_VENDOR (0x3F)
72
73/*
74 * Number of LE commands. NOTE: this is really just used to size the array
75 * containing the lengths of the LE commands.
76 */
77#define BLE_HCI_NUM_LE_CMDS (79)
78
79/* List of OCF for Link Control commands (OGF=0x01) */
80#define BLE_HCI_OCF_DISCONNECT_CMD (0x0006)
81struct ble_hci_lc_disconnect_cp {
82 uint16_t conn_handle;
83 uint8_t reason;
84} __attribute__((packed));
85
86#define BLE_HCI_OCF_RD_REM_VER_INFO (0x001D)
87struct ble_hci_rd_rem_ver_info_cp {
88 uint16_t conn_handle;
89} __attribute__((packed));
90
91/* List of OCF for Controller and Baseband commands (OGF=0x03) */
92#define BLE_HCI_OCF_CB_SET_EVENT_MASK (0x0001)
93struct ble_hci_cb_set_event_mask_cp {
94 uint64_t event_mask;
95} __attribute__((packed));
96
97#define BLE_HCI_OCF_CB_RESET (0x0003)
98
99#define BLE_HCI_OCF_CB_READ_TX_PWR (0x002D)
100struct ble_hci_cb_read_tx_pwr_cp {
101 uint16_t conn_handle;
102 uint8_t type;
103} __attribute__((packed));
104
105struct ble_hci_cb_read_tx_pwr_rp {
106 uint16_t conn_handle;
107 int8_t tx_level;
108} __attribute__((packed));
109
110
111#define BLE_HCI_OCF_CB_SET_CTLR_TO_HOST_FC (0x0031)
112struct ble_hci_cb_ctlr_to_host_fc_cp {
113 uint8_t enable;
114} __attribute__((packed));
115
116#define BLE_HCI_OCF_CB_HOST_BUF_SIZE (0x0033)
117struct ble_hci_cb_host_buf_size_cp {
118 uint16_t acl_data_len;
119 uint8_t sco_data_len;
120 uint16_t acl_num;
121 uint16_t sco_num;
122} __attribute__((packed));
123
124#define BLE_HCI_OCF_CB_HOST_NUM_COMP_PKTS (0x0035)
125struct ble_hci_cb_host_num_comp_pkts_entry {
126 uint16_t handle;
127 uint16_t count;
128} __attribute__((packed));
129struct ble_hci_cb_host_num_comp_pkts_cp {
130 uint8_t handles;
131 struct ble_hci_cb_host_num_comp_pkts_entry h[0];
132} __attribute__((packed));
133
134#define BLE_HCI_OCF_CB_SET_EVENT_MASK2 (0x0063)
135struct ble_hci_cb_set_event_mask2_cp {
136 uint64_t event_mask2;
137} __attribute__((packed));
138
139#define BLE_HCI_OCF_CB_RD_AUTH_PYLD_TMO (0x007B)
140struct ble_hci_cb_rd_auth_pyld_tmo_cp {
141 uint16_t conn_handle;
142} __attribute__((packed));
143struct ble_hci_cb_rd_auth_pyld_tmo_rp {
144 uint16_t conn_handle;
145 uint16_t tmo;
146} __attribute__((packed));
147
148#define BLE_HCI_OCF_CB_WR_AUTH_PYLD_TMO (0x007C)
149struct ble_hci_cb_wr_auth_pyld_tmo_cp {
150 uint16_t conn_handle;
151 uint16_t tmo;
152} __attribute__((packed));
153struct ble_hci_cb_wr_auth_pyld_tmo_rp {
154 uint16_t conn_handle;
155} __attribute__((packed));
156
157/* List of OCF for Info Param commands (OGF=0x04) */
158#define BLE_HCI_OCF_IP_RD_LOCAL_VER (0x0001)
159struct ble_hci_ip_rd_local_ver_rp {
160 uint8_t hci_ver;
161 uint16_t hci_rev;
162 uint8_t lmp_ver;
163 uint16_t manufacturer;
164 uint16_t lmp_subver;
165} __attribute__((packed));
166
167#define BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD (0x0002)
168struct ble_hci_ip_rd_loc_supp_cmd_rp {
169 uint8_t commands[64];
170} __attribute__((packed));
171
172#define BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT (0x0003)
173struct ble_hci_ip_rd_loc_supp_feat_rp {
174 uint64_t features;
175} __attribute__((packed));
176
177#define BLE_HCI_OCF_IP_RD_BUF_SIZE (0x0005)
178struct ble_hci_ip_rd_buf_size_rp {
179 uint16_t acl_data_len;
180 uint8_t sco_data_len;
181 uint16_t acl_num;
182 uint16_t sco_num;
183} __attribute__((packed));
184
185#define BLE_HCI_OCF_IP_RD_BD_ADDR (0x0009)
186struct ble_hci_ip_rd_bd_addr_rp {
187 uint8_t addr[6];
188} __attribute__((packed));
189
190/* List of OCF for Status parameters commands (OGF = 0x05) */
191#define BLE_HCI_OCF_RD_RSSI (0x0005)
192struct ble_hci_rd_rssi_cp {
193 uint16_t handle;
194} __attribute__((packed));
195struct ble_hci_rd_rssi_rp {
196 uint16_t handle;
197 int8_t rssi;
198} __attribute__((packed));
199
200/* List of OCF for LE commands (OGF = 0x08) */
201#define BLE_HCI_OCF_LE_SET_EVENT_MASK (0x0001)
202struct ble_hci_le_set_event_mask_cp {
203 uint64_t event_mask;
204} __attribute__((packed));
205
206#define BLE_HCI_OCF_LE_RD_BUF_SIZE (0x0002)
207struct ble_hci_le_rd_buf_size_rp {
208 uint16_t data_len;
209 uint8_t data_packets;
210} __attribute__((packed));
211
212#define BLE_HCI_OCF_LE_RD_BUF_SIZE_V2 (0x0060)
213struct ble_hci_le_rd_buf_size_v2_rp {
214 uint16_t data_len;
215 uint8_t data_packets;
216 uint16_t iso_data_len;
217 uint8_t iso_data_packets;
218} __attribute__((packed));
219
220#define BLE_HCI_OCF_LE_RD_LOC_SUPP_FEAT (0x0003)
221struct ble_hci_le_rd_loc_supp_feat_rp {
222 uint64_t features;
223} __attribute__((packed));
224
225/* NOTE: 0x0004 is intentionally left undefined */
226#define BLE_HCI_OCF_LE_SET_RAND_ADDR (0x0005)
227struct ble_hci_le_set_rand_addr_cp {
228 uint8_t addr[6];
229} __attribute__((packed));
230
231#define BLE_HCI_OCF_LE_SET_ADV_PARAMS (0x0006)
232struct ble_hci_le_set_adv_params_cp {
233 uint16_t min_interval;
234 uint16_t max_interval;
235 uint8_t type;
236 uint8_t own_addr_type;
237 uint8_t peer_addr_type;
238 uint8_t peer_addr[6];
239 uint8_t chan_map;
240 uint8_t filter_policy;
241} __attribute__((packed));
242
243#define BLE_HCI_OCF_LE_RD_ADV_CHAN_TXPWR (0x0007)
244struct ble_hci_le_rd_adv_chan_txpwr_rp {
245 int8_t power_level;
246} __attribute__((packed));
247
248#define BLE_HCI_OCF_LE_SET_ADV_DATA (0x0008)
249#define BLE_HCI_MAX_ADV_DATA_LEN (31)
250struct ble_hci_le_set_adv_data_cp {
251 uint8_t adv_data_len;
252 uint8_t adv_data[BLE_HCI_MAX_ADV_DATA_LEN];
253} __attribute__((packed));
254
255#define BLE_HCI_OCF_LE_SET_SCAN_RSP_DATA (0x0009)
256#define BLE_HCI_MAX_SCAN_RSP_DATA_LEN (31)
257struct ble_hci_le_set_scan_rsp_data_cp {
258 uint8_t scan_rsp_len;
259 uint8_t scan_rsp[BLE_HCI_MAX_SCAN_RSP_DATA_LEN];
260} __attribute__((packed));
261
262#define BLE_HCI_OCF_LE_SET_ADV_ENABLE (0x000A)
263struct ble_hci_le_set_adv_enable_cp {
264 uint8_t enable;
265} __attribute__((packed));
266
267#define BLE_HCI_OCF_LE_SET_SCAN_PARAMS (0x000B)
268struct ble_hci_le_set_scan_params_cp {
269 uint8_t scan_type;
270 uint16_t scan_itvl;
271 uint16_t scan_window;
272 uint8_t own_addr_type;
273 uint8_t filter_policy;
274} __attribute__((packed));
275
276#define BLE_HCI_OCF_LE_SET_SCAN_ENABLE (0x000C)
277struct ble_hci_le_set_scan_enable_cp {
278 uint8_t enable;
279 uint8_t filter_duplicates;
280} __attribute__((packed));
281
282#define BLE_HCI_OCF_LE_CREATE_CONN (0x000D)
283struct ble_hci_le_create_conn_cp {
284 uint16_t scan_itvl;
285 uint16_t scan_window;
286 uint8_t filter_policy;
287 uint8_t peer_addr_type;
288 uint8_t peer_addr[6];
289 uint8_t own_addr_type;
290 uint16_t min_conn_itvl;
291 uint16_t max_conn_itvl;
292 uint16_t conn_latency;
293 uint16_t tmo;
294 uint16_t min_ce;
295 uint16_t max_ce;
296} __attribute__((packed));
297
298#define BLE_HCI_OCF_LE_CREATE_CONN_CANCEL (0x000E)
299
300#define BLE_HCI_OCF_LE_RD_WHITE_LIST_SIZE (0x000F)
301struct ble_hci_le_rd_white_list_rp {
302 uint8_t size;
303} __attribute__((packed));
304
305#define BLE_HCI_OCF_LE_CLEAR_WHITE_LIST (0x0010)
306
307#define BLE_HCI_OCF_LE_ADD_WHITE_LIST (0x0011)
308struct ble_hci_le_add_whte_list_cp {
309 uint8_t addr_type;
310 uint8_t addr[6];
311} __attribute__((packed));
312
313#define BLE_HCI_OCF_LE_RMV_WHITE_LIST (0x0012)
314struct ble_hci_le_rmv_white_list_cp {
315 uint8_t addr_type;
316 uint8_t addr[6];
317} __attribute__((packed));
318
319#define BLE_HCI_OCF_LE_CONN_UPDATE (0x0013)
320struct ble_hci_le_conn_update_cp {
321 uint16_t conn_handle;
322 uint16_t conn_itvl_min;
323 uint16_t conn_itvl_max;
324 uint16_t conn_latency;
325 uint16_t supervision_timeout;
326 uint16_t min_ce_len;
327 uint16_t max_ce_len;
328} __attribute__((packed));
329
330#define BLE_HCI_OCF_LE_SET_HOST_CHAN_CLASS (0x0014)
331struct ble_hci_le_set_host_chan_class_cp {
332 uint8_t chan_map[5];
333} __attribute__((packed));
334
335#define BLE_HCI_OCF_LE_RD_CHAN_MAP (0x0015)
336struct ble_hci_le_rd_chan_map_cp {
337 uint16_t conn_handle;
338} __attribute__((packed));
339struct ble_hci_le_rd_chan_map_rp {
340 uint16_t conn_handle;
341 uint8_t chan_map[5];
342} __attribute__((packed));
343
344#define BLE_HCI_OCF_LE_RD_REM_FEAT (0x0016)
345struct ble_hci_le_rd_rem_feat_cp {
346 uint16_t conn_handle;
347} __attribute__((packed));
348
349#define BLE_HCI_OCF_LE_ENCRYPT (0x0017)
350struct ble_hci_le_encrypt_cp {
351 uint8_t key[16];
352 uint8_t data[16];
353} __attribute__((packed));
354struct ble_hci_le_encrypt_rp {
355 uint8_t data[16];
356} __attribute__((packed));
357
358#define BLE_HCI_OCF_LE_RAND (0x0018)
359struct ble_hci_le_rand_rp {
360 uint64_t random_number;
361} __attribute__((packed));
362
363#define BLE_HCI_OCF_LE_START_ENCRYPT (0x0019)
364struct ble_hci_le_start_encrypt_cp {
365 uint16_t conn_handle;
366 uint64_t rand;
367 uint16_t div;
368 uint8_t ltk[16];
369} __attribute__((packed));
370
371#define BLE_HCI_OCF_LE_LT_KEY_REQ_REPLY (0x001A)
372struct ble_hci_le_lt_key_req_reply_cp {
373 uint16_t conn_handle;
374 uint8_t ltk[16];
375} __attribute__((packed));
376struct ble_hci_le_lt_key_req_reply_rp {
377 uint16_t conn_handle;
378} __attribute__((packed));
379
380#define BLE_HCI_OCF_LE_LT_KEY_REQ_NEG_REPLY (0x001B)
381struct ble_hci_le_lt_key_req_neg_reply_cp {
382 uint16_t conn_handle;
383} __attribute__((packed));
384struct ble_hci_le_lt_key_req_neg_reply_rp {
385 uint16_t conn_handle;
386} __attribute__((packed));
387
388#define BLE_HCI_OCF_LE_RD_SUPP_STATES (0x001C)
389struct ble_hci_le_rd_supp_states_rp {
390 uint64_t states;
391} __attribute__((packed));
392
393#define BLE_HCI_OCF_LE_RX_TEST (0x001D)
394struct ble_hci_le_rx_test_cp {
395 uint8_t rx_chan;
396} __attribute__((packed));
397
398#define BLE_HCI_OCF_LE_TX_TEST (0x001E)
399struct ble_hci_le_tx_test_cp {
400 uint8_t tx_chan;
401 uint8_t test_data_len;
402 uint8_t payload;
403} __attribute__((packed));
404#if MYNEWT_VAL(BLE_LL_DTM_EXTENSIONS)
405struct ble_hci_le_tx_test_ext_cp {
406 uint8_t tx_chan;
407 uint8_t test_data_len;
408 uint8_t payload;
409 uint16_t interval;
410 uint16_t pkt_count;
411} __attribute__((packed));
412#endif
413
414#define BLE_HCI_OCF_LE_TEST_END (0x001F)
415struct ble_hci_le_test_end_rp {
416 uint16_t num_packets;
417} __attribute__((packed));
418
419#define BLE_HCI_OCF_LE_REM_CONN_PARAM_RR (0x0020)
420struct ble_hci_le_rem_conn_param_rr_cp {
421 uint16_t conn_handle;
422 uint16_t conn_itvl_min;
423 uint16_t conn_itvl_max;
424 uint16_t conn_latency;
425 uint16_t supervision_timeout;
426 uint16_t min_ce;
427 uint16_t max_ce;
428} __attribute__((packed));
429struct ble_hci_le_rem_conn_param_rr_rp {
430 uint16_t conn_handle;
431} __attribute__((packed));
432
433#define BLE_HCI_OCF_LE_REM_CONN_PARAM_NRR (0x0021)
434struct ble_hci_le_rem_conn_params_nrr_cp {
435 uint16_t conn_handle;
436 uint8_t reason;
437} __attribute__((packed));
438struct ble_hci_le_rem_conn_params_nrr_rp {
439 uint16_t conn_handle;
440} __attribute__((packed));
441
442#define BLE_HCI_OCF_LE_SET_DATA_LEN (0x0022)
443struct ble_hci_le_set_data_len_cp {
444 uint16_t conn_handle;
445 uint16_t tx_octets;
446 uint16_t tx_time;
447} __attribute__((packed));
448struct ble_hci_le_set_data_len_rp {
449 uint16_t conn_handle;
450} __attribute__((packed));
451
452#define BLE_HCI_OCF_LE_RD_SUGG_DEF_DATA_LEN (0x0023)
453struct ble_hci_le_rd_sugg_def_data_len_rp {
454 uint16_t max_tx_octets;
455 uint16_t max_tx_time;
456} __attribute__((packed));
457
458#define BLE_HCI_OCF_LE_WR_SUGG_DEF_DATA_LEN (0x0024)
459struct ble_hci_le_wr_sugg_def_data_len_cp {
460 uint16_t max_tx_octets;
461 uint16_t max_tx_time;
462} __attribute__((packed));
463
464#define BLE_HCI_OCF_LE_RD_P256_PUBKEY (0x0025)
465
466#define BLE_HCI_OCF_LE_GEN_DHKEY (0x0026)
467struct ble_hci_le_gen_dhkey_cp {
468 uint8_t pkey[64];
469} __attribute__((packed));
470
471#define BLE_HCI_OCF_LE_ADD_RESOLV_LIST (0x0027)
472struct ble_hci_le_add_resolv_list_cp {
473 uint8_t peer_addr_type;
474 uint8_t peer_id_addr[6];
475 uint8_t peer_irk[16];
476 uint8_t local_irk[16];
477} __attribute__((packed));
478
479#define BLE_HCI_OCF_LE_RMV_RESOLV_LIST (0x0028)
480struct ble_hci_le_rmv_resolve_list_cp {
481 uint8_t peer_addr_type;
482 uint8_t peer_id_addr[6];
483} __attribute__((packed));
484
485#define BLE_HCI_OCF_LE_CLR_RESOLV_LIST (0x0029)
486
487#define BLE_HCI_OCF_LE_RD_RESOLV_LIST_SIZE (0x002A)
488struct ble_hci_le_rd_resolv_list_size_rp {
489 uint8_t size;
490} __attribute__((packed));
491
492#define BLE_HCI_OCF_LE_RD_PEER_RESOLV_ADDR (0x002B)
493struct ble_hci_le_rd_peer_resolv_addr_cp {
494 uint8_t peer_addr_type;
495 uint8_t peer_id_addr[6];
496} __attribute__((packed));
497struct ble_hci_le_rd_peer_resolv_addr_rp {
498 uint8_t rpa[6];
499} __attribute__((packed));
500
501#define BLE_HCI_OCF_LE_RD_LOCAL_RESOLV_ADDR (0x002C)
502struct ble_hci_le_rd_local_resolv_addr_cp {
503 uint8_t peer_addr_type;
504 uint8_t peer_id_addr[6];
505} __attribute__((packed));
506struct ble_hci_le_rd_local_resolv_addr_rp {
507 uint8_t rpa[6];
508} __attribute__((packed));
509
510#define BLE_HCI_OCF_LE_SET_ADDR_RES_EN (0x002D)
511struct ble_hci_le_set_addr_res_en_cp {
512 uint8_t enable;
513} __attribute__((packed));
514
515#define BLE_HCI_OCF_LE_SET_RPA_TMO (0x002E)
516struct ble_hci_le_set_rpa_tmo_cp {
517 uint16_t rpa_timeout;
518} __attribute__((packed));
519
520#define BLE_HCI_OCF_LE_RD_MAX_DATA_LEN (0x002F)
521struct ble_hci_le_rd_max_data_len_rp {
522 uint16_t max_tx_octests;
523 uint16_t max_tx_time;
524 uint16_t max_rx_octests;
525 uint16_t max_rx_time;
526} __attribute__((packed));
527
528#define BLE_HCI_OCF_LE_RD_PHY (0x0030)
529struct ble_hci_le_rd_phy_cp {
530 uint16_t conn_handle;
531} __attribute__((packed));
532struct ble_hci_le_rd_phy_rp {
533 uint16_t conn_handle;
534 uint8_t tx_phy;
535 uint8_t rx_phy;
536} __attribute__((packed));
537
538#define BLE_HCI_OCF_LE_SET_DEFAULT_PHY (0x0031)
539struct ble_hci_le_set_default_phy_cp {
540 uint8_t all_phys;
541 uint8_t tx_phys;
542 uint8_t rx_phys;
543} __attribute__((packed));
544
545#define BLE_HCI_OCF_LE_SET_PHY (0x0032)
546struct ble_hci_le_set_phy_cp {
547 uint16_t conn_handle;
548 uint8_t all_phys;
549 uint8_t tx_phys;
550 uint8_t rx_phys;
551 uint16_t phy_options;
552} __attribute__((packed));
553
554#define BLE_HCI_OCF_LE_RX_TEST_V2 (0x0033)
555struct ble_hci_le_rx_test_v2_cp {
556 uint8_t rx_chan;
557 uint8_t phy;
558 uint8_t index;
559} __attribute__((packed));
560
561#define BLE_HCI_OCF_LE_TX_TEST_V2 (0x0034)
562struct ble_hci_le_tx_test_v2_cp {
563 uint8_t tx_chan;
564 uint8_t test_data_len;
565 uint8_t payload;
566 uint8_t phy;
567} __attribute__((packed));
568#if MYNEWT_VAL(BLE_LL_DTM_EXTENSIONS)
569struct ble_hci_le_tx_test_v2_ext_cp {
570 uint8_t tx_chan;
571 uint8_t test_data_len;
572 uint8_t payload;
573 uint8_t phy;
574 uint16_t interval;
575 uint16_t pkt_count;
576} __attribute__((packed));
577#endif
578
579#define BLE_HCI_OCF_LE_SET_ADV_SET_RND_ADDR (0x0035)
580struct ble_hci_le_set_adv_set_rnd_addr_cp {
581 uint8_t adv_handle;
582 uint8_t addr[6];
583} __attribute__((packed));
584
585#define BLE_HCI_OCF_LE_SET_EXT_ADV_PARAM (0x0036)
586struct ble_hci_le_set_ext_adv_params_cp {
587 uint8_t adv_handle;
588 uint16_t props;
589 uint8_t pri_itvl_min[3];
590 uint8_t pri_itvl_max[3];
591 uint8_t pri_chan_map;
592 uint8_t own_addr_type;
593 uint8_t peer_addr_type;
594 uint8_t peer_addr[6];
595 uint8_t filter_policy;
596 int8_t tx_power;
597 uint8_t pri_phy;
598 uint8_t sec_max_skip;
599 uint8_t sec_phy;
600 uint8_t sid;
601 uint8_t scan_req_notif;
602} __attribute__((packed));
603struct ble_hci_le_set_ext_adv_params_rp {
604 int8_t tx_power;
605} __attribute__((packed));
606
607#define BLE_HCI_OCF_LE_SET_EXT_ADV_DATA (0x0037)
608struct ble_hci_le_set_ext_adv_data_cp {
609 uint8_t adv_handle;
610 uint8_t operation;
611 uint8_t fragment_pref;
612 uint8_t adv_data_len;
613 uint8_t adv_data[0];
614} __attribute__((packed));
615
616#define BLE_HCI_OCF_LE_SET_EXT_SCAN_RSP_DATA (0x0038)
617struct ble_hci_le_set_ext_scan_rsp_data_cp {
618 uint8_t adv_handle;
619 uint8_t operation;
620 uint8_t fragment_pref;
621 uint8_t scan_rsp_len;
622 uint8_t scan_rsp[0];
623} __attribute__((packed));
624
625#define BLE_HCI_OCF_LE_SET_EXT_ADV_ENABLE (0x0039)
626struct adv_set {
627 uint8_t adv_handle;
628 uint16_t duration;
629 uint8_t max_events;
630} __attribute__((packed));
631struct ble_hci_le_set_ext_adv_enable_cp {
632 uint8_t enable;
633 uint8_t num_sets;
634 struct adv_set sets[0];
635} __attribute__((packed));
636
637#define BLE_HCI_OCF_LE_RD_MAX_ADV_DATA_LEN (0x003A)
638struct ble_hci_le_rd_max_adv_data_len_rp {
639 uint16_t max_adv_data_len;
640} __attribute__((packed));
641
642#define BLE_HCI_OCF_LE_RD_NUM_OF_ADV_SETS (0x003B)
643struct ble_hci_le_rd_num_of_adv_sets_rp {
644 uint8_t num_sets;
645} __attribute__((packed));
646
647#define BLE_HCI_OCF_LE_REMOVE_ADV_SET (0x003C)
648struct ble_hci_le_remove_adv_set_cp {
649 uint8_t adv_handle;
650} __attribute__((packed));
651
652#define BLE_HCI_OCF_LE_CLEAR_ADV_SETS (0x003D)
653
654#define BLE_HCI_OCF_LE_SET_PERIODIC_ADV_PARAMS (0x003E)
655struct ble_hci_le_set_periodic_adv_params_cp {
656 uint8_t adv_handle;
657 uint16_t min_itvl;
658 uint16_t max_itvl;
659 uint16_t props;
660} __attribute__((packed));
661
662#define BLE_HCI_OCF_LE_SET_PERIODIC_ADV_DATA (0x003F)
663struct ble_hci_le_set_periodic_adv_data_cp {
664 uint8_t adv_handle;
665 uint8_t operation;
666 uint8_t adv_data_len;
667 uint8_t adv_data[0];
668} __attribute__((packed));
669
670#define BLE_HCI_OCF_LE_SET_PERIODIC_ADV_ENABLE (0x0040)
671struct ble_hci_le_set_periodic_adv_enable_cp {
672 uint8_t enable;
673 uint8_t adv_handle;
674} __attribute__((packed));
675
676#define BLE_HCI_OCF_LE_SET_EXT_SCAN_PARAM (0x0041)
677struct scan_params {
678 uint8_t type;
679 uint16_t itvl;
680 uint16_t window;
681} __attribute__((packed));
682struct ble_hci_le_set_ext_scan_params_cp {
683 uint8_t own_addr_type;
684 uint8_t filter_policy;
685 uint8_t phys;
686 struct scan_params scans[0];
687} __attribute__((packed));
688
689#define BLE_HCI_OCF_LE_SET_EXT_SCAN_ENABLE (0x0042)
690struct ble_hci_le_set_ext_scan_enable_cp {
691 uint8_t enable;
692 uint8_t filter_dup;
693 uint16_t duration;
694 uint16_t period;
695} __attribute__((packed));
696
697#define BLE_HCI_OCF_LE_EXT_CREATE_CONN (0x0043)
698struct conn_params {
699 uint16_t scan_itvl;
700 uint16_t scan_window;
701 uint16_t conn_min_itvl;
702 uint16_t conn_max_itvl;
703 uint16_t conn_latency;
704 uint16_t supervision_timeout;
705 uint16_t min_ce;
706 uint16_t max_ce;
707} __attribute__((packed));
708struct ble_hci_le_ext_create_conn_cp {
709 uint8_t filter_policy;
710 uint8_t own_addr_type;
711 uint8_t peer_addr_type;
712 uint8_t peer_addr[6];
713 uint8_t init_phy_mask;
714 struct conn_params conn_params[0];
715} __attribute__((packed));
716
717#define BLE_HCI_LE_PERIODIC_ADV_CREATE_SYNC_OPT_FILTER 0x01
718#define BLE_HCI_LE_PERIODIC_ADV_CREATE_SYNC_OPT_DISABLED 0x02
719#define BLE_HCI_LE_PERIODIC_ADV_CREATE_SYNC_OPT_DUPLICATES 0x04
720
721#define BLE_HCI_OCF_LE_PERIODIC_ADV_CREATE_SYNC (0x0044)
722struct ble_hci_le_periodic_adv_create_sync_cp {
723 uint8_t options;
724 uint8_t sid;
725 uint8_t peer_addr_type;
726 uint8_t peer_addr[6];
727 uint16_t skip;
728 uint16_t sync_timeout;
729 uint8_t sync_cte_type;
730} __attribute__((packed));
731
732#define BLE_HCI_OCF_LE_PERIODIC_ADV_CREATE_SYNC_CANCEL (0x0045)
733
734#define BLE_HCI_OCF_LE_PERIODIC_ADV_TERM_SYNC (0x0046)
735struct ble_hci_le_periodic_adv_term_sync_cp {
736 uint16_t sync_handle;
737} __attribute__((packed));
738
739#define BLE_HCI_OCF_LE_ADD_DEV_TO_PERIODIC_ADV_LIST (0x0047)
740struct ble_hci_le_add_dev_to_periodic_adv_list_cp {
741 uint8_t peer_addr_type;
742 uint8_t peer_addr[6];
743 uint8_t sid;
744} __attribute__((packed));
745
746#define BLE_HCI_OCF_LE_REM_DEV_FROM_PERIODIC_ADV_LIST (0x0048)
747struct ble_hci_le_rem_dev_from_periodic_adv_list_cp {
748 uint8_t peer_addr_type;
749 uint8_t peer_addr[6];
750 uint8_t sid;
751} __attribute__((packed));
752
753#define BLE_HCI_OCF_LE_CLEAR_PERIODIC_ADV_LIST (0x0049)
754
755#define BLE_HCI_OCF_LE_RD_PERIODIC_ADV_LIST_SIZE (0x004A)
756struct ble_hci_le_rd_periodic_adv_list_size_rp {
757 uint8_t list_size;
758} __attribute__((packed));
759
760#define BLE_HCI_OCF_LE_RD_TRANSMIT_POWER (0x004B)
761struct ble_hci_le_rd_transmit_power_rp {
762 int8_t min_tx_power;
763 int8_t max_tx_power;
764} __attribute__((packed));
765
766#define BLE_HCI_OCF_LE_RD_RF_PATH_COMPENSATION (0x004C)
767struct ble_hci_le_rd_rf_path_compensation_rp {
768 int16_t tx_path_compensation;
769 int16_t rx_path_compensation;
770} __attribute__((packed));
771
772#define BLE_HCI_OCF_LE_WR_RF_PATH_COMPENSATION (0x004D)
773struct ble_hci_le_wr_rf_path_compensation_cp {
774 int16_t tx_path_compensation;
775 int16_t rx_path_compensation;
776} __attribute__((packed));
777
778#define BLE_HCI_OCF_LE_SET_PRIVACY_MODE (0x004E)
779struct ble_hci_le_set_privacy_mode_cp {
780 uint8_t peer_id_addr_type;
781 uint8_t peer_id_addr[6];
782 uint8_t mode;
783} __attribute__((packed));
784
785#define BLE_HCI_OCF_LE_RX_TEST_V3 (0x004F)
786#define BLE_HCI_OCF_LE_TX_TEST_V3 (0x0050)
787#define BLE_HCI_OCF_LE_SET_CONNLESS_CTE_TX_PARAMS (0x0051)
788#define BLE_HCI_OCF_LE_SET_CONNLESS_CTE_TX_ENABLE (0x0052)
789#define BLE_HCI_OCF_LE_SET_CONNLESS_IQ_SAMPLING_ENABLE (0x0053)
790#define BLE_HCI_OCF_LE_SET_CONN_CTE_RX_PARAMS (0x0054)
791#define BLE_HCI_OCF_LE_SET_CONN_CTE_TX_PARAMS (0x0055)
792#define BLE_HCI_OCF_LE_SET_CONN_CTE_REQ_ENABLE (0x0056)
793#define BLE_HCI_OCF_LE_SET_CONN_CTE_RESP_ENABLE (0x0057)
794#define BLE_HCI_OCF_LE_RD_ANTENNA_INFO (0x0058)
795
796#define BLE_HCI_OCF_LE_PERIODIC_ADV_RECEIVE_ENABLE (0x0059)
797struct ble_hci_le_periodic_adv_receive_enable_cp {
798 uint16_t sync_handle;
799 uint8_t enable;
800} __attribute__((packed));
801
802#define BLE_HCI_OCF_LE_PERIODIC_ADV_SYNC_TRANSFER (0x005A)
803struct ble_hci_le_periodic_adv_sync_transfer_cp {
804 uint16_t conn_handle;
805 uint16_t service_data;
806 uint16_t sync_handle;
807} __attribute__((packed));
808struct ble_hci_le_periodic_adv_sync_transfer_rp {
809 uint16_t conn_handle;
810} __attribute__((packed));
811
812#define BLE_HCI_OCF_LE_PERIODIC_ADV_SET_INFO_TRANSFER (0x005B)
813struct ble_hci_le_periodic_adv_set_info_transfer_cp {
814 uint16_t conn_handle;
815 uint16_t service_data;
816 uint8_t adv_handle;
817} __attribute__((packed));
818struct ble_hci_le_periodic_adv_set_info_transfer_rp {
819 uint16_t conn_handle;
820} __attribute__((packed));
821
822#define BLE_HCI_OCF_LE_PERIODIC_ADV_SYNC_TRANSFER_PARAMS (0x005C)
823struct ble_hci_le_periodic_adv_sync_transfer_params_cp {
824 uint16_t conn_handle;
825 uint8_t mode;
826 uint16_t skip;
827 uint16_t sync_timeout;
828 uint8_t sync_cte_type;
829} __attribute__((packed));
830struct ble_hci_le_periodic_adv_sync_transfer_params_rp {
831 uint16_t conn_handle;
832} __attribute__((packed));
833
834#define BLE_HCI_OCF_LE_SET_DEFAULT_SYNC_TRANSFER_PARAMS (0x005D)
835struct ble_hci_le_set_default_periodic_sync_transfer_params_cp {
836 uint8_t mode;
837 uint16_t skip;
838 uint16_t sync_timeout;
839 uint8_t sync_cte_type;
840} __attribute__((packed));
841
842#define BLE_HCI_OCF_LE_GENERATE_DHKEY_V2 (0x005E)
843#define BLE_HCI_OCF_LE_MODIFY_SCA (0x005F)
844
845#if MYNEWT_VAL(BLE_ISO)
846#define BLE_HCI_OCF_LE_READ_ISO_TX_SYNC (0x0061)
847struct ble_hci_le_read_iso_tx_sync_cp {
848 uint16_t conn_handle;
849} __attribute__((packed));
850
851struct ble_hci_le_read_iso_tx_sync_rp {
852 uint16_t conn_handle;
853 uint16_t packet_seq_num;
854 uint32_t timestamp;
855 uint8_t timeoffset[3];
856} __attribute__((packed));
857
858#define BLE_HCI_LE_SET_CIG_CIS_MAX_NUM (0x1F)
859#define BLE_HCI_OCF_LE_SET_CIG_PARAM (0x0062)
860struct ble_hci_le_cis_params {
861 uint8_t cis_id;
862 uint16_t max_sdu_mtos;
863 uint16_t max_sdu_stom;
864 uint8_t phy_mtos;
865 uint8_t phy_stom;
866 uint8_t rnt_mtos;
867 uint8_t rnt_stom;
868} __attribute__((packed));
869
870struct ble_hci_le_set_cig_params_cp {
871 uint8_t cig_id;
872 uint8_t sdu_interval_mtos[3];
873 uint8_t sdu_interval_stom[3];
874 uint8_t sca;
875 uint8_t packing;
876 uint8_t framing;
877 uint16_t max_latency_mtos;
878 uint16_t max_latency_stom;
879 uint8_t cis_cnt;
880 struct ble_hci_le_cis_params cis_params[0];
881} __attribute__((packed));
882
883struct ble_hci_le_set_cig_params_rp {
884 uint8_t cig_id;
885 uint8_t cis_cnt;
886 uint16_t cis_handle[0];
887} __attribute__((packed));
888
889#if MYNEWT_VAL(BLE_ISO_TEST)
890#define BLE_HCI_OCF_LE_SET_CIG_PARAM_TEST (0x0063)
891struct ble_hci_le_cis_params_test {
892 uint8_t cis_id;
893 uint8_t nse;
894 uint16_t max_sdu_mtos;
895 uint16_t max_sdu_stom;
896 uint16_t max_pdu_mtos;
897 uint16_t max_pdu_stom;
898 uint8_t phy_mtos;
899 uint8_t phy_stom;
900 uint8_t bn_mtos;
901 uint8_t bn_stom;
902} __attribute__((packed));
903
904struct ble_hci_le_set_cig_params_test_cp {
905 uint8_t cig_id;
906 uint8_t sdu_interval_mtos[3];
907 uint8_t sdu_interval_stom[3];
908 uint8_t ft_mtos;
909 uint8_t ft_stom;
910 uint16_t iso_interval;
911 uint8_t sca;
912 uint8_t packing;
913 uint8_t framing;
914 uint8_t cis_cnt;
915 struct ble_hci_le_cis_params_test cis_params[0];
916} __attribute__((packed));
917#endif
918
919#define BLE_HCI_LE_CREATE_CIS_MAX_CIS_NUM (0x1F)
920#define BLE_HCI_OCF_LE_CREATE_CIS (0x0064)
921struct ble_hci_le_create_cis_params {
922 uint16_t cis_handle;
923 uint16_t conn_handle;
924} __attribute__((packed));
925
926struct ble_hci_le_create_cis_cp {
927 uint8_t cis_cnt;
928 struct ble_hci_le_create_cis_params params[0];
929} __attribute__((packed));
930
931#define BLE_HCI_OCF_LE_REMOVE_CIG (0x0065)
932struct ble_hci_le_remove_cig_cp {
933 uint8_t cig_id;
934} __attribute__((packed));
935
936struct ble_hci_le_remove_cig_rp {
937 uint8_t cig_id;
938} __attribute__((packed));
939
940#define BLE_HCI_OCF_LE_ACCEPT_CIS_REQ (0x0066)
941struct ble_hci_le_accept_cis_request_cp {
942 uint16_t cis_handle;
943} __attribute__((packed));
944
945#define BLE_HCI_OCF_LE_REJECT_CIS_REQ (0x0067)
946struct ble_hci_le_reject_cis_request_cp {
947 uint16_t cis_handle;
948 uint8_t reason;
949} __attribute__((packed));
950
951struct ble_hci_le_reject_cis_request_rp {
952 uint16_t conn_handle;
953} __attribute__((packed));
954
955#define BLE_HCI_OCF_LE_CREATE_BIG (0x0068)
956struct ble_hci_le_create_big_cp {
957 uint8_t big_handle;
958 uint8_t adv_handle;
959 uint8_t bis_cnt;
960 uint8_t sdu_interval[3];
961 uint16_t max_sdu;
962 uint16_t max_transport_latency;
963 uint8_t rnt;
964 uint8_t phy;
965 uint8_t packing;
966 uint8_t framing;
967 uint8_t encryption;
968 uint8_t broadcast_code[16];
969} __attribute__((packed));
970
971#if MYNEWT_VAL(BLE_ISO_TEST)
972#define BLE_HCI_OCF_LE_CREATE_BIG_TEST (0x0069)
973struct ble_hci_le_create_big_test_cp {
974 uint8_t big_handle;
975 uint8_t adv_handle;
976 uint8_t bis_cnt;
977 uint8_t sdu_interval[3];
978 uint16_t iso_interval;
979 uint8_t nse;
980 uint16_t max_sdu;
981 uint16_t max_pdu;
982 uint8_t phy;
983 uint8_t packing;
984 uint8_t framing;
985 uint8_t bn;
986 uint8_t irc;
987 uint8_t pto;
988 uint8_t encryption;
989 uint8_t broadcast_code[16];
990} __attribute__((packed));
991#endif
992
993#define BLE_HCI_OCF_LE_TERMINATE_BIG (0x006a)
994struct ble_hci_le_terminate_big_cp {
995 uint8_t big_handle;
996 uint8_t reason;
997} __attribute__((packed));
998
999#define BLE_HCI_LE_BIG_CREATE_SYNC_LEN_MIN (25)
1000#define BLE_HCI_OCF_LE_BIG_CREATE_SYNC (0x006b)
1001struct ble_hci_le_big_create_sync_cp {
1002 uint8_t big_handle;
1003 uint16_t sync_handle;
1004 uint8_t big_cnt;
1005 uint8_t encryption;
1006 uint8_t broadcast_code[16];
1007 uint8_t mse;
1008 uint16_t timeout;
1009 uint8_t bis[0];
1010} __attribute__((packed));
1011
1012#define BLE_HCI_OCF_LE_BIG_TERMINATE_SYNC (0x006c)
1013struct ble_hci_le_terminate_big_sync_cp {
1014 uint8_t big_handle;
1015} __attribute__((packed));
1016#endif
1017
1018#define BLE_HCI_OCF_LE_REQ_PEER_SCA (0x006d)
1019struct ble_hci_le_request_peer_sca_cp {
1020 uint16_t conn_handle;
1021} __attribute__((packed));
1022
1023#if MYNEWT_VAL(BLE_ISO)
1024#define BLE_HCI_OCF_LE_SETUP_ISO_DATA_PATH (0x006e)
1025struct ble_hci_le_iso_setup_data_path_cp {
1026 uint16_t iso_handle;
1027 uint8_t direction;
1028 uint8_t id;
1029 uint8_t codec_id[5];
1030 uint8_t controller_delay[3];
1031 uint8_t codec_conf_len;
1032 uint8_t codec_conf[0];
1033} __attribute__((packed));
1034
1035#define BLE_HCI_LE_REMOVE_INPUT_DATA_PATH_BIT (0x01)
1036#define BLE_HCI_LE_REMOVE_OUTPUT_DATA_PATH_BIT (0x02)
1037#define BLE_HCI_OCF_LE_REMOVE_ISO_DATA_PATH (0x006f)
1038struct ble_hci_le_iso_remove_data_path_cp {
1039 uint16_t iso_handle;
1040 uint8_t direction;
1041} __attribute__((packed));
1042
1043#if MYNEWT_VAL(BLE_ISO_TEST)
1044#define BLE_HCI_OCF_LE_ISO_TRANSMIT_TEST (0x0070)
1045struct ble_hci_le_iso_transmit_test_cp {
1046 uint16_t iso_handle;
1047 uint8_t payload_type;
1048} __attribute__((packed));
1049
1050#define BLE_HCI_OCF_LE_ISO_RECEIVE_TEST (0x0071)
1051struct ble_hci_le_iso_receive_test_cp {
1052 uint16_t iso_handle;
1053} __attribute__((packed));
1054
1055#define BLE_HCI_OCF_LE_ISO_READ_TEST_COUNTERS (0x0072)
1056struct ble_hci_le_iso_read_test_counters_cp {
1057 uint16_t iso_handle;
1058} __attribute__((packed));
1059
1060#define BLE_HCI_OCF_LE_ISO_TEST_END (0x0073)
1061struct ble_hci_le_iso_test_end_cp {
1062 uint16_t iso_handle;
1063} __attribute__((packed));
1064#endif
1065#endif
1066
1067#define BLE_HCI_OCF_LE_SET_HOST_FEAT (0x0074)
1068struct ble_hci_le_set_host_feat_cp {
1069 uint8_t bit_num;
1070 uint8_t val;
1071} __attribute__((packed));
1072
1073#define BLE_HCI_OCF_LE_ENH_READ_TRANSMIT_POWER_LEVEL (0x0076)
1074struct ble_hci_le_enh_read_transmit_power_level_cp {
1075 uint16_t conn_handle;
1076 uint8_t phy;
1077} __attribute__((packed));
1078struct ble_hci_le_enh_read_transmit_power_level_rp {
1079 uint16_t conn_handle;
1080 uint8_t phy;
1081 uint8_t curr_tx_power_level;
1082 uint8_t max_tx_power_level;
1083} __attribute__((packed));
1084
1085#define BLE_HCI_OCF_LE_READ_REMOTE_TRANSMIT_POWER_LEVEL (0x0077)
1086struct ble_hci_le_read_remote_transmit_power_level_cp {
1087 uint16_t conn_handle;
1088 uint8_t phy;
1089} __attribute__((packed));
1090
1091#define BLE_HCI_OCF_LE_SET_PATH_LOSS_REPORT_PARAM (0x0078)
1092struct ble_hci_le_set_path_loss_report_param_cp {
1093 uint16_t conn_handle;
1094 uint8_t high_threshold;
1095 uint8_t high_hysteresis;
1096 uint8_t low_threshold;
1097 uint8_t low_hysteresis;
1098 uint16_t min_time_spent;
1099} __attribute__((packed));
1100
1101#define BLE_HCI_OCF_LE_SET_PATH_LOSS_REPORT_ENABLE (0x0079)
1102struct ble_hci_le_set_path_loss_report_enable_cp {
1103 uint16_t conn_handle;
1104 uint8_t enable;
1105} __attribute__((packed));
1106
1107#define BLE_HCI_OCF_LE_SET_TRANS_PWR_REPORT_ENABLE (0x007A)
1108struct ble_hci_le_set_transmit_power_report_enable_cp {
1109 uint16_t conn_handle;
1110 uint8_t local_enable;
1111 uint8_t remote_enable;
1112} __attribute__((packed));
1113
1114#define BLE_HCI_OCF_LE_SET_DATA_ADDR_CHANGE (0x007C)
1115struct ble_hci_le_set_data_addr_change_cp {
1116 uint8_t adv_handle;
1117 uint8_t change_reason;
1118} __attribute__((packed));
1119
1120#define BLE_HCI_OCF_LE_SET_DEFAULT_SUBRATE (0x007D)
1121struct ble_hci_le_set_default_subrate_cp {
1122 uint16_t subrate_min;
1123 uint16_t subrate_max;
1124 uint16_t max_latency;
1125 uint16_t cont_num;
1126 uint16_t supervision_tmo;
1127} __attribute__((packed));
1128
1129#define BLE_HCI_OCF_LE_SUBRATE_REQ (0x007E)
1130struct ble_hci_le_subrate_req_cp {
1131 uint16_t conn_handle;
1132 uint16_t subrate_min;
1133 uint16_t subrate_max;
1134 uint16_t max_latency;
1135 uint16_t cont_num;
1136 uint16_t supervision_tmo;
1137} __attribute__((packed));
1138
1139/* --- Vendor specific commands (OGF 0x003F) */
1140/* Read Random Static Address */
1141#define BLE_HCI_OCF_VS_RD_STATIC_ADDR (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0001))
1142struct ble_hci_vs_rd_static_addr_rp {
1143 uint8_t addr[6];
1144} __attribute__((packed));
1145
1146/* Set default transmit power. Actual selected TX power is returned
1147 * in reply. Setting 0xff restores controller reset default.
1148 */
1149#define BLE_HCI_OCF_VS_SET_TX_PWR (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0002))
1150struct ble_hci_vs_set_tx_pwr_cp {
1151 int8_t tx_power;
1152} __attribute__((packed));
1153struct ble_hci_vs_set_tx_pwr_rp {
1154 int8_t tx_power;
1155} __attribute__((packed));
1156
1157#define BLE_HCI_OCF_VS_CSS (0x0003)
1158struct ble_hci_vs_css_cp {
1159 uint8_t opcode;
1160} __attribute__((packed));
1161#define BLE_HCI_VS_CSS_OP_CONFIGURE 0x01
1162struct ble_hci_vs_css_configure_cp {
1163 uint8_t opcode;
1164 uint32_t slot_us;
1165 uint32_t period_slots;
1166} __attribute__((packed));
1167#define BLE_HCI_VS_CSS_OP_SET_NEXT_SLOT 0x02
1168struct ble_hci_vs_css_set_next_slot_cp {
1169 uint8_t opcode;
1170 uint16_t slot_idx;
1171} __attribute__((packed));
1172#define BLE_HCI_VS_CSS_OP_SET_CONN_SLOT 0x03
1173struct ble_hci_vs_css_set_conn_slot_cp {
1174 uint8_t opcode;
1175 uint16_t conn_handle;
1176 uint16_t slot_idx;
1177} __attribute__((packed));
1178
1179#define BLE_HCI_OCF_VS_DUPLICATE_EXCEPTION_LIST (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0108))
1180struct ble_hci_vs_duplicate_exception_list_cp {
1181 uint8_t operation;
1182 uint32_t type;
1183 uint8_t device_info[6];
1184} __attribute__((packed));
1185
1186#define BLE_HCI_OCF_VS_LEGACY_ADV_CLEAR (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x010C))
1187
1188#if SOC_BLE_POWER_CONTROL_SUPPORTED
1189#define BLE_HCI_OCF_VS_PCL_SET_RSSI (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0111))
1190#endif
1191
1192#define BLE_HCI_OCF_VS_SET_CHAN_SELECT (MYNEWT_VAL(BLE_HCI_VS_OCF_OFFSET) + (0x0112))
1193
1194/* Command Specific Definitions */
1195/* --- Set controller to host flow control (OGF 0x03, OCF 0x0031) --- */
1196#define BLE_HCI_CTLR_TO_HOST_FC_OFF (0)
1197#define BLE_HCI_CTLR_TO_HOST_FC_ACL (1)
1198#define BLE_HCI_CTLR_TO_HOST_FC_SYNC (2)
1199#define BLE_HCI_CTLR_TO_HOST_FC_BOTH (3)
1200
1201/* --- LE set advertising parameters (OCF 0x0006) */
1202/* Advertising types */
1203#define BLE_HCI_ADV_TYPE_ADV_IND (0)
1204#define BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_HD (1)
1205#define BLE_HCI_ADV_TYPE_ADV_SCAN_IND (2)
1206#define BLE_HCI_ADV_TYPE_ADV_NONCONN_IND (3)
1207#define BLE_HCI_ADV_TYPE_ADV_DIRECT_IND_LD (4)
1208#define BLE_HCI_ADV_TYPE_MAX (4)
1209
1210#define BLE_HCI_ADV_CONN_MASK (0x0001)
1211#define BLE_HCI_ADV_SCAN_MASK (0x0002)
1212#define BLE_HCI_ADV_DIRECT_MASK (0x0004)
1213#define BLE_HCI_ADV_SCAN_RSP_MASK (0x0008)
1214#define BLE_HCI_ADV_LEGACY_MASK (0x0010)
1215
1216#define BLE_HCI_ADV_DATA_STATUS_COMPLETE (0x0000)
1217#define BLE_HCI_ADV_DATA_STATUS_INCOMPLETE (0x0020)
1218#define BLE_HCI_ADV_DATA_STATUS_TRUNCATED (0x0040)
1219#define BLE_HCI_ADV_DATA_STATUS_MASK (0x0060)
1220
1221/* Own address types */
1222#define BLE_HCI_ADV_OWN_ADDR_PUBLIC (0)
1223#define BLE_HCI_ADV_OWN_ADDR_RANDOM (1)
1224#define BLE_HCI_ADV_OWN_ADDR_PRIV_PUB (2)
1225#define BLE_HCI_ADV_OWN_ADDR_PRIV_RAND (3)
1226#define BLE_HCI_ADV_OWN_ADDR_MAX (3)
1227
1228/* Advertisement peer address Type */
1229#define BLE_HCI_ADV_PEER_ADDR_PUBLIC (0)
1230#define BLE_HCI_ADV_PEER_ADDR_RANDOM (1)
1231#define BLE_HCI_ADV_PEER_ADDR_MAX (1)
1232
1233/* --- LE advertising channel tx power (OCF 0x0007) */
1234#define BLE_HCI_ADV_CHAN_TXPWR_MIN (-20)
1235#define BLE_HCI_ADV_CHAN_TXPWR_MAX (10)
1236
1237/* --- LE set scan enable (OCF 0x000c) */
1238
1239/* Connect peer address type */
1240#define BLE_HCI_CONN_PEER_ADDR_PUBLIC (0)
1241#define BLE_HCI_CONN_PEER_ADDR_RANDOM (1)
1242#define BLE_HCI_CONN_PEER_ADDR_PUBLIC_IDENT (2)
1243#define BLE_HCI_CONN_PEER_ADDR_RANDOM_IDENT (3)
1244#define BLE_HCI_CONN_PEER_ADDR_MAX (3)
1245
1246/*
1247 * Advertising filter policy
1248 *
1249 * Determines how an advertiser filters scan and connection requests.
1250 *
1251 * NONE: no filtering (default value). No whitelist used.
1252 * SCAN: process all connection requests but only scans from white list.
1253 * CONN: process all scan request but only connection requests from white list
1254 * BOTH: ignore all scan and connection requests unless in white list.
1255 */
1256#define BLE_HCI_ADV_FILT_NONE (0)
1257#define BLE_HCI_ADV_FILT_SCAN (1)
1258#define BLE_HCI_ADV_FILT_CONN (2)
1259#define BLE_HCI_ADV_FILT_BOTH (3)
1260#define BLE_HCI_ADV_FILT_MAX (3)
1261
1262#define BLE_HCI_ADV_FILT_DEF (BLE_HCI_ADV_FILT_NONE)
1263
1264/* Advertising interval */
1265#define BLE_HCI_ADV_ITVL (625) /* usecs */
1266#define BLE_HCI_ADV_ITVL_MIN (32) /* units */
1267#define BLE_HCI_ADV_ITVL_MAX (16384) /* units */
1268#define BLE_HCI_ADV_ITVL_NONCONN_MIN (160) /* units */
1269
1270#define BLE_HCI_ADV_ITVL_DEF (0x800) /* 1.28 seconds */
1271#define BLE_HCI_ADV_CHANMASK_DEF (0x7) /* all channels */
1272
1273#define BLE_HCI_PERIODIC_ADV_ITVL (1250) /* usecs */
1274
1275/* Set scan parameters */
1276#define BLE_HCI_SCAN_TYPE_PASSIVE (0)
1277#define BLE_HCI_SCAN_TYPE_ACTIVE (1)
1278
1279/* Scan interval and scan window timing */
1280#define BLE_HCI_SCAN_ITVL (625) /* usecs */
1281#define BLE_HCI_SCAN_ITVL_MIN (0x0004) /* units */
1282#define BLE_HCI_SCAN_ITVL_MAX (0x4000) /* units */
1283#define BLE_HCI_SCAN_ITVL_MAX_EXT (0xffff) /* units */
1284#define BLE_HCI_SCAN_ITVL_DEF (16) /* units */
1285#define BLE_HCI_SCAN_WINDOW_MIN (0x0004) /* units */
1286#define BLE_HCI_SCAN_WINDOW_MAX (0x4000) /* units */
1287#define BLE_HCI_SCAN_WINDOW_MAX_EXT (0xffff) /* units */
1288#define BLE_HCI_SCAN_WINDOW_DEF (16) /* units */
1289
1290/*
1291 * Scanning filter policy
1292 * NO_WL:
1293 * Scanner processes all advertising packets (white list not used) except
1294 * directed, connectable advertising packets not sent to the scanner.
1295 * USE_WL:
1296 * Scanner processes advertisements from white list only. A connectable,
1297 * directed advertisment is ignored unless it contains scanners address.
1298 * NO_WL_INITA:
1299 * Scanner process all advertising packets (white list not used). A
1300 * connectable, directed advertisement shall not be ignored if the InitA
1301 * is a resolvable private address.
1302 * USE_WL_INITA:
1303 * Scanner process advertisements from white list only. A connectable,
1304 * directed advertisement shall not be ignored if the InitA is a
1305 * resolvable private address.
1306 */
1307#define BLE_HCI_SCAN_FILT_NO_WL (0)
1308#define BLE_HCI_SCAN_FILT_USE_WL (1)
1309#define BLE_HCI_SCAN_FILT_NO_WL_INITA (2)
1310#define BLE_HCI_SCAN_FILT_USE_WL_INITA (3)
1311#define BLE_HCI_SCAN_FILT_MAX (3)
1312
1313/* Whitelist commands */
1314#define BLE_HCI_ADD_WHITE_LIST_LEN (7)
1315#define BLE_HCI_RMV_WHITE_LIST_LEN (7)
1316
1317/* Create Connection */
1318#define BLE_HCI_CREATE_CONN_LEN (25)
1319#define BLE_HCI_CONN_ITVL (1250) /* usecs */
1320#define BLE_HCI_CONN_FILT_NO_WL (0)
1321#define BLE_HCI_CONN_FILT_USE_WL (1)
1322#define BLE_HCI_CONN_FILT_MAX (1)
1323#define BLE_HCI_CONN_ITVL_MIN (0x0006)
1324#define BLE_HCI_CONN_ITVL_MAX (0x0c80)
1325#define BLE_HCI_CONN_LATENCY_MIN (0x0000)
1326#define BLE_HCI_CONN_LATENCY_MAX (0x01f3)
1327#define BLE_HCI_CONN_SPVN_TIMEOUT_MIN (0x000a)
1328#define BLE_HCI_CONN_SPVN_TIMEOUT_MAX (0x0c80)
1329#define BLE_HCI_CONN_SPVN_TMO_UNITS (10) /* msecs */
1330#define BLE_HCI_INITIATOR_FILT_POLICY_MAX (1)
1331
1332/* Peer Address Type */
1333#define BLE_HCI_CONN_PEER_ADDR_PUBLIC (0)
1334#define BLE_HCI_CONN_PEER_ADDR_RANDOM (1)
1335#define BLE_HCI_CONN_PEER_ADDR_PUB_ID (2)
1336#define BLE_HCI_CONN_PEER_ADDR_RAND_ID (3)
1337#define BLE_HCI_CONN_PEER_ADDR_MAX (3)
1338
1339
1340/* --- LE set data length (OCF 0x0022) */
1341#define BLE_HCI_SET_DATALEN_TX_OCTETS_MIN (0x001b)
1342#define BLE_HCI_SET_DATALEN_TX_OCTETS_MAX (0x00fb)
1343#define BLE_HCI_SET_DATALEN_TX_TIME_MIN (0x0148)
1344#define BLE_HCI_SET_DATALEN_TX_TIME_MAX (0x4290)
1345
1346/* --- LE read/write suggested default data length (OCF 0x0023 and 0x0024) */
1347#define BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MIN (0x001b)
1348#define BLE_HCI_SUGG_DEF_DATALEN_TX_OCTETS_MAX (0x00fb)
1349#define BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MIN (0x0148)
1350#define BLE_HCI_SUGG_DEF_DATALEN_TX_TIME_MAX (0x4290)
1351
1352/* --- LE read maximum default PHY (OCF 0x0030) */
1353#define BLE_HCI_LE_PHY_1M (1)
1354#define BLE_HCI_LE_PHY_2M (2)
1355#define BLE_HCI_LE_PHY_CODED (3)
1356
1357/* --- LE set default PHY (OCF 0x0031) */
1358#define BLE_HCI_LE_PHY_NO_TX_PREF_MASK (0x01)
1359#define BLE_HCI_LE_PHY_NO_RX_PREF_MASK (0x02)
1360#define BLE_HCI_LE_PHY_1M_PREF_MASK (0x01)
1361#define BLE_HCI_LE_PHY_2M_PREF_MASK (0x02)
1362#define BLE_HCI_LE_PHY_CODED_PREF_MASK (0x04)
1363
1364#define BLE_HCI_LE_PHY_PREF_MASK_ALL \
1365 (BLE_HCI_LE_PHY_1M_PREF_MASK | BLE_HCI_LE_PHY_2M_PREF_MASK | \
1366 BLE_HCI_LE_PHY_CODED_PREF_MASK)
1367
1368/* --- LE set PHY (OCF 0x0032) */
1369#define BLE_HCI_LE_PHY_CODED_ANY (0x0000)
1370#define BLE_HCI_LE_PHY_CODED_S2_PREF (0x0001)
1371#define BLE_HCI_LE_PHY_CODED_S8_PREF (0x0002)
1372
1373/* --- LE enhanced receiver test (OCF 0x0033) */
1374#define BLE_HCI_LE_PHY_1M (1)
1375#define BLE_HCI_LE_PHY_2M (2)
1376#define BLE_HCI_LE_PHY_CODED (3)
1377
1378/* --- LE enhanced transmitter test (OCF 0x0034) */
1379#define BLE_HCI_LE_PHY_CODED_S8 (3)
1380#define BLE_HCI_LE_PHY_CODED_S2 (4)
1381
1382/* --- LE set extended advertising parameters (OCF 0x0036) */
1383#define BLE_HCI_LE_SET_EXT_ADV_PROP_CONNECTABLE (0x0001)
1384#define BLE_HCI_LE_SET_EXT_ADV_PROP_SCANNABLE (0x0002)
1385#define BLE_HCI_LE_SET_EXT_ADV_PROP_DIRECTED (0x0004)
1386#define BLE_HCI_LE_SET_EXT_ADV_PROP_HD_DIRECTED (0x0008)
1387#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY (0x0010)
1388#define BLE_HCI_LE_SET_EXT_ADV_PROP_ANON_ADV (0x0020)
1389#define BLE_HCI_LE_SET_EXT_ADV_PROP_INC_TX_PWR (0x0040)
1390#define BLE_HCI_LE_SET_EXT_ADV_PROP_MASK (0x7F)
1391
1392#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_IND (0x0013)
1393#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_LD_DIR (0x0015)
1394#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_HD_DIR (0x001d)
1395#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_SCAN (0x0012)
1396#define BLE_HCI_LE_SET_EXT_ADV_PROP_LEGACY_NONCONN (0x0010)
1397
1398/* --- LE set extended advertising data (OCF 0x0037) */
1399#define BLE_HCI_MAX_EXT_ADV_DATA_LEN (251)
1400
1401#define BLE_HCI_LE_SET_DATA_OPER_INT (0)
1402#define BLE_HCI_LE_SET_DATA_OPER_FIRST (1)
1403#define BLE_HCI_LE_SET_DATA_OPER_LAST (2)
1404#define BLE_HCI_LE_SET_DATA_OPER_COMPLETE (3)
1405#define BLE_HCI_LE_SET_DATA_OPER_UNCHANGED (4)
1406
1407/* --- LE set extended scan response data (OCF 0x0038) */
1408#define BLE_HCI_MAX_EXT_SCAN_RSP_DATA_LEN (251)
1409
1410/* --- LE set periodic advertising parameters (OCF 0x003E) */
1411#define BLE_HCI_LE_SET_PERIODIC_ADV_PROP_INC_TX_PWR (0x0040)
1412#define BLE_HCI_LE_SET_PERIODIC_ADV_PROP_MASK (0x0040)
1413
1414/* --- LE set periodic advertising data (OCF 0x003F) */
1415#define BLE_HCI_MAX_PERIODIC_ADV_DATA_LEN (252)
1416
1417/* --- LE remove device from periodic advertising list (OCF 0x0048) */
1418#define BLE_HCI_PERIODIC_DATA_STATUS_COMPLETE 0x00
1419#define BLE_HCI_PERIODIC_DATA_STATUS_INCOMPLETE 0x01
1420#define BLE_HCI_PERIODIC_DATA_STATUS_TRUNCATED 0x02
1421
1422/* --- LE set privacy mode (OCF 0x004E) */
1423#define BLE_HCI_PRIVACY_NETWORK (0)
1424#define BLE_HCI_PRIVACY_DEVICE (1)
1425
1426/* Event Codes */
1427#define BLE_HCI_EVCODE_INQUIRY_CMP (0x01)
1428#define BLE_HCI_EVCODE_INQUIRY_RESULT (0x02)
1429#define BLE_HCI_EVCODE_CONN_DONE (0x03)
1430#define BLE_HCI_EVCODE_CONN_REQUEST (0x04)
1431#define BLE_HCI_EVCODE_DISCONN_CMP (0x05)
1432struct ble_hci_ev_disconn_cmp {
1433 uint8_t status;
1434 uint16_t conn_handle;
1435 uint8_t reason;
1436} __attribute__((packed));
1437
1438#define BLE_HCI_EVCODE_AUTH_CMP (0x06)
1439#define BLE_HCI_EVCODE_REM_NAME_REQ_CMP (0x07)
1440
1441#define BLE_HCI_EVCODE_ENCRYPT_CHG (0x08)
1442struct ble_hci_ev_enrypt_chg {
1443 uint8_t status;
1444 uint16_t connection_handle;
1445 uint8_t enabled;
1446} __attribute__((packed));
1447
1448#define BLE_HCI_EVCODE_CHG_LINK_KEY_CMP (0x09)
1449#define BLE_HCI_EVCODE_MASTER_LINK_KEY_CMP (0x0A)
1450#define BLE_HCI_EVCODE_RD_REM_SUPP_FEAT_CMP (0x0B)
1451#define BLE_HCI_EVCODE_RD_REM_VER_INFO_CMP (0x0C)
1452struct ble_hci_ev_rd_rem_ver_info_cmp {
1453 uint8_t status;
1454 uint16_t conn_handle;
1455 uint8_t version;
1456 uint16_t manufacturer;
1457 uint16_t subversion;
1458} __attribute__((packed));
1459
1460#define BLE_HCI_EVCODE_QOS_SETUP_CMP (0x0D)
1461
1462#define BLE_HCI_EVCODE_COMMAND_COMPLETE (0x0E)
1463struct ble_hci_ev_command_complete {
1464 uint8_t num_packets;
1465 uint16_t opcode;
1466 uint8_t status;
1467 uint8_t return_params[0];
1468} __attribute__((packed));
1469/* NOP is exception and has no return parameters */
1470struct ble_hci_ev_command_complete_nop {
1471 uint8_t num_packets;
1472 uint16_t opcode;
1473} __attribute__((packed));
1474
1475#define BLE_HCI_EVCODE_COMMAND_STATUS (0x0F)
1476struct ble_hci_ev_command_status {
1477 uint8_t status;
1478 uint8_t num_packets;
1479 uint16_t opcode;
1480} __attribute__((packed));
1481
1482#define BLE_HCI_EVCODE_HW_ERROR (0x10)
1483struct ble_hci_ev_hw_error {
1484 uint8_t hw_code;
1485} __attribute__((packed));
1486
1487#define BLE_HCI_EVCODE_NUM_COMP_PKTS (0x13)
1488struct comp_pkt {
1489 uint16_t handle;
1490 uint16_t packets;
1491} __attribute__((packed));;
1492struct ble_hci_ev_num_comp_pkts {
1493 uint8_t count;
1494 struct comp_pkt completed[0];
1495} __attribute__((packed));
1496
1497#define BLE_HCI_EVCODE_MODE_CHANGE (0x14)
1498#define BLE_HCI_EVCODE_RETURN_LINK_KEYS (0x15)
1499#define BLE_HCI_EVCODE_PIN_CODE_REQ (0x16)
1500#define BLE_HCI_EVCODE_LINK_KEY_REQ (0x17)
1501#define BLE_HCI_EVCODE_LINK_KEY_NOTIFY (0x18)
1502#define BLE_HCI_EVCODE_LOOPBACK_CMD (0x19)
1503
1504#define BLE_HCI_EVCODE_DATA_BUF_OVERFLOW (0x1A)
1505struct ble_hci_ev_data_buf_overflow {
1506 uint8_t link_type;
1507} __attribute__((packed));
1508
1509#define BLE_HCI_EVCODE_MAX_SLOTS_CHG (0x1B)
1510#define BLE_HCI_EVCODE_READ_CLK_OFF_COMP (0x1C)
1511#define BLE_HCI_EVCODE_CONN_PKT_TYPE_CHG (0x1D)
1512#define BLE_HCI_EVCODE_QOS_VIOLATION (0x1E)
1513/* NOTE: 0x1F not defined */
1514#define BLE_HCI_EVCODE_PSR_MODE_CHG (0x20)
1515#define BLE_HCI_EVCODE_FLOW_SPEC_COMP (0x21)
1516#define BLE_HCI_EVCODE_INQ_RESULT_RSSI (0x22)
1517#define BLE_HCI_EVCODE_READ_REM_EXT_FEAT (0x23)
1518/* NOTE: 0x24 - 0x2B not defined */
1519#define BLE_HCI_EVCODE_SYNCH_CONN_COMP (0x2C)
1520#define BLE_HCI_EVCODE_SYNCH_CONN_CHG (0x2D)
1521#define BLE_HCI_EVCODE_SNIFF_SUBRATING (0x2E)
1522#define BLE_HCI_EVCODE_EXT_INQ_RESULT (0x2F)
1523
1524#define BLE_HCI_EVCODE_ENC_KEY_REFRESH (0x30)
1525struct ble_hci_ev_enc_key_refresh {
1526 uint8_t status;
1527 uint16_t conn_handle;
1528} __attribute__((packed));
1529
1530#define BLE_HCI_EVOCDE_IO_CAP_REQ (0x31)
1531#define BLE_HCI_EVCODE_IO_CAP_RSP (0x32)
1532#define BLE_HCI_EVCODE_USER_CONFIRM_REQ (0x33)
1533#define BLE_HCI_EVCODE_PASSKEY_REQ (0x34)
1534#define BLE_HCI_EVCODE_REM_OOB_DATA_REQ (0x35)
1535#define BLE_HCI_EVCODE_SIMPLE_PAIR_COMP (0x36)
1536/* NOTE: 0x37 not defined */
1537#define BLE_HCI_EVCODE_LNK_SPVN_TMO_CHG (0x38)
1538#define BLE_HCI_EVCODE_ENH_FLUSH_COMP (0x39)
1539#define BLE_HCI_EVCODE_USER_PASSKEY_NOTIFY (0x3B)
1540#define BLE_HCI_EVCODE_KEYPRESS_NOTIFY (0x3C)
1541#define BLE_HCI_EVCODE_REM_HOST_SUPP_FEAT (0x3D)
1542
1543#define BLE_HCI_EVCODE_LE_META (0x3E)
1544struct ble_hci_ev_le_meta {
1545 uint8_t subevent;
1546 uint8_t data[0];
1547} __attribute__((packed));
1548
1549/* NOTE: 0x3F not defined */
1550#define BLE_HCI_EVCODE_PHYS_LINK_COMP (0x40)
1551#define BLE_HCI_EVCODE_CHAN_SELECTED (0x41)
1552#define BLE_HCI_EVCODE_DISCONN_PHYS_LINK (0x42)
1553#define BLE_HCI_EVCODE_PHYS_LINK_LOSS_EARLY (0x43)
1554#define BLE_HCI_EVCODE_PHYS_LINK_RECOVERY (0x44)
1555#define BLE_HCI_EVCODE_LOGICAL_LINK_COMP (0x45)
1556#define BLE_HCI_EVCODE_DISCONN_LOGICAL_LINK (0x46)
1557#define BLE_HCI_EVCODE_FLOW_SPEC_MODE_COMP (0x47)
1558#define BLE_HCI_EVCODE_NUM_COMP_DATA_BLKS (0x48)
1559#define BLE_HCI_EVCODE_AMP_START_TEST (0x49)
1560#define BLE_HCI_EVOCDE_AMP_TEST_END (0x4A)
1561#define BLE_HCI_EVOCDE_AMP_RCVR_REPORT (0x4B)
1562#define BLE_HCI_EVCODE_SHORT_RANGE_MODE_CHG (0x4C)
1563#define BLE_HCI_EVCODE_AMP_STATUS_CHG (0x4D)
1564#define BLE_HCI_EVCODE_TRIG_CLK_CAPTURE (0x4E)
1565#define BLE_HCI_EVCODE_SYNCH_TRAIN_COMP (0x4F)
1566#define BLE_HCI_EVCODE_SYNCH_TRAIN_RCVD (0x50)
1567#define BLE_HCI_EVCODE_SLAVE_BCAST_RX (0x51)
1568#define BLE_HCI_EVCODE_SLAVE_BCAST_TMO (0x52)
1569#define BLE_HCI_EVCODE_TRUNC_PAGE_COMP (0x53)
1570#define BLE_HCI_EVCODE_SLAVE_PAGE_RSP_TMO (0x54)
1571#define BLE_HCI_EVCODE_SLAVE_BCAST_CHAN_MAP (0x55)
1572#define BLE_HCI_EVCODE_INQ_RSP_NOTIFY (0x56)
1573
1574#define BLE_HCI_EVCODE_AUTH_PYLD_TMO (0x57)
1575struct ble_hci_ev_auth_pyld_tmo {
1576 uint16_t conn_handle;
1577} __attribute__((packed));
1578
1579#define BLE_HCI_EVCODE_SAM_STATUS_CHG (0x58)
1580
1581#define BLE_HCI_EVCODE_VS_DEBUG (0xFF)
1582struct ble_hci_ev_vs_debug {
1583 uint8_t id;
1584 uint8_t data[0];
1585} __attribute__((packed));
1586
1587/* LE sub-event codes */
1588#define BLE_HCI_LE_SUBEV_CONN_COMPLETE (0x01)
1589struct ble_hci_ev_le_subev_conn_complete {
1590 uint8_t subev_code;
1591 uint8_t status;
1592 uint16_t conn_handle;
1593 uint8_t role;
1594 uint8_t peer_addr_type;
1595 uint8_t peer_addr[6];
1596 uint16_t conn_itvl;
1597 uint16_t conn_latency;
1598 uint16_t supervision_timeout;
1599 uint8_t mca;
1600} __attribute__((packed));
1601
1602#define BLE_HCI_LE_SUBEV_ADV_RPT (0x02)
1603struct adv_report {
1604 uint8_t type;
1605 uint8_t addr_type;
1606 uint8_t addr[6];
1607 uint8_t data_len;
1608 uint8_t data[0];
1609} __attribute__((packed));
1610struct ble_hci_ev_le_subev_adv_rpt {
1611 uint8_t subev_code;
1612 uint8_t num_reports;
1613 struct adv_report reports[0];
1614} __attribute__((packed));
1615
1616#define BLE_HCI_LE_SUBEV_CONN_UPD_COMPLETE (0x03)
1617struct ble_hci_ev_le_subev_conn_upd_complete {
1618 uint8_t subev_code;
1619 uint8_t status;
1620 uint16_t conn_handle;
1621 uint16_t conn_itvl;
1622 uint16_t conn_latency;
1623 uint16_t supervision_timeout;
1624} __attribute__((packed));
1625
1626#define BLE_HCI_LE_SUBEV_RD_REM_USED_FEAT (0x04)
1627struct ble_hci_ev_le_subev_rd_rem_used_feat {
1628 uint8_t subev_code;
1629 uint8_t status;
1630 uint16_t conn_handle;
1631 uint8_t features[8];
1632} __attribute__((packed));
1633
1634#define BLE_HCI_LE_SUBEV_LT_KEY_REQ (0x05)
1635struct ble_hci_ev_le_subev_lt_key_req {
1636 uint8_t subev_code;
1637 uint16_t conn_handle;
1638 uint64_t rand;
1639 uint16_t div;
1640} __attribute__((packed));
1641
1642#define BLE_HCI_LE_SUBEV_REM_CONN_PARM_REQ (0x06)
1643struct ble_hci_ev_le_subev_rem_conn_param_req {
1644 uint8_t subev_code;
1645 uint16_t conn_handle;
1646 uint16_t min_interval;
1647 uint16_t max_interval;
1648 uint16_t latency;
1649 uint16_t timeout;
1650} __attribute__((packed));
1651
1652#define BLE_HCI_LE_SUBEV_DATA_LEN_CHG (0x07)
1653struct ble_hci_ev_le_subev_data_len_chg {
1654 uint8_t subev_code;
1655 uint16_t conn_handle;
1656 uint16_t max_tx_octets;
1657 uint16_t max_tx_time;
1658 uint16_t max_rx_octets;
1659 uint16_t max_rx_time;
1660} __attribute__((packed));
1661
1662#define BLE_HCI_LE_SUBEV_RD_LOC_P256_PUBKEY (0x08)
1663struct ble_hci_ev_le_subev_rd_loc_p256_pubkey {
1664 uint8_t subev_code;
1665 uint8_t status;
1666 uint8_t public_key[64];
1667} __attribute__((packed));
1668
1669#define BLE_HCI_LE_SUBEV_GEN_DHKEY_COMPLETE (0x09)
1670struct ble_hci_ev_le_subev_gen_dhkey_complete {
1671 uint8_t subev_code;
1672 uint8_t status;
1673 uint8_t dh_key[32];
1674} __attribute__((packed));
1675
1676#define BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE (0x0A)
1677struct ble_hci_ev_le_subev_enh_conn_complete {
1678 uint8_t subev_code;
1679 uint8_t status;
1680 uint16_t conn_handle;
1681 uint8_t role;
1682 uint8_t peer_addr_type;
1683 uint8_t peer_addr[6];
1684 uint8_t local_rpa[6];
1685 uint8_t peer_rpa[6];
1686 uint16_t conn_itvl;
1687 uint16_t conn_latency;
1688 uint16_t supervision_timeout;
1689 uint8_t mca;
1690} __attribute__((packed));
1691
1692#define BLE_HCI_LE_SUBEV_DIRECT_ADV_RPT (0x0B)
1693struct dir_adv_report {
1694 uint8_t type;
1695 uint8_t addr_type;
1696 uint8_t addr[6];
1697 uint8_t dir_addr_type;
1698 uint8_t dir_addr[6];
1699 int8_t rssi;
1700} __attribute__((packed));
1701struct ble_hci_ev_le_subev_direct_adv_rpt {
1702 uint8_t subev_code;
1703 uint8_t num_reports;
1704 struct dir_adv_report reports[0];
1705} __attribute__((packed));
1706
1707#define BLE_HCI_LE_SUBEV_PHY_UPDATE_COMPLETE (0x0C)
1708struct ble_hci_ev_le_subev_phy_update_complete {
1709 uint8_t subev_code;
1710 uint8_t status;
1711 uint16_t conn_handle;
1712 uint8_t tx_phy;
1713 uint8_t rx_phy;
1714} __attribute__((packed));
1715
1716#define BLE_HCI_LE_SUBEV_EXT_ADV_RPT (0x0D)
1717struct ext_adv_report {
1718 uint16_t evt_type;
1719 uint8_t addr_type;
1720 uint8_t addr[6];
1721 uint8_t pri_phy;
1722 uint8_t sec_phy;
1723 uint8_t sid;
1724 int8_t tx_power;
1725 int8_t rssi;
1726 uint16_t periodic_itvl;
1727 uint8_t dir_addr_type;
1728 uint8_t dir_addr[6];
1729 uint8_t data_len;
1730 uint8_t data[0];
1731} __attribute__((packed));
1732struct ble_hci_ev_le_subev_ext_adv_rpt {
1733 uint8_t subev_code;
1734 uint8_t num_reports;
1735 struct ext_adv_report reports[0];
1736} __attribute__((packed));
1737
1738#define BLE_HCI_LE_SUBEV_PERIODIC_ADV_SYNC_ESTAB (0x0E)
1739struct ble_hci_ev_le_subev_periodic_adv_sync_estab {
1740 uint8_t subev_code;
1741 uint8_t status;
1742 uint16_t sync_handle;
1743 uint8_t sid;
1744 uint8_t peer_addr_type;
1745 uint8_t peer_addr[6];
1746 uint8_t phy;
1747 uint16_t interval;
1748 uint8_t aca;
1749} __attribute__((packed));
1750
1751#define BLE_HCI_LE_SUBEV_PERIODIC_ADV_RPT (0x0F)
1752struct ble_hci_ev_le_subev_periodic_adv_rpt {
1753 uint8_t subev_code;
1754 uint16_t sync_handle;
1755 int8_t tx_power;
1756 int8_t rssi;
1757 uint8_t cte_type;
1758 uint8_t data_status;
1759 uint8_t data_len;
1760 uint8_t data[0];
1761} __attribute__((packed));
1762
1763#define BLE_HCI_LE_SUBEV_PERIODIC_ADV_SYNC_LOST (0x10)
1764struct ble_hci_ev_le_subev_periodic_adv_sync_lost {
1765 uint8_t subev_code;
1766 uint16_t sync_handle;
1767} __attribute__((packed));
1768
1769#define BLE_HCI_LE_SUBEV_SCAN_TIMEOUT (0x11)
1770struct ble_hci_ev_le_subev_scan_timeout {
1771 uint8_t subev_code;
1772} __attribute__((packed));
1773
1774#define BLE_HCI_LE_SUBEV_ADV_SET_TERMINATED (0x12)
1775struct ble_hci_ev_le_subev_adv_set_terminated {
1776 uint8_t subev_code;
1777 uint8_t status;
1778 uint8_t adv_handle;
1779 uint16_t conn_handle;
1780 uint8_t num_events;
1781} __attribute__((packed));
1782
1783#define BLE_HCI_LE_SUBEV_SCAN_REQ_RCVD (0x13)
1784struct ble_hci_ev_le_subev_scan_req_rcvd {
1785 uint8_t subev_code;
1786 uint8_t adv_handle;
1787 uint8_t peer_addr_type;
1788 uint8_t peer_addr[6];
1789} __attribute__((packed));
1790
1791#define BLE_HCI_LE_SUBEV_CHAN_SEL_ALG (0x14)
1792struct ble_hci_ev_le_subev_chan_sel_alg {
1793 uint8_t subev_code;
1794 uint16_t conn_handle;
1795 uint8_t csa;
1796} __attribute__((packed));
1797
1798#define BLE_HCI_LE_SUBEV_CONNLESS_IQ_RPT (0x15)
1799#define BLE_HCI_LE_SUBEV_CONN_IQ_RPT (0x16)
1800#define BLE_HCI_LE_SUBEV_CTE_REQ_FAILED (0x17)
1801
1802#define BLE_HCI_LE_SUBEV_PERIODIC_ADV_SYNC_TRANSFER (0x18)
1803struct ble_hci_ev_le_subev_periodic_adv_sync_transfer {
1804 uint8_t subev_code;
1805 uint8_t status;
1806 uint16_t conn_handle;
1807 uint16_t service_data;
1808 uint16_t sync_handle;
1809 uint8_t sid;
1810 uint8_t peer_addr_type;
1811 uint8_t peer_addr[6];
1812 uint8_t phy;
1813 uint16_t interval;
1814 uint8_t aca;
1815} __attribute__((packed));
1816
1817#define BLE_HCI_LE_SUBEV_CIS_ESTAB (0x19)
1818struct ble_hci_ev_le_subev_cis_established {
1819 uint8_t subev_code;
1820 uint8_t status;
1821 uint16_t cis_handle;
1822 uint8_t cig_sync_delay[3];
1823 uint8_t cis_sync_delay[3];
1824 uint8_t trans_latency_mtos[3];
1825 uint8_t trans_latency_stom[3];
1826 uint8_t phy_mtos;
1827 uint8_t phy_stom;
1828 uint8_t nse;
1829 uint8_t bn_mtos;
1830 uint8_t bn_stom;
1831 uint8_t ft_mtos;
1832 uint8_t ft_stom;
1833 uint16_t max_pdu_mtos;
1834 uint16_t max_pdu_stom;
1835 uint16_t iso_interval;
1836} __attribute__((packed));
1837
1838#define BLE_HCI_LE_SUBEV_CIS_REQUEST (0x1A)
1839struct ble_hci_ev_le_subev_cis_request {
1840 uint8_t subev_code;
1841 uint16_t conn_handle;
1842 uint16_t cis_handle;
1843 uint8_t cig_id;
1844 uint8_t cis_id;
1845} __attribute__((packed));
1846
1847#define BLE_HCI_LE_SUBEV_BIG_COMP (0x1B)
1848struct ble_hci_ev_le_subev_big_complete {
1849 uint8_t subev_code;
1850 uint8_t status;
1851 uint8_t big_handle;
1852 uint8_t big_sync_delay[3];
1853 uint8_t transport_latency[3];
1854 uint8_t phy;
1855 uint8_t nse;
1856 uint8_t bn;
1857 uint8_t pto;
1858 uint8_t irc;
1859 uint16_t max_pdu;
1860 uint16_t iso_interval;
1861 uint8_t bis_cnt;
1862 uint16_t bis[0];
1863} __attribute__((packed));
1864
1865#define BLE_HCI_LE_SUBEV_BIG_TERMINATE_COMP (0x1C)
1866struct ble_hci_ev_le_subev_big_terminate_complete {
1867 uint8_t subev_code;
1868 uint8_t big_handle;
1869 uint8_t reason;
1870} __attribute__((packed));
1871
1872#define BLE_HCI_LE_SUBEV_BIG_SYNC_ESTAB (0x1D)
1873struct ble_hci_ev_le_subev_big_sync_established {
1874 uint8_t subev_code;
1875 uint8_t status;
1876 uint8_t big_handle;
1877 uint8_t transport_latency[3];
1878 uint8_t nse;
1879 uint8_t bn;
1880 uint8_t pto;
1881 uint8_t irc;
1882 uint16_t max_pdu;
1883 uint16_t iso_interval;
1884 uint8_t bis_cnt;
1885 uint16_t bis_handles[0];
1886} __attribute__((packed));
1887
1888#define BLE_HCI_LE_SUBEV_BIG_SYNC_LOST (0x1E)
1889struct ble_hci_ev_le_subev_big_sync_lost {
1890 uint8_t subev_code;
1891 uint8_t big_handle;
1892 uint8_t reason;
1893} __attribute__((packed));
1894
1895#define BLE_HCI_LE_SUBEV_REQ_PEER_SCA_COMP (0x1F)
1896struct ble_hci_ev_le_subev_peer_sca_complete {
1897 uint8_t subev_code;
1898 uint8_t status;
1899 uint16_t conn_handle;
1900 uint8_t sca;
1901} __attribute__((packed));
1902
1903#define BLE_HCI_LE_SUBEV_PATH_LOSS_THRESHOLD (0x20)
1904struct ble_hci_ev_le_subev_path_loss_threshold {
1905 uint8_t subev_code;
1906 uint16_t conn_handle;
1907 uint8_t current_path_loss;
1908 uint8_t zone_entered;
1909} __attribute__((packed));
1910
1911#define BLE_HCI_LE_SUBEV_TRANSMIT_POWER_REPORT (0x21)
1912struct ble_hci_ev_le_subev_transmit_power_report {
1913 uint8_t subev_code;
1914 uint8_t status;
1915 uint16_t conn_handle;
1916 uint8_t reason;
1917 uint8_t phy;
1918 int8_t transmit_power_level;
1919 uint8_t transmit_power_level_flag;
1920 int8_t delta;
1921} __attribute__((packed));
1922
1923#define BLE_HCI_LE_SUBEV_BIGINFO_ADV_REPORT (0x22)
1924struct ble_hci_ev_le_subev_biginfo_adv_report {
1925 uint8_t subev_code;
1926 uint16_t sync_handle;
1927 uint8_t bis_cnt;
1928 uint8_t nse;
1929 uint16_t iso_interval;
1930 uint8_t bn;
1931 uint8_t pto;
1932 uint8_t irc;
1933 uint16_t max_pdu;
1934 uint8_t sdu_interval[3];
1935 uint16_t max_sdu;
1936 uint8_t phy;
1937 uint8_t framing;
1938 uint8_t encryption;
1939} __attribute__((packed));
1940
1941#define BLE_HCI_LE_SUBEV_SUBRATE_CHANGE (0x23)
1942struct ble_hci_ev_le_subev_subrate_change {
1943 uint8_t subev_code;
1944 uint8_t status;
1945 uint16_t conn_handle;
1946 uint16_t subrate_factor;
1947 uint16_t periph_latency;
1948 uint16_t cont_num;
1949 uint16_t supervision_tmo;
1950} __attribute__((packed));
1951
1952#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
1953// LE vendor hci event
1954#define BLE_HCI_LE_SUBEV_DISCARD_REPORT_EVT 0XF0
1955#endif // (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
1956
1957/* Data buffer overflow event */
1958#define BLE_HCI_EVENT_ACL_BUF_OVERFLOW (0x01)
1959
1960/* Advertising report */
1961#define BLE_HCI_ADV_RPT_EVTYPE_ADV_IND (0)
1962#define BLE_HCI_ADV_RPT_EVTYPE_DIR_IND (1)
1963#define BLE_HCI_ADV_RPT_EVTYPE_SCAN_IND (2)
1964#define BLE_HCI_ADV_RPT_EVTYPE_NONCONN_IND (3)
1965#define BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP (4)
1966
1967/* Bluetooth 5, Vol 2, Part E, 7.7.65.13 */
1968#define BLE_HCI_LEGACY_ADV_EVTYPE_ADV_IND (0x13)
1969#define BLE_HCI_LEGACY_ADV_EVTYPE_ADV_DIRECT_IND (0x15)
1970#define BLE_HCI_LEGACY_ADV_EVTYPE_ADV_SCAN_IND (0x12)
1971#define BLE_HCI_LEGACY_ADV_EVTYPE_ADV_NONCON_IND (0x10)
1972#define BLE_HCI_LEGACY_ADV_EVTYPE_SCAN_RSP_ADV_IND (0x1b)
1973#define BLE_HCI_LEGACY_ADV_EVTYPE_SCAN_RSP_ADV_SCAN_IND (0x1a)
1974
1975/* LE connection complete event (sub event 0x01) */
1976#define BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER (0x00)
1977#define BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE (0x01)
1978
1979/* Maximum valid connection handle value */
1980#define BLE_HCI_LE_CONN_HANDLE_MAX (0x0eff)
1981
1982/* LE advertising report event. (sub event 0x02) */
1983#define BLE_HCI_LE_ADV_RPT_NUM_RPTS_MIN (1)
1984#define BLE_HCI_LE_ADV_RPT_NUM_RPTS_MAX (0x19)
1985
1986/* Bluetooth Assigned numbers for version information.*/
1987#define BLE_HCI_VER_BCS_1_0b (0)
1988#define BLE_HCI_VER_BCS_1_1 (1)
1989#define BLE_HCI_VER_BCS_1_2 (2)
1990#define BLE_HCI_VER_BCS_2_0_EDR (3)
1991#define BLE_HCI_VER_BCS_2_1_EDR (4)
1992#define BLE_HCI_VER_BCS_3_0_HCS (5)
1993#define BLE_HCI_VER_BCS_4_0 (6)
1994#define BLE_HCI_VER_BCS_4_1 (7)
1995#define BLE_HCI_VER_BCS_4_2 (8)
1996#define BLE_HCI_VER_BCS_5_0 (9)
1997#define BLE_HCI_VER_BCS_5_1 (10)
1998#define BLE_HCI_VER_BCS_5_2 (11)
1999#define BLE_HCI_VER_BCS_5_3 (12)
2000
2001#define BLE_LMP_VER_BCS_1_0b (0)
2002#define BLE_LMP_VER_BCS_1_1 (1)
2003#define BLE_LMP_VER_BCS_1_2 (2)
2004#define BLE_LMP_VER_BCS_2_0_EDR (3)
2005#define BLE_LMP_VER_BCS_2_1_EDR (4)
2006#define BLE_LMP_VER_BCS_3_0_HCS (5)
2007#define BLE_LMP_VER_BCS_4_0 (6)
2008#define BLE_LMP_VER_BCS_4_1 (7)
2009#define BLE_LMP_VER_BCS_4_2 (8)
2010#define BLE_LMP_VER_BCS_5_0 (9)
2011#define BLE_LMP_VER_BCS_5_1 (10)
2012#define BLE_LMP_VER_BCS_5_2 (11)
2013#define BLE_LMP_VER_BCS_5_3 (12)
2014
2015/* selected HCI and LMP version */
2016#if MYNEWT_VAL(BLE_VERSION) == 50
2017#define BLE_HCI_VER_BCS BLE_HCI_VER_BCS_5_0
2018#define BLE_LMP_VER_BCS BLE_LMP_VER_BCS_5_0
2019#elif MYNEWT_VAL(BLE_VERSION) == 51
2020#define BLE_HCI_VER_BCS BLE_HCI_VER_BCS_5_1
2021#define BLE_LMP_VER_BCS BLE_LMP_VER_BCS_5_1
2022#elif MYNEWT_VAL(BLE_VERSION) == 52
2023#define BLE_HCI_VER_BCS BLE_HCI_VER_BCS_5_2
2024#define BLE_LMP_VER_BCS BLE_LMP_VER_BCS_5_2
2025#elif MYNEWT_VAL(BLE_VERSION) == 53
2026#define BLE_HCI_VER_BCS BLE_HCI_VER_BCS_5_3
2027#define BLE_LMP_VER_BCS BLE_LMP_VER_BCS_5_3
2028#endif
2029
2030#define BLE_HCI_DATA_HDR_SZ 4
2031#define BLE_HCI_DATA_HANDLE(handle_pb_bc) (((handle_pb_bc) & 0x0fff) >> 0)
2032#define BLE_HCI_DATA_PB(handle_pb_bc) (((handle_pb_bc) & 0x3000) >> 12)
2033#define BLE_HCI_DATA_BC(handle_pb_bc) (((handle_pb_bc) & 0xc000) >> 14)
2034
2035struct hci_data_hdr
2036{
2037 uint16_t hdh_handle_pb_bc;
2038 uint16_t hdh_len;
2039};
2040
2041#define BLE_HCI_PB_FIRST_NON_FLUSH 0
2042#define BLE_HCI_PB_MIDDLE 1
2043#define BLE_HCI_PB_FIRST_FLUSH 2
2044#define BLE_HCI_PB_FULL 3
2045
2046#ifdef __cplusplus
2047}
2048#endif
2049
2050#endif /* H_BLE_HCI_COMMON_ */