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