hci_le.h revision 1.1 1 1.1 nat /* $NetBSD: hci_le.h,v 1.1 2024/03/13 07:22:16 nat Exp $ */
2 1.1 nat
3 1.1 nat /*-
4 1.1 nat * Copyright (c) 2020 Nathanial Sloss <nathanialsloss (at) yahoo.com.au>
5 1.1 nat * All rights reserved.
6 1.1 nat *
7 1.1 nat * Redistribution and use in source and binary forms, with or without
8 1.1 nat * modification, are permitted provided that the following conditions
9 1.1 nat * are met:
10 1.1 nat * 1. Redistributions of source code must retain the above copyright
11 1.1 nat * notice, this list of conditions and the following disclaimer.
12 1.1 nat * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 nat * notice, this list of conditions and the following disclaimer in the
14 1.1 nat * documentation and/or other materials provided with the distribution.
15 1.1 nat *
16 1.1 nat * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 nat * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 nat * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 nat * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 nat * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 nat * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 nat * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 nat * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 nat * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 nat * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 nat * POSSIBILITY OF SUCH DAMAGE.
27 1.1 nat */
28 1.1 nat
29 1.1 nat #define HCI_ADVERT_DATA_SIZE 31 /* advertising data size */
30 1.1 nat #define HCI_SCAN_DATA_SIZE 31 /* scan resp. data size */
31 1.1 nat
32 1.1 nat /* LE Event masks */
33 1.1 nat #define HCI_LE_EVMSK_ALL 0x000000000000001f
34 1.1 nat #define HCI_LE_EVMSK_NONE 0x0000000000000000
35 1.1 nat #define HCI_LE_EVMSK_CON_COMPL 0x0000000000000001
36 1.1 nat #define HCI_LE_EVMSK_ADV_REPORT 0x0000000000000002
37 1.1 nat #define HCI_LE_EVMSK_CON_UPDATE_COMPL 0x0000000000000004
38 1.1 nat #define HCI_LE_EVMSK_READ_REMOTE_FEATURES_COMPL 0x0000000000000008
39 1.1 nat #define HCI_LE_EVMSK_LONG_TERM_KEY_REQ 0x0000000000000010
40 1.1 nat /* 0x0000000000000020 - 0x8000000000000000 - reserved for future use */
41 1.1 nat
42 1.1 nat /**************************************************************************
43 1.1 nat **************************************************************************
44 1.1 nat ** OGF 0x08 Bluetooth Low Energy (LE) Link commands
45 1.1 nat **************************************************************************
46 1.1 nat **************************************************************************/
47 1.1 nat
48 1.1 nat #define HCI_OGF_LE 0x08
49 1.1 nat
50 1.1 nat #define HCI_OCF_LE_SET_EVENT_MASK 0x0001
51 1.1 nat #define HCI_CMD_LE_SET_EVENT_MASK 0x2001
52 1.1 nat typedef struct {
53 1.1 nat uint8_t event_mask[HCI_EVENT_MASK_SIZE]; /* event_mask */
54 1.1 nat } __packed hci_le_set_event_mask_cp;
55 1.1 nat
56 1.1 nat typedef hci_status_rp hci_le_set_event_mask_rp;
57 1.1 nat
58 1.1 nat #define HCI_OCF_LE_READ_BUFFER_SIZE 0x0002
59 1.1 nat #define HCI_CMD_LE_READ_BUFFER_SIZE 0x2002
60 1.1 nat /* No command parameter(s) */
61 1.1 nat
62 1.1 nat typedef struct {
63 1.1 nat uint8_t status; /* status 0x00 = success */
64 1.1 nat uint16_t le_data_pktlen; /* buffer len*/
65 1.1 nat uint8_t le_num_pkts; /* no. acl data packets */
66 1.1 nat } __packed hci_le_read_buffer_size_rp;
67 1.1 nat
68 1.1 nat #define HCI_OCF_LE_READ_LOCAL_FEATURES 0x0003
69 1.1 nat #define HCI_CMD_LE_READ_LOCAL_FEATURES 0x2003
70 1.1 nat /* No command parameter(s) */
71 1.1 nat
72 1.1 nat typedef struct {
73 1.1 nat uint8_t status; /* status 0x00 = success */
74 1.1 nat uint8_t features[HCI_FEATURES_SIZE]; /* le features */
75 1.1 nat } __packed hci_le_read_local_features_rp;
76 1.1 nat
77 1.1 nat #define HCI_OCF_LE_SET_RND_ADDR 0x0005
78 1.1 nat #define HCI_CMD_LE_SET_RND_ADDR 0x2005
79 1.1 nat typedef struct {
80 1.1 nat bdaddr_t bdaddr; /* random local address */
81 1.1 nat } __packed hci_le_set_rnd_addr_cp;
82 1.1 nat
83 1.1 nat typedef hci_status_rp hci_le_set_rnd_addr_rp;
84 1.1 nat /* XXX NS Finish defines. */
85 1.1 nat #define HCI_OCF_LE_SET_ADVERT_PARAM 0x0006
86 1.1 nat #define HCI_CMD_LE_SET_ADVERT_PARAM 0x2006
87 1.1 nat typedef struct {
88 1.1 nat uint16_t min_interval; /* min interval * 0.625ms */
89 1.1 nat uint16_t max_interval; /* max_interval * 0.625ms */
90 1.1 nat uint8_t advert_type;
91 1.1 nat uint8_t own_address_type;
92 1.1 nat uint8_t direct_address_type;
93 1.1 nat bdaddr_t direct_address; /* remote address */
94 1.1 nat uint8_t advert_channel_map;
95 1.1 nat uint8_t advert_filter_policy;
96 1.1 nat } __packed hci_le_set_advert_param_cp;
97 1.1 nat
98 1.1 nat typedef hci_status_rp hci_le_set_advert_param_rp;
99 1.1 nat
100 1.1 nat #define HCF_OCF_LE_READ_ADVERT_CHAN_TX_PWR 0x0007
101 1.1 nat #define HCF_CMD_LE_READ_ADVERT_CHAN_TX_PWR 0x2007
102 1.1 nat /* No command parameter(s) */
103 1.1 nat
104 1.1 nat typedef struct {
105 1.1 nat uint8_t status; /* status 0x00 = success */
106 1.1 nat int8_t tx_power_level; /* -20 - 10 dBm */
107 1.1 nat } __packed hci_le_read_advert_chan_tx_pwr_rp;
108 1.1 nat
109 1.1 nat #define HCF_OCF_LE_SET_ADVERT_DATA 0x0008
110 1.1 nat #define HCF_CMD_LE_SET_ADVERT_DATA 0x2008
111 1.1 nat typedef struct {
112 1.1 nat uint8_t advert_data_len; /* 0x00 - 0x1f */
113 1.1 nat uint8_t advert_data[HCI_ADVERT_DATA_SIZE]; /* def all 0's */
114 1.1 nat } __packed hci_le_set_advert_data_cp;
115 1.1 nat
116 1.1 nat typedef hci_status_rp hci_le_set_advert_data_rp;
117 1.1 nat
118 1.1 nat #define HCF_OCF_LE_SET_SCAN_RESP_DATA 0x0009
119 1.1 nat #define HCF_CMD_LE_SET_SCAN_RESP_DATA 0x2009
120 1.1 nat typedef struct {
121 1.1 nat uint8_t scan_resp_data_len; /* 0x00 - 0x1f */
122 1.1 nat uint8_t scan_resp_data[HCI_SCAN_DATA_SIZE]; /* def all 0's */
123 1.1 nat } __packed hci_le_set_scan_resp_data_cp;
124 1.1 nat
125 1.1 nat typedef hci_status_rp hci_le_set_scan_resp_data_rp;
126 1.1 nat
127 1.1 nat #define HCF_OCF_LE_SET_ADVERT_ENABLE 0x000a
128 1.1 nat #define HCF_CMD_LE_SET_ADVERT_ENABLE 0x200A
129 1.1 nat typedef struct {
130 1.1 nat uint8_t advert_enable; /* 0x00 - disable 0x1 - enable */
131 1.1 nat /* 0x2 - 0xff reserved */
132 1.1 nat } __packed hci_le_set_advert_enable_cp;
133 1.1 nat
134 1.1 nat typedef hci_status_rp hci_le_set_advert_enable_rp;
135 1.1 nat
136 1.1 nat #define HCI_OCF_LE_SET_SCAN_PARAM 0x000b
137 1.1 nat #define HCI_CMD_LE_SET_SCAN_PARAM 0x200B
138 1.1 nat typedef struct {
139 1.1 nat uint8_t scan_type;
140 1.1 nat uint16_t scan_interval; /* min interval * 0.625ms */
141 1.1 nat uint16_t scan_window; /* max_interval * 0.625ms */
142 1.1 nat uint8_t own_address_type;
143 1.1 nat uint8_t scan_filter_policy;
144 1.1 nat } __packed hci_le_set_scan_param_cp;
145 1.1 nat
146 1.1 nat typedef hci_status_rp hci_le_set_scan_param_rp;
147 1.1 nat
148 1.1 nat #define HCF_OCF_LE_SET_SCAN_ENABLE 0x000c
149 1.1 nat #define HCF_CMD_LE_SET_SCAN_ENABLE 0x200C
150 1.1 nat typedef struct {
151 1.1 nat uint8_t scan_enable; /* 0x00 - disable 0x1 - enable */
152 1.1 nat /* 0x2 - 0xff reserved */
153 1.1 nat uint8_t filter_dup; /* 0x00 - no filtering 0x1 - filter */
154 1.1 nat /* 0x2 - 0xff reserved */
155 1.1 nat } __packed hci_le_set_scan_enable_cp;
156 1.1 nat
157 1.1 nat typedef hci_status_rp hci_le_set_scan_enable_rp;
158 1.1 nat
159 1.1 nat #define HCI_OCF_CREATE_CON_LE 0x000d
160 1.1 nat #define HCI_CMD_CREATE_CON_LE 0x200D
161 1.1 nat typedef struct {
162 1.1 nat uint16_t scan_interval; /* min interval * 0.625ms */
163 1.1 nat uint16_t scan_window; /* max_interval * 0.625ms */
164 1.1 nat uint8_t initiator_filter_policy;
165 1.1 nat uint8_t peer_address_type;
166 1.1 nat bdaddr_t peer_address; /* remote address */
167 1.1 nat uint8_t own_address_type;
168 1.1 nat uint16_t con_interval_min; /* min interval * 1.25ms */
169 1.1 nat uint16_t con_interval_max; /* max_interval * 1.25ms */
170 1.1 nat uint16_t con_latency; /* 0x0 - 0x1f4 */
171 1.1 nat uint16_t supervision_timo; /* timeout * 10ms */
172 1.1 nat uint16_t min_ce_length; /* min length * 0.625ms */
173 1.1 nat uint16_t max_ce_length; /* max length * 0.625ms */
174 1.1 nat } __packed hci_create_con_le_cp;
175 1.1 nat /* No return parameter(s) */
176 1.1 nat
177 1.1 nat #define HCI_OCF_CREATE_CON_LE_CANCEL 0x000e
178 1.1 nat #define HCI_CMD_CREATE_CON_LE_CANCEL 0x200E
179 1.1 nat /* No command parameter(s) */
180 1.1 nat
181 1.1 nat typedef hci_status_rp hci_create_con_le_cancel_rp;
182 1.1 nat
183 1.1 nat #define HCI_OCF_LE_READ_WHITE_LIST_SIZE 0x000f
184 1.1 nat #define HCI_CMD_LE_READ_WHITE_LIST_SIZE 0x200F
185 1.1 nat /* No command parameter(s) */
186 1.1 nat
187 1.1 nat typedef struct {
188 1.1 nat uint8_t status; /* status 0x00 = success */
189 1.1 nat uint8_t white_list_size; /* 0x1 - 0xff */
190 1.1 nat /* 0x0 reserved */
191 1.1 nat } __packed hci_le_read_white_list_size_rp;
192 1.1 nat
193 1.1 nat #define HCI_OCF_LE_CLEAR_WHITE_LIST 0x0010
194 1.1 nat #define HCI_CMD_LE_CLEAR_WHITE_LIST 0x2010
195 1.1 nat /* No command parameter(s) */
196 1.1 nat
197 1.1 nat typedef hci_status_rp hci_le_clear_white_list_rp;
198 1.1 nat
199 1.1 nat #define HCI_OCF_LE_ADD_DEV_TO_WHITE_LIST 0x0011
200 1.1 nat #define HCI_CMD_LE_ADD_DEV_TO_WHITE_LIST 0x2011
201 1.1 nat typedef struct {
202 1.1 nat uint8_t address_type;
203 1.1 nat bdaddr_t address; /* remote address */
204 1.1 nat } __packed hci_le_add_dev_to_white_list_cp;
205 1.1 nat
206 1.1 nat typedef hci_status_rp hci_le_add_dev_to_white_list_rp;
207 1.1 nat
208 1.1 nat #define HCI_OCF_LE_REMOVE_DEV_FROM_WHITE_LIST 0x0012
209 1.1 nat #define HCI_CMD_LE_REMOVE_DEV_FROM_WHITE_LIST 0x2012
210 1.1 nat typedef struct {
211 1.1 nat uint8_t address_type;
212 1.1 nat bdaddr_t address; /* remote address */
213 1.1 nat } __packed hci_le_remove_dev_from_white_list_cp;
214 1.1 nat
215 1.1 nat typedef hci_status_rp hci_le_remove_dev_from_white_list_rp;
216 1.1 nat
217 1.1 nat #define HCI_OCF_UPDATE_CON_LE 0x0013
218 1.1 nat #define HCI_CMD_UPDATE_CON_LE 0x2013
219 1.1 nat typedef struct {
220 1.1 nat uint16_t con_handle; /* handle 12 bits */
221 1.1 nat uint16_t con_interval_min; /* min interval * 1.25ms */
222 1.1 nat uint16_t con_interval_max; /* max_interval * 1.25ms */
223 1.1 nat uint16_t con_latency; /* 0x0 - 0x1f4 */
224 1.1 nat uint16_t supervision_timo; /* timeout * 10ms */
225 1.1 nat uint16_t min_ce_length; /* min length * 0.625ms */
226 1.1 nat uint16_t max_ce_length; /* max length * 0.625ms */
227 1.1 nat } __packed hci_update_con_le_cp;
228 1.1 nat /* No return parameter(s) */
229 1.1 nat
230 1.1 nat #define HCI_OCF_LE_SET_HOST_CHAN_CLASSIFICATION 0x0014
231 1.1 nat #define HCI_CMD_LE_SET_HOST_CHAN_CLASSIFICATION 0x2014
232 1.1 nat typedef struct {
233 1.1 nat uint8_t map[5];
234 1.1 nat } __packed hci_le_set_host_chan_classification_cp;
235 1.1 nat
236 1.1 nat typedef hci_status_rp hci_le_set_host_chan_classification_rp;
237 1.1 nat
238 1.1 nat #define HCI_OCF_LE_READ_CHANNEL_MAP 0x0015
239 1.1 nat #define HCI_CMD_LE_READ_CHANNEL_MAP 0x2015
240 1.1 nat typedef struct {
241 1.1 nat uint16_t con_handle; /* connection handle */
242 1.1 nat } __packed hci_le_read_channel_map_cp;
243 1.1 nat
244 1.1 nat typedef struct {
245 1.1 nat uint8_t status; /* status 0x00 = success */
246 1.1 nat uint16_t con_handle; /* connection handle */
247 1.1 nat uint8_t map[5]; /* LE channel map */
248 1.1 nat } __packed hci_le_read_channel_map_rp;
249 1.1 nat
250 1.1 nat #define HCI_OCF_LE_READ_REMOTE_FEATURES 0x0016
251 1.1 nat #define HCI_CMD_LE_READ_REMOTE_FEATURES 0x2016
252 1.1 nat typedef struct {
253 1.1 nat uint16_t con_handle; /* connection handle */
254 1.1 nat } __packed hci_le_read_remote_features_cp;
255 1.1 nat /* No return parameter(s) */
256 1.1 nat
257 1.1 nat #define HCI_OCF_LE_ENCRYPT 0x0017
258 1.1 nat #define HCI_CMD_LE_ENCRYPT 0x2017
259 1.1 nat typedef struct {
260 1.1 nat uint8_t key[16];
261 1.1 nat uint8_t plaintext_data[16];
262 1.1 nat } __packed hci_le_encrypt_cp;
263 1.1 nat
264 1.1 nat typedef struct {
265 1.1 nat uint8_t status; /* status 0x00 = success */
266 1.1 nat uint16_t enc_data[16];
267 1.1 nat } __packed hci_le_encrypt_rp;
268 1.1 nat
269 1.1 nat #define HCI_OCF_LE_RAND 0x0018
270 1.1 nat #define HCI_CMD_LE_RAND 0x2018
271 1.1 nat /* No command parameter(s) */
272 1.1 nat
273 1.1 nat typedef struct {
274 1.1 nat uint8_t status; /* status 0x00 = success */
275 1.1 nat uint8_t rand_num[8];
276 1.1 nat } __packed hci_le_rand_rp;
277 1.1 nat
278 1.1 nat #define HCI_OCF_LE_START_ENCRYPT 0x0019
279 1.1 nat #define HCI_CMD_LE_START_ENCRYPT 0x2019
280 1.1 nat typedef struct {
281 1.1 nat uint16_t con_handle; /* connection handle */
282 1.1 nat uint8_t rand_num[8];
283 1.1 nat uint16_t enc_diversifier;
284 1.1 nat uint8_t key[HCI_KEY_SIZE]; /* key */
285 1.1 nat } __packed hci_le_start_encrypt_cp;
286 1.1 nat /* No return parameter(s) */
287 1.1 nat
288 1.1 nat #define HCI_OCF_LE_LONG_TERM_KEY_REQ_REP 0x001a
289 1.1 nat #define HCI_CMD_LE_LONG_TERM_KEY_REQ_REP 0x201A
290 1.1 nat typedef struct {
291 1.1 nat uint16_t con_handle; /* connection handle */
292 1.1 nat uint8_t key[HCI_KEY_SIZE]; /* key */
293 1.1 nat } __packed hci_le_long_term_key_req_rep_cp;
294 1.1 nat
295 1.1 nat typedef struct {
296 1.1 nat uint8_t status; /* status 0x00 = success */
297 1.1 nat uint16_t con_handle; /* connection handle */
298 1.1 nat } __packed hci_le_long_term_key_req_rep_rp;
299 1.1 nat
300 1.1 nat #define HCI_OCF_LE_LONG_TERM_KEY_REQ_REP_NEG 0x001b
301 1.1 nat #define HCI_CMD_LE_LONG_TERM_KEY_REQ_REP_NEG 0x201B
302 1.1 nat typedef struct {
303 1.1 nat uint16_t con_handle; /* connection handle */
304 1.1 nat } __packed hci_le_long_term_key_req_rep_neg_cp;
305 1.1 nat
306 1.1 nat typedef struct {
307 1.1 nat uint8_t status; /* status 0x00 = success */
308 1.1 nat uint16_t con_handle; /* connection handle */
309 1.1 nat } __packed hci_le_long_term_key_req_rep_neg_rp;
310 1.1 nat
311 1.1 nat /* XXX NS Read supported states */
312 1.1 nat
313 1.1 nat #define HCI_OCF_LE_RECEIVER_TEST 0x001d
314 1.1 nat #define HCI_CMD_LE_RECEIVER_TEST 0x201D
315 1.1 nat typedef struct {
316 1.1 nat uint8_t rx_freq; /* 0x00 - 0x27 (2402 - 2480MHz) */
317 1.1 nat } __packed hci_le_receiver_test_cp;
318 1.1 nat
319 1.1 nat typedef struct {
320 1.1 nat uint8_t status; /* status 0x00 = success */
321 1.1 nat } __packed hci_le_receiver_test_rp;
322 1.1 nat
323 1.1 nat #define HCI_OCF_LE_TRANSMITTER_TEST 0x001e
324 1.1 nat #define HCI_CMD_LE_TRANSMITTER_TEST 0x201E
325 1.1 nat typedef struct {
326 1.1 nat uint8_t tx_freq; /* 0x00 - 0x27 (2402 - 2480MHz) */
327 1.1 nat uint8_t test_len; /* 0x00 - 0x25 bytes */
328 1.1 nat /* 0x26 - 0xff reserved */
329 1.1 nat uint8_t payload; /* 0x00 - 0x02 mandatory */
330 1.1 nat /* 0x03 - 0x07 opt. test patterns */
331 1.1 nat /* 0x08 - 0xff reserved */
332 1.1 nat } __packed hci_le_transmitter_test_cp;
333 1.1 nat
334 1.1 nat typedef struct {
335 1.1 nat uint8_t status; /* status 0x00 = success */
336 1.1 nat } __packed hci_le_transmitter_test_rp;
337 1.1 nat
338 1.1 nat #define HCI_OCF_LE_TEST_END 0x001f
339 1.1 nat #define HCI_CMD_LE_TEST_END 0x201F
340 1.1 nat /* No command parameter(s) */
341 1.1 nat
342 1.1 nat typedef struct {
343 1.1 nat uint8_t status; /* status 0x00 = success */
344 1.1 nat uint16_t num_pkts; /* num pkts received */
345 1.1 nat /* 0x0000 for tx test */
346 1.1 nat } __packed hci_le_test_end_rp;
347 1.1 nat
348 1.1 nat /**************************************************************************
349 1.1 nat **************************************************************************
350 1.1 nat ** Events and event parameters
351 1.1 nat **************************************************************************
352 1.1 nat **************************************************************************/
353 1.1 nat
354 1.1 nat #define HCI_LE_META_EVENT 0x3e
355 1.1 nat #define HCI_SUBEVT_CON_COMP 0x01
356 1.1 nat typedef struct {
357 1.1 nat uint8_t subevt_code;
358 1.1 nat uint8_t status; /* status 0x00 = success */
359 1.1 nat uint16_t con_handle; /* handle 12 bits */
360 1.1 nat uint8_t role;
361 1.1 nat uint8_t peer_address_type;
362 1.1 nat bdaddr_t peer_address; /* remote address */
363 1.1 nat uint8_t own_address_type;
364 1.1 nat uint16_t con_interval; /* min interval * 1.25ms */
365 1.1 nat uint16_t con_latency; /* 0x0 - 0x1f4 */
366 1.1 nat uint8_t master_clk_accuracy;
367 1.1 nat } __packed hci_le_con_comp_ep;
368 1.1 nat
369