• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef _BT_COMMON_HCI_H
16 #define _BT_COMMON_HCI_H
17 
18 #include <stdbool.h>       // standard boolean definitions
19 #include <stddef.h>        // standard definitions
20 #include <stdint.h>        // standard integer definitions
21 
22 #include "ble_ip_config.h"   // IP configuration
23 
24 #include "compiler.h"      // compiler definitions
25 /*
26  * DEFINES
27  ****************************************************************************************
28  */
29 
30 
31 /******************************************************************************************/
32 /* -------------------------   H4TL DEFINITIONS Part IV.A    -----------------------------*/
33 /******************************************************************************************/
34 
35 ///HCI Transport Header length - change if different transport
36 #define HCI_TRANSPORT_HDR_LEN                       0x01
37 
38 ///UART header: command message type
39 #define HCI_CMD_MSG_TYPE                            0x01
40 
41 ///UART header: ACL data message type
42 #define HCI_ACL_MSG_TYPE                            0x02
43 
44 ///UART header: Synchronous data message type
45 #define HCI_SYNC_MSG_TYPE                           0x03
46 
47 ///UART header: event message type
48 #define HCI_EVT_MSG_TYPE                            0x04
49 
50 ///UART header: event message type
51 #define HCI_TCI_MSG_TYPE                            0xFF
52 
53 /******************************************************************************************/
54 /* -------------------------   HCI DEFINITIONS Part II.E     -----------------------------*/
55 /******************************************************************************************/
56 
57 ///HCI Command Opcode byte length
58 #define HCI_CMD_OPCODE_LEN         (0x02)
59 
60 ///HCI Event code byte length
61 #define HCI_EVT_CODE_LEN           (0x01)
62 
63 ///HCI Command/Event parameter length field byte length
64 #define HCI_CMDEVT_PARLEN_LEN      (0x01)
65 
66 ///HCI Command header length
67 #define HCI_CMD_HDR_LEN            (HCI_CMD_OPCODE_LEN + HCI_CMDEVT_PARLEN_LEN)
68 
69 ///HCI Event header length
70 #define HCI_EVT_HDR_LEN            (HCI_EVT_CODE_LEN + HCI_CMDEVT_PARLEN_LEN)
71 
72 /// HCI ACL header: handle and flags decoding
73 enum  hci_acl_hdr_fields
74 {
75 
76     /// bits[00:11]: Connection handle
77     HCI_ACL_HDR_HDL_LSB        = (0),
78     HCI_ACL_HDR_HDL_MASK       = (0x0FFF),
79     /// bits[12:13]: Packet boundary flag
80     HCI_ACL_HDR_PB_FLAG_LSB    = (12),
81     HCI_ACL_HDR_PB_FLAG_MASK   = (0x3000),
82     /// bits[14:15]: Broadcast flag
83     HCI_ACL_HDR_BC_FLAG_LSB    = (14),
84     HCI_ACL_HDR_BC_FLAG_MASK   = (0xC000),
85 
86     /// Packet boundary and Broadcast flags
87     HCI_ACL_HDR_DATA_FLAGS_LSB  = (12),
88     HCI_ACL_HDR_DATA_FLAGS_MASK = (0xF000),
89 };
90 
91 #define HCI_ACL_HDR_HDL_FLAGS_POS  (0)
92 #define HCI_ACL_HDR_HDL_FLAGS_LEN  (2)
93 /// HCI ACL header: data length field length
94 #define HCI_ACL_HDR_DATA_LEN_POS   (HCI_ACL_HDR_HDL_FLAGS_LEN)
95 #define HCI_ACL_HDR_DATA_LEN_LEN   (2)
96 
97 ///HCI ACL data packet header length
98 #define HCI_ACL_HDR_LEN            (HCI_ACL_HDR_HDL_FLAGS_LEN + HCI_ACL_HDR_DATA_LEN_LEN)
99 
100 /// HCI Synchronous header: handle and flags decoding
101 enum hci_syn_hdr_fields
102 {
103     /// bits[00:11]: Connection handle
104     HCI_SYNC_HDR_HDL_LSB   = (0),
105     HCI_SYNC_HDR_HDL_MASK  = (0x0FFF),
106     /// bits[12:13]: Packet status flag
107     HCI_SYNC_HDR_PSF_LSB   = (12),
108     HCI_SYNC_HDR_PSF_MASK  = (0x3000),
109     /// bits[14:15]: RFU
110     HCI_SYNC_HDR_RFU_LSB   = (14),
111     HCI_SYNC_HDR_RFU_MASK  = (0xC000),
112 };
113 
114 #define HCI_SYNC_HDR_HDL_FLAGS_POS  (0)
115 #define HCI_SYNC_HDR_HDL_FLAGS_LEN  (2)
116 #define HCI_SYNC_HDR_HDL_POS        (0)
117 #define HCI_SYNC_HDR_HDL_MASK       (0x0FFF)
118 #define HCI_SYNC_HDR_PSF_FLAG_POS   (12)
119 #define HCI_SYNC_HDR_PSF_FLAG_MASK  (0x3000)
120 #define HCI_SYNC_HDR_RES_FLAG_POS   (14)
121 #define HCI_SYNC_HDR_RES_FLAG_MASK  (0xC000)
122 #define HCI_SYNC_HDR_DATA_FLAG_POS  (12)
123 #define HCI_SYNC_HDR_DATA_FLAG_MASK (0xF000)
124 
125 /// HCI Synchronous header: data length field length
126 #define HCI_SYNC_HDR_DATA_LEN_POS   (HCI_SYNC_HDR_HDL_FLAGS_LEN)
127 #define HCI_SYNC_HDR_DATA_LEN_LEN   (1)
128 #define HCI_SYNC_MAX_DATA_SIZE      (255)
129 
130 ///HCI sync data packet header length
131 #define HCI_SYNC_HDR_LEN           (HCI_SYNC_HDR_HDL_FLAGS_LEN + HCI_SYNC_HDR_DATA_LEN_LEN)
132 
133 ///HCI Command Complete Event minimum parameter length: 1(nb_pk)+2(opcode)
134 #define HCI_CCEVT_HDR_PARLEN       (0x03)
135 
136 ///HCI Command Complete Event header length:1(code)+1(len)+1(pk)+2(opcode)
137 #define HCI_CCEVT_HDR_LEN          (HCI_EVT_HDR_LEN + HCI_CCEVT_HDR_PARLEN)
138 
139 ///HCI Basic Command Complete Event packet length
140 #define HCI_CCEVT_BASIC_LEN        (HCI_CCEVT_HDR_LEN + 1)
141 
142 ///HCI Command Status Event parameter length - constant
143 #define HCI_CSEVT_PARLEN           (0x04)
144 
145 ///HCI Command Status Event length:1(code)+1(len)+1(st)+1(pk)+2(opcode)
146 #define HCI_CSEVT_LEN              (HCI_EVT_HDR_LEN + HCI_CSEVT_PARLEN)
147 
148 ///HCI Reset Command parameter length
149 #define HCI_RESET_CMD_PARLEN       0
150 
151 /// Default return parameter length for HCI Command Complete Event
152 #define HCI_CCEVT_BASIC_RETPAR_LEN 1
153 
154 /// Max HCI commands param size
155 #define HCI_MAX_CMD_PARAM_SIZE    255
156 
157 /// Macro to extract OCF from OPCODE
158 #define HCI_OP2OCF(opcode)        ((opcode) & 0x03FF)
159 
160 /// Macro to extract OGF from OPCODE
161 #define HCI_OP2OGF(opcode)        ((opcode) >> 10 & 0x003F)
162 
163 /// Macro to create OPCODE from OGF and OCF
164 #define HCI_OPCODE(ocf, ogf)      (((ogf) << 10) | ocf)
165 
166 /// Maximum length of HCI advertising data fragments
167 #define HCI_ADV_DATA_FRAG_MAX_LEN        252
168 
169 
170 /**************************************************************************************
171  **************                       HCI COMMANDS                     ****************
172  **************************************************************************************/
173 
174 ///HCI enumeration of possible Command OGF values.
175 enum
176 {
177     ///HCI Link Control Commands Group OGF code
178     LK_CNTL_OGF = 0x01,
179     ///HCI Link Policy Commands Group OGF code
180     LK_POL_OGF,
181     ///HCI Controller and Baseband Commands Group OGF code
182     CNTLR_BB_OGF,
183     ///HCI Information Parameters Commands Group OGF code
184     INFO_PAR_OGF,
185     ///HCI Status Commands Group OGF code
186     STAT_PAR_OGF,
187     ///HCI Test Commands Group OGF code
188     TEST_OGF,
189     ///HCI Low Energy Commands Group OGF code
190     LE_CNTLR_OGF=0x08,
191     ///HCI Vendor Specific Group OGF code
192     VS_OGF = 0x3F,
193     MAX_OGF
194 };
195 
196 
197 ///Commands Opcodes: OGF(6b) | OCF(10b)
198 /* Some Abbreviation used in names:
199  *  - LK   = Link Key
200  *  - RD   = Read
201  *  - WR   = Write
202  *  - REM  = Remote
203  *  - STG  = Settings
204  *  - CON  = Connection
205  *  - CHG  = Change
206  *  - DFT  = Default
207  *  - PER  = Periodic
208  */
209 
210 ///HCI enumeration of possible Command OP Codes.
211 enum hci_opcode
212 {
213     HCI_NO_OPERATION_CMD_OPCODE               = 0x0000,
214 
215     //Link Control Commands
216     HCI_INQ_CMD_OPCODE                        = 0x0401,
217     HCI_INQ_CANCEL_CMD_OPCODE                 = 0x0402,
218     HCI_PER_INQ_MODE_CMD_OPCODE               = 0x0403,
219     HCI_EXIT_PER_INQ_MODE_CMD_OPCODE          = 0x0404,
220     HCI_CREATE_CON_CMD_OPCODE                 = 0x0405,
221     HCI_DISCONNECT_CMD_OPCODE                 = 0x0406,
222     HCI_CREATE_CON_CANCEL_CMD_OPCODE          = 0x0408,
223     HCI_ACCEPT_CON_REQ_CMD_OPCODE             = 0x0409,
224     HCI_REJECT_CON_REQ_CMD_OPCODE             = 0x040A,
225     HCI_LK_REQ_REPLY_CMD_OPCODE               = 0x040B,
226     HCI_LK_REQ_NEG_REPLY_CMD_OPCODE           = 0x040C,
227     HCI_PIN_CODE_REQ_REPLY_CMD_OPCODE         = 0x040D,
228     HCI_PIN_CODE_REQ_NEG_REPLY_CMD_OPCODE     = 0x040E,
229     HCI_CHG_CON_PKT_TYPE_CMD_OPCODE           = 0x040F,
230     HCI_AUTH_REQ_CMD_OPCODE                   = 0x0411,
231     HCI_SET_CON_ENC_CMD_OPCODE                = 0x0413,
232     HCI_CHG_CON_LK_CMD_OPCODE                 = 0x0415,
233     HCI_MASTER_LK_CMD_OPCODE                  = 0x0417,
234     HCI_REM_NAME_REQ_CMD_OPCODE               = 0x0419,
235     HCI_REM_NAME_REQ_CANCEL_CMD_OPCODE        = 0x041A,
236     HCI_RD_REM_SUPP_FEATS_CMD_OPCODE          = 0x041B,
237     HCI_RD_REM_EXT_FEATS_CMD_OPCODE           = 0x041C,
238     HCI_RD_REM_VER_INFO_CMD_OPCODE            = 0x041D,
239     HCI_RD_CLK_OFF_CMD_OPCODE                 = 0x041F,
240     HCI_RD_LMP_HDL_CMD_OPCODE                 = 0x0420,
241     HCI_SETUP_SYNC_CON_CMD_OPCODE             = 0x0428,
242     HCI_ACCEPT_SYNC_CON_REQ_CMD_OPCODE        = 0x0429,
243     HCI_REJECT_SYNC_CON_REQ_CMD_OPCODE        = 0x042A,
244     HCI_IO_CAP_REQ_REPLY_CMD_OPCODE           = 0x042B,
245     HCI_USER_CFM_REQ_REPLY_CMD_OPCODE         = 0x042C,
246     HCI_USER_CFM_REQ_NEG_REPLY_CMD_OPCODE     = 0x042D,
247     HCI_USER_PASSKEY_REQ_REPLY_CMD_OPCODE     = 0x042E,
248     HCI_USER_PASSKEY_REQ_NEG_REPLY_CMD_OPCODE = 0x042F,
249     HCI_REM_OOB_DATA_REQ_REPLY_CMD_OPCODE     = 0x0430,
250     HCI_REM_OOB_DATA_REQ_NEG_REPLY_CMD_OPCODE = 0x0433,
251     HCI_IO_CAP_REQ_NEG_REPLY_CMD_OPCODE       = 0x0434,
252     HCI_ENH_SETUP_SYNC_CON_CMD_OPCODE         = 0x043D,
253     HCI_ENH_ACCEPT_SYNC_CON_CMD_OPCODE        = 0x043E,
254     HCI_TRUNC_PAGE_CMD_OPCODE                 = 0x043F,
255     HCI_TRUNC_PAGE_CAN_CMD_OPCODE             = 0x0440,
256     HCI_SET_CON_SLV_BCST_CMD_OPCODE           = 0x0441,
257     HCI_SET_CON_SLV_BCST_REC_CMD_OPCODE       = 0x0442,
258     HCI_START_SYNC_TRAIN_CMD_OPCODE           = 0x0443,
259     HCI_REC_SYNC_TRAIN_CMD_OPCODE             = 0x0444,
260     HCI_REM_OOB_EXT_DATA_REQ_REPLY_CMD_OPCODE = 0x0445,
261 
262     //Link Policy Commands
263     HCI_HOLD_MODE_CMD_OPCODE                  = 0x0801,
264     HCI_SNIFF_MODE_CMD_OPCODE                 = 0x0803,
265     HCI_EXIT_SNIFF_MODE_CMD_OPCODE            = 0x0804,
266     HCI_PARK_STATE_CMD_OPCODE                 = 0x0805,
267     HCI_EXIT_PARK_STATE_CMD_OPCODE            = 0x0806,
268     HCI_QOS_SETUP_CMD_OPCODE                  = 0x0807,
269     HCI_ROLE_DISCOVERY_CMD_OPCODE             = 0x0809,
270     HCI_SWITCH_ROLE_CMD_OPCODE                = 0x080B,
271     HCI_RD_LINK_POL_STG_CMD_OPCODE            = 0x080C,
272     HCI_WR_LINK_POL_STG_CMD_OPCODE            = 0x080D,
273     HCI_RD_DFT_LINK_POL_STG_CMD_OPCODE        = 0x080E,
274     HCI_WR_DFT_LINK_POL_STG_CMD_OPCODE        = 0x080F,
275     HCI_FLOW_SPEC_CMD_OPCODE                  = 0x0810,
276     HCI_SNIFF_SUB_CMD_OPCODE                  = 0x0811,
277 
278     //Controller and Baseband Commands
279     HCI_SET_EVT_MASK_CMD_OPCODE               = 0x0C01,
280     HCI_RESET_CMD_OPCODE                      = 0x0C03,
281     HCI_SET_EVT_FILTER_CMD_OPCODE             = 0x0C05,
282     HCI_FLUSH_CMD_OPCODE                      = 0x0C08,
283     HCI_RD_PIN_TYPE_CMD_OPCODE                = 0x0C09,
284     HCI_WR_PIN_TYPE_CMD_OPCODE                = 0x0C0A,
285     HCI_CREATE_NEW_UNIT_KEY_CMD_OPCODE        = 0x0C0B,
286     HCI_RD_STORED_LK_CMD_OPCODE               = 0x0C0D,
287     HCI_WR_STORED_LK_CMD_OPCODE               = 0x0C11,
288     HCI_DEL_STORED_LK_CMD_OPCODE              = 0x0C12,
289     HCI_WR_LOCAL_NAME_CMD_OPCODE              = 0x0C13,
290     HCI_RD_LOCAL_NAME_CMD_OPCODE              = 0x0C14,
291     HCI_RD_CON_ACCEPT_TO_CMD_OPCODE           = 0x0C15,
292     HCI_WR_CON_ACCEPT_TO_CMD_OPCODE           = 0x0C16,
293     HCI_RD_PAGE_TO_CMD_OPCODE                 = 0x0C17,
294     HCI_WR_PAGE_TO_CMD_OPCODE                 = 0x0C18,
295     HCI_RD_SCAN_EN_CMD_OPCODE                 = 0x0C19,
296     HCI_WR_SCAN_EN_CMD_OPCODE                 = 0x0C1A,
297     HCI_RD_PAGE_SCAN_ACT_CMD_OPCODE           = 0x0C1B,
298     HCI_WR_PAGE_SCAN_ACT_CMD_OPCODE           = 0x0C1C,
299     HCI_RD_INQ_SCAN_ACT_CMD_OPCODE            = 0x0C1D,
300     HCI_WR_INQ_SCAN_ACT_CMD_OPCODE            = 0x0C1E,
301     HCI_RD_AUTH_EN_CMD_OPCODE                 = 0x0C1F,
302     HCI_WR_AUTH_EN_CMD_OPCODE                 = 0x0C20,
303     HCI_RD_CLASS_OF_DEV_CMD_OPCODE            = 0x0C23,
304     HCI_WR_CLASS_OF_DEV_CMD_OPCODE            = 0x0C24,
305     HCI_RD_VOICE_STG_CMD_OPCODE               = 0x0C25,
306     HCI_WR_VOICE_STG_CMD_OPCODE               = 0x0C26,
307     HCI_RD_AUTO_FLUSH_TO_CMD_OPCODE           = 0x0C27,
308     HCI_WR_AUTO_FLUSH_TO_CMD_OPCODE           = 0x0C28,
309     HCI_RD_NB_BDCST_RETX_CMD_OPCODE           = 0x0C29,
310     HCI_WR_NB_BDCST_RETX_CMD_OPCODE           = 0x0C2A,
311     HCI_RD_HOLD_MODE_ACTIVITY_CMD_OPCODE      = 0x0C2B,
312     HCI_WR_HOLD_MODE_ACTIVITY_CMD_OPCODE      = 0x0C2C,
313     HCI_RD_TX_PWR_LVL_CMD_OPCODE              = 0x0C2D,
314     HCI_RD_SYNC_FLOW_CTRL_EN_CMD_OPCODE       = 0x0C2E,
315     HCI_WR_SYNC_FLOW_CTRL_EN_CMD_OPCODE       = 0x0C2F,
316     HCI_SET_CTRL_TO_HOST_FLOW_CTRL_CMD_OPCODE = 0x0C31,
317     HCI_HOST_BUF_SIZE_CMD_OPCODE              = 0x0C33,
318     HCI_HOST_NB_CMP_PKTS_CMD_OPCODE           = 0x0C35,
319     HCI_RD_LINK_SUPV_TO_CMD_OPCODE            = 0x0C36,
320     HCI_WR_LINK_SUPV_TO_CMD_OPCODE            = 0x0C37,
321     HCI_RD_NB_SUPP_IAC_CMD_OPCODE             = 0x0C38,
322     HCI_RD_CURR_IAC_LAP_CMD_OPCODE            = 0x0C39,
323     HCI_WR_CURR_IAC_LAP_CMD_OPCODE            = 0x0C3A,
324     HCI_SET_AFH_HOST_CH_CLASS_CMD_OPCODE      = 0x0C3F,
325     HCI_RD_INQ_SCAN_TYPE_CMD_OPCODE           = 0x0C42,
326     HCI_WR_INQ_SCAN_TYPE_CMD_OPCODE           = 0x0C43,
327     HCI_RD_INQ_MODE_CMD_OPCODE                = 0x0C44,
328     HCI_WR_INQ_MODE_CMD_OPCODE                = 0x0C45,
329     HCI_RD_PAGE_SCAN_TYPE_CMD_OPCODE          = 0x0C46,
330     HCI_WR_PAGE_SCAN_TYPE_CMD_OPCODE          = 0x0C47,
331     HCI_RD_AFH_CH_ASSESS_MODE_CMD_OPCODE      = 0x0C48,
332     HCI_WR_AFH_CH_ASSESS_MODE_CMD_OPCODE      = 0x0C49,
333     HCI_RD_EXT_INQ_RSP_CMD_OPCODE             = 0x0C51,
334     HCI_WR_EXT_INQ_RSP_CMD_OPCODE             = 0x0C52,
335     HCI_REFRESH_ENC_KEY_CMD_OPCODE            = 0x0C53,
336     HCI_RD_SP_MODE_CMD_OPCODE                 = 0x0C55,
337     HCI_WR_SP_MODE_CMD_OPCODE                 = 0x0C56,
338     HCI_RD_LOC_OOB_DATA_CMD_OPCODE            = 0x0C57,
339     HCI_RD_INQ_RSP_TX_PWR_LVL_CMD_OPCODE      = 0x0C58,
340     HCI_WR_INQ_TX_PWR_LVL_CMD_OPCODE          = 0x0C59,
341     HCI_RD_DFT_ERR_DATA_REP_CMD_OPCODE        = 0x0C5A,
342     HCI_WR_DFT_ERR_DATA_REP_CMD_OPCODE        = 0x0C5B,
343     HCI_ENH_FLUSH_CMD_OPCODE                  = 0x0C5F,
344     HCI_SEND_KEYPRESS_NOTIF_CMD_OPCODE        = 0x0C60,
345     HCI_SET_EVT_MASK_PAGE_2_CMD_OPCODE        = 0x0C63,
346     HCI_RD_FLOW_CNTL_MODE_CMD_OPCODE          = 0x0C66,
347     HCI_WR_FLOW_CNTL_MODE_CMD_OPCODE          = 0x0C67,
348     HCI_RD_ENH_TX_PWR_LVL_CMD_OPCODE          = 0x0C68,
349     HCI_RD_LE_HOST_SUPP_CMD_OPCODE            = 0x0C6C,
350     HCI_WR_LE_HOST_SUPP_CMD_OPCODE            = 0x0C6D,
351     HCI_SET_MWS_CHANNEL_PARAMS_CMD_OPCODE     = 0x0C6E,
352     HCI_SET_EXTERNAL_FRAME_CONFIG_CMD_OPCODE  = 0x0C6F,
353     HCI_SET_MWS_SIGNALING_CMD_OPCODE          = 0x0C70,
354     HCI_SET_MWS_TRANSPORT_LAYER_CMD_OPCODE    = 0x0C71,
355     HCI_SET_MWS_SCAN_FREQ_TABLE_CMD_OPCODE    = 0x0C72,
356     HCI_SET_MWS_PATTERN_CONFIG_CMD_OPCODE     = 0x0C73,
357     HCI_SET_RES_LT_ADDR_CMD_OPCODE            = 0x0C74,
358     HCI_DEL_RES_LT_ADDR_CMD_OPCODE            = 0x0C75,
359     HCI_SET_CON_SLV_BCST_DATA_CMD_OPCODE      = 0x0C76,
360     HCI_RD_SYNC_TRAIN_PARAM_CMD_OPCODE        = 0x0C77,
361     HCI_WR_SYNC_TRAIN_PARAM_CMD_OPCODE        = 0x0C78,
362     HCI_RD_SEC_CON_HOST_SUPP_CMD_OPCODE       = 0x0C79,
363     HCI_WR_SEC_CON_HOST_SUPP_CMD_OPCODE       = 0x0C7A,
364     HCI_RD_AUTH_PAYL_TO_CMD_OPCODE            = 0x0C7B,
365     HCI_WR_AUTH_PAYL_TO_CMD_OPCODE            = 0x0C7C,
366     HCI_RD_LOC_OOB_EXT_DATA_CMD_OPCODE        = 0x0C7D,
367     HCI_RD_EXT_PAGE_TO_CMD_OPCODE             = 0x0C7E,
368     HCI_WR_EXT_PAGE_TO_CMD_OPCODE             = 0x0C7F,
369     HCI_RD_EXT_INQ_LEN_CMD_OPCODE             = 0x0C80,
370     HCI_WR_EXT_INQ_LEN_CMD_OPCODE             = 0x0C81,
371 
372     //Info Params
373     HCI_RD_LOCAL_VER_INFO_CMD_OPCODE          = 0x1001,
374     HCI_RD_LOCAL_SUPP_CMDS_CMD_OPCODE         = 0x1002,
375     HCI_RD_LOCAL_SUPP_FEATS_CMD_OPCODE        = 0x1003,
376     HCI_RD_LOCAL_EXT_FEATS_CMD_OPCODE         = 0x1004,
377     HCI_RD_BUFF_SIZE_CMD_OPCODE               = 0x1005,
378     HCI_RD_BD_ADDR_CMD_OPCODE                 = 0x1009,
379     HCI_RD_LOCAL_SUPP_CODECS_CMD_OPCODE       = 0x100B,
380     HCI_RD_LOCAL_SP_OPT_CMD_OPCODE                 = 0x100C,
381 
382     //Status Params
383     HCI_RD_FAIL_CONTACT_CNT_CMD_OPCODE        = 0x1401,
384     HCI_RST_FAIL_CONTACT_CNT_CMD_OPCODE       = 0x1402,
385     HCI_RD_LINK_QUAL_CMD_OPCODE               = 0x1403,
386     HCI_RD_RSSI_CMD_OPCODE                    = 0x1405,
387     HCI_RD_AFH_CH_MAP_CMD_OPCODE              = 0x1406,
388     HCI_RD_CLK_CMD_OPCODE                     = 0x1407,
389     HCI_RD_ENC_KEY_SIZE_CMD_OPCODE            = 0x1408,
390     HCI_GET_MWS_TRANSPORT_LAYER_CONFIG_CMD_OPCODE = 0x140C,
391 
392     //Testing Commands
393     HCI_RD_LOOPBACK_MODE_CMD_OPCODE           = 0x1801,
394     HCI_WR_LOOPBACK_MODE_CMD_OPCODE           = 0x1802,
395     HCI_EN_DUT_MODE_CMD_OPCODE                = 0x1803,
396     HCI_WR_SP_DBG_MODE_CMD_OPCODE             = 0x1804,
397     HCI_WR_SEC_CON_TEST_MODE_CMD_OPCODE            = 0x180A,
398 
399     /// LE Commands Opcodes
400     HCI_LE_SET_EVT_MASK_CMD_OPCODE                 = 0x2001,
401     HCI_LE_RD_BUFF_SIZE_CMD_OPCODE                 = 0x2002,
402     HCI_LE_RD_LOCAL_SUPP_FEATS_CMD_OPCODE          = 0x2003,
403     HCI_LE_SET_RAND_ADDR_CMD_OPCODE                = 0x2005,
404     HCI_LE_SET_ADV_PARAM_CMD_OPCODE                = 0x2006,
405     HCI_LE_RD_ADV_CHNL_TX_PW_CMD_OPCODE            = 0x2007,
406     HCI_LE_SET_ADV_DATA_CMD_OPCODE                 = 0x2008,
407     HCI_LE_SET_SCAN_RSP_DATA_CMD_OPCODE            = 0x2009,
408     HCI_LE_SET_ADV_EN_CMD_OPCODE                   = 0x200A,
409     HCI_LE_SET_SCAN_PARAM_CMD_OPCODE               = 0x200B,
410     HCI_LE_SET_SCAN_EN_CMD_OPCODE                  = 0x200C,
411     HCI_LE_CREATE_CON_CMD_OPCODE                   = 0x200D,
412     HCI_LE_CREATE_CON_CANCEL_CMD_OPCODE            = 0x200E,
413     HCI_LE_RD_WLST_SIZE_CMD_OPCODE                 = 0x200F,
414     HCI_LE_CLEAR_WLST_CMD_OPCODE                   = 0x2010,
415     HCI_LE_ADD_DEV_TO_WLST_CMD_OPCODE              = 0x2011,
416     HCI_LE_RMV_DEV_FROM_WLST_CMD_OPCODE            = 0x2012,
417     HCI_LE_CON_UPDATE_CMD_OPCODE                   = 0x2013,
418     HCI_LE_SET_HOST_CH_CLASS_CMD_OPCODE            = 0x2014,
419     HCI_LE_RD_CHNL_MAP_CMD_OPCODE                  = 0x2015,
420     HCI_LE_RD_REM_FEATS_CMD_OPCODE                 = 0x2016,
421     HCI_LE_ENC_CMD_OPCODE                          = 0x2017,
422     HCI_LE_RAND_CMD_OPCODE                         = 0x2018,
423     HCI_LE_START_ENC_CMD_OPCODE                    = 0x2019,
424     HCI_LE_LTK_REQ_REPLY_CMD_OPCODE                = 0x201A,
425     HCI_LE_LTK_REQ_NEG_REPLY_CMD_OPCODE            = 0x201B,
426     HCI_LE_RD_SUPP_STATES_CMD_OPCODE               = 0x201C,
427     HCI_LE_RX_TEST_CMD_OPCODE                      = 0x201D,
428     HCI_LE_TX_TEST_CMD_OPCODE                      = 0x201E,
429     HCI_LE_TEST_END_CMD_OPCODE                     = 0x201F,
430     HCI_LE_REM_CON_PARAM_REQ_REPLY_CMD_OPCODE      = 0x2020,
431     HCI_LE_REM_CON_PARAM_REQ_NEG_REPLY_CMD_OPCODE  = 0x2021,
432     HCI_LE_SET_DATA_LEN_CMD_OPCODE                 = 0x2022,
433     HCI_LE_RD_SUGGTED_DFT_DATA_LEN_CMD_OPCODE      = 0x2023,
434     HCI_LE_WR_SUGGTED_DFT_DATA_LEN_CMD_OPCODE      = 0x2024,
435     HCI_LE_RD_LOC_P256_PUB_KEY_CMD_OPCODE          = 0x2025,
436     HCI_LE_GEN_DHKEY_CMD_OPCODE                    = 0x2026,
437     HCI_LE_ADD_DEV_TO_RSLV_LIST_CMD_OPCODE         = 0x2027,
438     HCI_LE_RMV_DEV_FROM_RSLV_LIST_CMD_OPCODE       = 0x2028,
439     HCI_LE_CLEAR_RSLV_LIST_CMD_OPCODE              = 0x2029,
440     HCI_LE_RD_RSLV_LIST_SIZE_CMD_OPCODE            = 0x202A,
441     HCI_LE_RD_PEER_RSLV_ADDR_CMD_OPCODE            = 0x202B,
442     HCI_LE_RD_LOC_RSLV_ADDR_CMD_OPCODE             = 0x202C,
443     HCI_LE_SET_ADDR_RESOL_EN_CMD_OPCODE            = 0x202D,
444     HCI_LE_SET_RSLV_PRIV_ADDR_TO_CMD_OPCODE        = 0x202E,
445     HCI_LE_RD_MAX_DATA_LEN_CMD_OPCODE              = 0x202F,
446     HCI_LE_RD_PHY_CMD_OPCODE                       = 0x2030,
447     HCI_LE_SET_DFT_PHY_CMD_OPCODE                  = 0x2031,
448     HCI_LE_SET_PHY_CMD_OPCODE                      = 0x2032,
449     HCI_LE_ENH_RX_TEST_CMD_OPCODE                  = 0x2033,
450     HCI_LE_ENH_TX_TEST_CMD_OPCODE                  = 0x2034,
451     HCI_LE_SET_ADV_SET_RAND_ADDR_CMD_OPCODE        = 0x2035,
452     HCI_LE_SET_EXT_ADV_PARAM_CMD_OPCODE            = 0x2036,
453     HCI_LE_SET_EXT_ADV_DATA_CMD_OPCODE             = 0x2037,
454     HCI_LE_SET_EXT_SCAN_RSP_DATA_CMD_OPCODE        = 0x2038,
455     HCI_LE_SET_EXT_ADV_EN_CMD_OPCODE               = 0x2039,
456     HCI_LE_RD_MAX_ADV_DATA_LEN_CMD_OPCODE          = 0x203A,
457     HCI_LE_RD_NB_SUPP_ADV_SETS_CMD_OPCODE          = 0x203B,
458     HCI_LE_RMV_ADV_SET_CMD_OPCODE                  = 0x203C,
459     HCI_LE_CLEAR_ADV_SETS_CMD_OPCODE               = 0x203D,
460     HCI_LE_SET_PER_ADV_PARAM_CMD_OPCODE            = 0x203E,
461     HCI_LE_SET_PER_ADV_DATA_CMD_OPCODE             = 0x203F,
462     HCI_LE_SET_PER_ADV_EN_CMD_OPCODE               = 0x2040,
463     HCI_LE_SET_EXT_SCAN_PARAM_CMD_OPCODE           = 0x2041,
464     HCI_LE_SET_EXT_SCAN_EN_CMD_OPCODE              = 0x2042,
465     HCI_LE_EXT_CREATE_CON_CMD_OPCODE               = 0x2043,
466     HCI_LE_PER_ADV_CREATE_SYNC_CMD_OPCODE          = 0x2044,
467     HCI_LE_PER_ADV_CREATE_SYNC_CANCEL_CMD_OPCODE   = 0x2045,
468     HCI_LE_PER_ADV_TERM_SYNC_CMD_OPCODE            = 0x2046,
469     HCI_LE_ADD_DEV_TO_PER_ADV_LIST_CMD_OPCODE      = 0x2047,
470     HCI_LE_RMV_DEV_FROM_PER_ADV_LIST_CMD_OPCODE    = 0x2048,
471     HCI_LE_CLEAR_PER_ADV_LIST_CMD_OPCODE           = 0x2049,
472     HCI_LE_RD_PER_ADV_LIST_SIZE_CMD_OPCODE         = 0x204A,
473     HCI_LE_RD_TX_PWR_CMD_OPCODE                    = 0x204B,
474     HCI_LE_RD_RF_PATH_COMP_CMD_OPCODE              = 0x204C,
475     HCI_LE_WR_RF_PATH_COMP_CMD_OPCODE              = 0x204D,
476     HCI_LE_SET_PRIV_MODE_CMD_OPCODE                = 0x204E,
477     HCI_LE_SET_MIN_NUM_USED_CHAN_CMD_OPCODE        = 0x204F,
478 
479     ///Debug commands - OGF = 0x3F (spec)
480     #ifndef HCI_DBG_RD_MEM_CMD_OPCODE
481     HCI_DBG_RD_MEM_CMD_OPCODE                   = 0xFC01,
482     #endif
483 
484     #ifndef HCI_DBG_WR_MEM_CMD_OPCODE
485     HCI_DBG_WR_MEM_CMD_OPCODE                   = 0xFC02,
486     #endif
487     #ifndef HCI_DBG_DEL_PAR_CMD_OPCODE
488     HCI_DBG_DEL_PAR_CMD_OPCODE                  = 0xFC03,
489     #endif
490     HCI_DBG_ID_FLASH_CMD_OPCODE                 = 0xFC05,
491     HCI_DBG_ER_FLASH_CMD_OPCODE                 = 0xFC06,
492     HCI_DBG_WR_FLASH_CMD_OPCODE                 = 0xFC07,
493     HCI_DBG_RD_FLASH_CMD_OPCODE                 = 0xFC08,
494     #ifndef HCI_DBG_RD_PAR_CMD_OPCODE
495     HCI_DBG_RD_PAR_CMD_OPCODE                   = 0xFC09,
496     #endif
497     #ifndef HCI_DBG_WR_PAR_CMD_OPCODE
498     HCI_DBG_WR_PAR_CMD_OPCODE                   = 0xFC0A,
499     #endif
500     #ifndef HCI_DBG_WLAN_COEX_CMD_OPCODE
501     HCI_DBG_WLAN_COEX_CMD_OPCODE                = 0xFC0B,
502     #endif
503     #ifndef HCI_DBG_WLAN_COEXTST_SCEN_CMD_OPCODE
504     HCI_DBG_WLAN_COEXTST_SCEN_CMD_OPCODE        = 0xFC0D,
505     #endif
506     HCI_DBG_BT_SEND_LMP_CMD_OPCODE              = 0xFC0E,
507     HCI_DBG_SET_LOCAL_CLOCK_CMD_OPCODE             = 0xFC0F,
508     HCI_VS_SET_PREF_SLAVE_LATENCY_CMD_OPCODE       = 0xFC13,
509     HCI_VS_SET_PREF_SLAVE_EVT_DUR_CMD_OPCODE       = 0xFC14,
510     HCI_DBG_BLE_REG_RD_CMD_OPCODE                  = 0xFC30,
511     HCI_DBG_BLE_REG_WR_CMD_OPCODE                  = 0xFC31,
512     HCI_DBG_SEND_LLCP_CMD_OPCODE                   = 0xFC35,
513 
514     #ifndef HCI_DBG_RD_KE_STATS_CMD_OPCODE
515     HCI_DBG_RD_KE_STATS_CMD_OPCODE              = 0xFC10,
516     #endif
517 
518     #ifndef HCI_DBG_PLF_RESET_CMD_OPCODE
519     HCI_DBG_PLF_RESET_CMD_OPCODE                = 0xFC11,
520     #endif
521 
522     #ifndef HCI_DBG_RD_MEM_INFO_CMD_OPCODE
523     HCI_DBG_RD_MEM_INFO_CMD_OPCODE              = 0xFC12,
524     #endif
525 
526     HCI_DBG_HW_REG_RD_CMD_OPCODE                = 0xFC30,
527     HCI_DBG_HW_REG_WR_CMD_OPCODE                = 0xFC31,
528 
529     #ifndef HCI_CMD_SET_BLE_ADDR
530     HCI_CMD_SET_BLE_ADDR                        = 0xFC32,
531     #endif
532 
533     HCI_DBG_SET_TYPE_PUB_CMD_OPCODE             = 0xFC33,
534     HCI_DBG_SET_TYPE_RAND_CMD_OPCODE            = 0xFC34,
535     HCI_DBG_SET_CRC_CMD_OPCODE                  = 0xFC35,
536     HCI_DBG_LLCP_DISCARD_CMD_OPCODE             = 0xFC36,
537     HCI_DBG_RESET_RX_CNT_CMD_OPCODE             = 0xFC37,
538     HCI_DBG_RESET_TX_CNT_CMD_OPCODE             = 0xFC38,
539 
540     #ifndef HCI_DBG_RF_REG_RD_CMD_OPCODE
541     HCI_DBG_RF_REG_RD_CMD_OPCODE                = 0xFC39,
542     #endif
543 
544     #ifndef HCI_DBG_RF_REG_WR_CMD_OPCODE
545     HCI_DBG_RF_REG_WR_CMD_OPCODE                = 0xFC3A,
546     #endif
547     HCI_DBG_SET_TX_PW_CMD_OPCODE                = 0xFC3B,
548     HCI_DBG_RF_SWITCH_CLK_CMD_OPCODE            = 0xFC3C,
549     HCI_DBG_RF_WR_DATA_TX_CMD_OPCODE            = 0xFC3D,
550     HCI_DBG_RF_RD_DATA_RX_CMD_OPCODE            = 0xFC3E,
551     HCI_DBG_RF_CNTL_TX_CMD_OPCODE               = 0xFC3F,
552     HCI_DBG_RF_SYNC_P_CNTL_CMD_OPCODE           = 0xFC40,
553     HCI_TESTER_SET_LE_PARAMS_CMD_OPCODE         = 0xFC40,
554     HCI_DBG_WR_DLE_DFT_VALUE_CMD_OPCODE         = 0xFC41,
555 #if (BLE_EMB_PRESENT)
556 #if (BLE_TESTER)
557     HCI_DBG_BLE_TST_LLCP_PT_EN_CMD_OPCODE       = 0xFC42,
558     HCI_DBG_BLE_TST_SEND_LLCP_CMD_OPCODE        = 0xFC43,
559 #endif // (BLE_TESTER)
560 #if (BLE_AUDIO)
561     HCI_DBG_AUDIO_CONFIGURE_CMD_OPCODE          = 0xFC50,
562     HCI_DBG_AUDIO_SET_MODE_CMD_OPCODE           = 0xFC51,
563     HCI_DBG_AUDIO_RESET_CMD_OPCODE              = 0xFC52,
564     HCI_DBG_AUDIO_SET_POINTER_CMD_OPCODE        = 0xFC53,
565     HCI_DBG_AUDIO_ALLOCATE_CMD_OPCODE           = 0xFC54,
566     HCI_DBG_AUDIO_GET_VX_CH_CMD_OPCODE          = 0xFC55,
567 #endif
568 #endif // (BLE_EMB_PRESENT)
569 
570     #if (RW_DEBUG && BT_EMB_PRESENT)
571 	HCI_DBG_BT_DISCARD_LMP_EN_CMD_OPCODE      	= 0xFC44,
572     #endif //RW_DEBUG && BT_EMB_PRESENT
573 
574     HCI_DBG_MWS_COEX_CMD_OPCODE                 = 0xFC45,
575     HCI_DBG_MWS_COEXTST_SCEN_CMD_OPCODE         = 0xFC46,
576 
577     #if (BLE_ISO_MODE_0)
578     /// Vendor Specific commands for ISO Mode 0
579     HCI_VS_SETUP_AM0_CHAN_CMD_OPCODE               = 0xFC54,
580     HCI_VS_REMOVE_AM0_CHAN_CMD_OPCODE              = 0xFC55,
581     HCI_VS_CONTROL_AM0_CHAN_CMD_OPCODE             = 0xFC56,
582     #endif // (BLE_ISO_MODE_0)
583 
584     #if CRYPTO_UT
585     HCI_DBG_TEST_CRYPTO_FUNC_CMD_OPCODE         = 0xFC60,
586     #endif //CRYPTO_UT
587     #if RW_DEBUG
588     HCI_DBG_TEST_SCH_PLAN_SET_CMD_OPCODE           = 0xFC61,
589     HCI_DBG_TEST_SCH_PLAN_REM_CMD_OPCODE           = 0xFC62,
590     HCI_DBG_TEST_SCH_PLAN_CHK_CMD_OPCODE           = 0xFC63,
591     HCI_DBG_TEST_SCH_PLAN_REQ_CMD_OPCODE           = 0xFC64,
592     #endif //RW_DEBUG
593 };
594 
595 /**************************************************************************************
596  **************                        HCI EVENTS                      ****************
597  **************************************************************************************/
598 
599 ///Event Codes
600 enum hci_evt_code
601 {
602     HCI_INQ_CMP_EVT_CODE                       = 0x01,
603     HCI_INQ_RES_EVT_CODE                       = 0x02,
604     HCI_CON_CMP_EVT_CODE                       = 0x03,
605     HCI_CON_REQ_EVT_CODE                       = 0x04,
606     HCI_DISC_CMP_EVT_CODE                      = 0x05,
607     HCI_AUTH_CMP_EVT_CODE                      = 0x06,
608     HCI_REM_NAME_REQ_CMP_EVT_CODE              = 0x07,
609     HCI_ENC_CHG_EVT_CODE                       = 0x08,
610     HCI_CHG_CON_LK_CMP_EVT_CODE                = 0x09,
611     HCI_MASTER_LK_CMP_EVT_CODE                 = 0x0A,
612     HCI_RD_REM_SUPP_FEATS_CMP_EVT_CODE         = 0x0B,
613     HCI_RD_REM_VER_INFO_CMP_EVT_CODE           = 0x0C,
614     HCI_QOS_SETUP_CMP_EVT_CODE                 = 0x0D,
615     HCI_CMD_CMP_EVT_CODE                       = 0x0E,
616     HCI_CMD_STATUS_EVT_CODE                    = 0x0F,
617     HCI_HW_ERR_EVT_CODE                        = 0x10,
618     HCI_FLUSH_OCCURRED_EVT_CODE                = 0x11,
619     HCI_ROLE_CHG_EVT_CODE                      = 0x12,
620     HCI_NB_CMP_PKTS_EVT_CODE                   = 0x13,
621     HCI_MODE_CHG_EVT_CODE                      = 0x14,
622     HCI_RETURN_LINK_KEYS_EVT_CODE              = 0x15,
623     HCI_PIN_CODE_REQ_EVT_CODE                  = 0x16,
624     HCI_LK_REQ_EVT_CODE                        = 0x17,
625     HCI_LK_NOTIF_EVT_CODE                      = 0x18,
626     HCI_DATA_BUF_OVFLW_EVT_CODE                = 0x1A,
627     HCI_MAX_SLOT_CHG_EVT_CODE                  = 0x1B,
628     HCI_RD_CLK_OFF_CMP_EVT_CODE                = 0x1C,
629     HCI_CON_PKT_TYPE_CHG_EVT_CODE              = 0x1D,
630     HCI_QOS_VIOL_EVT_CODE                      = 0x1E,
631     HCI_PAGE_SCAN_REPET_MODE_CHG_EVT_CODE      = 0x20,
632     HCI_FLOW_SPEC_CMP_EVT_CODE                 = 0x21,
633     HCI_INQ_RES_WITH_RSSI_EVT_CODE             = 0x22,
634     HCI_RD_REM_EXT_FEATS_CMP_EVT_CODE          = 0x23,
635     HCI_SYNC_CON_CMP_EVT_CODE                  = 0x2C,
636     HCI_SYNC_CON_CHG_EVT_CODE                  = 0x2D,
637     HCI_SNIFF_SUB_EVT_CODE                     = 0x2E,
638     HCI_EXT_INQ_RES_EVT_CODE                   = 0x2F,
639     HCI_ENC_KEY_REFRESH_CMP_EVT_CODE           = 0x30,
640     HCI_IO_CAP_REQ_EVT_CODE                    = 0x31,
641     HCI_IO_CAP_RSP_EVT_CODE                    = 0x32,
642     HCI_USER_CFM_REQ_EVT_CODE                  = 0x33,
643     HCI_USER_PASSKEY_REQ_EVT_CODE              = 0x34,
644     HCI_REM_OOB_DATA_REQ_EVT_CODE              = 0x35,
645     HCI_SP_CMP_EVT_CODE                        = 0x36,
646     HCI_LINK_SUPV_TO_CHG_EVT_CODE              = 0x38,
647     HCI_ENH_FLUSH_CMP_EVT_CODE                 = 0x39,
648     HCI_USER_PASSKEY_NOTIF_EVT_CODE            = 0x3B,
649     HCI_KEYPRESS_NOTIF_EVT_CODE                = 0x3C,
650     HCI_REM_HOST_SUPP_FEATS_NOTIF_EVT_CODE     = 0x3D,
651     HCI_LE_META_EVT_CODE                       = 0x3E,
652     HCI_MAX_EVT_MSK_PAGE_1_CODE                = 0x40,
653     HCI_SYNC_TRAIN_CMP_EVT_CODE                = 0x4F,
654     HCI_SYNC_TRAIN_REC_EVT_CODE                = 0x50,
655     HCI_CON_SLV_BCST_REC_EVT_CODE              = 0x51,
656     HCI_CON_SLV_BCST_TO_EVT_CODE               = 0x52,
657     HCI_TRUNC_PAGE_CMP_EVT_CODE                = 0x53,
658     HCI_SLV_PAGE_RSP_TO_EVT_CODE               = 0x54,
659     HCI_CON_SLV_BCST_CH_MAP_CHG_EVT_CODE       = 0x55,
660     HCI_AUTH_PAYL_TO_EXP_EVT_CODE              = 0x57,
661     HCI_SAM_STATUS_CHANGE_EVT_CODE             = 0x58,
662     HCI_MAX_EVT_MSK_PAGE_2_CODE                = 0x59,
663     HCI_DBG_META_EVT_CODE                      = 0xFF,
664 };
665 
666 /*@TRACE*/
667 enum hci_le_evt_subcode
668 {
669     /// LE Events Subcodes
670     HCI_LE_CON_CMP_EVT_SUBCODE                 = 0x01,
671     HCI_LE_ADV_REPORT_EVT_SUBCODE              = 0x02,
672     HCI_LE_CON_UPDATE_CMP_EVT_SUBCODE          = 0x03,
673     HCI_LE_RD_REM_FEATS_CMP_EVT_SUBCODE        = 0x04,
674     HCI_LE_LTK_REQUEST_EVT_SUBCODE             = 0x05,
675     HCI_LE_REM_CON_PARAM_REQ_EVT_SUBCODE       = 0x06,
676     HCI_LE_DATA_LEN_CHG_EVT_SUBCODE            = 0x07,
677     HCI_LE_RD_LOC_P256_PUB_KEY_CMP_EVT_SUBCODE = 0x08,
678     HCI_LE_GEN_DHKEY_CMP_EVT_SUBCODE           = 0x09,
679     HCI_LE_ENH_CON_CMP_EVT_SUBCODE             = 0x0A,
680     HCI_LE_DIR_ADV_REP_EVT_SUBCODE             = 0x0B,
681     HCI_LE_PHY_UPD_CMP_EVT_SUBCODE             = 0x0C,
682     HCI_LE_EXT_ADV_REPORT_EVT_SUBCODE          = 0x0D,
683     HCI_LE_PER_ADV_SYNC_EST_EVT_SUBCODE        = 0x0E,
684     HCI_LE_PER_ADV_REPORT_EVT_SUBCODE          = 0x0F,
685     HCI_LE_PER_ADV_SYNC_LOST_EVT_SUBCODE       = 0x10,
686     HCI_LE_SCAN_TIMEOUT_EVT_SUBCODE            = 0x11,
687     HCI_LE_ADV_SET_TERMINATED_EVT_SUBCODE      = 0x12,
688     HCI_LE_SCAN_REQ_RCVD_EVT_SUBCODE           = 0x13,
689     HCI_LE_CH_SEL_ALGO_EVT_SUBCODE             = 0x14,
690 };
691 
692 #if (RW_DEBUG || BLE_ISOGEN)
693 /*@TRACE*/
694 enum hci_vs_evt_subcode
695 {
696     #if (RW_DEBUG)
697     /// DBG Events Subcodes
698     HCI_DBG_ASSERT_EVT_SUBCODE             = 0x02,
699     #endif //(RW_DEBUG)
700 
701     #if (BLE_ISOGEN)
702     /// VS ISO Gen Statistics Status
703     HCI_VS_ISOGEN_STAT_EVT_SUBCODE                    = 0x03,
704     #endif // (BLE_ISOGEN)
705 };
706 #endif //(RW_DEBUG || BLE_ISOGEN)
707 
708 /// Event mask page enum
709 enum hci_evt_mask_page
710 {
711     /// page 0
712     HCI_PAGE_0,
713     /// page 1
714     HCI_PAGE_1,
715     /// page 2
716     HCI_PAGE_2,
717     /// Default
718     HCI_PAGE_DFT,
719     /// LE event
720     HCI_PAGE_LE,
721 };
722 
723 #if (BLE_ISO_PRESENT)
724 #if (BLE_ISO_MODE_0)
725 /// Current audio mode
726 enum iso_am0_ctrl
727 {
728     // Stop Audio Mode 0 Stream
729     ISO_AM0_CRL_DISABLE,
730     // Start Audio Mode 0 Stream
731     ISO_AM0_CRL_ENABLE,
732 };
733 #endif // (BLE_ISO_MODE_0)
734 
735 /// Isochronous Channel data path selection
736 enum iso_dp_type
737 {
738     /// Data Path direction is disabled
739     ISO_DP_DISABLE                  = 0x00,
740     /// Voice over HCI Data Path
741     ISO_DP_VOHCI                    = 0x01,
742 
743     // vendor specifics
744     // @see enum dp_type
745     // @see enum plf_dp_type
746 };
747 
748 #endif // (BLE_ISO_PRESENT)
749 
750 
751 
752 /**************************************************************************************
753  **************                 HCI MESSAGE STRUCTURES                 ****************
754  **************************************************************************************/
755 
756 /*
757  * HCI COMMANDS PARAMETERS (to classify)
758  ****************************************************************************************
759  */
760 
761 /// HCI basic command structure with connection handle
762 /*@TRACE
763  * hci_rd_rssi_cmd = hci_basic_conhdl_cmd
764  * hci_le_rd_chnl_map_cmd = hci_basic_conhdl_cmd
765  * hci_le_ltk_req_neg_reply_cmd = hci_basic_conhdl_cmd*/
766 struct hci_basic_conhdl_cmd
767 {
768     /// connection handle
769     uint16_t    conhdl;
770 };
771 
772 /// HCI basic command structure with BD address
773 struct hci_basic_bd_addr_cmd
774 {
775     ///BdAddr
776     struct bd_addr  bd_addr;
777 };
778 
779 /// HCI Accept connection request command structure
780 struct hci_accept_con_req_cmd
781 {
782     ///BdAddr
783     struct bd_addr  bd_addr;
784     ///Page Scan Repetition Mode
785     uint8_t         role;
786 };
787 
788 /// HCI Accept synchronous connection request command structure
789 struct hci_accept_sync_con_req_cmd
790 {
791     ///BdAddr
792     struct bd_addr  bd_addr;
793     ///Transmit bandwidth
794     uint32_t    tx_bw;
795     ///Receive bandwidth
796     uint32_t    rx_bw;
797     ///Max latency
798     uint16_t    max_lat;
799     ///Voice settings
800     uint16_t    vx_set;
801     ///Retransmission effort
802     uint8_t      retx_eff;
803     ///Packet type
804     uint16_t     pkt_type  ;
805 };
806 
807 /// HCI Enhanced Accept synchronous connection request command structure
808 struct hci_enh_accept_sync_con_cmd
809 {
810 
811     struct bd_addr    bd_addr;            // BD address
812     uint32_t          tx_bw;              // Transmit Bandwidth (in B/sec)
813     uint32_t          rx_bw;              // Receive Bandwidth (in B/sec)
814     uint8_t           tx_cod_fmt[5];      // Transmit Coding Format
815     uint8_t           rx_cod_fmt[5];      // Receive Coding Format
816     uint16_t          tx_cod_fr_sz;       // Transmit Codec Frame Size (in B)
817     uint16_t          rx_cod_fr_sz;       // Receive Codec Frame Size (in B)
818     uint32_t          in_bw;              // Input Bandwidth (in B/sec)
819     uint32_t          out_bw;             // Output Bandwidth (in B/sec)
820     uint8_t           in_cod_fmt[5];      // Input Coding Format
821     uint8_t           out_cod_fmt[5];     // Output Coding Format
822     uint16_t          in_cod_data_sz;     // Input Coded Data Size (in bits)
823     uint16_t          out_cod_data_sz;    // Output Coded Data Size (in bits)
824     uint8_t           in_data_fmt;        // Input PCM Data Format
825     uint8_t           out_data_fmt;       // Output PCM Data Format
826     uint8_t           in_msb_pos;         // Input PCM Sample Payload MSB Position (in bits)
827     uint8_t           out_msb_pos;        // Output PCM Sample Payload MSB Position (in bits)
828     uint8_t           in_data_path;       // Input Data Path
829     uint8_t           out_data_path;      // Output Data Path
830     uint8_t           in_tr_unit_sz;      // Input Transport Unit Size (in bits)
831     uint8_t           out_tr_unit_sz;     // Output Transport Unit Size (in bits)
832     uint16_t          max_lat;            // Max Latency (in ms)
833     uint16_t          packet_type;        // Packet Type
834     uint8_t           retx_eff;           // Retransmission Effort
835 
836 
837 };
838 
839 /// HCI reject connection request command structure
840 struct hci_reject_con_req_cmd
841 {
842     ///BdAddr
843     struct bd_addr  bd_addr;
844     ///Reason
845     uint8_t         reason;
846 };
847 
848 /// HCI reject synchronous connection request command structure
849 struct hci_reject_sync_con_req_cmd
850 {
851     ///BdAddr
852     struct bd_addr  bd_addr;
853     ///Reason
854     uint8_t         reason;
855 };
856 
857 /// HCI link key request reply command structure
858 struct hci_lk_req_reply_cmd
859 {
860     ///BdAddr
861     struct bd_addr  bd_addr;
862     ///Key
863     struct ltk         key;
864 };
865 
866 /// HCI link key request reply command structure
867 struct hci_pin_code_req_reply_cmd
868 {
869     ///BdAddr
870     struct bd_addr  bd_addr;
871     ///Pin code length
872     uint8_t     pin_len;
873     ///Key
874     struct pin_code pin;
875 };
876 
877 /// HCI switch role command structure
878 struct hci_switch_role_cmd
879 {
880     ///BdAddr
881     struct bd_addr  bd_addr;
882     ///Read all flag
883     uint8_t role;
884 };
885 
886 /// HCI flow specification command parameters structure
887 struct hci_flow_spec_cmd
888 {
889     ///Connection handle
890     uint16_t conhdl;
891     ///Flags
892     uint8_t flags;
893     ///Flow direction
894     uint8_t flow_dir;
895     ///Service type
896     uint8_t serv_type;
897     ///Token rate
898     uint32_t tk_rate;
899     ///Token buffer size
900     uint32_t tk_buf_sz;
901     ///Peak bandwidth
902     uint32_t pk_bw;
903     ///Access latency
904     uint32_t acc_lat;
905 };
906 
907 /// HCI enhanced flush command parameters structure
908 struct hci_enh_flush_cmd
909 {
910     ///Connection handle
911     uint16_t conhdl;
912     ///Packet Type
913     uint8_t pkt_type;
914 };
915 
916 /// HCI command complete event structure for the read auto flush TO command
917 struct hci_rd_auto_flush_to_cmd_cmp_evt
918 {
919     ///Status for command reception
920     uint8_t status;
921     ///Connection handle
922     uint16_t conhdl;
923     ///Flush timeout
924     uint16_t flush_to;
925 };
926 
927 /// HCI write flush timeout command parameters structure
928 struct hci_wr_auto_flush_to_cmd
929 {
930     ///Connection handle
931     uint16_t conhdl;
932     ///Flush timeout
933     uint16_t flush_to;
934 };
935 
936 /// HCI change connection packet type command parameters structure
937 struct hci_chg_con_pkt_type_cmd
938 {
939     ///Connection handle
940     uint16_t conhdl;
941     ///Packet type
942     uint16_t pkt_type;
943 };
944 
945 /// HCI read link policy settings command parameters structure
946 struct hci_rd_link_pol_stg_cmd_cmp_evt
947 {
948     ///Status for command reception
949     uint8_t status;
950     ///Connection handle
951     uint16_t conhdl;
952     ///Link policy
953     uint16_t lnk_policy;
954 };
955 
956 /// HCI read link policy settings command parameters structure
957 struct hci_wr_link_pol_stg_cmd
958 {
959     ///Connection handle
960     uint16_t    conhdl;
961     ///Link policy
962     uint16_t lnk_policy;
963 };
964 
965 /// HCI sniff mode request command parameters structure
966 struct hci_sniff_mode_cmd
967 {
968     ///Connection handle
969     uint16_t    conhdl;
970     /// Maximum interval (in slots)
971     uint16_t    max_int;
972     /// Minimum interval (in slots)
973     uint16_t    min_int;
974     /// Attempts (number of receive slots) (in slots)
975     uint16_t    attempt;
976     /// Timeout (number of receive slots) (in slots)
977     uint16_t    timeout;
978 };
979 
980 /// HCI sniff subrating mode request command parameters structure
981 struct hci_sniff_sub_cmd
982 {
983     ///Connection handle
984     uint16_t    conhdl;
985     /// Maximum latency used to calculate the maximum sniff subrate that the remote device may use (in slots)
986     uint16_t    max_lat;
987     /// Minimum base sniff subrate timeout that the remote device may use (in slots)
988     uint16_t    min_rem_to;
989     /// Minimum base sniff subrate timeout that the local device may use (in slots)
990     uint16_t    min_loc_to;
991 };
992 
993 /// HCI role discovery complete event parameters structure
994 struct hci_role_discovery_cmd_cmp_evt
995 {
996     ///Status for command reception
997     uint8_t status;
998     ///Connection handle
999     uint16_t conhdl;
1000     ///Role
1001     uint8_t role;
1002 
1003 };
1004 
1005 /// HCI read failed contact counter command parameters structure
1006 struct hci_rd_fail_contact_cnt_cmd_cmp_evt
1007 {
1008     ///Status for command reception
1009     uint8_t status;
1010     ///Connection handle
1011     uint16_t conhdl;
1012     ///Fail contact counter
1013     uint16_t fail_cnt;
1014 };
1015 
1016 /// HCI read link quality complete event parameters structure
1017 struct hci_rd_link_qual_cmd_cmp_evt
1018 {
1019     ///Status for command reception
1020     uint8_t status;
1021     ///Connection handle
1022     uint16_t conhdl;
1023     ///Quality type
1024     uint8_t quality;
1025 };
1026 
1027 /// HCI read afh channel map complete event parameters structure
1028 struct hci_rd_afh_ch_map_cmd_cmp_evt
1029 {
1030     ///Status for command reception
1031     uint8_t status;
1032     ///Connection handle
1033     uint16_t conhdl;
1034     /// AFH mode
1035     uint8_t afh_mode;
1036     /// AFH channel map
1037     struct chnl_map afh_map;
1038 };
1039 
1040 /// HCI read lmp handle complete event parameters structure
1041 struct hci_rd_lmp_hdl_cmd_cmp_evt
1042 {
1043     ///Status for command reception
1044     uint8_t status;
1045     ///Connection handle
1046     uint16_t conhdl;
1047     ///lmp handle
1048     uint8_t lmp_hdl;
1049     ///rsvd
1050     uint32_t rsvd;
1051 };
1052 
1053 /// HCI read remote extended features command parameters structure
1054 struct hci_rd_rem_ext_feats_cmd
1055 {
1056     ///Connection handle
1057     uint16_t conhdl;
1058     ///page number
1059     uint8_t pg_nb;
1060 };
1061 
1062 /// HCI read encryption key size complete event parameters structure
1063 struct hci_rd_enc_key_size_cmd_cmp_evt
1064 {
1065     ///Status for command reception
1066     uint8_t status;
1067     ///Connection handle
1068     uint16_t conhdl;
1069     ///Key size
1070     uint8_t key_sz;
1071 };
1072 
1073 /// HCI read enhanced transmit power command parameters structure
1074 struct hci_rd_enh_tx_pwr_lvl_cmd
1075 {
1076     ///Connection handle
1077     uint16_t conhdl;
1078     ///Type
1079     uint8_t type;
1080 };
1081 
1082 /// HCI read enhanced transmit power complete event parameters structure
1083 struct hci_rd_enh_tx_pwr_lvl_cmd_cmp_evt
1084 {
1085     ///Status for command reception
1086     uint8_t status;
1087     ///Connection handle
1088     uint16_t conhdl;
1089     ///Transmit power GFSK
1090     uint8_t pw_gfsk;
1091     ///Transmit power DQPSK
1092     uint8_t pw_dqpsk;
1093     ///Transmit power 8DPSK
1094     uint8_t pw_8dpsk;
1095 };
1096 
1097 
1098 /*
1099  * HCI LINK CONTROL COMMANDS PARAMETERS
1100  ****************************************************************************************
1101  */
1102 
1103 /// Format of the message of the Group: LINK_CONTROL_COMMANDS
1104 /// HCI Inquiry command parameters structure
1105 struct hci_inq_cmd
1106 {
1107     ///Lap
1108     struct lap  lap;
1109     ///Inquiry Length in units of 1.28 s
1110     uint8_t     inq_len;
1111     ///Number of response
1112     uint8_t     nb_rsp;
1113 };
1114 struct hci_per_inq_mode_cmd
1115 {
1116     ///Maximum period length
1117     uint16_t max_per_len;
1118     ///Minimum period length
1119     uint16_t min_per_len;
1120     ///lap
1121     struct lap lap;
1122     ///Inquiry length in units of 1.28 s
1123     uint8_t inq_len;
1124     ///Number of response
1125     uint8_t nb_rsp;
1126 };
1127 struct hci_create_con_cmd
1128 {
1129     /// BdAddr
1130     struct bd_addr  bd_addr;
1131     /// Packet Type
1132     uint16_t        pkt_type;
1133     /// Page Scan Repetition Mode
1134     uint8_t         page_scan_rep_mode;
1135     /// Reserved
1136     uint8_t         rsvd;
1137     /**
1138      * Clock Offset
1139      *
1140      * Bits 14-0 : Bits 16-2 of CLKNslave-CLK
1141      * Bit 15 : Clock_Offset_Valid_Flag
1142      *   Invalid Clock Offset = 0
1143      *   Valid Clock Offset = 1
1144      */
1145     uint16_t        clk_off;
1146     /// Allow Switch
1147     uint8_t         switch_en;
1148 };
1149 
1150 /// HCI disconnect command structure
1151 struct hci_disconnect_cmd
1152 {
1153     /// connection handle
1154     uint16_t    conhdl;
1155     /// reason
1156     uint8_t     reason;
1157 };
1158 
1159 /// HCI master link key command structure
1160 struct hci_master_lk_cmd
1161 {
1162     ///Key flag
1163     uint8_t key_flag;
1164 };
1165 
1166 /// HCI authentication request command parameters structure
1167 struct hci_set_con_enc_cmd
1168 {
1169     ///Connection handle
1170     uint16_t conhdl;
1171     ///Encryption mode
1172     uint8_t enc_en;
1173 };
1174 
1175 struct hci_rem_name_req_cmd
1176 {
1177     ///BdAddr
1178     struct bd_addr  bd_addr;
1179     ///Page Scan Repetition Mode
1180     uint8_t         page_scan_rep_mode;
1181     ///Reserved
1182     uint8_t         rsvd;
1183     /**
1184      * Clock Offset
1185      *
1186      * Bits 14-0 : Bits 16-2 of CLKNslave-CLK
1187      * Bit 15 : Clock_Offset_Valid_Flag
1188      *   Invalid Clock Offset = 0
1189      *   Valid Clock Offset = 1
1190      */
1191     uint16_t        clk_off;
1192 };
1193 
1194 /// HCI remote name request complete event structure
1195 struct hci_rem_name_req_cmp_evt
1196 {
1197     /// Status
1198     uint8_t status;
1199     /// BD Addr
1200     struct bd_addr bd_addr;
1201     /// Name
1202     struct device_name name;
1203 };
1204 
1205 /// HCI setup synchronous connection command structure
1206 struct hci_setup_sync_con_cmd
1207 {
1208     ///Connection handle
1209     uint16_t conhdl;
1210     ///Transmit bandwidth
1211     uint32_t tx_bw;
1212     ///Receive bandwidth
1213     uint32_t rx_bw;
1214     ///Max latency
1215     uint16_t max_lat;
1216     ///Voice setting
1217     uint16_t vx_set;
1218     ///Retransmission effort
1219     uint8_t retx_eff;
1220     ///Packet type
1221     uint16_t pkt_type;
1222 };
1223 
1224 /// HCI setup synchronous connection command structure
1225 struct hci_enh_setup_sync_con_cmd
1226 {
1227     uint16_t      conhdl;               // Connection Handle
1228     uint32_t      tx_bw;                // Transmit Bandwidth (in B/sec)
1229     uint32_t      rx_bw;                // Receive Bandwidth (in B/sec)
1230     uint8_t       tx_cod_fmt[5];        // Transmit Coding Format
1231     uint8_t       rx_cod_fmt[5];        // Receive Coding Format
1232     uint16_t      tx_cod_fr_sz;         // Transmit Codec Frame Size (in B)
1233     uint16_t      rx_cod_fr_sz;         // Receive Codec Frame Size (in B)
1234     uint32_t      in_bw;                // Input Bandwidth (in B/sec)
1235     uint32_t      out_bw;               // Output Bandwidth (in B/sec)
1236     uint8_t       in_cod_fmt[5];        // Input Coding Format
1237     uint8_t       out_cod_fmt[5];       // Output Coding Format
1238     uint16_t      in_cod_data_sz;       // Input Coded Data Size (in bits)
1239     uint16_t      out_cod_data_sz;      // Output Coded Data Size (in bits)
1240     uint8_t       in_data_fmt;          // Input PCM Data Format
1241     uint8_t       out_data_fmt;         // Output PCM Data Format
1242     uint8_t       in_msb_pos;           // Input PCM Sample Payload MSB Position (in bits)
1243     uint8_t       out_msb_pos;          // Output PCM Sample Payload MSB Position (in bits)
1244     uint8_t       in_data_path;         // Input Data Path
1245     uint8_t       out_data_path;        // Output Data Path
1246     uint8_t       in_tr_unit_sz;        // Input Transport Unit Size (in bits)
1247     uint8_t       out_tr_unit_sz;       // Output Transport Unit Size (in bits)
1248     uint16_t      max_lat;              // Max Latency (in ms)
1249     uint16_t      packet_type;          // Packet Type
1250     uint8_t       retx_eff;             // Retransmission Effort
1251 };
1252 
1253 /// HCI io capability request reply command structure
1254 struct hci_io_cap_req_reply_cmd
1255 {
1256     ///BdAddr
1257     struct bd_addr  bd_addr;
1258     ///IO capability
1259     uint8_t io_capa;
1260     ///OOB data present
1261     uint8_t oob_data_pres;
1262     ///Authentication requirements
1263     uint8_t auth_req;
1264 
1265 };
1266 
1267 /// HCI io capability request negative reply command structure
1268 struct hci_io_cap_req_neg_reply_cmd
1269 {
1270     ///BdAddr
1271     struct bd_addr  bd_addr;
1272     ///Reason
1273     uint8_t reason;
1274 };
1275 
1276 /// HCI user pass key request reply command structure
1277 struct hci_user_passkey_req_reply_cmd
1278 {
1279     ///BdAddr
1280     struct bd_addr  bd_addr;
1281     ///Numeric value
1282     uint32_t num_val;
1283 };
1284 
1285 /// HCI remote oob data request reply command structure
1286 struct hci_rem_oob_data_req_reply_cmd
1287 {
1288     ///BdAddr
1289     struct bd_addr  bd_addr;
1290     ///hash part
1291     struct hash oob_c;
1292     ///random part
1293     struct randomizer oob_r;
1294 };
1295 
1296 /// HCI send key press notification command structure
1297 struct hci_send_keypress_notif_cmd
1298 {
1299     ///BdAddr
1300     struct bd_addr  bd_addr;
1301     ///Notification type
1302     uint8_t notif_type;
1303 };
1304 
1305 /// HCI truncated page command structure
1306 struct hci_trunc_page_cmd
1307 {
1308     ///BdAddr
1309     struct bd_addr  bd_addr;
1310     /// Page Scan Repetition Mode
1311     uint8_t         page_scan_rep_mode;
1312     /**
1313      * Clock Offset
1314      *
1315      * Bits 14-0 : Bits 16-2 of CLKNslave-CLK
1316      * Bit 15 : Clock_Offset_Valid_Flag
1317      *   Invalid Clock Offset = 0
1318      *   Valid Clock Offset = 1
1319      */
1320     uint16_t        clk_off;
1321 };
1322 
1323 /// HCI truncated page cancel command structure
1324 struct hci_trunc_page_can_cmd
1325 {
1326     ///BdAddr
1327     struct bd_addr  bd_addr;
1328 };
1329 
1330 /// HCI set connectionless slave broadcast command structure
1331 struct hci_set_con_slv_bcst_cmd
1332 {
1333     /// Enable
1334     uint8_t enable;
1335     /// LT_ADDR
1336     uint8_t lt_addr;
1337     /// LPO_Allowed
1338     uint8_t lpo_allowed;
1339     /// Packet_Type
1340     uint16_t packet_type;
1341     /// Interval_Min (in slots)
1342     uint16_t interval_min;
1343     /// Interval_Max (in slots)
1344     uint16_t interval_max;
1345     /// CSB_supervisionTO (in slots)
1346     uint16_t csb_supv_to;
1347 };
1348 
1349 /// HCI set connectionless slave broadcast command complete event structure
1350 struct hci_set_con_slv_bcst_cmd_cmp_evt
1351 {
1352     /// Status
1353     uint8_t status;
1354     /// LT_ADDR
1355     uint8_t lt_addr;
1356     /// Interval (in slots)
1357     uint16_t interval;
1358 };
1359 
1360 /// HCI set connectionless slave broadcast receive command structure
1361 struct hci_set_con_slv_bcst_rec_cmd
1362 {
1363     /// Enable
1364     uint8_t enable;
1365     /// BD_ADDR
1366     struct bd_addr  bd_addr;
1367     /// LT_ADDR
1368     uint8_t lt_addr;
1369     /// Interval (in slots)
1370     uint16_t interval;
1371     /// Clock_Offset (28 bits) - (CLKNslave - CLK) modulo 2^28
1372     uint32_t clock_offset;
1373     /// Next_Connectionless_Slave_Broadcast_Clock (28 bits)
1374     uint32_t next_csb_clock;
1375     /// CSB_supervisionTO (in slots)
1376     uint16_t csb_supv_to;
1377     /// Remote_Timing_Accuracy (in ppm)
1378     uint8_t remote_timing_accuracy;
1379     /// Skip
1380     uint8_t skip;
1381     /// Packet_Type
1382     uint16_t packet_type;
1383     /// AFH_Channel_Map
1384     struct chnl_map afh_ch_map;
1385 };
1386 
1387 /// HCI set connectionless slave broadcast receive command complete event structure
1388 struct hci_set_con_slv_bcst_rec_cmd_cmp_evt
1389 {
1390     /// Status
1391     uint8_t status;
1392     /// BD_ADDR
1393     struct bd_addr  bd_addr;
1394     /// LT_ADDR
1395     uint8_t lt_addr;
1396 };
1397 
1398 /// HCI Receive Synchronization Train command structure
1399 struct hci_rec_sync_train_cmd
1400 {
1401     /// BD_ADDR
1402     struct bd_addr  bd_addr;
1403     /// Synchronization_scanTO (in slots)
1404     uint16_t sync_scan_to;
1405     /// Sync_Scan_Window (in slots)
1406      uint16_t sync_scan_win;
1407     /// Sync_Scan_Interval (in slots)
1408      uint16_t sync_scan_int;
1409 };
1410 
1411 /// HCI remote oob extended data request reply command structure
1412 struct hci_rem_oob_ext_data_req_reply_cmd
1413 {
1414     ///BdAddr
1415     struct bd_addr  bd_addr;
1416     ///hash part
1417     struct hash oob_c_192;
1418     ///random part
1419     struct randomizer oob_r_192;
1420     ///hash part
1421     struct hash oob_c_256;
1422     ///random part
1423     struct randomizer oob_r_256;
1424 };
1425 
1426 
1427 struct hci_le_generate_dh_key_cmd
1428 {
1429     uint8_t public_key[64];
1430 };
1431 /*
1432  * HCI LINK POLICY COMMANDS PARAMETERS
1433  ****************************************************************************************
1434  */
1435 
1436 /// HCI setup quality of service command structure
1437 struct hci_qos_setup_cmd
1438 {
1439     ///Connection handle
1440     uint16_t conhdl;
1441     ///Flags
1442     uint8_t flags;
1443     ///Service type
1444     uint8_t serv_type;
1445     ///Token rate
1446     uint32_t tok_rate;
1447     ///Peak bandwidth
1448     uint32_t pk_bw;
1449     ///Latency
1450     uint32_t lat;
1451     ///Delay variation
1452     uint32_t del_var;
1453 };
1454 
1455 /// HCI command complete event structure for read default link policy command structure
1456 struct hci_rd_dft_link_pol_stg_cmd_cmp_evt
1457 {
1458     ///Status of the command reception
1459     uint8_t     status;
1460     ///Link policy
1461     uint16_t    link_pol_stg;
1462 };
1463 
1464 struct hci_wr_dft_link_pol_stg_cmd
1465 {
1466         ///Link policy
1467         uint16_t    link_pol_stg;
1468 };
1469 
1470 /*
1471  * HCI CONTROL & BASEBAND COMMANDS PARAMETERS
1472  ****************************************************************************************
1473  */
1474 
1475 /// HCI set event mask command structure
1476 struct hci_set_evt_mask_cmd
1477 {
1478     ///Event Mask
1479     struct evt_mask    event_mask;
1480 };
1481 
1482 /// HCI set event filter command structure
1483 struct hci_set_evt_filter_cmd
1484 {
1485     /// Filter type
1486     uint8_t filter_type;
1487 
1488     /// Filters
1489     union hci_filter
1490     {
1491         uint8_t clear_all_filter_reserved;
1492 
1493         /// Inquiry Result Filter
1494         struct inq_res_filter
1495         {
1496             /// Filter Condition type
1497             uint8_t cond_type;
1498 
1499             /// Filter conditions
1500             union hci_inq_filter_cond
1501             {
1502                 /// Reserved value (Inquiry Result Filter - condition type 0x00 has no condition)
1503                 uint8_t cond_0_reserved;
1504 
1505                 /// Inquiry Result Filter Condition - condition type 0x01
1506                 struct inq_res_filter_cond_1
1507                 {
1508                     /// Class_of_Device
1509                     struct devclass class_of_dev;
1510                     /// Class_of_Device_Mask
1511                     struct devclass class_of_dev_msk;
1512                 } cond_1;
1513 
1514                 /// Inquiry Result Filter Condition - condition type 0x02
1515                 struct inq_res_filter_cond_2
1516                 {
1517                     /// BD Address
1518                     struct bd_addr bd_addr;
1519                 } cond_2;
1520             } cond;
1521         } inq_res;
1522 
1523         /// Connection Setup Filter
1524         struct con_set_filter
1525         {
1526             /// Filter Condition type
1527             uint8_t cond_type;
1528 
1529             /// Filter conditions
1530             union hci_con_filter_cond
1531             {
1532                 /// Connection Setup Filter Condition - condition type 0x00
1533                 struct con_set_filter_cond_0
1534                 {
1535                     /// Auto_Accept_Flag
1536                     uint8_t auto_accept;
1537                 } cond_0;
1538 
1539                 /// Connection Setup Filter Condition - condition type 0x01
1540                 struct con_set_filter_cond_1
1541                 {
1542                     /// Class_of_Device
1543                     struct devclass class_of_dev;
1544                     /// Class_of_Device_Mask
1545                     struct devclass class_of_dev_msk;
1546                     /// Auto_Accept_Flag
1547                     uint8_t auto_accept;
1548                 } cond_1;
1549 
1550                 /// Connection Setup Filter Condition - condition type 0x02
1551                 struct con_set_filter_cond_2
1552                 {
1553                     /// BD Address
1554                     struct bd_addr bd_addr;
1555                     /// Auto_Accept_Flag
1556                     uint8_t auto_accept;
1557                 } cond_2;
1558             } cond;
1559 
1560         } con_set;
1561 
1562     } filter;
1563 };
1564 
1565 /// HCI command completed event structure for the flush command
1566 struct hci_flush_cmd_cmp_evt
1567 {
1568     ///Status for command reception
1569     uint8_t status;
1570     ///Connection handle
1571     uint16_t conhdl;
1572 };
1573 
1574 /// HCI command complete event structure for the Read pin type command
1575 struct hci_rd_pin_type_cmd_cmp_evt
1576 {
1577     ///Status of the command
1578     uint8_t     status;
1579     ///PIN type
1580     uint8_t   pin_type;
1581 };
1582 
1583 struct hci_wr_pin_type_cmd
1584 {
1585     ///PIN type
1586     uint8_t pin_type;
1587 };
1588 
1589 struct hci_rd_stored_lk_cmd
1590 {
1591     ///BdAddr
1592     struct bd_addr  bd_addr;
1593     ///Read all flag
1594     uint8_t rd_all_flag;
1595 };
1596 
1597 /// HCI command complete event structure for read stored link key command
1598 struct hci_rd_stored_lk_cmd_cmp_evt
1599 {
1600     /// Status of the command reception
1601     uint8_t     status;
1602     ///Maximum number of key
1603     uint16_t num_key_max;
1604     ///Read number of key
1605     uint16_t num_key_rd;
1606 };
1607 
1608 #if BT_EMB_PRESENT
1609 struct hci_wr_stored_lk_cmd
1610 {
1611     /// Number of key to write
1612     uint8_t num_key_wr;
1613 
1614     /// BD Address + Key table
1615     struct bd_addr_plus_key link_keys[HCI_MAX_CMD_PARAM_SIZE / sizeof(struct bd_addr_plus_key)];
1616 };
1617 #endif //BT_EMB_PRESENT
1618 
1619 /// HCI command complete event structure for write stored link key command
1620 struct hci_wr_stored_lk_cmd_cmp_evt
1621 {
1622     /// Status of the command reception
1623     uint8_t     status;
1624     ///number of key written
1625     uint8_t    num_key_wr;
1626 };
1627 
1628 struct hci_del_stored_lk_cmd
1629 {
1630     ///BdAddr
1631     struct bd_addr  bd_addr;
1632     ///Delete all flag
1633     uint8_t del_all_flag;
1634 };
1635 
1636 /// HCI command complete event structure for delete stored link key command
1637 struct hci_del_stored_lk_cmd_cmp_evt
1638 {
1639     /// Status of the command reception
1640     uint8_t     status;
1641     ///Read number of key
1642     uint16_t num_key_del;
1643 };
1644 
1645 struct hci_wr_local_name_cmd
1646 {
1647     ///Name
1648     struct device_name  name;
1649 };
1650 
1651 /// HCI command complete event structure for the read local name command
1652 struct hci_rd_local_name_cmd_cmp_evt
1653 {
1654     ///Status of the command
1655     uint8_t     status;
1656     ///Name
1657     uint8_t  name[BD_NAME_SIZE];
1658 };
1659 
1660 /// HCI command complete event structure for the Read connection accept to command
1661 struct hci_rd_con_accept_to_cmd_cmp_evt
1662 {
1663     ///Status of the command
1664     uint8_t     status;
1665     /// Connection accept timeout (in slots)
1666     uint16_t    con_acc_to;
1667 };
1668 
1669 struct hci_wr_con_accept_to_cmd
1670 {
1671     /// Connection accept timeout (in slots)
1672     uint16_t    con_acc_to;
1673 };
1674 
1675 /// HCI command complete event structure for the Read page to command
1676 struct hci_rd_page_to_cmd_cmp_evt
1677 {
1678     ///Status of the command
1679     uint8_t     status;
1680     /// Page timeout (in slots)
1681     uint16_t    page_to;
1682 };
1683 
1684 struct hci_wr_page_to_cmd
1685 {
1686     /// Page timeout (in slots)
1687     uint16_t    page_to;
1688 };
1689 
1690 /// HCI command complete event structure for the Read scan enable command
1691 struct hci_rd_scan_en_cmd_cmp_evt
1692 {
1693     ///Status of the command
1694     uint8_t     status;
1695     ///Status of the scan enable
1696     uint8_t     scan_en;
1697 };
1698 
1699 struct hci_wr_scan_en_cmd
1700 {
1701         ///Status of the scan enable
1702         uint8_t scan_en;
1703 };
1704 
1705 /// HCI command complete event structure for the Read scan activity command
1706 struct hci_rd_page_scan_act_cmd_cmp_evt
1707 {
1708     ///Status of the command
1709     uint8_t     status;
1710     /// Page scan interval (in slots)
1711     uint16_t page_scan_intv;
1712     /// Page scan window (in slots)
1713     uint16_t page_scan_win;
1714 };
1715 
1716 struct hci_wr_page_scan_act_cmd
1717 {
1718     /// Page scan interval (in slots)
1719     uint16_t page_scan_intv;
1720     /// Page scan window (in slots)
1721     uint16_t page_scan_win;
1722 };
1723 
1724 /// HCI command complete event structure for the Read inquiry scan activity command
1725 struct hci_rd_inq_scan_act_cmd_cmp_evt
1726 {
1727     /// Status of the command
1728     uint8_t  status;
1729     /// Inquiry scan interval (in slots)
1730     uint16_t inq_scan_intv;
1731     /// Inquiry scan window (in slots)
1732     uint16_t inq_scan_win;
1733 };
1734 
1735 struct hci_wr_inq_scan_act_cmd
1736 {
1737     /// Inquiry scan interval (in slots)
1738     uint16_t inq_scan_intv;
1739     /// Inquiry scan window (in slots)
1740     uint16_t inq_scan_win;
1741 };
1742 
1743 /// HCI command complete event structure for the Read authentication command
1744 struct hci_rd_auth_en_cmd_cmp_evt
1745 {
1746     ///Status of the command
1747     uint8_t     status;
1748     ///Value of the authentication
1749     uint8_t    auth_en;
1750 };
1751 
1752 struct hci_wr_auth_en_cmd
1753 {
1754     ///Value of the authentication
1755     uint8_t auth_en;
1756 };
1757 
1758 /// HCI command complete event structure for the read class of device command
1759 struct hci_rd_class_of_dev_cmd_cmp_evt
1760 {
1761     ///Status of the command
1762     uint8_t     status;
1763     ///Class of device
1764     struct devclass class_of_dev;
1765 };
1766 
1767 struct hci_wr_class_of_dev_cmd
1768 {
1769     ///Class of device
1770     struct devclass class_of_dev;
1771 };
1772 
1773 /// HCI read voice settings complete event
1774 struct hci_rd_voice_stg_cmd_cmp_evt
1775 {
1776     ///Status of the command reception
1777     uint8_t     status;
1778     /// Voice setting
1779     uint16_t voice_stg;
1780 };
1781 
1782 struct hci_wr_voice_stg_cmd
1783 {
1784     /// voice setting
1785     uint16_t voice_stg;
1786 };
1787 
1788 /// HCI command complete event structure for read number of broadcast retrans command
1789 struct hci_rd_nb_bdcst_retx_cmd_cmp_evt
1790 {
1791     /// Status of the command reception
1792     uint8_t     status;
1793     ///Read number of broadcast retransmission
1794     uint8_t num_bcst_ret;
1795 };
1796 
1797 struct hci_wr_nb_bdcst_retx_cmd
1798 {
1799     ///Read number of broadcast retransmission
1800     uint8_t num_bcst_ret;
1801 };
1802 
1803 /// HCI command complete event structure for the Read Synchronous Flow Control command
1804 struct hci_rd_sync_flow_ctrl_en_cmd_cmp_evt
1805 {
1806     /// Status of the command reception
1807     uint8_t     status;
1808     ///Synchronous flow control enable
1809     uint8_t     sync_flow_ctrl_en;
1810 };
1811 
1812 struct hci_wr_sync_flow_ctrl_en_cmd
1813 {
1814     /// Synchronous Flow Control enable
1815     uint8_t   sync_flow_ctrl_en;
1816 };
1817 
1818 ///HCI set controller to host flow control command
1819 struct hci_set_ctrl_to_host_flow_ctrl_cmd
1820 {
1821     ///Flow control enable for controller
1822     uint8_t flow_cntl;
1823 };
1824 
1825 ///HCI host buffer size command
1826 struct hci_host_buf_size_cmd
1827 {
1828     ///Host ACL packet length
1829     uint16_t    acl_pkt_len;
1830     ///Host synchronous packet length
1831     uint8_t     sync_pkt_len;
1832     ///Host Total number of ACL packets allowed
1833     uint16_t    nb_acl_pkts;
1834     ///Host total number of synchronous packets allowed
1835     uint16_t    nb_sync_pkts;
1836 };
1837 
1838 #if BT_EMB_PRESENT
1839 ///HCI host number of completed packets command
1840 struct hci_host_nb_cmp_pkts_cmd
1841 {
1842     ///Number of handles for which the completed packets number is given
1843     uint8_t     nb_of_hdl;
1844     ///Array of connection handles
1845     uint16_t    con_hdl[MAX_NB_ACTIVE_ACL];
1846     ///Array of number of completed packets values for connection handles.
1847     uint16_t    nb_comp_pkt[MAX_NB_ACTIVE_ACL];
1848 };
1849 #elif BLE_EMB_PRESENT || BLE_HOST_PRESENT
1850 ///HCI host number of completed packets command
1851 struct hci_host_nb_cmp_pkts_cmd
1852 {
1853     ///Number of handles for which the completed packets number is given
1854     uint8_t     nb_of_hdl;
1855     ///Array of connection handles
1856     uint16_t    con_hdl[BLE_ACTIVITY_MAX+1];     // ensure that at least 1 element is present
1857     ///Array of number of completed packets values for connection handles.
1858     uint16_t    nb_comp_pkt[BLE_ACTIVITY_MAX+1]; // ensure that at least 1 element is present
1859 };
1860 #endif //BLE_EMB_PRESENT || BLE_HOST_PRESENT
1861 
1862 /// HCI read link supervision timeout command parameters structure
1863 struct hci_rd_link_supv_to_cmd_cmp_evt
1864 {
1865     ///Status for command reception
1866     uint8_t status;
1867     ///Connection handle
1868     uint16_t conhdl;
1869     ///Link supervision timeout
1870     uint16_t lsto_val;
1871 };
1872 
1873 /// HCI write link supervision timeout command parameters structure
1874 struct hci_wr_link_supv_to_cmd
1875 {
1876     ///Connection handle
1877     uint16_t conhdl;
1878     ///Link supervision timeout
1879     uint16_t lsto_val;
1880 };
1881 
1882 /// HCI command complete event structure for the nb of supported IAC command
1883 struct hci_rd_nb_supp_iac_cmd_cmp_evt
1884 {
1885     ///Status of the command
1886     uint8_t     status;
1887     ///nb_of iac
1888     uint8_t  nb_iac;
1889 };
1890 
1891 /// HCI command complete event structure for read current IAC LAP command
1892 struct hci_rd_curr_iac_lap_cmd_cmp_evt
1893 {
1894     ///Status of the command
1895     uint8_t     status;
1896     ///nb of current iac
1897     uint8_t  nb_curr_iac;
1898     ///lap
1899     struct lap iac_lap;
1900 };
1901 
1902 /// HCI write current IAC LAP command structure
1903 struct hci_wr_curr_iac_lap_cmd
1904 {
1905     /// Number of current iac laps
1906     uint8_t  nb_curr_iac;
1907     ///lap
1908     struct lap iac_lap[(HCI_MAX_CMD_PARAM_SIZE / BD_ADDR_LAP_LEN) - 1];
1909 };
1910 
1911 struct hci_set_afh_host_ch_class_cmd
1912 {
1913     ///AFH channel map
1914     struct chnl_map   afh_ch;
1915 };
1916 
1917 /// HCI command complete event structure for write inquiry scan type command structure
1918 struct hci_rd_inq_scan_type_cmd_cmp_evt
1919 {
1920     /// Status of the command reception
1921     uint8_t     status;
1922     /// Inquiry scan type
1923     uint8_t     inq_scan_type;
1924 };
1925 
1926 struct hci_wr_inq_scan_type_cmd
1927 {
1928     /// Inquiry scan type
1929     uint8_t     inq_scan_type;
1930 };
1931 
1932 /// HCI command complete event structure for read inquiry mode command structure
1933 struct hci_rd_inq_mode_cmd_cmp_evt
1934 {
1935     /// Status of the command reception
1936     uint8_t     status;
1937     /// Inquiry mode
1938     uint8_t     inq_mode;
1939 };
1940 
1941 struct hci_wr_inq_mode_cmd
1942 {
1943     /// Inquiry mode
1944     uint8_t     inq_mode;
1945 };
1946 
1947 /// HCI command complete event structure for write page scan type command structure
1948 struct hci_rd_page_scan_type_cmd_cmp_evt
1949 {
1950     /// Status of the command reception
1951     uint8_t     status;
1952     /// Page scan type
1953     uint8_t     page_scan_type;
1954 };
1955 
1956 struct hci_wr_page_scan_type_cmd
1957 {
1958     /// Page scan type
1959     uint8_t     page_scan_type;
1960 };
1961 
1962 /// HCI command complete event structure for read assessment mode command structure
1963 struct hci_rd_afh_ch_assess_mode_cmd_cmp_evt
1964 {
1965     /// Status of the command reception
1966     uint8_t     status;
1967     ///AFH channel assessment mode
1968     uint8_t     afh_ch_ass_mode;
1969 };
1970 
1971 struct hci_wr_afh_ch_assess_mode_cmd
1972 {
1973     ///AFH channel assessment mode
1974     uint8_t     afh_ch_ass_mode;
1975 };
1976 
1977 /// HCI command complete event structure for remote name request cancel command
1978 struct hci_rd_ext_inq_rsp_cmd_cmp_evt
1979 {
1980     ///status
1981     uint8_t     status;
1982     ///FEC required
1983     uint8_t     fec_req;
1984     ///Extended inquiry response
1985     struct eir  eir;
1986 };
1987 
1988 struct hci_wr_ext_inq_rsp_cmd
1989 {
1990     ///FEC required
1991     uint8_t     fec_req;
1992     ///Extended inquiry response
1993     struct eir  eir;
1994 };
1995 
1996 /// HCI command complete event structure for remote name request cancel command
1997 struct hci_rd_sp_mode_cmd_cmp_evt
1998 {
1999     ///status
2000     uint8_t     status;
2001     ///Simple pairing mode
2002     uint8_t     sp_mode;
2003 };
2004 
2005 struct hci_wr_sp_mode_cmd
2006 {
2007     ///Simple pairing mode
2008     uint8_t     sp_mode;
2009 };
2010 
2011 /// HCI command complete event structure for read oob data command
2012 struct hci_rd_loc_oob_data_cmd_cmp_evt
2013 {
2014     ///status
2015     uint8_t     status;
2016     ///hash part
2017     struct hash oob_c;
2018     ///random part
2019     struct randomizer oob_r;
2020 };
2021 
2022 /// HCI command complete event structure for read inquiry response transmit power command
2023 struct hci_rd_inq_rsp_tx_pwr_lvl_cmd_cmp_evt
2024 {
2025     ///status
2026     uint8_t status;
2027     ///TX power
2028     uint8_t tx_pwr;
2029 };
2030 
2031 struct hci_wr_inq_tx_pwr_lvl_cmd
2032 {
2033     ///TX power
2034     int8_t tx_pwr;
2035 };
2036 
2037 /// HCI command complete event structure for read erroneous data reporting command
2038 struct hci_rd_dft_err_data_rep_cmd_cmp_evt
2039 {
2040     ///status
2041     uint8_t     status;
2042     ///Erroneous data reporting
2043     uint8_t     err_data_rep;
2044 };
2045 
2046 struct hci_wr_dft_err_data_rep_cmd
2047 {
2048     ///Erroneous data reporting
2049     uint8_t err_data_rep;
2050 };
2051 
2052 /// HCI read LE Host Supported complete event
2053 struct  hci_rd_le_host_supp_cmd_cmp_evt
2054 {
2055     ///Status
2056     uint8_t status;
2057     ///LE_Supported_Host
2058     uint8_t le_supported_host;
2059     ///Simultaneous_LE_Host
2060     uint8_t simultaneous_le_host;
2061 };
2062 
2063 /// HCI write LE Host Supported command
2064 struct  hci_wr_le_host_supp_cmd
2065 {
2066     ///LE_Supported_Host
2067     uint8_t le_supported_host;
2068     ///Simultaneous_LE_Host
2069     uint8_t simultaneous_le_host;
2070 };
2071 
2072 /// HCI Set MWS Channel Parameters command
2073 struct hci_set_mws_channel_params_cmd
2074 {
2075     ///MWS_Channel_Enable
2076     uint8_t mws_channel_enable;
2077     ///MWS_RX_Center_Frequency
2078     uint16_t mws_rx_center_frequency;
2079     ///MWS_TX_Center_Frequency
2080     uint16_t mws_tx_center_frequency;
2081     ///MWS_RX_Channel_Bandwidth
2082     uint16_t mws_rx_channel_bandwidth;
2083     ///MWS_TX_Channel_Bandwidth
2084     uint16_t mws_tx_channel_bandwidth;
2085     ///MWS_Channel_Type
2086     uint8_t mws_channel_type;
2087 };
2088 
2089 /// HCI Set External Frame Configuration command
2090 struct hci_set_external_frame_config_cmd
2091 {
2092     /// Ext_Frame_Duration
2093     uint16_t ext_fr_duration;
2094     /// Ext_Frame_Sync_Assert_Offset
2095     int16_t ext_fr_sync_assert_offset;
2096     /// Ext_Frame_Sync_Assert_Jitter
2097     uint16_t ext_fr_sync_assert_jitter;
2098     /// Ext_Frame_Num_Periods
2099     uint8_t ext_fr_num_periods;
2100     /// Period Durations & Types
2101     struct ext_fr_period period[1/*__ARRAY_EMPTY*/];
2102 };
2103 
2104 /// HCI Set MWS Signaling command
2105 struct hci_set_mws_signaling_cmd
2106 {
2107     ///MWS_RX_Assert_Offset
2108     int16_t mws_rx_assert_offset;
2109     ///MWS_RX_Assert_Jitter
2110     uint16_t mws_rx_assert_jitter;
2111     ///MWS_RX_Deassert_Offset
2112     int16_t mws_rx_deassert_offset;
2113     ///MWS_RX_Deassert_Jitter
2114     uint16_t mws_rx_deassert_jitter;
2115     ///MWS_TX_Assert_Offset
2116     int16_t mws_tx_assert_offset;
2117     ///MWS_TX_Assert_Jitter
2118     uint16_t mws_tx_assert_jitter;
2119     ///MWS_TX_Deassert_Offset
2120     int16_t mws_tx_deassert_offset;
2121     ///MWS_TX_Deassert_Jitter
2122     uint16_t mws_tx_deassert_jitter;
2123     ///MWS_Pattern_Assert_Offset
2124     int16_t mws_pattern_assert_offset;
2125     ///MWS_Pattern_Assert_Jitter
2126     uint16_t mws_pattern_assert_jitter;
2127     ///MWS_Inactivity_Duration_Assert_Offset
2128     int16_t mws_inactivity_duration_assert_offset;
2129     ///MWS_Inactivity_Duration_Assert_Jitter
2130     uint16_t mws_inactivity_duration_assert_jitter;
2131     ///MWS_Scan_Frequency_Assert_Offset
2132     int16_t mws_scan_frequency_assert_offset;
2133     ///MWS_Scan_Frequency_Assert_Jitter
2134     uint16_t mws_scan_frequency_assert_jitter;
2135     ///MWS_Priority_Assert_Offset_Request
2136     uint16_t mws_priority_assert_offset_request;
2137 };
2138 
2139 /// HCI Set MWS Signaling command complete event
2140 struct hci_set_mws_signaling_cmd_cmp_evt
2141 {
2142     ///Status
2143     uint8_t status;
2144     ///Bluetooth_Rx_Priority_Assert_Offset
2145     int16_t bt_rx_prio_assert_offset;
2146     ///Bluetooth_Rx_Priority_Assert_Jitter
2147     uint16_t bt_rx_prio_assert_jitter;
2148     ///Bluetooth_Rx_Priority_Deassert_Offset
2149     int16_t bt_rx_prio_deassert_offset;
2150     ///Bluetooth_Rx_Priority_Deassert_Jitter
2151     uint16_t bt_rx_prio_deassert_jitter;
2152     ///802_Rx_Priority_Assert_Offset
2153     int16_t _802_rx_prio_assert_offset;
2154     ///802_Rx_Priority_Assert_Jitter
2155     uint16_t _802_rx_prio_assert_jitter;
2156     ///802_Rx_Priority_Deassert_Offset
2157     int16_t _802_rx_prio_deasssert_offset;
2158     ///802_Rx_Priority_Deassert_Jitter
2159     uint16_t _802_rx_prio_deassert_jitter;
2160     ///Bluetooth_Tx_On_Assert_Offset
2161     int16_t bt_tx_on_assert_offset;
2162     ///Bluetooth_Tx_On_Assert_Jitter
2163     uint16_t bt_tx_on_assert_jitter;
2164     ///Bluetooth_Tx_On_Deassert_Offset
2165     int16_t bt_tx_on_deassert_offset;
2166     ///Bluetooth_Tx_On_Deassert_Jitter
2167     uint16_t bt_tx_on_deassert_jitter;
2168     ///802_Tx_On_Assert_Offset
2169     int16_t _802_tx_on_assert_offset;
2170     ///802_Tx_On_Assert_Jitter
2171     uint16_t _802_tx_on_assert_jitter;
2172     ///802_Tx_On_Deassert_Offset
2173     int16_t _802_tx_on_deassert_offset;
2174     ///802_Tx_On_Deassert_Jitter
2175     uint16_t _802_tx_on_deassert_jitter;
2176 };
2177 
2178 /// HCI Set MWS Transport Layer command
2179 struct hci_set_mws_transport_layer_cmd
2180 {
2181     ///Transport_Layer
2182     uint8_t transport_layer;
2183     ///To_MWS_Baud_Rate
2184     uint32_t to_mws_baud_rate;
2185     ///From_MWS_Baud_Rate
2186     uint32_t from_mws_baud_rate;
2187 };
2188 
2189 /// HCI Set MWS Scan Frequency Table command
2190 struct hci_set_mws_scan_freq_table_cmd
2191 {
2192     ///Num_Scan_Frequencies
2193     uint8_t num_scan_frequencies;
2194     ///Scan_Frequencys Low & High
2195     struct mws_scan_freq scan_freq[1/*__ARRAY_EMPTY*/];
2196 };
2197 
2198 /// HCI Set MWS Pattern Configuration command
2199 struct hci_set_mws_pattern_config_cmd
2200 {
2201     ///MWS_PATTERN_Index
2202     uint8_t mws_pattern_index;
2203     ///MWS_PATTERN_NumIntervals
2204     uint8_t num_intervals;
2205     ///MWS_PATTERN_Interval Duration & Type
2206     struct mws_pattern_intv intv[1/*__ARRAY_EMPTY*/];
2207 };
2208 
2209 /// Hci Get MWS Transport Layer Configuration command complete event
2210 struct hci_get_mws_transport_layer_config_cmd_cmp_evt
2211 {
2212     ///Status
2213     uint8_t status;
2214     ///Num_Transports
2215     uint8_t num_transports;
2216     ///Transport_Layers
2217     struct mws_transport tran[1/*__ARRAY_EMPTY*/];
2218 };
2219 
2220 /// HCI read Secure Connections Host Support complete event
2221 struct  hci_rd_sec_con_host_supp_cmd_cmp_evt
2222 {
2223     ///Status
2224     uint8_t status;
2225     /// Secure Connections Host Support
2226     uint8_t sec_con_host_supp;
2227 };
2228 
2229 /// HCI write Secure Connections Host Support command
2230 struct  hci_wr_sec_con_host_supp_cmd
2231 {
2232     /// Secure Connections Host Support
2233     uint8_t sec_con_host_supp;
2234 };
2235 
2236 /// HCI write Secure Connections Test Mode command
2237 struct  hci_wr_sec_con_test_mode_cmd
2238 {
2239     /// Connection handle
2240     uint16_t conhdl;
2241     /// DM1 ACL-U mode
2242     uint8_t dm1_acl_u_mode;
2243     /// eSCO loopback mode
2244     uint8_t esco_loopback_mode;
2245 };
2246 
2247 /// HCI write Secure Connections Test Mode complete event
2248 struct  hci_wr_sec_con_test_mode_cmd_cmp_evt
2249 {
2250     ///Status
2251     uint8_t status;
2252     /// Connection handle
2253     uint16_t conhdl;
2254 };
2255 
2256 /// HCI Set Reserved LT_ADDR command
2257 struct hci_set_res_lt_addr_cmd
2258 {
2259     /// LT_ADDR
2260     uint8_t lt_addr;
2261 };
2262 
2263 /// HCI Set Reserved LT_ADDR command complete event
2264 struct hci_set_res_lt_addr_cmd_cmp_evt
2265 {
2266     /// Status
2267     uint8_t  status;
2268     /// LT_ADDR
2269     uint8_t lt_addr;
2270 };
2271 
2272 /// HCI Delete Reserved LT_ADDR command
2273 struct hci_del_res_lt_addr_cmd
2274 {
2275     /// LT_ADDR
2276     uint8_t lt_addr;
2277 };
2278 
2279 /// HCI Delete Reserved LT_ADDR command complete event
2280 struct hci_del_res_lt_addr_cmd_cmp_evt
2281 {
2282     /// Status
2283     uint8_t  status;
2284     /// LT_ADDR
2285     uint8_t lt_addr;
2286 };
2287 
2288 /// HCI Set Connectionless Slave Broadcast Data command
2289 struct hci_set_con_slv_bcst_data_cmd
2290 {
2291     /// LT_ADDR
2292     uint8_t lt_addr;
2293     /// Fragment
2294     uint8_t fragment;
2295     /// Data_Length (in bytes)
2296     uint8_t data_length;
2297     /// Data
2298     uint8_t data[__ARRAY_EMPTY];
2299 };
2300 
2301 /// HCI Set Connectionless Slave Broadcast Data command complete event
2302 struct hci_set_con_slv_bcst_data_cmd_cmp_evt
2303 {
2304     /// Status
2305     uint8_t  status;
2306     /// LT_ADDR
2307     uint8_t lt_addr;
2308 };
2309 
2310 /// HCI Read Synchronization Train Parameters command complete event
2311 struct hci_rd_sync_train_param_cmd_cmp_evt
2312 {
2313     /// Status
2314     uint8_t  status;
2315     /// Sync_Train_Interval (in slots)
2316     uint16_t sync_train_int;
2317     /// synchronization_trainTO (in slots)
2318     uint32_t sync_train_to;
2319     /// Service_Data
2320     uint8_t service_data;
2321 };
2322 
2323 /// HCI Write Synchronization Train Parameters command
2324 struct hci_wr_sync_train_param_cmd
2325 {
2326     /// Interval_Min (in slots)
2327     uint16_t int_min;
2328     /// Interval_Max (in slots)
2329     uint16_t int_max;
2330     /// synchronization_trainTO (in slots)
2331     uint32_t sync_train_to;
2332     /// Service_Data
2333     uint8_t service_data;
2334 };
2335 
2336 /// HCI Write Synchronization Train Parameters command complete event
2337 struct hci_wr_sync_train_param_cmd_cmp_evt
2338 {
2339     /// Status
2340     uint8_t  status;
2341     /// Sync_Train_Interval (in slots)
2342     uint16_t sync_train_int;
2343 };
2344 
2345 // HCI Synchronization Train Complete event
2346 struct hci_sync_train_cmp_evt
2347 {
2348     /// Status
2349     uint8_t  status;
2350 };
2351 
2352 /// HCI read authenticated payload timeout command
2353 struct hci_rd_auth_payl_to_cmd
2354 {
2355     ///Connection handle
2356     uint16_t     conhdl;
2357 };
2358 
2359 /// HCI command complete event structure for the Read Authenticated Payload Timeout Command
2360 struct hci_rd_auth_payl_to_cmd_cmp_evt
2361 {
2362     /// Status of the command reception
2363     uint8_t     status;
2364     ///Connection handle
2365     uint16_t     conhdl;
2366     ///Authenticated payload timeout
2367     uint16_t     auth_payl_to;
2368 };
2369 
2370 /// HCI command complete event structure for read oob extended data command
2371 struct hci_rd_loc_oob_ext_data_cmd_cmp_evt
2372 {
2373     ///status
2374     uint8_t     status;
2375     ///hash part
2376     struct hash oob_c_192;
2377     ///random part
2378     struct randomizer oob_r_192;
2379     ///hash part
2380     struct hash oob_c_256;
2381     ///random part
2382     struct randomizer oob_r_256;
2383 };
2384 
2385 /// HCI read Extended Page Timeout CC event
2386 struct hci_rd_ext_page_to_cmd_cmp_evt
2387 {
2388     /// Status
2389     uint8_t  status;
2390     /**
2391      * Extended Page Timeout measured in Number of Baseband slots. Interval Length = N * 0.625 msec (1 Baseband slot)
2392      * Range for N: 0x0000 (default) - 0xFFFF
2393      * Time Range: 0 - 40.9 Seconds
2394      */
2395     uint16_t ext_page_to;
2396 };
2397 
2398 /// HCI write Extended Page Timeout
2399 struct hci_wr_ext_page_to_cmd
2400 {
2401     /**
2402      * Extended Page Timeout measured in Number of Baseband slots. Interval Length = N * 0.625 msec (1 Baseband slot)
2403      * Range for N: 0x0000 (default) - 0xFFFF
2404      * Time Range: 0 - 40.9 Seconds
2405      */
2406     uint16_t ext_page_to;
2407 };
2408 
2409 /// HCI read Extended Inquiry Length CC event
2410 struct hci_rd_ext_inq_len_cmd_cmp_evt
2411 {
2412     /// Status
2413     uint8_t  status;
2414     /// Extended Inquiry Length
2415     uint16_t ext_inq_len;
2416 };
2417 
2418 /// HCI write Extended Inquiry Length
2419 struct hci_wr_ext_inq_len_cmd
2420 {
2421     /// Extended Inquiry Length
2422     uint16_t ext_inq_len;
2423 };
2424 
2425 /*
2426  * HCI INFORMATIONAL PARAMETERS COMMANDS PARAMETERS
2427  ****************************************************************************************
2428  */
2429 
2430 ///HCI command complete event structure for read local version information
2431 struct hci_rd_local_ver_info_cmd_cmp_evt
2432 {
2433     /// Status of the command reception
2434     uint8_t     status;
2435     ///HCI version number
2436     uint8_t     hci_ver;
2437     ///HCI revision number
2438     uint16_t    hci_rev;
2439     ///LMP version
2440     uint8_t     lmp_ver;
2441     ///manufacturer name
2442     uint16_t    manuf_name;
2443     ///LMP Subversion
2444     uint16_t    lmp_subver;
2445 };
2446 
2447 ///HCI command complete event structure for read local supported commands
2448 struct hci_rd_local_supp_cmds_cmd_cmp_evt
2449 {
2450     /// Status of the command reception
2451     uint8_t             status;
2452     ///Supported Commands structure
2453     struct supp_cmds    local_cmds;
2454 };
2455 
2456 /// HCI command complete event structure for read local supported features command
2457 struct hci_rd_local_supp_feats_cmd_cmp_evt
2458 {
2459     /// Status of the command reception
2460     uint8_t         status;
2461     ///Local  supported features
2462     struct features feats;
2463 };
2464 
2465 struct hci_rd_local_ext_feats_cmd
2466 {
2467     ///Page number
2468     uint8_t page_nb;
2469 };
2470 
2471 /// HCI command complete event structure for read local extended features command
2472 struct hci_rd_local_ext_feats_cmd_cmp_evt
2473 {
2474     /// Status of the command reception
2475     uint8_t     status;
2476     ///Page number
2477     uint8_t     page_nb;
2478     ///Maximum page number
2479     uint8_t     page_nb_max;
2480     ///Extended LMP features
2481     struct features ext_feats;
2482 };
2483 
2484 ///HCI command complete event structure for the Read Buffer Size Command
2485 struct hci_rd_buff_size_cmd_cmp_evt
2486 {
2487     /// Status of the command reception
2488     uint8_t     status;
2489     ///ACL data packet length controller can receive from host
2490     uint16_t     hc_data_pk_len;
2491     ///Synchronous data packet length controller can receive from host
2492     uint8_t      hc_sync_pk_len;
2493     ///Total number of ACL data packets controller can receive from host
2494     uint16_t     hc_tot_nb_data_pkts;
2495     ///Total number of synchronous data packets controller can receive from host
2496     uint16_t     hc_tot_nb_sync_pkts;
2497 };
2498 
2499 ///HCI command complete event structure for read bd address
2500 struct hci_rd_bd_addr_cmd_cmp_evt
2501 {
2502     /// Status of the command reception
2503     uint8_t             status;
2504     ///BD address
2505     struct bd_addr      local_addr;
2506 };
2507 
2508 /// HCI command complete event structure for read local supported codecs
2509 struct hci_rd_local_supp_codecs_cmd_cmp_evt
2510 {
2511     /// Status of the command reception
2512     uint8_t               status;
2513     uint8_t               nb_supp_codecs;
2514     uint8_t               nb_supp_vendor_specific_codecs;
2515 
2516 //    ///Supported Codecs structure
2517 //    struct supp_codecs    local_codecs;
2518 };
2519 
2520 /// HCI command complete event structure for read local simple pairing options
2521 /*@TRACE*/
2522 struct hci_rd_local_sp_opt_cmd_cmp_evt
2523 {
2524     /// Status of the command reception
2525     uint8_t status;
2526     /// Simple Pairing options (bit 0: Remote public key validation)
2527     uint8_t sp_opt;
2528     /// Maximum Encryption Key Size (in octets)
2529     uint8_t max_enc_key_size;
2530 };
2531 
2532 
2533 /*
2534  * HCI STATUS PARAMETERS COMMANDS PARAMETERS
2535  ****************************************************************************************
2536  */
2537 
2538 /// HCI command complete event structure for read rssi
2539 struct hci_rd_rssi_cmd_cmp_evt
2540 {
2541     ///Status for command reception
2542     uint8_t status;
2543     ///Connection handle
2544     uint16_t conhdl;
2545     ///RSSI value
2546     uint8_t rssi;
2547 };
2548 
2549 struct hci_rd_clk_cmd
2550 {
2551     ///Connection handle
2552     uint16_t conhdl;
2553     ///Which clock
2554     uint8_t clk_type;
2555 };
2556 
2557 /// HCI read clock command structure
2558 struct hci_rd_clk_cmd_cmp_evt
2559 {
2560     /// Status of the command reception
2561     uint8_t     status;
2562     ///Connection handle
2563     uint16_t conhdl;
2564     ///clock
2565     uint32_t clk;
2566     ///Accuracy
2567     uint16_t clk_acc;
2568 };
2569 
2570 
2571 /*
2572  * HCI TESTING COMMANDS PARAMETERS
2573  ****************************************************************************************
2574  */
2575 
2576 /// HCI command complete event structure for read loop back mode command
2577 struct hci_rd_loopback_mode_cmd_cmp_evt
2578 {
2579     /// Status of the command reception
2580     uint8_t     status;
2581     ///Local  supported features
2582     uint8_t     lb_mode;
2583 };
2584 
2585 struct hci_wr_loopback_mode_cmd
2586 {
2587     ///Local  supported features
2588     uint8_t     lb_mode;
2589 };
2590 struct hci_wr_sp_dbg_mode_cmd
2591 {
2592     ///Simple pairing mode
2593     uint8_t     sp_mode;
2594 };
2595 
2596 
2597 /// * TCI Event subcodes
2598 enum tci_evt_subcode
2599 {
2600      TCI_LMP_TX_EVENT    = 0x22,
2601      TCI_LMP_RX_EVENT    = 0x23,
2602      TCI_LC_TX_EVENT     = 0x24,
2603      TCI_LC_RX_EVENT     = 0x25,
2604      TCI_BB_TX_EVENT     = 0x26,
2605      TCI_BB_RX_EVENT     = 0x27,
2606      TCI_HW_ERROR_EVENT  = 0x28,
2607      TCI_RADIO_EVENT     = 0x30,
2608      TCI_INTERRUPT_EVENT = 0x40,
2609 };
2610 
2611 /// LMP direction
2612 #define TCI_LMP_DIR_TX	0
2613 #define TCI_LMP_DIR_RX	1
2614 
2615 /// HCI tci lmp exchange event structure
2616 struct hci_tci_lmp_evt
2617 {
2618     ///code
2619     uint8_t  tci_code;
2620     ///length
2621     uint8_t  evt_len;
2622     ///subcode
2623     uint8_t  subcode;
2624     ///evt direction
2625     uint8_t  direction;
2626     ///lmp evt body
2627     uint8_t  body[17];
2628 };
2629 
2630 /*
2631  * HCI LE CONTROLLER COMMANDS PARAMETERS
2632  ****************************************************************************************
2633  */
2634 
2635 ///HCI LE Set Event Mask Command parameters structure
2636 struct hci_le_set_evt_mask_cmd
2637 {
2638     ///LE Event Mask
2639     struct evt_mask le_mask;
2640 };
2641 
2642 ///HCI LE Set Random Address Command parameters structure
2643 struct hci_le_set_rand_addr_cmd
2644 {
2645     ///Random address to set
2646     struct bd_addr rand_addr;
2647 };
2648 
2649 ///HCI LE Set Advertising Parameters Command parameters structure
2650 struct hci_le_set_adv_param_cmd
2651 {
2652     ///Minimum interval for advertising
2653     uint16_t       adv_intv_min;
2654     ///Maximum interval for advertising
2655     uint16_t       adv_intv_max;
2656     ///Advertising type
2657     uint8_t        adv_type;
2658     ///Own address type:  public=0 / random=1 / rpa_or_pub=2 / rpa_or_rnd=3
2659     uint8_t        own_addr_type;
2660     ///Peer address type: public=0 / random=1
2661     uint8_t        peer_addr_type;
2662     ///Peer Bluetooth device address
2663     struct bd_addr peer_addr;
2664     ///Advertising channel map
2665     uint8_t        adv_chnl_map;
2666     ///Advertising filter policy
2667     uint8_t        adv_filt_policy;
2668 };
2669 
2670 ///HCI LE Set Advertising Data Command parameters structure
2671 struct hci_le_set_adv_data_cmd
2672 {
2673     ///Advertising data length
2674     uint8_t         adv_data_len;
2675     ///Advertising data - maximum 31 bytes
2676     struct adv_data data;
2677 };
2678 
2679 ///HCI LE Set Scan Response Data Command parameters structure
2680 struct hci_le_set_scan_rsp_data_cmd
2681 {
2682     ///Scan response data length
2683     uint8_t              scan_rsp_data_len;
2684     ///Scan response data - maximum 31 bytes
2685     struct scan_rsp_data data;
2686 };
2687 
2688 ///HCI LE Set Advertise Enable Command parameters structure
2689 struct hci_le_set_adv_en_cmd
2690 {
2691     ///Advertising enable - 0=disabled, 1=enabled
2692     uint8_t        adv_en;
2693 };
2694 
2695 ///HCI LE Set Scan Parameters Command parameters structure
2696 struct hci_le_set_scan_param_cmd
2697 {
2698     ///Scan type - 0=passive / 1=active
2699     uint8_t        scan_type;
2700     ///Scan interval
2701     uint16_t       scan_intv;
2702     ///Scan window size
2703     uint16_t       scan_window;
2704     ///Own address type - public=0 / random=1 / rpa_or_pub=2 / rpa_or_rnd=3
2705     uint8_t        own_addr_type;
2706     ///Scan filter policy
2707     uint8_t        scan_filt_policy;
2708 };
2709 
2710 ///HCI LE Set Scan Enable Command parameters structure
2711 struct hci_le_set_scan_en_cmd
2712 {
2713     ///Scan enable - 0=disabled, 1=enabled
2714     uint8_t        scan_en;
2715     ///Enable for duplicates filtering - 0 =disabled/ 1=enabled
2716     uint8_t        filter_duplic;
2717 };
2718 
2719 ///HCI LE Create Connection Command parameters structure
2720 struct hci_le_create_con_cmd
2721 {
2722     ///Scan interval (N * 0.625 ms)
2723     uint16_t       scan_intv;
2724     ///Scan window size (N * 0.625 ms)
2725     uint16_t       scan_window;
2726     ///Initiator filter policy
2727     uint8_t        init_filt_policy;
2728     ///Peer address type - public=0 / random=1 / rpa_or_pub=2 / rpa_or_rnd=3
2729     uint8_t        peer_addr_type;
2730     ///Peer BD address
2731     struct bd_addr peer_addr;
2732     ///Own address type - public=0 / random=1 / rpa_or_pub=2 / rpa_or_rnd=3
2733     uint8_t        own_addr_type;
2734     ///Minimum of connection interval (N * 1.25 ms)
2735     uint16_t       con_intv_min;
2736     ///Maximum of connection interval (N * 1.25 ms)
2737     uint16_t       con_intv_max;
2738     ///Connection latency
2739     uint16_t       con_latency;
2740     ///Link supervision timeout
2741     uint16_t       superv_to;
2742     ///Minimum CE length (N * 0.625 ms)
2743     uint16_t       ce_len_min;
2744     ///Maximum CE length (N * 0.625 ms)
2745     uint16_t       ce_len_max;
2746 };
2747 
2748 ///HCI LE Add Device to White List Command parameters structure
2749 struct hci_le_add_dev_to_wlst_cmd
2750 {
2751     ///Type of address of the device to be added to the White List - 0=public/1=random
2752     uint8_t        dev_addr_type;
2753     ///Address of device to be added to White List
2754     struct bd_addr dev_addr;
2755 };
2756 
2757 ///HCI LE Remove Device from White List Command parameters structure
2758 struct hci_le_rmv_dev_from_wlst_cmd
2759 {
2760     ///Type of address of the device to be removed from the White List - 0=public/1=random
2761     uint8_t        dev_addr_type;
2762     ///Address of device to be removed from White List
2763     struct bd_addr dev_addr;
2764 };
2765 
2766 ///HCI LE Set Extended Scan Paramaters Command parameters structure
2767 struct hci_le_set_ext_scan_param_cmd
2768 {
2769     ///Own address type public/random/rpa
2770     uint8_t         own_addr_type;
2771     ///Scanning filter policy
2772     uint8_t         scan_filt_policy;
2773     ///Indicates the PHY(s) on which the advertising packets should be received
2774     uint8_t         scan_phys;
2775     ///Paramaters for PHY(s)
2776     struct scan_phy_param
2777     {
2778         ///Scaning Type: passive/active
2779         uint8_t         scan_type;
2780         ///Scan interval (slots)
2781         uint16_t        scan_intv;
2782         ///Scan window size (slots)
2783         uint16_t        scan_window;
2784     } phy[MAX_SCAN_PHYS];
2785 };
2786 
2787 ///HCI LE Set Extended Scan Enable Command parameters structure
2788 struct hci_le_set_ext_scan_en_cmd
2789 {
2790     ///Scan enable - 0=disabled, 1=enabled
2791     uint8_t             scan_en;
2792     ///Filter duplicates - 0=disabled, 1=enabled, 2=enabled & reset each scan period
2793     uint8_t             filter_duplic;
2794     ///Scan duration (Time=N*10ms)  | 0x0000: Scan continuously until explicitly disable
2795     uint16_t            duration;
2796     ///Scan period (Time=N*1.28sec) | 0x0000: Periodic scanning disabled
2797     uint16_t            period;
2798 };
2799 
2800 /*@TRACE*/
2801 struct init_phy_param
2802 {
2803     ///Scan interval (N * 0.625 ms)
2804     uint16_t        scan_interval;
2805     ///Scan window size (N * 0.625 ms)
2806     uint16_t        scan_window;
2807     ///Minimum of connection interval (N * 1.25 ms)
2808     uint16_t       con_intv_min;
2809     ///Maximum of connection interval (N * 1.25 ms)
2810     uint16_t       con_intv_max;
2811     ///Connection latency
2812     uint16_t       con_latency;
2813     ///Link supervision timeout
2814     uint16_t       superv_to;
2815     ///Minimum CE length (N * 0.625 ms)
2816     uint16_t       ce_len_min;
2817     ///Maximum CE length (N * 0.625 ms)
2818     uint16_t       ce_len_max;
2819 };
2820 
2821 ///HCI LE Extended Create Connection Command parameters structure
2822 /*@TRACE*/
2823 struct hci_le_ext_create_con_cmd
2824 {
2825     ///Initiator filter policy
2826     uint8_t         init_filter_policy;
2827     ///Own address type public/random/rpa
2828     uint8_t         own_addr_type;
2829     ///Peer address type public/random/rpa
2830     uint8_t         peer_addr_type;
2831     ///Peer address
2832     struct bd_addr  peer_addr;
2833     ///Indicates the PHY(s) on which the advertising packets should be received
2834     uint8_t         init_phys;
2835     ///Paramaters for PHY(s)
2836     struct init_phy_param phy[MAX_INIT_PHYS];
2837 };
2838 
2839 ///HCI LE Periodic Advertising Create Sync Command parameters strucutre
2840 struct hci_le_per_adv_create_sync_cmd
2841 {
2842     ///Filter policy
2843     uint8_t         filter_policy;
2844     ///Advertising SID
2845     uint8_t         adv_sid;
2846     ///Advertising address type
2847     uint8_t         adv_addr_type;
2848     ///Advertiser address
2849     struct bd_addr  adv_addr;
2850     ///max Skip after receive
2851     uint16_t        skip;
2852     ///Sync timeout (Time=N*10ms)
2853     uint16_t        sync_to;
2854     ///Unused (supplemental type)
2855     uint8_t         unused;
2856 };
2857 
2858 ///HCI LE Periodic Advertising Terminate Sync Command parameters structure
2859 struct hci_le_per_adv_term_sync_cmd
2860 {
2861     ///Sync handle
2862     uint16_t        sync_handle;
2863 };
2864 
2865 ///HCI LE Add Device to Periodic Advertiser List Command parameters structure
2866 struct hci_le_add_dev_to_per_adv_list_cmd
2867 {
2868      ///Advertiser address type
2869     uint8_t         adv_addr_type;
2870     ///Advertiser address
2871     struct bd_addr  adv_addr;
2872     ///Advertising SID
2873     uint8_t         adv_sid;
2874 };
2875 
2876 ///HCI LE Remove Device from Periodic Advertiser List Command parameters structure
2877 struct hci_le_rmv_dev_from_per_adv_list_cmd
2878 {
2879      ///Advertiser address type
2880     uint8_t         adv_addr_type;
2881     ///Advertiser address
2882     struct bd_addr  adv_addr;
2883     ///Advertising SID
2884     uint8_t         adv_sid;
2885 };
2886 
2887 ///HCI LE Set Privacy Mode Command parameters structure
2888 struct hci_le_set_priv_mode_cmd
2889 {
2890     ///Peer identity address type
2891     uint8_t         peer_addr_type;
2892     ///Peer identity address
2893     struct bd_addr  peer_addr;
2894     ///Privacy mode
2895     uint8_t         priv_mode;
2896 };
2897 
2898 ///HCI LE Set Host Channel Classification Command parameters structure
2899 struct hci_le_set_host_ch_class_cmd
2900 {
2901     ///Channel map
2902     struct le_chnl_map chmap;
2903 };
2904 
2905 
2906 ///HCI LE Receiver Test Command parameters structure
2907 struct hci_le_rx_test_cmd
2908 {
2909     ///RX frequency for Rx test
2910     uint8_t        rx_freq;
2911 };
2912 
2913 ///HCI LE Transmitter Test Command parameters structure
2914 struct hci_le_tx_test_cmd
2915 {
2916     ///TX frequency for Tx test
2917     uint8_t        tx_freq;
2918     ///TX test data length
2919     uint8_t        test_data_len;
2920     ///TX test payload type - see enum
2921     uint8_t        pk_payload_type;
2922 };
2923 
2924 ///HCI LE Encrypt Command parameters structure
2925 struct hci_le_enc_cmd
2926 {
2927     ///Long term key structure
2928     struct ltk     key;
2929     ///Pointer to buffer with plain data to encrypt - 16 bytes
2930     uint8_t        plain_data[16];
2931 };
2932 
2933 /// HCI LE Connection Update Command parameters structure
2934 struct hci_le_con_update_cmd
2935 {
2936     ///Connection Handle
2937     uint16_t       conhdl;
2938     ///Minimum of connection interval (units of 1.25 ms)
2939     uint16_t       con_intv_min;
2940     ///Maximum of connection interval (units of 1.25 ms)
2941     uint16_t       con_intv_max;
2942     ///Connection latency (units of connection event)
2943     uint16_t       con_latency;
2944     ///Link supervision timeout (units of 10 ms)
2945     uint16_t       superv_to;
2946     ///Minimum of CE length (units of 0.625 ms)
2947     uint16_t       ce_len_min;
2948     ///Maximum of CE length (units of 0.625 ms)
2949     uint16_t       ce_len_max;
2950 };
2951 
2952 /// HCI LE Start Encryption Command parameters structure
2953 struct hci_le_start_enc_cmd
2954 {
2955     ///Connection handle
2956     uint16_t        conhdl;
2957     ///Random number - 8B
2958     struct rand_nb  nb;
2959     ///Encryption Diversifier
2960     uint16_t       enc_div;
2961     ///Long term key
2962     struct ltk     ltk;
2963 };
2964 
2965 /// HCI long term key request reply command parameters structure
2966 struct hci_le_ltk_req_reply_cmd
2967 {
2968     ///Connection handle
2969     uint16_t        conhdl;
2970     ///Long term key
2971     struct ltk      ltk;
2972 };
2973 
2974 /// HCI long term key request negative reply command parameters structure
2975 struct hci_le_ltk_req_neg_reply_cmd
2976 {
2977     ///Connection handle
2978     uint16_t        conhdl;
2979 };
2980 
2981 /// HCI LE remote connection parameter request reply command parameters structure
2982 struct hci_le_rem_con_param_req_reply_cmd
2983 {
2984     ///Connection handle
2985     uint16_t        conhdl;
2986     ///Interval_Min
2987     uint16_t        interval_min;
2988     ///Interval_Max
2989     uint16_t        interval_max;
2990     ///Latency
2991     uint16_t        latency;
2992     ///Timeout
2993     uint16_t        timeout;
2994     ///Minimum_CE_Length (N * 0.625 ms)
2995     uint16_t        min_ce_len;
2996     ///Maximum_CE_Length (N * 0.625 ms)
2997     uint16_t        max_ce_len;
2998 };
2999 
3000 /// HCI LE remote connection parameter request negative reply command parameters structure
3001 struct hci_le_rem_con_param_req_neg_reply_cmd
3002 {
3003     ///Connection handle
3004     uint16_t        conhdl;
3005     ///Reason
3006     uint8_t         reason;
3007 };
3008 
3009 
3010 /// HCI LE Set Data Length  Command parameters structure
3011 struct hci_le_set_data_len_cmd
3012 {
3013     ///Connection Handle
3014     uint16_t       conhdl;
3015     ///Preferred maximum number of payload octets that the local Controller should include
3016     ///in a single Link Layer Data Channel PDU.
3017     uint16_t       tx_octets;
3018     ///Preferred maximum number of microseconds that the local Controller should use to transmit
3019     ///a single Link Layer Data Channel PDU
3020     uint16_t       tx_time;
3021 };
3022 
3023 /// HCI LE Read Suggested Default Data Length Command
3024 struct hci_le_wr_suggted_dft_data_len_cmd
3025 {
3026     ///Suggested value for the Controller's maximum transmitted number of payload octets to be used
3027     uint16_t       suggted_max_tx_octets;
3028     ///Suggested value for the Controller's maximum packet transmission time to be used
3029     uint16_t       suggted_max_tx_time;
3030 };
3031 
3032 /// HCI LE Add Device to Resolving List Command
3033 struct hci_le_add_dev_to_rslv_list_cmd
3034 {
3035     /// Peer Identity Address Type
3036     uint8_t             peer_id_addr_type;
3037     /// Peer Identity Address
3038     struct bd_addr      peer_id_addr;
3039     /// Peer IRK
3040     struct irk          peer_irk;
3041     /// Local IRK
3042     struct irk          local_irk;
3043 };
3044 
3045 /// HCI LE Remove Device From Resolving List Command
3046 struct hci_le_rmv_dev_from_rslv_list_cmd
3047 {
3048     /// Peer Identity Address Type
3049     uint8_t             peer_id_addr_type;
3050     /// Peer Identity Address
3051     struct bd_addr      peer_id_addr;
3052 };
3053 
3054 /// HCI LE Read Peer Resolvable Address Command
3055 struct hci_le_rd_peer_rslv_addr_cmd
3056 {
3057     /// Peer Identity Address Type
3058     uint8_t             peer_id_addr_type;
3059     /// Peer Identity Address
3060     struct bd_addr      peer_id_addr;
3061 };
3062 
3063 /// HCI LE Read Local Resolvable Address Command
3064 struct hci_le_rd_loc_rslv_addr_cmd
3065 {
3066     /// Peer Identity Address Type
3067     uint8_t             peer_id_addr_type;
3068     /// Peer Identity Address
3069     struct bd_addr      peer_id_addr;
3070 };
3071 
3072 /// HCI LE Set Address Resolution Enable Command
3073 struct hci_le_set_addr_resol_en_cmd
3074 {
3075     /// Address Resolution Enable
3076     uint8_t             enable;
3077 };
3078 
3079 /// HCI LE Set Resolvable Private Address Timeout Command
3080 struct hci_le_set_rslv_priv_addr_to_cmd
3081 {
3082     /// RPA Timeout
3083     uint16_t            rpa_timeout;
3084 };
3085 
3086 /*
3087  * HCI EVENTS PARAMETERS
3088  ****************************************************************************************
3089  */
3090 
3091 /// HCI inquiry complete event structure
3092 struct hci_inq_cmp_evt
3093 {
3094     ///Status of the procedure
3095     uint8_t status;
3096 };
3097 
3098 
3099 /// HCI Inquiry result event structure (with only 1 result)
3100 struct hci_inq_res_evt
3101 {
3102 
3103     ///Number of response
3104     uint8_t     nb_rsp;
3105     ///BdAddr
3106     struct bd_addr bd_addr;
3107     ///Page Scan Repetition Mode
3108     uint8_t     page_scan_rep_mode;
3109     ///Reserved
3110     uint8_t     reserved1;
3111     ///Reserved
3112     uint8_t     reserved2;
3113     ///class of device
3114     struct devclass class_of_dev;
3115     ///Clock Offset
3116     uint16_t        clk_off;
3117 
3118 };
3119 
3120 /// HCI Inquiry result with rssi event structure (with only 1 result)
3121 struct hci_inq_res_with_rssi_evt
3122 {
3123     ///Number of response
3124     uint8_t     nb_rsp;
3125     ///BdAddr
3126     struct bd_addr  bd_addr;
3127     ///Page Scan Repetition Mode
3128     uint8_t     page_scan_rep_mode;
3129     ///Reserved
3130     uint8_t     reserved1;
3131     ///class of device
3132     struct devclass class_of_dev;
3133     ///Clock Offset
3134     uint16_t     clk_off;
3135     ///Rssi
3136     uint8_t      rssi;
3137 
3138 };
3139 
3140 /// HCI Extended inquiry result indication structure (with only 1 result)
3141 struct hci_ext_inq_res_evt
3142 {
3143     ///Number of response
3144     uint8_t     nb_rsp;
3145     ///BdAddr
3146     struct bd_addr  bd_addr;
3147     ///Page Scan Repetition Mode
3148     uint8_t     page_scan_rep_mode;
3149     ///Reserved
3150     uint8_t     reserved1;
3151     ///class of device
3152     struct devclass class_of_dev;
3153     ///Clock Offset
3154     uint16_t        clk_off;
3155     ///RSSi
3156     uint8_t         rssi;
3157     ///Extended inquiry response data
3158     struct eir      eir;
3159 };
3160 
3161 /// HCI disconnect complete event structure
3162 struct hci_disc_cmp_evt
3163 {
3164     ///Status of received command
3165     uint8_t     status;
3166     ///Connection Handle
3167     uint16_t    conhdl;
3168     ///Reason for disconnection
3169     uint8_t     reason;
3170 };
3171 
3172 /// HCI basic command complete event structure
3173 /*@TRACE
3174  * hci_dbg_wr_par_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3175  * hci_dbg_llcp_discard_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3176  * hci_reset_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3177  * hci_set_evt_mask_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3178  * hci_le_set_per_adv_en_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3179  * hci_le_create_con_cancel_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3180  * hci_le_set_evt_mask_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3181  * hci_le_set_host_ch_class_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3182  * hci_le_wr_suggted_dft_data_len_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3183  * hci_le_set_dft_phy_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3184  * hci_le_rmv_dev_from_wlst_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3185  * hci_le_set_adv_param_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3186  * hci_le_set_adv_data_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3187  * hci_le_set_scan_rsp_data_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3188  * hci_le_set_adv_en_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3189  * hci_le_set_scan_param_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3190  * hci_le_set_scan_en_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3191  * hci_le_set_rand_addr_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3192  * hci_le_set_addr_resol_en_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3193  * hci_le_set_rslv_priv_addr_to_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3194  * hci_le_rmv_dev_from_rslv_list_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3195  * hci_le_create_con_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3196  * hci_dbg_plf_reset_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3197  * hci_le_wr_rf_path_comp_cmd_cmp_evt = hci_basic_cmd_cmp_evt
3198  * */
3199 struct hci_basic_cmd_cmp_evt
3200 {
3201     ///Status of the command reception
3202     uint8_t status;
3203 };
3204 
3205 /// HCI basic command complete event structure with connection handle
3206 struct hci_basic_conhdl_cmd_cmp_evt
3207 {
3208     /// status
3209     uint8_t     status;
3210     /// connection handle
3211     uint16_t    conhdl;
3212 };
3213 
3214 /// HCI basic command complete event structure with BD address
3215 struct hci_basic_bd_addr_cmd_cmp_evt
3216 {
3217     ///status
3218    uint8_t         status;
3219    ///BdAddr
3220     struct bd_addr bd_addr;
3221 };
3222 
3223 /// HCI basic event structure with status and BD address
3224 struct hci_basic_stat_bd_addr_evt
3225 {
3226     ///status
3227    uint8_t         status;
3228    ///BdAddr
3229     struct bd_addr bd_addr;
3230 };
3231 
3232 /// HCI basic event including a connection handle as parameter
3233 struct hci_basic_conhdl_evt
3234 {
3235     ///Connection handle
3236     uint16_t     conhdl;
3237 };
3238 
3239 /// HCI complete event with status only.
3240 struct hci_cmd_stat_event
3241 {
3242     /// Status of the command reception
3243     uint8_t status;
3244 };
3245 
3246 /// HCI number of packet complete event structure
3247 struct hci_nb_cmp_pkts_evt
3248 {
3249     /// number of handles
3250     uint8_t     nb_of_hdl;
3251     /// connection handle
3252     uint16_t    conhdl[1];
3253     /// number of completed packets
3254     uint16_t    nb_comp_pkt[1];
3255 };
3256 
3257 /// HCI data buffer overflow event structure
3258 struct hci_data_buf_ovflw_evt
3259 {
3260     ///Link type
3261     uint8_t link_type;
3262 };
3263 
3264 /// HCI Hardware Error Event parameters structure
3265 struct hci_hw_err_evt
3266 {
3267     /// HW error code
3268     uint8_t hw_code;
3269 };
3270 
3271 /// HCI encryption change event structure
3272 struct hci_enc_change_evt
3273 {
3274     ///Status for command reception
3275     uint8_t status;
3276     ///Connection handle
3277     uint16_t conhdl;
3278     ///Encryption enabled information
3279     uint8_t     enc_stat;
3280 };
3281 
3282 /// HCI encryption key refresh complete event structure
3283 struct hci_enc_key_ref_cmp_evt
3284 {
3285     ///Status for command reception
3286     uint8_t status;
3287     ///Connection handle
3288     uint16_t conhdl;
3289 };
3290 
3291 /// HCI Authenticated Payload Timeout Expired Event structure
3292 struct hci_auth_payl_to_exp_evt
3293 {
3294     ///Connection handle
3295     uint16_t     conhdl;
3296 };
3297 
3298 /// HCI command complete event structure for create connection
3299 struct hci_con_cmp_evt
3300 {
3301     /// Status
3302     uint8_t             status;
3303     ///Connection handle
3304     uint16_t            conhdl;
3305     ///Bluetooth Device address
3306     struct bd_addr      bd_addr;
3307     ///Link type
3308     uint8_t             link_type;
3309     ///Encryption state
3310     uint8_t             enc_en;
3311 };
3312 
3313 /// HCI command complete event structure for qos setup
3314 struct hci_qos_setup_cmp_evt
3315 {
3316     ///Status for command reception
3317     uint8_t status;
3318     ///Connection handle
3319     uint16_t conhdl;
3320     ///Flags
3321     uint8_t flags;
3322     ///Service type
3323     uint8_t serv_type;
3324     ///Token rate
3325     uint32_t tok_rate;
3326     ///Peak bandwidth
3327     uint32_t pk_bw;
3328     ///Latency
3329     uint32_t lat;
3330     ///Delay variation
3331     uint32_t del_var;
3332 };
3333 
3334 /// HCI flow specification complete event parameters structure
3335 struct hci_flow_spec_cmp_evt
3336 {
3337     ///Status for command reception
3338     uint8_t status;
3339     ///Connection handle
3340     uint16_t conhdl;
3341     ///Flags
3342     uint8_t flags;
3343     ///Flow direction
3344     uint8_t flow_dir;
3345     ///Service type
3346     uint8_t serv_type;
3347     ///Token rate
3348     uint32_t tk_rate;
3349     ///Token buffer size
3350     uint32_t tk_buf_sz;
3351     ///Peak bandwidth
3352     uint32_t pk_bw;
3353     ///Access latency
3354     uint32_t acc_lat;
3355 };
3356 
3357 /// HCI role change event parameters structure
3358 struct hci_role_chg_evt
3359 {
3360     ///Status
3361     uint8_t status;
3362     ///BD address
3363     struct bd_addr bd_addr;
3364     ///New role
3365     uint8_t new_role;
3366 };
3367 
3368 /// HCI complete event structure for the read clock offset command
3369 struct hci_rd_clk_off_cmp_evt
3370 {
3371     ///Status for command reception
3372     uint8_t status;
3373     ///Connection handle
3374     uint16_t conhdl;
3375     ///Clock offset
3376     uint16_t clk_off_val;
3377 };
3378 
3379 /// HCI event structure for the flush occurred event
3380 struct hci_flush_occurred_evt
3381 {
3382     ///Connection handle
3383     uint16_t conhdl;
3384 };
3385 
3386 /// HCI max slot change event structure
3387 struct hci_max_slot_chg_evt
3388 {
3389     ///Connection handle
3390     uint16_t conhdl;
3391     ///Max slot
3392     uint8_t max_slot;
3393 };
3394 
3395 /// HCI sniff subrating event parameters structure
3396 struct hci_sniff_sub_evt
3397 {
3398     ///Status.
3399     uint8_t     status;
3400     ///Connection handle
3401     uint16_t    conhdl;
3402     ///Maximum transmit latency
3403     uint16_t    max_lat_tx;
3404     ///Maximum receive latency
3405     uint16_t    max_lat_rx;
3406     ///Minimum remote TO
3407     uint16_t    min_rem_to;
3408     ///Minimum local TO
3409     uint16_t    min_loc_to;
3410 };
3411 
3412 /// HCI read remote extended features complete event parameters structure
3413 struct hci_rd_rem_ext_feats_cmp_evt
3414 {
3415     ///Status for command reception
3416     uint8_t status;
3417     ///Connection handle
3418     uint16_t conhdl;
3419     ///page number
3420     uint8_t pg_nb;
3421     ///page number max
3422     uint8_t pg_nb_max;
3423     ///ext LMP features
3424     struct features ext_feats;
3425 };
3426 
3427 /// HCI read remote extended features complete event parameters structure
3428 struct hci_rem_host_supp_feats_notif_evt
3429 {
3430     ///BD address
3431     struct bd_addr bd_addr;
3432     ///ext lmp features
3433     struct features ext_feats;
3434 };
3435 
3436 /// HCI command complete event structure for the read remote supported features command
3437 struct hci_rd_rem_supp_feats_cmp_evt
3438 {
3439     ///Status for command reception
3440     uint8_t status;
3441     ///Connection handle
3442     uint16_t conhdl;
3443     ///Remote features
3444     struct features rem_feats;
3445 };
3446 
3447 /// HCI command complete event structure for the read remote information version command
3448 struct hci_rd_rem_ver_info_cmp_evt
3449 {
3450     ///Status for command reception
3451     uint8_t status;
3452     ///Connection handle
3453     uint16_t conhdl;
3454     ///LMP version
3455     uint8_t     vers;
3456     ///Manufacturer name
3457     uint16_t    compid;
3458     ///LMP subversion
3459     uint16_t    subvers;
3460 };
3461 
3462 /// HCI encryption change event structure
3463 struct hci_enc_chg_evt
3464 {
3465     ///Status for command reception
3466     uint8_t status;
3467     ///Connection handle
3468     uint16_t conhdl;
3469     ///Encryption enabled information
3470     uint8_t     enc_stat;
3471 };
3472 
3473 /// HCI mode change event structure
3474 struct hci_mode_chg_evt
3475 {
3476     ///Status for command reception
3477     uint8_t status;
3478     ///Connection handle
3479     uint16_t    conhdl;
3480     ///Current mode
3481     uint8_t    cur_mode;
3482     /// Interval
3483     uint16_t    interv;
3484 };
3485 
3486 /// HCI simple pairing complete event structure
3487 struct hci_sp_cmp_evt
3488 {
3489     ///Status for command reception
3490     uint8_t status;
3491     ///Bluetooth Device address
3492     struct bd_addr      bd_addr;
3493 };
3494 
3495 /// HCI Authentication complete event structure
3496 struct hci_auth_cmp_evt
3497 {
3498     ///Status for command reception
3499     uint8_t status;
3500     ///Connection handle
3501     uint16_t    conhdl;
3502 };
3503 
3504 /// HCI change connection link key complete event structure
3505 struct hci_chg_con_lk_cmp_evt
3506 {
3507     ///Status
3508     uint8_t status;
3509     ///Connection handle
3510     uint16_t    conhdl;
3511 };
3512 
3513 /// HCI encryption key refresh complete event structure
3514 struct hci_enc_key_refresh_cmp_evt
3515 {
3516     ///Status for command reception
3517     uint8_t status;
3518     ///Connection handle
3519     uint16_t    conhdl;
3520 };
3521 
3522 /// HCI master link key complete event structure
3523 struct hci_master_lk_cmp_evt
3524 {
3525     ///Status for command reception
3526     uint8_t status;
3527     ///Connection handle
3528     uint16_t    conhdl;
3529     ///Key flag
3530     uint8_t key_flag;
3531 };
3532 /// HCI synchronous link connection complete event structure
3533 struct hci_sync_con_cmp_evt
3534 {
3535     ///Status for command reception
3536     uint8_t status;
3537     ///Connection handle
3538     uint16_t    conhdl;
3539     ///BD address
3540     struct bd_addr bd_addr;
3541     ///Link type
3542     uint8_t lk_type;
3543     ///Transmit interval
3544     uint8_t tx_int;
3545     ///Retransmission window
3546     uint8_t ret_win;
3547     ///rx packet length
3548     uint16_t rx_pkt_len;
3549     ///tx packet length
3550     uint16_t tx_pkt_len;
3551     ///Air mode
3552     uint8_t air_mode;
3553 
3554 };
3555 
3556 /// HCI synchronous connection change event structure
3557 struct hci_sync_con_chg_evt
3558 {
3559     ///Status for command reception
3560     uint8_t status;
3561     ///Synchronous Connection handle
3562     uint16_t    sync_conhdl;
3563     ///Transmit interval
3564     uint8_t tx_int;
3565     ///Retransmission window
3566     uint8_t ret_win;
3567     ///rx packet length
3568     uint16_t rx_pkt_len;
3569     ///tx packet length
3570     uint16_t tx_pkt_len;
3571 };
3572 
3573 /// HCI connection packet type change event structure
3574 struct hci_con_pkt_type_chg_evt
3575 {
3576     ///Status for command reception
3577     uint8_t status;
3578     ///Synchronous Connection handle
3579     uint16_t    sync_conhdl;
3580     ///Synchronous packet type
3581     uint16_t    pkt_type;
3582 };
3583 
3584 /// HCI link supervision timeout change event structure
3585 struct hci_link_supv_to_chg_evt
3586 {
3587     ///Connection handle
3588     uint16_t    conhdl;
3589     ///Link supervision timeout
3590     uint16_t    lsto_val;
3591 };
3592 
3593 /// HCI link key request event structure
3594 struct hci_lk_req_evt
3595 {
3596     ///BD address
3597     struct bd_addr bd_addr;
3598 };
3599 
3600 /// HCI encryption key refresh event structure
3601 struct hci_enc_key_refresh_evt
3602 {
3603     ///Status for command reception
3604     uint8_t status;
3605     ///Connection handle
3606     uint16_t    conhdl;
3607 };
3608 
3609 /// HCI connection request event structure
3610 struct hci_con_req_evt
3611 {
3612     ///BD address
3613     struct bd_addr bd_addr;
3614     ///Class of device
3615     struct devclass classofdev;
3616     ///link type
3617     uint8_t lk_type;
3618 };
3619 
3620 /// HCI quality of service violation event structure
3621 struct hci_qos_viol_evt
3622 {
3623     ///Connection handle
3624     uint16_t conhdl;
3625 };
3626 
3627 /// HCI io capability response event structure
3628 struct hci_io_cap_rsp_evt
3629 {
3630     ///BdAddr
3631     struct bd_addr  bd_addr;
3632     ///IO capability
3633     uint8_t io_capa;
3634     ///OOB data present
3635     uint8_t oob_data_pres;
3636     ///Authentication requirements
3637     uint8_t auth_req;
3638 
3639 };
3640 
3641 /// HCI IO capability response event structure
3642 struct hci_io_cap_req_evt
3643 {
3644     ///BdAddr
3645     struct bd_addr  bd_addr;
3646 };
3647 
3648 /// HCI Return link keys event structure
3649 struct hci_return_link_keys_evt
3650 {
3651     ///Number of Keys
3652     uint8_t num_keys;
3653     ///BdAddr
3654     struct bd_addr  bd_addr;
3655     ///Key
3656     struct ltk      key;
3657 };
3658 
3659 /// HCI pin code request event structure
3660 struct hci_pin_code_req_evt
3661 {
3662     ///BdAddr
3663     struct bd_addr  bd_addr;
3664 };
3665 
3666 /// HCI user passkey request event structure
3667 struct hci_user_passkey_req_evt
3668 {
3669     ///BdAddr
3670     struct bd_addr  bd_addr;
3671 };
3672 
3673 /// HCI user passkey notification event structure
3674 struct hci_user_passkey_notif_evt
3675 {
3676     ///BdAddr
3677     struct bd_addr  bd_addr;
3678     ///Passkey
3679     uint32_t passkey;
3680 };
3681 
3682 /// HCI remote OOB data request event structure
3683 struct hci_rem_oob_data_req_evt
3684 {
3685     ///BdAddr
3686     struct bd_addr  bd_addr;
3687 };
3688 
3689 /// HCI user confirmation request event structure
3690 struct hci_user_cfm_req_evt
3691 {
3692     ///BdAddr
3693     struct bd_addr  bd_addr;
3694     ///Passkey
3695     uint32_t passkey;
3696 };
3697 
3698 /// HCI keypress notification event structure
3699 struct hci_keypress_notif_evt
3700 {
3701     ///BdAddr
3702     struct bd_addr  bd_addr;
3703     ///type
3704     uint8_t type;
3705 };
3706 
3707 /// HCI link key notification event structure
3708 struct hci_lk_notif_evt
3709 {
3710     ///BdAddr
3711     struct bd_addr  bd_addr;
3712     ///Key
3713     struct ltk  key;
3714     ///type
3715     uint8_t key_type;
3716 };
3717 
3718 /// HCI SAM status change event strucutre
3719 struct hci_sam_status_change_evt
3720 {
3721     ///Connection handle
3722     uint16_t    conhdl;
3723     ///Local SAM index
3724     uint8_t     loc_idx;
3725     ///Local SAM TX availability
3726     uint8_t     loc_tx_av;
3727     ///Local SAM RX availability
3728     uint8_t     loc_rx_av;
3729     ///Remote SAM index
3730     uint8_t     rem_idx;
3731     ///Remote SAM TX availability
3732     uint8_t     rem_tx_av;
3733     ///Remote SAM RX availability
3734     uint8_t     rem_rx_av;
3735 };
3736 
3737 /*
3738  * HCI LE META EVENTS PARAMETERS
3739  ****************************************************************************************
3740  */
3741 
3742 
3743 // LE event structures
3744 
3745 /// HCI command complete event structure for the Read Local Supported Features
3746 struct hci_le_rd_local_supp_feats_cmd_cmp_evt
3747 {
3748     /// Status of the command reception
3749     uint8_t             status;
3750     ///Local LE supported features
3751     struct le_features  feats;
3752 };
3753 
3754 /// HCI command complete event structure for the Read Advertising Channel Tx Power Command
3755 /*@TRACE
3756  * hci_le_rd_adv_chnl_tx_pw_cmd_cmp_evt = hci_rd_adv_chnl_tx_pw_cmd_cmp_evt*/
3757 struct hci_rd_adv_chnl_tx_pw_cmd_cmp_evt
3758 {
3759     /// Status of the command reception
3760     uint8_t     status;
3761     ///Advertising channel Tx power level
3762     int8_t     adv_tx_pw_lvl;
3763 };
3764 
3765 ///HCI command complete event structure for the Read White List Size Command
3766 struct hci_le_rd_wlst_size_cmd_cmp_evt
3767 {
3768     /// Status of the command reception
3769     uint8_t     status;
3770     ///White List size
3771     uint8_t     wlst_size;
3772 };
3773 
3774 ///HCI command complete event structure for the Read Buffer Size Command
3775 struct hci_le_rd_buff_size_cmd_cmp_evt
3776 {
3777     /// Status of the command reception
3778     uint8_t     status;
3779     ///ACL data packet length that can be sent from host to controller
3780     uint16_t    hc_data_pk_len;
3781     ///Total number of ACL data packets that can be sent from host to controller.
3782     uint8_t     hc_tot_nb_data_pkts;
3783 };
3784 
3785 ///HCI command complete event structure for LE Rand Command
3786 struct hci_le_rand_cmd_cmp_evt
3787 {
3788     /// Status of the command reception
3789     uint8_t             status;
3790     ///Random number
3791     struct rand_nb      nb;
3792 };
3793 
3794 ///HCI command complete event structure for Read Supported States Command
3795 struct hci_rd_supp_states_cmd_cmp_evt
3796 {
3797     /// Status of the command reception
3798     uint8_t             status;
3799     ///LE supported states response
3800     struct le_states    states;
3801 };
3802 
3803 ///HCI command complete event structure for Read Transmit Power Command
3804 struct hci_rd_tx_pwr_cmd_cmp_evt
3805 {
3806     /// Status of the command reception
3807     uint8_t             status;
3808     /// Minimum transmit power
3809     uint8_t             min_tx_pwr;
3810     /// Maximum transmit power
3811     uint8_t             max_tx_pwr;
3812 };
3813 
3814 ///HCI command complete event structure for Test End
3815 struct hci_test_end_cmd_cmp_evt
3816 {
3817     /// Status of the command reception
3818     uint8_t             status;
3819     ///Number of RX packets - null if TX test was the ended one
3820     uint16_t            nb_packet_received;
3821 };
3822 
3823 ///HCI LE Encrypt complete event structure
3824 struct hci_le_enc_cmd_cmp_evt
3825 {
3826     /// Status of the command reception
3827     uint8_t status;
3828     ///Encrypted data to return to command source.
3829     uint8_t encrypted_data[ENC_DATA_LEN];
3830 };
3831 
3832 #if BLE_EMB_PRESENT || BLE_HOST_PRESENT
3833 ///HCI LE advertising report event structure
3834 struct hci_le_adv_report_evt
3835 {
3836     ///LE Subevent code
3837     uint8_t             subcode;
3838     ///Number of advertising reports in this event
3839     uint8_t             nb_reports;
3840     ///Advertising reports structures array
3841     struct adv_report   adv_rep[BLE_ADV_REPORTS_MAX];
3842 };
3843 
3844 ///HCI LE extended advertising report event structure
3845 struct hci_le_ext_adv_report_evt
3846 {
3847     ///LE Subevent code
3848     uint8_t             subcode;
3849     ///Number of advertising reports in this event
3850     uint8_t             nb_reports;
3851     ///Paramaters for each report
3852     struct ext_adv_report adv_rep[BLE_ADV_REPORTS_MAX];
3853 };
3854 
3855 ///HCI LE periodic advertising sync established event structure
3856 struct hci_le_per_adv_sync_est_evt
3857 {
3858     ///LE Subevent code
3859     uint8_t             subcode;
3860     /// Status of the advertising sync
3861     uint8_t             status;
3862     /// Sync Handle to be used
3863     uint16_t            sync_handle;
3864     /// Advertising SID
3865     uint8_t             adv_sid;
3866     ///Advertising address type: public/random
3867     uint8_t             adv_addr_type;
3868     ///Advertising address value
3869     struct bd_addr      adv_addr;
3870     /// Advertiser PHY
3871     uint8_t             phy;
3872     /// Advertising interval (Time=N*1.25ms)
3873     uint16_t            interval;
3874     /// Advertiser clock accuracy
3875     uint8_t             adv_ca;
3876 };
3877 
3878 ///HCI LE periodic advertising report event structure
3879 struct hci_le_per_adv_report_evt
3880 {
3881     ///LE Subevent code
3882     uint8_t             subcode;
3883     /// Sync Handle to be used
3884     uint16_t            sync_handle;
3885     /// Tx Power
3886     uint8_t             tx_power;
3887     /// RSSI
3888     uint8_t             rssi;
3889     ///Unused
3890     uint8_t             unused;
3891     /// Data Status
3892     uint8_t             status;
3893     ///Data length in advertising packet
3894     uint8_t             data_len;
3895     ///Data of advertising packet
3896     uint8_t             data[PER_ADV_DATA_MAX_LEN];
3897 };
3898 
3899 ///HCI LE periodic advertising sync lost event structure
3900 struct hci_le_per_adv_sync_lost_evt
3901 {
3902     ///LE Subevent code
3903     uint8_t             subcode;
3904     /// Sync Handle to be used
3905     uint16_t            sync_handle;
3906 };
3907 
3908 ///HCI LE scan timeout event structure
3909 struct hci_le_scan_timeout_evt
3910 {
3911     ///LE Subevent code
3912     uint8_t             subcode;
3913 };
3914 
3915 #endif //BLE_EMB_PRESENT || BLE_HOST_PRESENT
3916 
3917 /// HCI command complete event structure for Read Channel Map Command
3918 struct hci_le_rd_chnl_map_cmd_cmp_evt
3919 {
3920     ///Status of command reception
3921     uint8_t            status;
3922     ///Connection handle
3923     uint16_t           conhdl;
3924     ///Channel map
3925     struct le_chnl_map ch_map;
3926 };
3927 
3928 /// HCI command complete event structure for Long Term Key Request Reply Command
3929 struct hci_le_ltk_req_reply_cmd_cmp_evt
3930 {
3931     ///Status of command reception
3932     uint8_t        status;
3933     ///Connection handle
3934     uint16_t       conhdl;
3935 };
3936 
3937 /// HCI command complete event structure for Long Term Key Request Negative Reply Command
3938 struct hci_le_ltk_req_neg_reply_cmd_cmp_evt
3939 {
3940     ///Status of command reception
3941     uint8_t        status;
3942     ///Connection handle
3943     uint16_t       conhdl;
3944 };
3945 
3946 /// HCI command complete event structure for LE Read Suggested Default Data Length Command
3947 struct hci_le_rd_suggted_dft_data_len_cmd_cmp_evt
3948 {
3949     ///Status of command reception
3950     uint8_t        status;
3951     ///Host's suggested value for the Controller's maximum transmitted number of payload octets
3952     uint16_t       suggted_max_tx_octets;
3953     ///Host's suggested value for the Controller's maximum packet transmission time
3954     uint16_t       suggted_max_tx_time;
3955 };
3956 /// HCI command complete event structure for LE Read Maximum Data Length Command
3957 struct hci_le_rd_max_data_len_cmd_cmp_evt
3958 {
3959     ///Status of command reception
3960     uint8_t        status;
3961     ///Maximum number of payload octets that the local Controller supports for transmission
3962     uint16_t       suppted_max_tx_octets;
3963     ///Maximum time, in microseconds, that the local Controller supports for transmission
3964     uint16_t       suppted_max_tx_time;
3965     ///Maximum number of payload octets that the local Controller supports for reception
3966     uint16_t       suppted_max_rx_octets;
3967     ///Maximum time, in microseconds, that the local Controller supports for reception
3968     uint16_t       suppted_max_rx_time;
3969 };
3970 
3971 /// HCI LE Read Peer Resolvable Address Command Complete Event
3972 struct hci_le_rd_peer_rslv_addr_cmd_cmp_evt
3973 {
3974     ///Status
3975     uint8_t status;
3976     /// Peer Resolvable Address
3977     struct bd_addr      peer_rslv_addr;
3978 };
3979 
3980 /// HCI LE Read Local Resolvable Address Command Complete Event
3981 struct hci_le_rd_loc_rslv_addr_cmd_cmp_evt
3982 {
3983     ///Status
3984     uint8_t status;
3985     /// Local Resolvable Address
3986     struct bd_addr      loc_rslv_addr;
3987 };
3988 
3989 /// HCI LE Read Resolving List Size Command Complete Event
3990 struct hci_le_rd_rslv_list_size_cmd_cmp_evt
3991 {
3992     ///Status
3993     uint8_t status;
3994     /// Resolving List Size
3995     uint8_t             size;
3996 };
3997 
3998 
3999 /// HCI write authenticated payload timeout command
4000 struct hci_wr_auth_payl_to_cmd
4001 {
4002     ///Connection handle
4003     uint16_t     conhdl;
4004     ///Authenticated payload timeout (N*10ms)
4005     uint16_t     auth_payl_to;
4006 };
4007 
4008 /// HCI command complete event structure for the Write Authenticated Payload Timeout Command
4009 struct hci_wr_auth_payl_to_cmd_cmp_evt
4010 {
4011     /// Status of the command reception
4012     uint8_t     status;
4013     ///Connection handle
4014     uint16_t     conhdl;
4015 };
4016 
4017 /// HCI command complete event structure for HCI LE Connection Update Command
4018 struct hci_le_con_update_cmp_evt
4019 {
4020     ///LE Subevent code
4021     uint8_t             subcode;
4022     ///Status of received command
4023     uint8_t             status;
4024     ///Connection handle
4025     uint16_t            conhdl;
4026     ///Connection interval value
4027     uint16_t            con_interval;
4028     ///Connection latency value
4029     uint16_t            con_latency;
4030     ///Supervision timeout
4031     uint16_t            sup_to;
4032 };
4033 
4034 /// HCI command complete event structure for create connection
4035 struct hci_le_con_cmp_evt
4036 {
4037     ///LE Subevent code
4038     uint8_t             subcode;
4039     ///Status of received command
4040     uint8_t             status;
4041     ///Connection handle
4042     uint16_t            conhdl;
4043     ///Device role - 0=Master/ 1=Slave
4044     uint8_t             role;
4045     ///Peer address type - 0=public/1=random
4046     uint8_t             peer_addr_type;
4047     ///Peer address
4048     struct bd_addr      peer_addr;
4049     ///Connection interval
4050     uint16_t            con_interval;
4051     ///Connection latency
4052     uint16_t            con_latency;
4053     ///Link supervision timeout
4054     uint16_t            sup_to;
4055     ///Master clock accuracy
4056     uint8_t             clk_accuracy;
4057 };
4058 
4059 /// HCI LE read remote used feature command parameters structure
4060 struct hci_le_rd_rem_feats_cmd
4061 {
4062     ///Connection handle
4063     uint16_t            conhdl;
4064 };
4065 
4066 /// HCI command complete event structure for HCI LE read remote feature Command
4067 struct hci_le_rd_rem_feats_cmd_cmp_evt
4068 {
4069     ///LE Subevent code
4070     uint8_t             subcode;
4071     ///Status of received command
4072     uint8_t             status;
4073     ///Connection handle
4074     uint16_t            conhdl;
4075     ///Le Features
4076     struct le_features  le_feats;
4077 };
4078 
4079 /// HCI command structure for the read transmit power level command
4080 struct hci_rd_tx_pwr_lvl_cmd
4081 {
4082     ///Connection handle
4083     uint16_t    conhdl;
4084     ///Power Level type: current or maximum
4085     uint8_t     type;
4086 };
4087 
4088 /// HCI command complete event structure for the read transmit power level command
4089 struct hci_rd_tx_pwr_lvl_cmd_cmp_evt
4090 {
4091     ///Status for command reception
4092     uint8_t status;
4093     ///Connection handle
4094     uint16_t conhdl;
4095     ///Value of TX power level
4096     uint8_t     tx_pow_lvl;
4097 };
4098 
4099 /// HCI read remote information version command parameters structure
4100 struct hci_rd_rem_ver_info_cmd
4101 {
4102     ///Connection handle
4103     uint16_t    conhdl;
4104 };
4105 
4106 /// HCI LE remote connection parameter request event
4107 struct hci_le_rem_con_param_req_evt
4108 {
4109     ///LE Subevent code
4110     uint8_t             subcode;
4111     ///Connection handle
4112     uint16_t            conhdl;
4113     ///Interval_Min
4114     uint16_t            interval_min;
4115     ///Interval_Max
4116     uint16_t            interval_max;
4117     ///Latency
4118     uint16_t            latency;
4119     ///Timeout
4120     uint16_t            timeout;
4121 };
4122 
4123 
4124 /// HCI command complete event structure for enhance create connection
4125 struct hci_le_enh_con_cmp_evt
4126 {
4127     ///LE Subevent code
4128     uint8_t             subcode;
4129     ///Status of received command
4130     uint8_t             status;
4131     ///Connection handle
4132     uint16_t            conhdl;
4133     ///Device role - 0=Master/ 1=Slave
4134     uint8_t             role;
4135     ///Peer address type - 0=public/1=random
4136     uint8_t             peer_addr_type;
4137     ///Peer address
4138     struct bd_addr      peer_addr;
4139     ///Local Resolvable Private Address
4140     struct bd_addr      loc_rslv_priv_addr;
4141     ///Peer Resolvable Private Address
4142     struct bd_addr      peer_rslv_priv_addr;
4143     ///Connection interval
4144     uint16_t            con_interval;
4145     ///Connection latency
4146     uint16_t            con_latency;
4147     ///Link supervision timeout
4148     uint16_t            sup_to;
4149     ///Master clock accuracy
4150     uint8_t             clk_accuracy;
4151 };
4152 
4153 
4154 struct hci_generate_dhkey_cmp_evt
4155 {
4156     ///LE Subevent code
4157     uint8_t             subcode;
4158     ///Status of received command
4159     uint8_t             status;
4160     /// The 32 byte Diffie Helman Key
4161     uint8_t             dh_key[32];
4162 };
4163 
4164 
4165 struct hci_rd_local_p256_public_key_cmp_evt
4166 {
4167     ///LE Subevent code
4168     uint8_t             subcode;
4169     ///Status of received command
4170     uint8_t             status;
4171     /// The 32 byte Diffie Helman Key
4172     uint8_t             public_key[64];
4173 
4174 };
4175 
4176 #if BLE_EMB_PRESENT || BLE_HOST_PRESENT
4177 /// HCI LE Direct Advertising Report Event
4178 struct hci_le_dir_adv_rep_evt
4179 {
4180     ///LE Subevent code
4181     uint8_t                 subcode;
4182     ///Number of reports
4183     uint8_t                 nb_reports;
4184     ///Direct Advertising reports structures array
4185     struct dir_adv_report   adv_rep[BLE_ADV_REPORTS_MAX];
4186 };
4187 #endif //BLE_EMB_PRESENT || BLE_HOST_PRESENT
4188 
4189 /// Connected LE event
4190 struct hci_le_con_evt
4191 {
4192     ///LE Subevent code
4193     uint8_t             subcode;
4194     ///Connection handle
4195     uint16_t            conhdl;
4196 };
4197 
4198 /// HCI command complete event structure for HCI LE read remote used feature Command
4199 struct hci_le_ltk_request_evt
4200 {
4201     ///LE Subevent code
4202     uint8_t             subcode;
4203     ///Connection handle
4204     uint16_t            conhdl;
4205     ///Random number
4206     struct rand_nb      rand;
4207     ///Encryption diversifier
4208     uint16_t            ediv;
4209 };
4210 
4211 /// HCI LE META event LE Data Length Change Event
4212 struct hci_le_data_len_chg_evt
4213 {
4214     ///LE Subevent code
4215     uint8_t             subcode;
4216     ///Connection handle
4217     uint16_t            conhdl;
4218     ///The maximum number of payload octets in TX
4219     uint16_t            max_tx_octets;
4220     ///The maximum time that the local Controller will take to TX
4221     uint16_t            max_tx_time;
4222     ///The maximum number of payload octets in RX
4223     uint16_t            max_rx_octets;
4224     ///The maximum time that the local Controller will take to RX
4225     uint16_t            max_rx_time;
4226 };
4227 
4228 
4229 /// HCI Synchronization Train Received Event
4230 struct hci_sync_train_rec_evt
4231 {
4232     /// Status
4233     uint8_t            status;
4234     /// BD_ADDR
4235     struct bd_addr     bd_addr;
4236     /// Clock_Offset (28 bits) - (CLKNslave - CLK) modulo 2^28
4237     uint32_t           clock_offset;
4238     /// AFH_Channel_Map
4239     struct chnl_map    afh_ch_map;
4240     /// LT_ADDR
4241     uint8_t            lt_addr;
4242     /// Next_Broadcast_Instant (28 bits)
4243     uint32_t next_bcst_instant;
4244     /// Connectionless_Slave_Broadcast_Interval (in slots)
4245     uint16_t csb_int;
4246     /// Service_Data
4247     uint8_t service_data;
4248 };
4249 
4250 /// HCI Connectionless Slave Broadcast Receive Event
4251 struct hci_con_slv_bcst_rec_evt
4252 {
4253     /// BD_ADDR
4254     struct bd_addr     bd_addr;
4255     /// LT_ADDR
4256     uint8_t            lt_addr;
4257     /// CLK (28 bits)
4258     uint32_t           clk;
4259     /// Offset (28 bits) - (CLKNslave - CLK) modulo 2^28
4260     uint32_t           offset;
4261     /// Receive Status
4262     uint8_t            receive_status;
4263     /// Fragment
4264     uint8_t fragment;
4265     /// Data_Length (in bytes)
4266     uint8_t data_length;
4267     /// Data
4268     uint8_t data[__ARRAY_EMPTY];
4269 };
4270 
4271 /// HCI Connectionless Slave Broadcast Timeout Event
4272 struct hci_con_slv_bcst_to_evt
4273 {
4274     /// BD_ADDR
4275     struct bd_addr     bd_addr;
4276     /// LT_ADDR
4277     uint8_t            lt_addr;
4278 };
4279 
4280 /// HCI Connectionless Slave Broadcast Channel Map Change Event
4281 struct hci_con_slv_bcst_ch_map_chg_evt
4282 {
4283     /// Channel_Map
4284     struct chnl_map    ch_map;
4285 };
4286 
4287 
4288 struct hci_le_generate_dhkey_cmp_evt
4289 {
4290     ///LE Subevent code
4291     uint8_t      subcode;
4292     uint8_t      status;
4293     uint8_t      dh_key[32];
4294 };
4295 
4296 struct hci_le_generate_p256_public_key_cmp_evt
4297 {
4298     ///LE Subevent code
4299     uint8_t       subcode;
4300     uint8_t       status;
4301     t_public_key  public_key;
4302 };
4303 
4304 /*
4305  * HCI VENDOR SPECIFIC COMMANDS PARAMETERS
4306  ****************************************************************************************
4307  */
4308 
4309 /// Buffer structure
4310 struct buffer_tag
4311 {
4312     /// length of buffer
4313     uint8_t length;
4314     /// data of 128 bytes length
4315     uint8_t data[128];
4316 };
4317 
4318 /// Common structure for Command Complete Event of HCI Debug Read Memory/Flash/Param complete event parameters - vendor specific
4319 /*@TRACE
4320  * hci_dbg_rd_mem_cmd_cmp_evt = hci_dbg_basic_rd_data_cmd_cmp_evt
4321  * hci_dbg_rd_flash_cmd_cmp_evt = hci_dbg_basic_rd_data_cmd_cmp_evt
4322  * hci_dbg_rd_par_cmd_cmp_evt = hci_dbg_basic_rd_data_cmd_cmp_evt
4323  * */
4324 struct hci_dbg_basic_rd_data_cmd_cmp_evt
4325 {
4326     ///Status
4327     uint8_t status;
4328     ///buffer structure to return
4329     struct buffer_tag buf;
4330 };
4331 
4332 ///HCI Debug read memory variable command parameters - vendor specific
4333 struct hci_dbg_rd_mem_cmd
4334 {
4335     ///Start address to read
4336     uint32_t start_addr;
4337     ///Access size
4338     uint8_t type;
4339     ///Length to read
4340     uint8_t length;
4341 };
4342 
4343 ///HCI Debug write memory variable command parameters - vendor specific
4344 struct hci_dbg_wr_mem_cmd
4345 {
4346     ///Start address to read
4347     uint32_t start_addr;
4348     ///Access size
4349     uint8_t type;
4350     ///buffer structure to return
4351     struct buffer_tag buf;
4352 };
4353 
4354 ///HCI Debug delete parameter command parameters - vendor specific
4355 struct hci_dbg_del_param_cmd
4356 {
4357     ///Parameter tag
4358     uint16_t param_tag;
4359 };
4360 
4361 ///HCI Debug erase flash command parameters - vendor specific
4362 struct hci_dbg_er_flash_cmd
4363 {
4364     ///Flash type
4365     uint8_t flashtype;
4366     ///Start offset address
4367     uint32_t startoffset;
4368     ///Size to erase
4369     uint32_t size;
4370 };
4371 
4372 ///HCI Debug write flash command parameters - vendor specific
4373 struct hci_dbg_wr_flash_cmd
4374 {
4375     ///Flash type
4376     uint8_t flashtype;
4377     ///Start offset address
4378     uint32_t startoffset;
4379     ///buffer structure
4380     struct buffer_tag buf;
4381 };
4382 
4383 ///HCI Debug read flash command parameters - vendor specific
4384 struct hci_dbg_rd_flash_cmd
4385 {
4386     ///Flash type
4387     uint8_t flashtype;
4388     ///Start offset address
4389     uint32_t startoffset;
4390     ///Size to read
4391     uint8_t size;
4392 };
4393 
4394 ///HCI Debug read parameter command parameters - vendor specific
4395 struct hci_dbg_rd_par_cmd
4396 {
4397     ///Parameter tag
4398     uint16_t param_tag;
4399 };
4400 
4401 ///HCI Debug read parameters command parameters - vendor specific
4402 struct hci_dbg_wr_par_cmd
4403 {
4404     ///Parameter tag
4405     uint16_t param_tag;
4406     ///Structure buffer
4407     struct buffer_tag buf;
4408 };
4409 
4410 #if CRYPTO_UT
4411 struct hci_dbg_test_crypto_func_cmd
4412 {
4413     /// Id of Function to be tested
4414     uint8_t function;
4415     /// Structure buffer
4416     struct buffer_tag buf;
4417 };
4418 #endif //CRYPTO_UT
4419 
4420 #if RW_DEBUG
4421 ///HCI Debug Test scheduling planner set function command parameters - vendor specific
4422 /*@TRACE*/
4423 struct hci_dbg_test_sch_plan_set_cmd
4424 {
4425     /// Activity identifier
4426     uint32_t id;
4427     /// Interval (in slots)
4428     uint32_t interval;
4429     /// Offset (in slots)
4430     uint32_t offset;
4431     /// Minimum duration (in slots)
4432     uint32_t duration_min;
4433     /// Maximum duration (in slots)
4434     uint32_t duration_max;
4435     /// Indicate activity is movable
4436     bool mobility_level;
4437 };
4438 
4439 ///HCI Debug Test scheduling planner set function command complete event parameters - vendor specific
4440 /*@TRACE*/
4441 struct hci_dbg_test_sch_plan_set_cmd_cmp_evt
4442 {
4443     /// Status
4444     uint8_t status;
4445     /// Activity identifier
4446     uint32_t moved_id;
4447 };
4448 
4449 ///HCI Debug Test scheduling planner remove function command parameters - vendor specific
4450 /*@TRACE*/
4451 struct hci_dbg_test_sch_plan_rem_cmd
4452 {
4453     /// Activity identifier
4454     uint32_t id;
4455 };
4456 
4457 ///HCI Debug Test scheduling planner check function command parameters - vendor specific
4458 /*@TRACE*/
4459 struct hci_dbg_test_sch_plan_chk_cmd
4460 {
4461     /// Activity identifier
4462     uint32_t id;
4463     /// Interval (in slots)
4464     uint32_t interval;
4465     /// Offset (in slots)
4466     uint32_t offset;
4467     /// Minimum duration (in slots)
4468     uint32_t duration_min;
4469 };
4470 
4471 ///HCI Debug Test scheduling planner request function command parameters - vendor specific
4472 /*@TRACE*/
4473 struct hci_dbg_test_sch_plan_req_cmd
4474 {
4475     /// Activity identifier
4476     uint32_t id;
4477     /// Minimum interval (in slots)
4478     uint32_t interval_min;
4479     /// Maximum interval (in slots)
4480     uint32_t interval_max;
4481     /// Minimum duration (in slots)
4482     uint32_t duration_min;
4483     /// Maximum duration (in slots)
4484     uint32_t duration_max;
4485     /// Period (in slots)
4486     uint8_t period;
4487 };
4488 
4489 ///HCI Debug Test scheduling planner request function command complete event parameters - vendor specific
4490 /*@TRACE*/
4491 struct hci_dbg_test_sch_plan_req_cmd_cmp_evt
4492 {
4493     /// Status
4494     uint8_t status;
4495     /// Interval (in slots)
4496     uint32_t interval;
4497     /// Minimum offset (in slots)
4498     uint32_t offset_min;
4499     /// Maximum offset (in slots)
4500     uint32_t offset_max;
4501 };
4502 #endif //RW_DEBUG
4503 
4504 ///HCI Debug Read Kernel Statistics complete event parameters - vendor specific
4505 struct hci_dbg_rd_ke_stats_cmd_cmp_evt
4506 {
4507     ///Status
4508     uint8_t status;
4509     ///Max message sent
4510     uint8_t max_msg_sent;
4511     ///Max message saved
4512     uint8_t max_msg_saved;
4513     ///Max timer used
4514     uint8_t max_timer_used;
4515     ///Max heap used
4516     uint16_t max_heap_used;
4517     ///Max stack used
4518     uint16_t max_stack_used;
4519 };
4520 
4521 
4522 /// HCI Debug Read information about memory usage. - vendor specific
4523 struct hci_dbg_rd_mem_info_cmd_cmp_evt
4524 {
4525     ///Status
4526     uint8_t status;
4527     /// memory size currently used into each heaps.
4528     uint16_t mem_used[KE_MEM_BLOCK_MAX];
4529     /// peak of memory usage measured
4530     uint32_t max_mem_used;
4531 };
4532 
4533 ///HCI Debug identify Flash command complete event parameters - vendor specific
4534 struct hci_dbg_id_flash_cmd_cmp_evt
4535 {
4536     ///Status
4537     uint8_t status;
4538     ///Flash identity
4539     uint8_t flash_id;
4540 };
4541 
4542 ///HCI Debug RF Register read command
4543 struct hci_dbg_rf_reg_rd_cmd
4544 {
4545     /// register address
4546     uint16_t addr;
4547 };
4548 
4549 ///HCI Debug RF Register read command complete event
4550 struct hci_dbg_rf_reg_rd_cmd_cmp_evt
4551 {
4552     /// status
4553     uint8_t status;
4554     /// register address
4555     uint16_t addr;
4556     /// register value
4557     uint32_t value;
4558 };
4559 
4560 ///HCI Debug RF Register write command
4561 struct hci_dbg_rf_reg_wr_cmd
4562 {
4563     /// register address
4564     uint16_t addr;
4565     /// register value
4566     uint32_t value;
4567 };
4568 
4569 ///HCI Debug RF Register write command complete event
4570 struct hci_dbg_rf_reg_wr_cmd_cmp_evt
4571 {
4572     /// status
4573     uint8_t status;
4574     /// address
4575     uint16_t addr;
4576 };
4577 
4578 ///HCI Debug platform reset command parameters - vendor specific
4579 struct hci_dbg_plf_reset_cmd
4580 {
4581     /// reason
4582     uint8_t reason;
4583 };
4584 
4585 #if (RW_DEBUG && BT_EMB_PRESENT)
4586 /// Discard LMP Packets
4587 struct hci_dbg_bt_send_lmp_cmd
4588 {
4589     /// Connection handle
4590     uint16_t conhdl;
4591     ///buffer structure to return
4592     struct buffer_tag buf;
4593 };
4594 
4595 /// Discard LMP Packets
4596 struct hci_dbg_bt_discard_lmp_en_cmd
4597 {
4598     /// Connection handle
4599     uint16_t conhdl;
4600     /// Enable/Disable LMP discard (0: disable / 1: enable)
4601     uint8_t enable;
4602 };
4603 
4604 /// Set local clock
4605 /*@TRACE*/
4606 struct hci_dbg_set_local_clock_cmd
4607 {
4608     /// Clock (in half-slots)
4609     uint32_t clock;
4610 };
4611 #endif //(RW_DEBUG && BT_EMB_PRESENT)
4612 
4613 #if (RW_WLAN_COEX)
4614 ///HCI Debug wlan coexistence command parameters - vendor specific
4615 struct hci_dbg_wlan_coex_cmd
4616 {
4617     /// State
4618     uint8_t state;
4619 };
4620 #if (RW_WLAN_COEX_TEST)
4621 ///HCI Debug wlan coexistence test scenario command parameters - vendor specific
4622 struct hci_dbg_wlan_coextst_scen_cmd
4623 {
4624     /// Scenario
4625     uint32_t scenario;
4626 };
4627 #endif //RW_WLAN_COEX_TEST
4628 #endif //RW_WLAN_COEX
4629 
4630 #if (RW_MWS_COEX)
4631 ///HCI Debug mws coexistence command parameters - vendor specific
4632 struct hci_dbg_mws_coex_cmd
4633 {
4634     /// State
4635     uint8_t state;
4636 };
4637 #if (RW_MWS_COEX_TEST)
4638 ///HCI Debug mws coexistence test scenario command parameters - vendor specific
4639 struct hci_dbg_mws_coextst_scen_cmd
4640 {
4641     /// Scenario
4642     uint32_t scenario;
4643 };
4644 #endif //RW_MWS_COEX_TEST
4645 #endif //RW_MWS_COEX
4646 
4647 #if (BLE_ISO_MODE_0)
4648 /// HCI VS Setup Audio Mode 0 channel command parameters
4649 /*@TRACE*/
4650 struct hci_vs_setup_am0_chan_cmd
4651 {
4652     /// Handle that identify an ACL link between a Master and a Slave device that is requesting
4653     /// an Audio Mode 0 Channel (range 0x0000-0x0EFF)
4654     uint16_t    conhdl;
4655 
4656     // *** Data path settings ***
4657     /// Host to Controller nominal data rate in octets per second
4658     uint32_t    tx_bandwidth;
4659     /// Controller to Host nominal data rate in octets per second
4660     uint32_t    rx_bandwidth;
4661     /// Host to Controller Data path type
4662     /// 0x00       Disabled
4663     /// 0x01       HCI
4664     /// 0x02-0xFE  Logical_Channel_Number. The meaning of the logical channels will be vendor specific.
4665     /// 0xFF       Test Mode
4666     uint8_t     tx_data_path;
4667     /// Controller to Host Data path type
4668     /// 0x00       Disabled
4669     /// 0x01       HCI
4670     /// 0x02-0xFE  Logical_Channel_Number. The meaning of the logical channels will be vendor specific.
4671     /// 0xFF       Test Mode
4672     uint8_t     rx_data_path;
4673     /// The number of bits in each unit of data received from the Host over the data transport. (Range 0x01 - 0xFB)
4674     uint8_t     tx_size;
4675     /// The number of bits in each unit of data sent to the Host over the data transport. (Range 0x01 - 0xFB)
4676     uint8_t     rx_size;
4677 };
4678 
4679 /// Used to read the maximum size of the data portion of isochronous packets
4680 /// no parameter on command, only need to specify returned parameters
4681 struct hci_vs_setup_am0_chan_cmd_cmp_evt
4682 {
4683     /// 0x00 - Request succeed ; 0x01-0xFF Failed reason
4684     uint8_t  status;
4685     /// Handle that identify an ACL link between a Master and a Slave device that is requesting
4686     /// an Audio Mode 0 Channel (range 0x0000-0x0EFF)
4687     uint16_t conhdl;
4688     /// Channel_Handle to be used to identify an Audio Mode 0 Channel (range 0x0000-0x0EFF)
4689     uint16_t am0_hdl;
4690 };
4691 
4692 
4693 /// Removes existing Audio Mode 0 channel command parameters
4694 /*@TRACE*/
4695 struct hci_vs_remove_am0_chan_cmd
4696 {
4697     /// Channel_Handles used to identify Audio Mode 0 Channel (range 0x0000-0x0EFF)
4698     uint16_t am0_hdl;
4699 };
4700 
4701 
4702 /// Used to Control the channel that will b.e part of an Audio Mode 0 Connection
4703 /*@TRACE*/
4704 struct hci_vs_control_am0_chan_cmd
4705 {
4706     /// Channel_Handles used to identify Audio Mode 0 Channel (range 0x0000-0x0EFF)
4707     uint16_t am0_hdl;
4708     /// Control if the stream should be Enabled (0x01) or Disabled (0x00)
4709     uint8_t  enable;
4710     /// Control if slave audio source is enabled or not
4711     uint8_t  slv_src_enable;
4712 };
4713 
4714 /// HCI basic command complete event structure with AM0 Channel handle
4715 /*@TRACE*/
4716 struct hci_vs_basic_am0_cmd_cmp_evt
4717 {
4718     /// status
4719     uint8_t     status;
4720     /// Channel_Handles used to identify Audio Mode 0 Channel (range 0x0000-0x0EFF)
4721     uint16_t    am0_hdl;
4722 };
4723 #endif // (BLE_ISO_MODE_0)
4724 
4725 
4726 ///HCI Debug HW Register Read command parameters - vendor specific
4727 /*@TRACE*/
4728 struct hci_dbg_ble_reg_rd_cmd
4729 {
4730     /// register address
4731     uint16_t reg_addr;
4732 };
4733 
4734 ///HCI Debug HW Register write command parameters - vendor specific
4735 /*@TRACE*/
4736 struct hci_dbg_ble_reg_wr_cmd
4737 {
4738     /// register address
4739     uint16_t reg_addr;
4740     /// extra parameter
4741     uint16_t reserved;
4742     /// register value
4743     uint32_t reg_value;
4744 };
4745 
4746 ///HCI Debug HW Register Read Complete event parameters - vendor specific
4747 /*@TRACE*/
4748 struct hci_dbg_ble_reg_rd_cmd_cmp_evt
4749 {
4750     /// status
4751     uint8_t  status;
4752     /// register address
4753     uint16_t reg_addr;
4754     /// register value
4755     uint32_t reg_value;
4756 };
4757 
4758 ///HCI Debug HW Register Write Complete event parameters - vendor specific
4759 /*@TRACE*/
4760 struct hci_dbg_ble_reg_wr_cmd_cmp_evt
4761 {
4762     /// status
4763     uint8_t  status;
4764     /// register address
4765     uint16_t reg_addr;
4766 };
4767 
4768 ///HCI Debug write DLE default value command parameters - vendor specific
4769 struct hci_dbg_wr_dle_dft_value_cmd
4770 {
4771     /// Max transmit packet size supported
4772     uint16_t suppted_max_tx_octets;
4773     /// Max transmit packet time supported
4774     uint16_t suppted_max_tx_time;
4775     /// Max receive packet size supported
4776     uint16_t suppted_max_rx_octets;
4777     /// Max receive packet time supported
4778     uint16_t suppted_max_rx_time;
4779 
4780 };
4781 
4782 #if (BLE_EMB_PRESENT || BLE_HOST_PRESENT)
4783 ///HCI Debug bd address write command parameters - vendor specific
4784 struct hci_dbg_set_bd_addr_cmd
4785 {
4786     ///bd address to set
4787     struct bd_addr addr;
4788 };
4789 
4790 ///HCI Debug crc write command parameters - vendor specific
4791 struct hci_dbg_set_crc_cmd
4792 {
4793     /// Handle pointing to the connection for which CRC has to be modified
4794     uint16_t conhdl;
4795     /// CRC to set
4796     struct crc_init crc;
4797 };
4798 
4799 ///HCI Debug LLC discard command parameters - vendor specific
4800 struct hci_dbg_llcp_discard_cmd
4801 {
4802     /// Handle pointing to the connection for which LLCP commands have to be discarded
4803     uint16_t conhdl;
4804     /// Flag indicating if the discarding has to be enabled or disabled
4805     uint8_t enable;
4806 };
4807 
4808 ///HCI Debug reset RX counter command parameters - vendor specific
4809 struct hci_dbg_reset_rx_cnt_cmd
4810 {
4811     /// Handle pointing to the connection for which the counter have to be reseted
4812     uint16_t conhdl;
4813 };
4814 
4815 ///HCI Debug reset TX counter command parameters - vendor specific
4816 struct hci_dbg_reset_tx_cnt_cmd
4817 {
4818     /// Handle pointing to the connection for which the counter have to be reseted
4819     uint16_t conhdl;
4820 };
4821 
4822 ///HCI Debug Set TX Power Level Command parameters
4823 struct hci_dbg_set_tx_pw_cmd
4824 {
4825     /// Connection handle
4826     uint16_t conhdl;
4827     /// Power level
4828     uint8_t  pw_lvl;
4829 };
4830 
4831 ///HCI Debug configure audio command parameters - vendor specific
4832 
4833 struct hci_dbg_audio_configure_audio_cmd
4834 {
4835     /// Voice channel to be updated
4836     uint8_t     voice_channel;
4837     /// Configure transmitter size in bytes
4838     uint8_t     tx_size;
4839     /// Configure receiver size in bytes
4840     uint8_t     rx_size;
4841     /// Configure transmitter rate
4842     uint8_t     tx_rate;
4843     /// Configure receiver rate
4844     uint8_t     rx_rate;
4845     /// Configure number of retransmission
4846     uint8_t     nb_retx;
4847     /// Audio link priority
4848     uint8_t     priority;
4849     /// Encryption mode
4850     uint8_t     mode;
4851     /// Channel and mute configuration (@see enum audio_cfg)
4852     uint8_t     chan_mute_cfg;
4853     /// Mute Pattern
4854     uint8_t     mute_pattern;
4855 };
4856 
4857 struct hci_dbg_audio_set_pointer_cmd
4858 {
4859     /// Voice channel to be updated
4860     uint8_t voice_channel;
4861     /// Rx or Tx selection
4862     uint8_t rx_tx_select;
4863     /// Tog to be updated
4864     uint8_t tog;
4865     /// Exchange memory pointer
4866     uint16_t    em_ptr;
4867 };
4868 ///HCI Debug set audio mode command parameters - vendor specific
4869 struct hci_audio_set_mode_cmd
4870 {
4871     /// Voice channel to be updated
4872     uint8_t voice_channel;
4873     /// Mode
4874     uint8_t   mode;
4875 };
4876 
4877 ///HCI Debug set audio mode command parameters - vendor specific
4878 struct hci_dbg_audio_reset_cmd
4879 {
4880     /// Voice channel to be updated
4881     uint8_t voice_channel;
4882 };
4883 
4884 ///HCI Debug set audio mode command parameters - vendor specific
4885 struct hci_dbg_audio_allocate_cmd
4886 {
4887     /// Connection handle
4888     uint16_t conhdl;
4889     /// Audio mode
4890     uint8_t mode;
4891 };
4892 
4893 ///HCI Debug set audio mode command parameters - vendor specific
4894 struct hci_dbg_audio_get_vx_ch_cmd
4895 {
4896     /// Connection handle
4897     uint16_t conhdl;
4898 };
4899 ///HCI Tester set LE parameters
4900 struct hci_tester_set_le_params_cmd
4901 {
4902     /// Connection handle
4903     uint16_t conhdl;
4904     /// Tester features
4905     uint8_t  tester_feats;
4906     /// Preferred periodicity
4907     uint8_t  pref_period;
4908     /// Offset0
4909     uint16_t  offset0;
4910     /// Offset1
4911     uint16_t  offset1;
4912     /// Offset2
4913     uint16_t  offset2;
4914     /// Offset3
4915     uint16_t  offset3;
4916     /// Offset4
4917     uint16_t  offset4;
4918     /// Offset5
4919     uint16_t  offset5;
4920 };
4921 
4922 /// HCI BLE Tester: enable LLCP pass through mechanism
4923 struct hci_dbg_ble_tst_llcp_pt_en_cmd
4924 {
4925     /// Connection handle
4926     uint16_t conhdl;
4927     /// Enable or not LLCP pass through mechanism
4928     uint8_t  enable;
4929 };
4930 
4931 /// HCI BLE Tester: send an LLCP PDU
4932 struct hci_dbg_ble_tst_send_llcp_cmd
4933 {
4934     /// Connection handle
4935     uint16_t conhdl;
4936     /// length of LLCP PDU
4937     uint8_t  length;
4938     /// LLCP PDU data
4939     uint8_t data[26];
4940 };
4941 
4942 
4943 /// HCI DBG Meta Event trigg when LLCP message received with LLCP pass through mechanism
4944 struct hci_dbg_ble_tst_llcp_recv_evt
4945 {
4946     ///DBG Subevent code
4947     uint8_t             subcode;
4948     ///Connection handle
4949     uint16_t            conhdl;
4950     /// length of LLCP message
4951     uint8_t             length;
4952     /// LLCP data
4953     uint8_t             data[26];
4954 };
4955 
4956 #endif //BLE_EMB_PRESENT || BLE_HOST_PRESENT
4957 
4958 #if (RW_DEBUG)
4959 /// HCI DBG Meta Event indicating a SW assertion error
4960 struct hci_dbg_assert_err_evt
4961 {
4962     ///DBG Subevent code
4963     uint8_t             subcode;
4964     /// Line number
4965     uint32_t line;
4966     /// Param0
4967     uint32_t param0;
4968     /// Param1
4969     uint32_t param1;
4970     /// File name
4971     uint8_t file[__ARRAY_EMPTY];
4972 };
4973 #endif //(RW_DEBUG)
4974 
4975 #if(BLE_ISOGEN)
4976 /// Event is used to provide statistics about ISO Gen
4977 /*@TRACE*/
4978 struct hci_vs_isogen_stat_evt
4979 {
4980     /// VS Subevent code
4981     uint8_t  subcode;
4982 
4983     /// ISO Handle of the isochronous channel (Range 0x0000-0x0EFF)
4984     uint16_t iso_hdl;
4985 
4986     /// Statistics - Number of transmission attempts
4987     uint32_t nb_tx;
4988     /// Statistics - Number of transmission attempts that succeed
4989     uint32_t nb_tx_ok;
4990     /// Statistics - Number of Not granted packet packets
4991     uint32_t nb_tx_not_granted;
4992 
4993     /// Statistics - Number of reception attempt
4994     uint32_t nb_rx;
4995     /// Statistics - Number of reception attempts that succeed
4996     uint32_t nb_rx_ok;
4997     /// Statistics - Number of Not granted packet packets
4998     uint32_t nb_rx_not_granted;
4999     /// Statistics - Number of wrongly received packet (invalid data)
5000     uint32_t nb_rx_data_err;
5001     /// Statistics - Number of CRC Errors
5002     uint32_t nb_rx_crc_err;
5003     /// Statistics - Number of SYNC Errors
5004     uint32_t nb_rx_sync_err;
5005     /// Statistics - Number of received empty packets
5006     uint32_t nb_rx_empty;
5007 };
5008 #endif // (BLE_ISOGEN)
5009 
5010 
5011 /// HCI LE Read PHY command
5012 struct hci_le_rd_phy_cmd
5013 {
5014     /// Connection Handle
5015     uint16_t            conhdl;
5016 };
5017 
5018 /// HCI LE Set Default PHY Command
5019 struct hci_le_set_dft_phy_cmd
5020 {
5021     /// Preferred PHYS selection
5022     uint8_t            all_phys;
5023     /// Preferred PHYS for TX
5024     uint8_t            tx_phys;
5025     /// Preferred PHYS for RX
5026     uint8_t            rx_phys;
5027 };
5028 
5029 /// HCI LE Set PHY Command
5030 struct hci_le_set_phy_cmd
5031 {
5032     /// Connection Handle
5033     uint16_t           conhdl;
5034     /// Preferred PHYS selection
5035     uint8_t            all_phys;
5036     /// Preferred PHYS for TX
5037     uint8_t            tx_phys;
5038     /// Preferred PHYS for RX
5039     uint8_t            rx_phys;
5040     /// PHY options
5041     uint16_t           phy_opt;
5042 };
5043 
5044 /// HCI LE Set Extended Advertising Parameters Command Complete Event
5045 struct hci_le_set_ext_adv_param_cmd_cmp_evt
5046 {
5047     /// Status
5048     uint8_t            status;
5049     /// Selected Tx power
5050     int8_t             sel_tx_pwr;
5051 };
5052 
5053 /// HCI LE Enhanced Receiver Test Command
5054 struct hci_le_enh_rx_test_cmd
5055 {
5056     /// Reception channel value
5057     uint8_t            channel;
5058     /// Reception PHY rate
5059     uint8_t            phys;
5060     /// Modulation index
5061     uint8_t            modulation_idx;
5062 };
5063 
5064 /// HCI LE Enhanced Transmitter Test Command
5065 struct hci_le_enh_tx_test_cmd
5066 {
5067     /// Transmit channel value
5068     uint8_t            channel;
5069     /// Length of the data to be transmitted in a packet
5070     uint8_t            payload_length;
5071     /// Type of the data contained in a packet
5072     uint8_t            payload_type;
5073     /// Transmit PHY rate
5074     uint8_t            phys;
5075 };
5076 
5077 ///HCI LE Set Advertising Set Random Address Command parameters structure
5078 struct hci_le_set_adv_set_rand_addr_cmd
5079 {
5080     /// Advertising handle
5081     uint8_t adv_hdl;
5082     /// Advertising random address
5083     struct bd_addr rand_addr;
5084 };
5085 
5086 ///HCI LE Set Extended Advertising Parameters Command parameters structure
5087 struct hci_le_set_ext_adv_param_cmd
5088 {
5089     /// Advertising handle
5090     uint8_t adv_hdl;
5091     /// Advertising event properties
5092     uint16_t adv_evt_properties;
5093     /// Primary advertising minimum interval
5094     uint8_t prim_adv_intv_min[3];
5095     /// Primary advertising maximum interval
5096     uint8_t prim_adv_intv_max[3];
5097     /// Primary advertising channel map
5098     uint8_t prim_adv_chnl_map;
5099     /// Own address type:  public=0 / random=1 / rpa_or_pub=2 / rpa_or_rnd=3
5100     uint8_t own_addr_type;
5101     /// Peer address type: public=0 / random=1
5102     uint8_t peer_addr_type;
5103     /// Peer Bluetooth device address
5104     struct bd_addr peer_addr;
5105     /// Advertising filter policy
5106     uint8_t adv_filt_policy;
5107     /// Advertising Tx power
5108     int8_t adv_tx_pwr;
5109     /// Primary advertising PHY
5110     uint8_t prim_adv_phy;
5111     /// Secondary advertising max skip
5112     uint8_t sec_adv_max_skip;
5113     /// Secondary advertising PHY
5114     uint8_t sec_adv_phy;
5115     /// Advertising SID
5116     uint8_t adv_sid;
5117     /// Scan request notification enable
5118     uint8_t scan_req_notif_en;
5119 };
5120 
5121 ///HCI LE Set Extended Advertising Data Command parameters structure
5122 struct hci_le_set_ext_adv_data_cmd
5123 {
5124     /// Advertising handle
5125     uint8_t adv_hdl;
5126     /**
5127      *  Operation
5128      *  0x00 Intermediate fragment of fragmented extended advertising data
5129      *  0x01 First fragment of fragmented extended advertising data
5130      *  0x02 Last fragment of fragmented extended advertising data
5131      *  0x03 Complete extended advertising data
5132      *  0x04 [ID7300_r06] Unchanged data (just update the Advertising DID)
5133      *  All other values Reserved for future use
5134      */
5135     uint8_t operation;
5136     /**
5137      *  Fragment preference
5138      *  0x00 The Controller may fragment all Host advertising data
5139      *  0x01 The Controller should not fragment nor minimize fragmentation of Host advertising data
5140      *  All other values Reserved for future use
5141      */
5142     uint8_t frag_pref;
5143     /// Advertising Data Length (0-252 bytes)
5144     uint8_t data_len;
5145     /// Advertising data
5146     uint8_t data[__ARRAY_EMPTY];
5147 };
5148 
5149 ///HCI LE Set Extended Scan Response Data Command parameters structure
5150 struct hci_le_set_ext_scan_rsp_data_cmd
5151 {
5152     /// Advertising handle
5153     uint8_t adv_hdl;
5154     /**
5155      *  Operation
5156      *  0x00 Intermediate fragment of fragmented extended advertising data
5157      *  0x01 First fragment of fragmented extended advertising data
5158      *  0x02 Last fragment of fragmented extended advertising data
5159      *  0x03 Complete extended advertising data
5160      *  0x04 [ID7300_r06] Unchanged data (just update the Advertising DID)
5161      *  All other values Reserved for future use
5162      */
5163     uint8_t operation;
5164     /**
5165      *  Fragment preference
5166      *  0x00 The Controller may fragment all Host advertising data
5167      *  0x01 The Controller should not fragment nor minimize fragmentation of Host advertising data
5168      *  All other values Reserved for future use
5169      */
5170     uint8_t frag_pref;
5171     /// Scan Response Data Length (0-252 bytes)
5172     uint8_t data_len;
5173     /// Advertising data
5174     uint8_t data[__ARRAY_EMPTY];
5175 };
5176 
5177 #if BLE_EMB_PRESENT || BLE_HOST_PRESENT
5178 ///HCI LE Set Extended Advertising Enbale Command parameters structure
5179 struct hci_le_set_ext_adv_en_cmd
5180 {
5181     /// Enable
5182     uint8_t enable;
5183     /// Number of sets (1 - 0x3F)
5184     uint8_t nb_sets;
5185     /// Advertising handle
5186     uint8_t adv_hdl[BLE_ACTIVITY_MAX];
5187     /// Duration (N * 10 ms), 0x0000 No advertising duration. Advertising to continue until the Host disables it.
5188     uint16_t duration[BLE_ACTIVITY_MAX];
5189     /// Maximum number of extended advertising events
5190     uint8_t max_ext_adv_evt[BLE_ACTIVITY_MAX];
5191 };
5192 #endif //BLE_EMB_PRESENT || BLE_HOST_PRESENT
5193 
5194 ///HCI LE Read Maximum Advertising Data Length Command complete event
5195 struct hci_le_rd_max_adv_data_len_cmd_cmp_evt
5196 {
5197     /// Status
5198     uint8_t status;
5199     /// Maximum advertising data length
5200     uint16_t max_adv_data_len;
5201 };
5202 
5203 ///HCI LE Remove Advertising Set Command parameters structure
5204 struct hci_le_rem_adv_set_cmd
5205 {
5206     /// Advertising handle
5207     uint8_t adv_hdl;
5208 };
5209 
5210 ///HCI LE Read Number of Supported Advertising Sets Command complete event
5211 struct hci_le_rd_nb_supp_adv_sets_cmd_cmp_evt
5212 {
5213     /// Status
5214     uint8_t status;
5215     /// Number of supported advertising sets
5216     uint8_t nb_supp_adv_sets;
5217 };
5218 
5219 ///HCI LE Read Transmit Power Command complete event
5220 /*@TRACE*/
5221 struct hci_le_rd_tx_pwr_cmd_cmp_evt
5222 {
5223     /// Status
5224     uint8_t status;
5225     /// Minimum TX Power
5226     uint8_t min_tx_pwr;
5227     /// Maximum TX Power
5228     uint8_t max_tx_pwr;
5229 };
5230 
5231 ///HCI LE Read RF Path Compensation Command complete event
5232 /*@TRACE*/
5233 struct hci_le_rd_rf_path_comp_cmd_cmp_evt
5234 {
5235     /// Status
5236     uint8_t status;
5237     /// RF TX Path Compensation
5238     int16_t tx_path_comp;
5239     /// RF RX Path Compensation
5240     int16_t rx_path_comp;
5241 };
5242 
5243 ///HCI LE Write RF Path Compensation Command complete event
5244 /*@TRACE*/
5245 struct hci_le_wr_rf_path_comp_cmd
5246 {
5247     /// RF TX Path Compensation
5248     int16_t tx_path_comp;
5249     /// RF RX Path Compensation
5250     int16_t rx_path_comp;
5251 };
5252 
5253 ///HCI LE Set Periodic Advertising Parameters Command parameters structure
5254 struct hci_le_set_per_adv_param_cmd
5255 {
5256     /// Advertising handle
5257     uint8_t adv_hdl;
5258     /// Minimum advertising interval for periodic advertising
5259     uint16_t adv_intv_min;
5260     /// Maximum advertising interval for periodic advertising
5261     uint16_t adv_intv_max;
5262     /// Advertising properties
5263     uint16_t adv_prop;
5264 };
5265 
5266 ///HCI LE Set Periodic Advertising Data Command parameters structure
5267 struct hci_le_set_per_adv_data_cmd
5268 {
5269     /// Advertising handle
5270     uint8_t adv_hdl;
5271     /**
5272      *  Operation
5273      *  0x00 Intermediate fragment of fragmented periodic advertising data
5274      *  0x01 First fragment of fragmented periodic advertising data
5275      *  0x02 Last fragment of fragmented periodic advertising data
5276      *  0x03 Complete periodic advertising data
5277      *  All other values Reserved for future use
5278      */
5279     uint8_t operation;
5280     /// Advertising Data Length (0-252 bytes)
5281     uint8_t data_len;
5282     /// Advertising data
5283     uint8_t data[__ARRAY_EMPTY];
5284 };
5285 
5286 ///HCI LE Set Periodic Advertising Enable Command parameters structure
5287 struct hci_le_set_per_adv_en_cmd
5288 {
5289     /// Enable
5290     uint8_t enable;
5291     /// Advertising handle
5292     uint8_t adv_hdl;
5293 };
5294 
5295 ///HCI LE Advertising Set Terminated event
5296 struct hci_le_adv_set_term_evt
5297 {
5298     /// LE Subevent code
5299     uint8_t  subcode;
5300     /// Status
5301     uint8_t  status;
5302     /// Advertising handle
5303     uint8_t  adv_hdl;
5304     /// Connection handle
5305     uint16_t conhdl;
5306     /// Num_Completed_Extended_Advertising_Events
5307     uint8_t  nb_cmp_ext_adv_evt;
5308 };
5309 
5310 ///HCI LE Scan Request Received event
5311 struct hci_le_scan_req_rcvd_evt
5312 {
5313     /// LE Subevent code
5314     uint8_t  subcode;
5315     /// Advertising handle
5316     uint8_t  adv_hdl;
5317     /// Scanner address type:  public=0 / random=1 / rpa_or_pub=2 / rpa_or_rnd=3
5318     uint8_t scan_addr_type;
5319     /// Scanner address
5320     struct bd_addr scan_addr;
5321 };
5322 
5323 ///HCI LE Read Periodic Advertiser List Size Command complete event
5324 struct hci_le_rd_per_adv_list_size_cmd_cmp_evt
5325 {
5326     ///Status
5327     uint8_t status;
5328     /// Periodic Advertiser List Size
5329     uint8_t size;
5330 };
5331 
5332 ///HCI LE Channel Selection Algorithm event
5333 struct hci_le_ch_sel_algo_evt
5334 {
5335     /// LE Subevent code
5336     uint8_t  subcode;
5337     /// Connection handle
5338     uint16_t  conhdl;
5339     /// Channel selection algorithm
5340     uint8_t ch_sel_algo;
5341 };
5342 
5343 /// HCI LE read PHY Command complete event
5344 struct hci_le_rd_phy_cmd_cmp_evt
5345 {
5346     ///Status of received command
5347     uint8_t             status;
5348     /// Connection Handle
5349     uint16_t            conhdl;
5350     /// Current configured PHY for TX
5351     //@trc_ref le_phy_value
5352     uint8_t             tx_phy;
5353     /// Current configured PHY for RX
5354     //@trc_ref le_phy_value
5355     uint8_t             rx_phy;
5356 };
5357 
5358 /// HCI LE PHY Update Complete event
5359 /*@TRACE*/
5360 struct hci_le_phy_upd_cmp_evt
5361 {
5362     ///LE Subevent code
5363     uint8_t             subcode;
5364     ///Status of received command
5365     uint8_t             status;
5366     ///Connection handle
5367     uint16_t            conhdl;
5368     ///TX phy chosen
5369     //@trc_ref le_phy_value
5370     uint8_t             tx_phy;
5371     ///RX phy chosen
5372     //@trc_ref le_phy_value
5373     uint8_t             rx_phy;
5374 };
5375 
5376 #if (BLE_ISO_PRESENT && BLE_HW_50_ISO)
5377 // HCI ISO definitions for CIS and BIS
5378 #include "co_hci_iso.h"
5379 #endif // (BLE_ISO_PRESENT && BLE_HW_50_ISO)
5380 
5381 #endif // _BT_COMMON_HCI_H
5382