hcimsgs.h revision f6db7cb9a30b34493df8658d59b2fe2232bc828a
1/******************************************************************************
2 *
3 *  Copyright (C) 1999-2012 Broadcom Corporation
4 *
5 *  Licensed under the Apache License, Version 2.0 (the "License");
6 *  you may not use this file except in compliance with the License.
7 *  You may obtain a copy of the License at:
8 *
9 *  http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *  Unless required by applicable law or agreed to in writing, software
12 *  distributed under the License is distributed on an "AS IS" BASIS,
13 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *  See the License for the specific language governing permissions and
15 *  limitations under the License.
16 *
17 ******************************************************************************/
18
19#ifndef HCIMSGS_H
20#define HCIMSGS_H
21
22#include "bt_target.h"
23#include "bt_types.h"
24#include "hcidefs.h"
25
26#include <base/callback_forward.h>
27
28void bte_main_hci_send(BT_HDR* p_msg, uint16_t event);
29
30/* Message by message.... */
31
32extern void btsnd_hcic_inquiry(const LAP inq_lap, uint8_t duration,
33                               uint8_t response_cnt);
34
35#define HCIC_PARAM_SIZE_INQUIRY 5
36
37#define HCIC_INQ_INQ_LAP_OFF 0
38#define HCIC_INQ_DUR_OFF 3
39#define HCIC_INQ_RSP_CNT_OFF 4
40/* Inquiry */
41
42/* Inquiry Cancel */
43extern void btsnd_hcic_inq_cancel(void);
44
45#define HCIC_PARAM_SIZE_INQ_CANCEL 0
46
47/* Periodic Inquiry Mode */
48extern void btsnd_hcic_per_inq_mode(uint16_t max_period, uint16_t min_period,
49                                    const LAP inq_lap, uint8_t duration,
50                                    uint8_t response_cnt);
51
52#define HCIC_PARAM_SIZE_PER_INQ_MODE 9
53
54#define HCI_PER_INQ_MAX_INTRVL_OFF 0
55#define HCI_PER_INQ_MIN_INTRVL_OFF 2
56#define HCI_PER_INQ_INQ_LAP_OFF 4
57#define HCI_PER_INQ_DURATION_OFF 7
58#define HCI_PER_INQ_RSP_CNT_OFF 8
59/* Periodic Inquiry Mode */
60
61/* Exit Periodic Inquiry Mode */
62extern void btsnd_hcic_exit_per_inq(void);
63
64#define HCIC_PARAM_SIZE_EXIT_PER_INQ 0
65/* Create Connection */
66extern void btsnd_hcic_create_conn(BD_ADDR dest, uint16_t packet_types,
67                                   uint8_t page_scan_rep_mode,
68                                   uint8_t page_scan_mode,
69                                   uint16_t clock_offset, uint8_t allow_switch);
70
71#define HCIC_PARAM_SIZE_CREATE_CONN 13
72
73#define HCIC_CR_CONN_BD_ADDR_OFF 0
74#define HCIC_CR_CONN_PKT_TYPES_OFF 6
75#define HCIC_CR_CONN_REP_MODE_OFF 8
76#define HCIC_CR_CONN_PAGE_SCAN_MODE_OFF 9
77#define HCIC_CR_CONN_CLK_OFF_OFF 10
78#define HCIC_CR_CONN_ALLOW_SWITCH_OFF 12
79/* Create Connection */
80
81/* Disconnect */
82extern void btsnd_hcic_disconnect(uint16_t handle, uint8_t reason);
83
84#define HCIC_PARAM_SIZE_DISCONNECT 3
85
86#define HCI_DISC_HANDLE_OFF 0
87#define HCI_DISC_REASON_OFF 2
88/* Disconnect */
89
90#if (BTM_SCO_INCLUDED == TRUE)
91/* Add SCO Connection */
92extern void btsnd_hcic_add_SCO_conn(uint16_t handle, uint16_t packet_types);
93#endif /* BTM_SCO_INCLUDED */
94
95#define HCIC_PARAM_SIZE_ADD_SCO_CONN 4
96
97#define HCI_ADD_SCO_HANDLE_OFF 0
98#define HCI_ADD_SCO_PACKET_TYPES_OFF 2
99/* Add SCO Connection */
100
101/* Create Connection Cancel */
102extern void btsnd_hcic_create_conn_cancel(BD_ADDR dest);
103
104#define HCIC_PARAM_SIZE_CREATE_CONN_CANCEL 6
105
106#define HCIC_CR_CONN_CANCEL_BD_ADDR_OFF 0
107/* Create Connection Cancel */
108
109/* Accept Connection Request */
110extern void btsnd_hcic_accept_conn(BD_ADDR bd_addr, uint8_t role);
111
112#define HCIC_PARAM_SIZE_ACCEPT_CONN 7
113
114#define HCI_ACC_CONN_BD_ADDR_OFF 0
115#define HCI_ACC_CONN_ROLE_OFF 6
116/* Accept Connection Request */
117
118/* Reject Connection Request */
119extern void btsnd_hcic_reject_conn(BD_ADDR bd_addr, uint8_t reason);
120
121#define HCIC_PARAM_SIZE_REJECT_CONN 7
122
123#define HCI_REJ_CONN_BD_ADDR_OFF 0
124#define HCI_REJ_CONN_REASON_OFF 6
125/* Reject Connection Request */
126
127/* Link Key Request Reply */
128extern void btsnd_hcic_link_key_req_reply(BD_ADDR bd_addr, LINK_KEY link_key);
129
130#define HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY 22
131
132#define HCI_LINK_KEY_REPLY_BD_ADDR_OFF 0
133#define HCI_LINK_KEY_REPLY_LINK_KEY_OFF 6
134/* Link Key Request Reply  */
135
136/* Link Key Request Neg Reply */
137extern void btsnd_hcic_link_key_neg_reply(BD_ADDR bd_addr);
138
139#define HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY 6
140
141#define HCI_LINK_KEY_NEG_REP_BD_ADR_OFF 0
142/* Link Key Request Neg Reply  */
143
144/* PIN Code Request Reply */
145extern void btsnd_hcic_pin_code_req_reply(BD_ADDR bd_addr, uint8_t pin_code_len,
146                                          PIN_CODE pin_code);
147
148#define HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY 23
149
150#define HCI_PIN_CODE_REPLY_BD_ADDR_OFF 0
151#define HCI_PIN_CODE_REPLY_PIN_LEN_OFF 6
152#define HCI_PIN_CODE_REPLY_PIN_CODE_OFF 7
153/* PIN Code Request Reply  */
154
155/* Link Key Request Neg Reply */
156extern void btsnd_hcic_pin_code_neg_reply(BD_ADDR bd_addr);
157
158#define HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY 6
159
160#define HCI_PIN_CODE_NEG_REP_BD_ADR_OFF 0
161/* Link Key Request Neg Reply  */
162
163/* Change Connection Type */
164extern void btsnd_hcic_change_conn_type(uint16_t handle, uint16_t packet_types);
165
166#define HCIC_PARAM_SIZE_CHANGE_CONN_TYPE 4
167
168#define HCI_CHNG_PKT_TYPE_HANDLE_OFF 0
169#define HCI_CHNG_PKT_TYPE_PKT_TYPE_OFF 2
170/* Change Connection Type */
171
172#define HCIC_PARAM_SIZE_CMD_HANDLE 2
173
174#define HCI_CMD_HANDLE_HANDLE_OFF 0
175
176extern void btsnd_hcic_auth_request(
177    uint16_t handle); /* Authentication Request */
178
179/* Set Connection Encryption */
180extern void btsnd_hcic_set_conn_encrypt(uint16_t handle, bool enable);
181#define HCIC_PARAM_SIZE_SET_CONN_ENCRYPT 3
182
183#define HCI_SET_ENCRYPT_HANDLE_OFF 0
184#define HCI_SET_ENCRYPT_ENABLE_OFF 2
185/* Set Connection Encryption */
186
187/* Remote Name Request */
188extern void btsnd_hcic_rmt_name_req(BD_ADDR bd_addr, uint8_t page_scan_rep_mode,
189                                    uint8_t page_scan_mode,
190                                    uint16_t clock_offset);
191
192#define HCIC_PARAM_SIZE_RMT_NAME_REQ 10
193
194#define HCI_RMT_NAME_BD_ADDR_OFF 0
195#define HCI_RMT_NAME_REP_MODE_OFF 6
196#define HCI_RMT_NAME_PAGE_SCAN_MODE_OFF 7
197#define HCI_RMT_NAME_CLK_OFF_OFF 8
198/* Remote Name Request */
199
200/* Remote Name Request Cancel */
201extern void btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr);
202
203#define HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL 6
204
205#define HCI_RMT_NAME_CANCEL_BD_ADDR_OFF 0
206/* Remote Name Request Cancel */
207
208extern void btsnd_hcic_rmt_features_req(
209    uint16_t handle); /* Remote Features Request */
210
211/* Remote Extended Features */
212extern void btsnd_hcic_rmt_ext_features(uint16_t handle, uint8_t page_num);
213
214#define HCIC_PARAM_SIZE_RMT_EXT_FEATURES 3
215
216#define HCI_RMT_EXT_FEATURES_HANDLE_OFF 0
217#define HCI_RMT_EXT_FEATURES_PAGE_NUM_OFF 2
218/* Remote Extended Features */
219
220extern void btsnd_hcic_rmt_ver_req(
221    uint16_t handle); /* Remote Version Info Request */
222extern void btsnd_hcic_read_rmt_clk_offset(
223    uint16_t handle); /* Remote Clock Offset */
224extern void btsnd_hcic_read_lmp_handle(uint16_t handle); /* Remote LMP Handle */
225
226extern void btsnd_hcic_setup_esco_conn(uint16_t handle, uint32_t tx_bw,
227                                       uint32_t rx_bw, uint16_t max_latency,
228                                       uint16_t voice, uint8_t retrans_effort,
229                                       uint16_t packet_types);
230#define HCIC_PARAM_SIZE_SETUP_ESCO 17
231
232#define HCI_SETUP_ESCO_HANDLE_OFF 0
233#define HCI_SETUP_ESCO_TX_BW_OFF 2
234#define HCI_SETUP_ESCO_RX_BW_OFF 6
235#define HCI_SETUP_ESCO_MAX_LAT_OFF 10
236#define HCI_SETUP_ESCO_VOICE_OFF 12
237#define HCI_SETUP_ESCO_RETRAN_EFF_OFF 14
238#define HCI_SETUP_ESCO_PKT_TYPES_OFF 15
239
240extern void btsnd_hcic_accept_esco_conn(BD_ADDR bd_addr, uint32_t tx_bw,
241                                        uint32_t rx_bw, uint16_t max_latency,
242                                        uint16_t content_fmt,
243                                        uint8_t retrans_effort,
244                                        uint16_t packet_types);
245#define HCIC_PARAM_SIZE_ACCEPT_ESCO 21
246
247#define HCI_ACCEPT_ESCO_BDADDR_OFF 0
248#define HCI_ACCEPT_ESCO_TX_BW_OFF 6
249#define HCI_ACCEPT_ESCO_RX_BW_OFF 10
250#define HCI_ACCEPT_ESCO_MAX_LAT_OFF 14
251#define HCI_ACCEPT_ESCO_VOICE_OFF 16
252#define HCI_ACCEPT_ESCO_RETRAN_EFF_OFF 18
253#define HCI_ACCEPT_ESCO_PKT_TYPES_OFF 19
254
255extern void btsnd_hcic_reject_esco_conn(BD_ADDR bd_addr, uint8_t reason);
256#define HCIC_PARAM_SIZE_REJECT_ESCO 7
257
258#define HCI_REJECT_ESCO_BDADDR_OFF 0
259#define HCI_REJECT_ESCO_REASON_OFF 6
260
261/* Hold Mode */
262extern void btsnd_hcic_hold_mode(uint16_t handle, uint16_t max_hold_period,
263                                 uint16_t min_hold_period);
264
265#define HCIC_PARAM_SIZE_HOLD_MODE 6
266
267#define HCI_HOLD_MODE_HANDLE_OFF 0
268#define HCI_HOLD_MODE_MAX_PER_OFF 2
269#define HCI_HOLD_MODE_MIN_PER_OFF 4
270/* Hold Mode */
271
272/* Sniff Mode */
273extern void btsnd_hcic_sniff_mode(uint16_t handle, uint16_t max_sniff_period,
274                                  uint16_t min_sniff_period,
275                                  uint16_t sniff_attempt,
276                                  uint16_t sniff_timeout);
277
278#define HCIC_PARAM_SIZE_SNIFF_MODE 10
279
280#define HCI_SNIFF_MODE_HANDLE_OFF 0
281#define HCI_SNIFF_MODE_MAX_PER_OFF 2
282#define HCI_SNIFF_MODE_MIN_PER_OFF 4
283#define HCI_SNIFF_MODE_ATTEMPT_OFF 6
284#define HCI_SNIFF_MODE_TIMEOUT_OFF 8
285/* Sniff Mode */
286
287extern void btsnd_hcic_exit_sniff_mode(uint16_t handle); /* Exit Sniff Mode */
288
289/* Park Mode */
290extern void btsnd_hcic_park_mode(uint16_t handle, uint16_t beacon_max_interval,
291                                 uint16_t beacon_min_interval);
292
293#define HCIC_PARAM_SIZE_PARK_MODE 6
294
295#define HCI_PARK_MODE_HANDLE_OFF 0
296#define HCI_PARK_MODE_MAX_PER_OFF 2
297#define HCI_PARK_MODE_MIN_PER_OFF 4
298/* Park Mode */
299
300extern void btsnd_hcic_exit_park_mode(uint16_t handle); /* Exit Park Mode */
301
302/* QoS Setup */
303extern void btsnd_hcic_qos_setup(uint16_t handle, uint8_t flags,
304                                 uint8_t service_type, uint32_t token_rate,
305                                 uint32_t peak, uint32_t latency,
306                                 uint32_t delay_var);
307
308#define HCIC_PARAM_SIZE_QOS_SETUP 20
309
310#define HCI_QOS_HANDLE_OFF 0
311#define HCI_QOS_FLAGS_OFF 2
312#define HCI_QOS_SERVICE_TYPE_OFF 3
313#define HCI_QOS_TOKEN_RATE_OFF 4
314#define HCI_QOS_PEAK_BANDWIDTH_OFF 8
315#define HCI_QOS_LATENCY_OFF 12
316#define HCI_QOS_DELAY_VAR_OFF 16
317/* QoS Setup */
318
319/* Switch Role Request */
320extern void btsnd_hcic_switch_role(BD_ADDR bd_addr, uint8_t role);
321
322#define HCIC_PARAM_SIZE_SWITCH_ROLE 7
323
324#define HCI_SWITCH_BD_ADDR_OFF 0
325#define HCI_SWITCH_ROLE_OFF 6
326/* Switch Role Request */
327
328/* Write Policy Settings */
329extern void btsnd_hcic_write_policy_set(uint16_t handle, uint16_t settings);
330
331#define HCIC_PARAM_SIZE_WRITE_POLICY_SET 4
332
333#define HCI_WRITE_POLICY_HANDLE_OFF 0
334#define HCI_WRITE_POLICY_SETTINGS_OFF 2
335/* Write Policy Settings */
336
337/* Write Default Policy Settings */
338extern void btsnd_hcic_write_def_policy_set(uint16_t settings);
339
340#define HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET 2
341
342#define HCI_WRITE_DEF_POLICY_SETTINGS_OFF 0
343/* Write Default Policy Settings */
344
345/******************************************
346 *    Lisbon Features
347 ******************************************/
348#if (BTM_SSR_INCLUDED == TRUE)
349/* Sniff Subrating */
350extern void btsnd_hcic_sniff_sub_rate(uint16_t handle, uint16_t max_lat,
351                                      uint16_t min_remote_lat,
352                                      uint16_t min_local_lat);
353
354#define HCIC_PARAM_SIZE_SNIFF_SUB_RATE 8
355
356#define HCI_SNIFF_SUB_RATE_HANDLE_OFF 0
357#define HCI_SNIFF_SUB_RATE_MAX_LAT_OFF 2
358#define HCI_SNIFF_SUB_RATE_MIN_REM_LAT_OFF 4
359#define HCI_SNIFF_SUB_RATE_MIN_LOC_LAT_OFF 6
360/* Sniff Subrating */
361
362#else /* BTM_SSR_INCLUDED == FALSE */
363
364#define btsnd_hcic_sniff_sub_rate(handle, max_lat, min_remote_lat, \
365                                  min_local_lat)                   \
366  false
367
368#endif /* BTM_SSR_INCLUDED */
369
370/* Extended Inquiry Response */
371extern void btsnd_hcic_write_ext_inquiry_response(void* buffer,
372                                                  uint8_t fec_req);
373
374#define HCIC_PARAM_SIZE_EXT_INQ_RESP 241
375
376#define HCIC_EXT_INQ_RESP_FEC_OFF 0
377#define HCIC_EXT_INQ_RESP_RESPONSE 1
378/* IO Capabilities Response */
379extern void btsnd_hcic_io_cap_req_reply(BD_ADDR bd_addr, uint8_t capability,
380                                        uint8_t oob_present, uint8_t auth_req);
381
382#define HCIC_PARAM_SIZE_IO_CAP_RESP 9
383
384#define HCI_IO_CAP_BD_ADDR_OFF 0
385#define HCI_IO_CAPABILITY_OFF 6
386#define HCI_IO_CAP_OOB_DATA_OFF 7
387#define HCI_IO_CAP_AUTH_REQ_OFF 8
388
389/* IO Capabilities Req Neg Reply */
390extern void btsnd_hcic_io_cap_req_neg_reply(BD_ADDR bd_addr, uint8_t err_code);
391
392#define HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY 7
393
394#define HCI_IO_CAP_NR_BD_ADDR_OFF 0
395#define HCI_IO_CAP_NR_ERR_CODE 6
396
397/* Read Local OOB Data */
398extern void btsnd_hcic_read_local_oob_data(void);
399
400#define HCIC_PARAM_SIZE_R_LOCAL_OOB 0
401
402extern void btsnd_hcic_user_conf_reply(BD_ADDR bd_addr, bool is_yes);
403
404#define HCIC_PARAM_SIZE_UCONF_REPLY 6
405
406#define HCI_USER_CONF_BD_ADDR_OFF 0
407
408extern void btsnd_hcic_user_passkey_reply(BD_ADDR bd_addr, uint32_t value);
409
410#define HCIC_PARAM_SIZE_U_PKEY_REPLY 10
411
412#define HCI_USER_PASSKEY_BD_ADDR_OFF 0
413#define HCI_USER_PASSKEY_VALUE_OFF 6
414
415extern void btsnd_hcic_user_passkey_neg_reply(BD_ADDR bd_addr);
416
417#define HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY 6
418
419#define HCI_USER_PASSKEY_NEG_BD_ADDR_OFF 0
420
421/* Remote OOB Data Request Reply */
422extern void btsnd_hcic_rem_oob_reply(BD_ADDR bd_addr, uint8_t* p_c,
423                                     uint8_t* p_r);
424
425#define HCIC_PARAM_SIZE_REM_OOB_REPLY 38
426
427#define HCI_REM_OOB_DATA_BD_ADDR_OFF 0
428#define HCI_REM_OOB_DATA_C_OFF 6
429#define HCI_REM_OOB_DATA_R_OFF 22
430
431/* Remote OOB Data Request Negative Reply */
432extern void btsnd_hcic_rem_oob_neg_reply(BD_ADDR bd_addr);
433
434#define HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY 6
435
436#define HCI_REM_OOB_DATA_NEG_BD_ADDR_OFF 0
437
438/* Read Tx Power Level */
439extern void btsnd_hcic_read_inq_tx_power(void);
440
441#define HCIC_PARAM_SIZE_R_TX_POWER 0
442
443/* Read Default Erroneous Data Reporting */
444extern void btsnd_hcic_read_default_erroneous_data_rpt(void);
445
446#define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0
447
448#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
449extern void btsnd_hcic_enhanced_flush(uint16_t handle, uint8_t packet_type);
450
451#define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3
452#endif
453
454extern void btsnd_hcic_send_keypress_notif(BD_ADDR bd_addr, uint8_t notif);
455
456#define HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF 7
457
458#define HCI_SEND_KEYPRESS_NOTIF_BD_ADDR_OFF 0
459#define HCI_SEND_KEYPRESS_NOTIF_NOTIF_OFF 6
460
461/**** end of Simple Pairing Commands ****/
462
463/* Store Current Settings */
464#define MAX_FILT_COND (sizeof(BD_ADDR) + 1)
465
466extern void btsnd_hcic_set_event_filter(uint8_t filt_type,
467                                        uint8_t filt_cond_type,
468                                        uint8_t* filt_cond,
469                                        uint8_t filt_cond_len);
470
471#define HCIC_PARAM_SIZE_SET_EVT_FILTER 9
472
473#define HCI_FILT_COND_FILT_TYPE_OFF 0
474#define HCI_FILT_COND_COND_TYPE_OFF 1
475#define HCI_FILT_COND_FILT_OFF 2
476/* Set Event Filter */
477
478/* Delete Stored Key */
479extern void btsnd_hcic_delete_stored_key(BD_ADDR bd_addr, bool delete_all_flag);
480
481#define HCIC_PARAM_SIZE_DELETE_STORED_KEY 7
482
483#define HCI_DELETE_KEY_BD_ADDR_OFF 0
484#define HCI_DELETE_KEY_ALL_FLAG_OFF 6
485/* Delete Stored Key */
486
487/* Change Local Name */
488extern void btsnd_hcic_change_name(BD_NAME name);
489
490#define HCIC_PARAM_SIZE_CHANGE_NAME BD_NAME_LEN
491
492#define HCI_CHANGE_NAME_NAME_OFF 0
493/* Change Local Name */
494
495#define HCIC_PARAM_SIZE_READ_CMD 0
496
497#define HCIC_PARAM_SIZE_WRITE_PARAM1 1
498
499#define HCIC_WRITE_PARAM1_PARAM_OFF 0
500
501#define HCIC_PARAM_SIZE_WRITE_PARAM2 2
502
503#define HCIC_WRITE_PARAM2_PARAM_OFF 0
504
505#define HCIC_PARAM_SIZE_WRITE_PARAM3 3
506
507#define HCIC_WRITE_PARAM3_PARAM_OFF 0
508
509#define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
510
511extern void btsnd_hcic_write_pin_type(uint8_t type);    /* Write PIN Type */
512extern void btsnd_hcic_write_auto_accept(uint8_t flag); /* Write Auto Accept */
513extern void btsnd_hcic_read_name(void);                 /* Read Local Name */
514extern void btsnd_hcic_write_page_tout(
515    uint16_t timeout);                                  /* Write Page Timout */
516extern void btsnd_hcic_write_scan_enable(uint8_t flag); /* Write Scan Enable */
517extern void btsnd_hcic_write_pagescan_cfg(
518    uint16_t interval, uint16_t window); /* Write Page Scan Activity */
519
520#define HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG 4
521
522#define HCI_SCAN_CFG_INTERVAL_OFF 0
523#define HCI_SCAN_CFG_WINDOW_OFF 2
524/* Write Page Scan Activity */
525
526/* Write Inquiry Scan Activity */
527extern void btsnd_hcic_write_inqscan_cfg(uint16_t interval, uint16_t window);
528
529#define HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG 4
530
531#define HCI_SCAN_CFG_INTERVAL_OFF 0
532#define HCI_SCAN_CFG_WINDOW_OFF 2
533/* Write Inquiry Scan Activity */
534
535extern void btsnd_hcic_write_auth_enable(
536    uint8_t flag); /* Write Authentication Enable */
537extern void btsnd_hcic_write_dev_class(
538    DEV_CLASS dev); /* Write Class of Device */
539extern void btsnd_hcic_write_voice_settings(
540    uint16_t flags); /* Write Voice Settings */
541
542/* Host Controller to Host flow control */
543#define HCI_HOST_FLOW_CTRL_OFF 0
544#define HCI_HOST_FLOW_CTRL_ACL_ON 1
545#define HCI_HOST_FLOW_CTRL_SCO_ON 2
546#define HCI_HOST_FLOW_CTRL_BOTH_ON 3
547
548extern void btsnd_hcic_write_auto_flush_tout(
549    uint16_t handle, uint16_t timeout); /* Write Retransmit Timout */
550
551#define HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT 4
552
553#define HCI_FLUSH_TOUT_HANDLE_OFF 0
554#define HCI_FLUSH_TOUT_TOUT_OFF 2
555
556extern void btsnd_hcic_read_tx_power(uint16_t handle,
557                                     uint8_t type); /* Read Tx Power */
558
559#define HCIC_PARAM_SIZE_READ_TX_POWER 3
560
561#define HCI_READ_TX_POWER_HANDLE_OFF 0
562#define HCI_READ_TX_POWER_TYPE_OFF 2
563
564/* Read transmit power level parameter */
565#define HCI_READ_CURRENT 0x00
566#define HCI_READ_MAXIMUM 0x01
567
568extern void btsnd_hcic_host_num_xmitted_pkts(
569    uint8_t num_handles, uint16_t* handle,
570    uint16_t* num_pkts); /* Set Host Buffer Size */
571
572#define HCIC_PARAM_SIZE_NUM_PKTS_DONE_SIZE sizeof(btmsg_hcic_num_pkts_done_t)
573
574#define MAX_DATA_HANDLES 10
575
576#define HCI_PKTS_DONE_NUM_HANDLES_OFF 0
577#define HCI_PKTS_DONE_HANDLE_OFF 1
578#define HCI_PKTS_DONE_NUM_PKTS_OFF 3
579
580/* Write Link Supervision Timeout */
581extern void btsnd_hcic_write_link_super_tout(uint8_t local_controller_id,
582                                             uint16_t handle, uint16_t timeout);
583
584#define HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT 4
585
586#define HCI_LINK_SUPER_TOUT_HANDLE_OFF 0
587#define HCI_LINK_SUPER_TOUT_TOUT_OFF 2
588/* Write Link Supervision Timeout */
589
590extern void btsnd_hcic_write_cur_iac_lap(
591    uint8_t num_cur_iac, LAP* const iac_lap); /* Write Current IAC LAP */
592
593#define MAX_IAC_LAPS 0x40
594
595#define HCI_WRITE_IAC_LAP_NUM_OFF 0
596#define HCI_WRITE_IAC_LAP_LAP_OFF 1
597/* Write Current IAC LAP */
598
599extern void btsnd_hcic_get_link_quality(uint16_t handle); /* Get Link Quality */
600extern void btsnd_hcic_read_rssi(uint16_t handle);        /* Read RSSI */
601extern void btsnd_hcic_enable_test_mode(
602    void); /* Enable Device Under Test Mode */
603extern void btsnd_hcic_write_pagescan_type(
604    uint8_t type); /* Write Page Scan Type */
605extern void btsnd_hcic_write_inqscan_type(
606    uint8_t type); /* Write Inquiry Scan Type */
607extern void btsnd_hcic_write_inquiry_mode(
608    uint8_t type); /* Write Inquiry Mode */
609
610#define HCI_DATA_HANDLE_MASK 0x0FFF
611
612#define HCID_GET_HANDLE_EVENT(p)                     \
613  (uint16_t)((*((uint8_t*)((p) + 1) + (p)->offset) + \
614              (*((uint8_t*)((p) + 1) + (p)->offset + 1) << 8)))
615
616#define HCID_GET_HANDLE(u16) (uint16_t)((u16)&HCI_DATA_HANDLE_MASK)
617
618#define HCI_DATA_EVENT_MASK 3
619#define HCI_DATA_EVENT_OFFSET 12
620#define HCID_GET_EVENT(u16) \
621  (uint8_t)(((u16) >> HCI_DATA_EVENT_OFFSET) & HCI_DATA_EVENT_MASK)
622
623#define HCI_DATA_BCAST_MASK 3
624#define HCI_DATA_BCAST_OFFSET 10
625#define HCID_GET_BCAST(u16) \
626  (uint8_t)(((u16) >> HCI_DATA_BCAST_OFFSET) & HCI_DATA_BCAST_MASK)
627
628#define HCID_GET_ACL_LEN(p)                              \
629  (uint16_t)((*((uint8_t*)((p) + 1) + (p)->offset + 2) + \
630              (*((uint8_t*)((p) + 1) + (p)->offset + 3) << 8)))
631
632#define HCID_HEADER_SIZE 4
633
634#define HCID_GET_SCO_LEN(p) (*((uint8_t*)((p) + 1) + (p)->offset + 2))
635
636extern void btsnd_hcic_vendor_spec_cmd(void* buffer, uint16_t opcode,
637                                       uint8_t len, uint8_t* p_data,
638                                       void* p_cmd_cplt_cback);
639
640/*******************************************************************************
641 * BLE Commands
642 *      Note: "local_controller_id" is for transport, not counted in HCI
643 *             message size
644 ******************************************************************************/
645#define HCIC_BLE_RAND_DI_SIZE 8
646#define HCIC_BLE_ENCRYT_KEY_SIZE 16
647#define HCIC_BLE_IRK_SIZE 16
648
649#define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
650#define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
651#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
652#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
653#define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
654#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
655#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE 2
656#define HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN 25
657#define HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL 0
658#define HCIC_PARAM_SIZE_CLEAR_WHITE_LIST 0
659#define HCIC_PARAM_SIZE_ADD_WHITE_LIST 7
660#define HCIC_PARAM_SIZE_REMOVE_WHITE_LIST 7
661#define HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS 14
662#define HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS 5
663#define HCIC_PARAM_SIZE_READ_CHNL_MAP 2
664#define HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT 2
665#define HCIC_PARAM_SIZE_BLE_ENCRYPT 32
666#define HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED 2
667
668#define HCIC_BLE_RAND_DI_SIZE 8
669#define HCIC_BLE_ENCRYT_KEY_SIZE 16
670#define HCIC_PARAM_SIZE_BLE_START_ENC \
671  (4 + HCIC_BLE_RAND_DI_SIZE + HCIC_BLE_ENCRYT_KEY_SIZE)
672#define HCIC_PARAM_SIZE_LTK_REQ_REPLY (2 + HCIC_BLE_ENCRYT_KEY_SIZE)
673#define HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY 2
674#define HCIC_BLE_CHNL_MAP_SIZE 5
675#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31
676
677#define HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST (7 + HCIC_BLE_IRK_SIZE * 2)
678#define HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST 7
679#define HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE 8
680#define HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST 0
681#define HCIC_PARAM_SIZE_BLE_READ_RESOLVING_LIST_SIZE 0
682#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER 7
683#define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL 7
684#define HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE 1
685#define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2
686#define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
687#define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
688
689/* ULP HCI command */
690extern void btsnd_hcic_ble_set_evt_mask(BT_EVENT_MASK event_mask);
691
692extern void btsnd_hcic_ble_read_buffer_size(void);
693
694extern void btsnd_hcic_ble_read_local_spt_feat(void);
695
696extern void btsnd_hcic_ble_set_local_used_feat(uint8_t feat_set[8]);
697
698extern void btsnd_hcic_ble_set_random_addr(BD_ADDR random_addr);
699
700extern void btsnd_hcic_ble_write_adv_params(
701    uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type,
702    uint8_t addr_type_own, uint8_t addr_type_dir, BD_ADDR direct_bda,
703    uint8_t channel_map, uint8_t adv_filter_policy);
704
705extern void btsnd_hcic_ble_read_adv_chnl_tx_power(void);
706
707extern void btsnd_hcic_ble_set_adv_data(uint8_t data_len, uint8_t* p_data);
708
709extern void btsnd_hcic_ble_set_scan_rsp_data(uint8_t data_len,
710                                             uint8_t* p_scan_rsp);
711
712extern void btsnd_hcic_ble_set_adv_enable(uint8_t adv_enable);
713
714extern void btsnd_hcic_ble_set_scan_params(uint8_t scan_type, uint16_t scan_int,
715                                           uint16_t scan_win, uint8_t addr_type,
716                                           uint8_t scan_filter_policy);
717
718extern void btsnd_hcic_ble_set_scan_enable(uint8_t scan_enable,
719                                           uint8_t duplicate);
720
721extern void btsnd_hcic_ble_create_ll_conn(
722    uint16_t scan_int, uint16_t scan_win, uint8_t init_filter_policy,
723    uint8_t addr_type_peer, BD_ADDR bda_peer, uint8_t addr_type_own,
724    uint16_t conn_int_min, uint16_t conn_int_max, uint16_t conn_latency,
725    uint16_t conn_timeout, uint16_t min_ce_len, uint16_t max_ce_len);
726
727extern void btsnd_hcic_ble_create_conn_cancel(void);
728
729extern void btsnd_hcic_ble_read_white_list_size(void);
730
731extern void btsnd_hcic_ble_clear_white_list(void);
732
733extern void btsnd_hcic_ble_add_white_list(uint8_t addr_type, BD_ADDR bda);
734
735extern void btsnd_hcic_ble_remove_from_white_list(uint8_t addr_type,
736                                                  BD_ADDR bda);
737
738extern void btsnd_hcic_ble_upd_ll_conn_params(
739    uint16_t handle, uint16_t conn_int_min, uint16_t conn_int_max,
740    uint16_t conn_latency, uint16_t conn_timeout, uint16_t min_len,
741    uint16_t max_len);
742
743extern void btsnd_hcic_ble_set_host_chnl_class(
744    uint8_t chnl_map[HCIC_BLE_CHNL_MAP_SIZE]);
745
746extern void btsnd_hcic_ble_read_chnl_map(uint16_t handle);
747
748extern void btsnd_hcic_ble_read_remote_feat(uint16_t handle);
749
750extern void btsnd_hcic_ble_encrypt(uint8_t* key, uint8_t key_len,
751                                   uint8_t* plain_text, uint8_t pt_len,
752                                   void* p_cmd_cplt_cback);
753
754extern void btsnd_hcic_ble_rand(base::Callback<void(BT_OCTET8)> cb);
755
756extern void btsnd_hcic_ble_start_enc(uint16_t handle,
757                                     uint8_t rand[HCIC_BLE_RAND_DI_SIZE],
758                                     uint16_t ediv,
759                                     uint8_t ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
760
761extern void btsnd_hcic_ble_ltk_req_reply(uint16_t handle,
762                                         uint8_t ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
763
764extern void btsnd_hcic_ble_ltk_req_neg_reply(uint16_t handle);
765
766extern void btsnd_hcic_ble_read_supported_states(void);
767
768extern void btsnd_hcic_ble_write_host_supported(uint8_t le_host_spt,
769                                                uint8_t simul_le_host_spt);
770
771extern void btsnd_hcic_ble_read_host_supported(void);
772
773extern void btsnd_hcic_ble_receiver_test(uint8_t rx_freq);
774
775extern void btsnd_hcic_ble_transmitter_test(uint8_t tx_freq,
776                                            uint8_t test_data_len,
777                                            uint8_t payload);
778extern void btsnd_hcic_ble_test_end(void);
779
780#if (BLE_LLT_INCLUDED == TRUE)
781
782#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14
783extern void btsnd_hcic_ble_rc_param_req_reply(
784    uint16_t handle, uint16_t conn_int_min, uint16_t conn_int_max,
785    uint16_t conn_latency, uint16_t conn_timeout, uint16_t min_ce_len,
786    uint16_t max_ce_len);
787
788#define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3
789extern void btsnd_hcic_ble_rc_param_req_neg_reply(uint16_t handle,
790                                                  uint8_t reason);
791
792#endif /* BLE_LLT_INCLUDED */
793
794extern void btsnd_hcic_ble_set_data_length(uint16_t conn_handle,
795                                           uint16_t tx_octets,
796                                           uint16_t tx_time);
797
798extern void btsnd_hcic_ble_add_device_resolving_list(
799    uint8_t addr_type_peer, BD_ADDR bda_peer,
800    uint8_t irk_peer[HCIC_BLE_IRK_SIZE], uint8_t irk_local[HCIC_BLE_IRK_SIZE]);
801
802struct scanning_phy_cfg {
803  uint8_t scan_type;
804  uint16_t scan_int;
805  uint16_t scan_win;
806};
807
808extern void btsnd_hcic_ble_set_extended_scan_params(
809    uint8_t own_address_type, uint8_t scanning_filter_policy,
810    uint8_t scanning_phys, scanning_phy_cfg* phy_cfg);
811
812extern void btsnd_hcic_ble_set_extended_scan_enable(uint8_t enable,
813                                                    uint8_t filter_duplicates,
814                                                    uint16_t duration,
815                                                    uint16_t period);
816
817struct EXT_CONN_PHY_CFG {
818  uint16_t scan_int;
819  uint16_t scan_win;
820  uint16_t conn_int_min;
821  uint16_t conn_int_max;
822  uint16_t conn_latency;
823  uint16_t sup_timeout;
824  uint16_t min_ce_len;
825  uint16_t max_ce_len;
826};
827
828extern void btsnd_hcic_ble_ext_create_conn(
829    uint8_t init_filter_policy, uint8_t addr_type_own, uint8_t addr_type_peer,
830    BD_ADDR bda_peer, uint8_t initiating_phys, EXT_CONN_PHY_CFG* phy_cfg);
831
832extern void btsnd_hcic_ble_add_device_resolving_list(
833    uint8_t addr_type_peer, BD_ADDR bda_peer,
834    uint8_t irk_peer[HCIC_BLE_IRK_SIZE], uint8_t irk_local[HCIC_BLE_IRK_SIZE]);
835
836extern void btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer,
837                                                    BD_ADDR bda_peer);
838
839extern void btsnd_hcic_ble_set_privacy_mode(uint8_t addr_type_peer,
840                                            BD_ADDR bda_peer,
841                                            uint8_t privacy_type);
842
843extern void btsnd_hcic_ble_clear_resolving_list(void);
844
845extern void btsnd_hcic_ble_read_resolvable_addr_peer(uint8_t addr_type_peer,
846                                                     BD_ADDR bda_peer);
847
848extern void btsnd_hcic_ble_read_resolvable_addr_local(uint8_t addr_type_peer,
849                                                      BD_ADDR bda_peer);
850
851extern void btsnd_hcic_ble_set_addr_resolution_enable(
852    uint8_t addr_resolution_enable);
853
854extern void btsnd_hcic_ble_set_rand_priv_addr_timeout(uint16_t rpa_timout);
855
856extern void btsnd_hcic_read_authenticated_payload_tout(uint16_t handle);
857
858extern void btsnd_hcic_write_authenticated_payload_tout(uint16_t handle,
859                                                        uint16_t timeout);
860
861#define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
862
863#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0
864#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_TOUT_OFF 2
865
866#endif
867