1 /******************************************************************************
3 * Copyright (C) 1999-2012 Broadcom Corporation
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ******************************************************************************/
22 #include "bt_target.h"
26 void bte_main_hci_send(BT_HDR *p_msg, UINT16 event);
27 void bte_main_lpm_allow_bt_device_sleep(void);
29 /* Message by message.... */
31 extern BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration,
34 #define HCIC_PARAM_SIZE_INQUIRY 5
37 #define HCIC_INQ_INQ_LAP_OFF 0
38 #define HCIC_INQ_DUR_OFF 3
39 #define HCIC_INQ_RSP_CNT_OFF 4
43 extern BOOLEAN btsnd_hcic_inq_cancel(void);
45 #define HCIC_PARAM_SIZE_INQ_CANCEL 0
47 /* Periodic Inquiry Mode */
48 extern BOOLEAN btsnd_hcic_per_inq_mode(UINT16 max_period, UINT16 min_period,
49 const LAP inq_lap, UINT8 duration,
52 #define HCIC_PARAM_SIZE_PER_INQ_MODE 9
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 */
61 /* Exit Periodic Inquiry Mode */
62 extern BOOLEAN btsnd_hcic_exit_per_inq(void);
64 #define HCIC_PARAM_SIZE_EXIT_PER_INQ 0
65 /* Create Connection */
66 extern BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types,
67 UINT8 page_scan_rep_mode,
72 #define HCIC_PARAM_SIZE_CREATE_CONN 13
74 #define HCIC_CR_CONN_BD_ADDR_OFF 0
75 #define HCIC_CR_CONN_PKT_TYPES_OFF 6
76 #define HCIC_CR_CONN_REP_MODE_OFF 8
77 #define HCIC_CR_CONN_PAGE_SCAN_MODE_OFF 9
78 #define HCIC_CR_CONN_CLK_OFF_OFF 10
79 #define HCIC_CR_CONN_ALLOW_SWITCH_OFF 12
80 /* Create Connection */
83 extern BOOLEAN btsnd_hcic_disconnect(UINT16 handle, UINT8 reason);
85 #define HCIC_PARAM_SIZE_DISCONNECT 3
87 #define HCI_DISC_HANDLE_OFF 0
88 #define HCI_DISC_REASON_OFF 2
91 #if BTM_SCO_INCLUDED == TRUE
92 /* Add SCO Connection */
93 extern BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types);
94 #endif /* BTM_SCO_INCLUDED */
96 #define HCIC_PARAM_SIZE_ADD_SCO_CONN 4
98 #define HCI_ADD_SCO_HANDLE_OFF 0
99 #define HCI_ADD_SCO_PACKET_TYPES_OFF 2
100 /* Add SCO Connection */
102 /* Create Connection Cancel */
103 extern BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest);
105 #define HCIC_PARAM_SIZE_CREATE_CONN_CANCEL 6
107 #define HCIC_CR_CONN_CANCEL_BD_ADDR_OFF 0
108 /* Create Connection Cancel */
110 /* Accept Connection Request */
111 extern BOOLEAN btsnd_hcic_accept_conn (BD_ADDR bd_addr, UINT8 role);
113 #define HCIC_PARAM_SIZE_ACCEPT_CONN 7
115 #define HCI_ACC_CONN_BD_ADDR_OFF 0
116 #define HCI_ACC_CONN_ROLE_OFF 6
117 /* Accept Connection Request */
119 /* Reject Connection Request */
120 extern BOOLEAN btsnd_hcic_reject_conn (BD_ADDR bd_addr, UINT8 reason);
122 #define HCIC_PARAM_SIZE_REJECT_CONN 7
124 #define HCI_REJ_CONN_BD_ADDR_OFF 0
125 #define HCI_REJ_CONN_REASON_OFF 6
126 /* Reject Connection Request */
128 /* Link Key Request Reply */
129 extern BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr,
132 #define HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY 22
134 #define HCI_LINK_KEY_REPLY_BD_ADDR_OFF 0
135 #define HCI_LINK_KEY_REPLY_LINK_KEY_OFF 6
136 /* Link Key Request Reply */
138 /* Link Key Request Neg Reply */
139 extern BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr);
141 #define HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY 6
143 #define HCI_LINK_KEY_NEG_REP_BD_ADR_OFF 0
144 /* Link Key Request Neg Reply */
146 /* PIN Code Request Reply */
147 extern BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr,
151 #define HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY 23
153 #define HCI_PIN_CODE_REPLY_BD_ADDR_OFF 0
154 #define HCI_PIN_CODE_REPLY_PIN_LEN_OFF 6
155 #define HCI_PIN_CODE_REPLY_PIN_CODE_OFF 7
156 /* PIN Code Request Reply */
158 /* Link Key Request Neg Reply */
159 extern BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr);
161 #define HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY 6
163 #define HCI_PIN_CODE_NEG_REP_BD_ADR_OFF 0
164 /* Link Key Request Neg Reply */
166 /* Change Connection Type */
167 extern BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types);
169 #define HCIC_PARAM_SIZE_CHANGE_CONN_TYPE 4
171 #define HCI_CHNG_PKT_TYPE_HANDLE_OFF 0
172 #define HCI_CHNG_PKT_TYPE_PKT_TYPE_OFF 2
173 /* Change Connection Type */
175 #define HCIC_PARAM_SIZE_CMD_HANDLE 2
177 #define HCI_CMD_HANDLE_HANDLE_OFF 0
179 extern BOOLEAN btsnd_hcic_auth_request (UINT16 handle); /* Authentication Request */
181 /* Set Connection Encryption */
182 extern BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable);
183 #define HCIC_PARAM_SIZE_SET_CONN_ENCRYPT 3
186 #define HCI_SET_ENCRYPT_HANDLE_OFF 0
187 #define HCI_SET_ENCRYPT_ENABLE_OFF 2
188 /* Set Connection Encryption */
190 extern BOOLEAN btsnd_hcic_change_link_key (UINT16 handle); /* Change Connection Link Key */
192 /* Master Link Key */
193 extern BOOLEAN btsnd_hcic_master_link_key (BOOLEAN key_flag);
195 #define HCIC_PARAM_SIZE_MASTER_LINK_KEY 1
197 #define HCI_MASTER_KEY_FLAG_OFF 0
198 /* Master Link Key */
200 /* Remote Name Request */
201 extern BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr,
202 UINT8 page_scan_rep_mode,
203 UINT8 page_scan_mode,
204 UINT16 clock_offset);
206 #define HCIC_PARAM_SIZE_RMT_NAME_REQ 10
208 #define HCI_RMT_NAME_BD_ADDR_OFF 0
209 #define HCI_RMT_NAME_REP_MODE_OFF 6
210 #define HCI_RMT_NAME_PAGE_SCAN_MODE_OFF 7
211 #define HCI_RMT_NAME_CLK_OFF_OFF 8
212 /* Remote Name Request */
214 /* Remote Name Request Cancel */
215 extern BOOLEAN btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr);
217 #define HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL 6
219 #define HCI_RMT_NAME_CANCEL_BD_ADDR_OFF 0
220 /* Remote Name Request Cancel */
222 extern BOOLEAN btsnd_hcic_rmt_features_req(UINT16 handle); /* Remote Features Request */
224 /* Remote Extended Features */
225 extern BOOLEAN btsnd_hcic_rmt_ext_features(UINT16 handle, UINT8 page_num);
227 #define HCIC_PARAM_SIZE_RMT_EXT_FEATURES 3
229 #define HCI_RMT_EXT_FEATURES_HANDLE_OFF 0
230 #define HCI_RMT_EXT_FEATURES_PAGE_NUM_OFF 2
231 /* Remote Extended Features */
234 extern BOOLEAN btsnd_hcic_rmt_ver_req(UINT16 handle); /* Remote Version Info Request */
235 extern BOOLEAN btsnd_hcic_read_rmt_clk_offset(UINT16 handle); /* Remote Clock Offset */
236 extern BOOLEAN btsnd_hcic_read_lmp_handle(UINT16 handle); /* Remote LMP Handle */
238 extern BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle,
239 UINT32 tx_bw, UINT32 rx_bw,
240 UINT16 max_latency, UINT16 voice,
241 UINT8 retrans_effort,
242 UINT16 packet_types);
243 #define HCIC_PARAM_SIZE_SETUP_ESCO 17
245 #define HCI_SETUP_ESCO_HANDLE_OFF 0
246 #define HCI_SETUP_ESCO_TX_BW_OFF 2
247 #define HCI_SETUP_ESCO_RX_BW_OFF 6
248 #define HCI_SETUP_ESCO_MAX_LAT_OFF 10
249 #define HCI_SETUP_ESCO_VOICE_OFF 12
250 #define HCI_SETUP_ESCO_RETRAN_EFF_OFF 14
251 #define HCI_SETUP_ESCO_PKT_TYPES_OFF 15
254 extern BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr,
255 UINT32 tx_bw, UINT32 rx_bw,
258 UINT8 retrans_effort,
259 UINT16 packet_types);
260 #define HCIC_PARAM_SIZE_ACCEPT_ESCO 21
262 #define HCI_ACCEPT_ESCO_BDADDR_OFF 0
263 #define HCI_ACCEPT_ESCO_TX_BW_OFF 6
264 #define HCI_ACCEPT_ESCO_RX_BW_OFF 10
265 #define HCI_ACCEPT_ESCO_MAX_LAT_OFF 14
266 #define HCI_ACCEPT_ESCO_VOICE_OFF 16
267 #define HCI_ACCEPT_ESCO_RETRAN_EFF_OFF 18
268 #define HCI_ACCEPT_ESCO_PKT_TYPES_OFF 19
271 extern BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason);
272 #define HCIC_PARAM_SIZE_REJECT_ESCO 7
274 #define HCI_REJECT_ESCO_BDADDR_OFF 0
275 #define HCI_REJECT_ESCO_REASON_OFF 6
278 extern BOOLEAN btsnd_hcic_hold_mode(UINT16 handle, UINT16 max_hold_period,
279 UINT16 min_hold_period);
281 #define HCIC_PARAM_SIZE_HOLD_MODE 6
283 #define HCI_HOLD_MODE_HANDLE_OFF 0
284 #define HCI_HOLD_MODE_MAX_PER_OFF 2
285 #define HCI_HOLD_MODE_MIN_PER_OFF 4
289 extern BOOLEAN btsnd_hcic_sniff_mode(UINT16 handle,
290 UINT16 max_sniff_period,
291 UINT16 min_sniff_period,
292 UINT16 sniff_attempt,
293 UINT16 sniff_timeout);
295 #define HCIC_PARAM_SIZE_SNIFF_MODE 10
298 #define HCI_SNIFF_MODE_HANDLE_OFF 0
299 #define HCI_SNIFF_MODE_MAX_PER_OFF 2
300 #define HCI_SNIFF_MODE_MIN_PER_OFF 4
301 #define HCI_SNIFF_MODE_ATTEMPT_OFF 6
302 #define HCI_SNIFF_MODE_TIMEOUT_OFF 8
305 extern BOOLEAN btsnd_hcic_exit_sniff_mode(UINT16 handle); /* Exit Sniff Mode */
308 extern BOOLEAN btsnd_hcic_park_mode (UINT16 handle,
309 UINT16 beacon_max_interval,
310 UINT16 beacon_min_interval);
312 #define HCIC_PARAM_SIZE_PARK_MODE 6
314 #define HCI_PARK_MODE_HANDLE_OFF 0
315 #define HCI_PARK_MODE_MAX_PER_OFF 2
316 #define HCI_PARK_MODE_MIN_PER_OFF 4
319 extern BOOLEAN btsnd_hcic_exit_park_mode(UINT16 handle); /* Exit Park Mode */
322 extern BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags,
324 UINT32 token_rate, UINT32 peak,
325 UINT32 latency, UINT32 delay_var);
327 #define HCIC_PARAM_SIZE_QOS_SETUP 20
329 #define HCI_QOS_HANDLE_OFF 0
330 #define HCI_QOS_FLAGS_OFF 2
331 #define HCI_QOS_SERVICE_TYPE_OFF 3
332 #define HCI_QOS_TOKEN_RATE_OFF 4
333 #define HCI_QOS_PEAK_BANDWIDTH_OFF 8
334 #define HCI_QOS_LATENCY_OFF 12
335 #define HCI_QOS_DELAY_VAR_OFF 16
338 /* Switch Role Request */
339 extern BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role);
341 #define HCIC_PARAM_SIZE_SWITCH_ROLE 7
343 #define HCI_SWITCH_BD_ADDR_OFF 0
344 #define HCI_SWITCH_ROLE_OFF 6
345 /* Switch Role Request */
347 extern BOOLEAN btsnd_hcic_read_policy_set(UINT16 handle); /* Read Policy Settings */
349 /* Write Policy Settings */
350 extern BOOLEAN btsnd_hcic_write_policy_set(UINT16 handle, UINT16 settings);
352 #define HCIC_PARAM_SIZE_WRITE_POLICY_SET 4
354 #define HCI_WRITE_POLICY_HANDLE_OFF 0
355 #define HCI_WRITE_POLICY_SETTINGS_OFF 2
356 /* Write Policy Settings */
358 /* Write Default Policy Settings */
359 extern BOOLEAN btsnd_hcic_write_def_policy_set(UINT16 settings);
361 #define HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET 2
363 #define HCI_WRITE_DEF_POLICY_SETTINGS_OFF 0
364 /* Write Default Policy Settings */
366 /******************************************
368 *******************************************/
369 #if BTM_SSR_INCLUDED == TRUE
370 /* Sniff Subrating */
371 extern BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
372 UINT16 min_remote_lat,
373 UINT16 min_local_lat);
375 #define HCIC_PARAM_SIZE_SNIFF_SUB_RATE 8
377 #define HCI_SNIFF_SUB_RATE_HANDLE_OFF 0
378 #define HCI_SNIFF_SUB_RATE_MAX_LAT_OFF 2
379 #define HCI_SNIFF_SUB_RATE_MIN_REM_LAT_OFF 4
380 #define HCI_SNIFF_SUB_RATE_MIN_LOC_LAT_OFF 6
381 /* Sniff Subrating */
383 #else /* BTM_SSR_INCLUDED == FALSE */
385 #define btsnd_hcic_sniff_sub_rate(handle, max_lat, min_remote_lat, min_local_lat) FALSE
387 #endif /* BTM_SSR_INCLUDED */
389 /* Extended Inquiry Response */
390 #if (BTM_EIR_SERVER_INCLUDED == TRUE)
391 extern void btsnd_hcic_write_ext_inquiry_response(void *buffer, UINT8 fec_req);
393 #define HCIC_PARAM_SIZE_EXT_INQ_RESP 241
395 #define HCIC_EXT_INQ_RESP_FEC_OFF 0
396 #define HCIC_EXT_INQ_RESP_RESPONSE 1
399 #define btsnd_hcic_write_ext_inquiry_response(buffer, fec_req)
402 /* IO Capabilities Response */
403 extern BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability,
404 UINT8 oob_present, UINT8 auth_req);
406 #define HCIC_PARAM_SIZE_IO_CAP_RESP 9
408 #define HCI_IO_CAP_BD_ADDR_OFF 0
409 #define HCI_IO_CAPABILITY_OFF 6
410 #define HCI_IO_CAP_OOB_DATA_OFF 7
411 #define HCI_IO_CAP_AUTH_REQ_OFF 8
413 /* IO Capabilities Req Neg Reply */
414 extern BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code);
416 #define HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY 7
418 #define HCI_IO_CAP_NR_BD_ADDR_OFF 0
419 #define HCI_IO_CAP_NR_ERR_CODE 6
421 /* Read Local OOB Data */
422 extern BOOLEAN btsnd_hcic_read_local_oob_data (void);
424 #define HCIC_PARAM_SIZE_R_LOCAL_OOB 0
427 extern BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes);
429 #define HCIC_PARAM_SIZE_UCONF_REPLY 6
431 #define HCI_USER_CONF_BD_ADDR_OFF 0
434 extern BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value);
436 #define HCIC_PARAM_SIZE_U_PKEY_REPLY 10
438 #define HCI_USER_PASSKEY_BD_ADDR_OFF 0
439 #define HCI_USER_PASSKEY_VALUE_OFF 6
442 extern BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr);
444 #define HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY 6
446 #define HCI_USER_PASSKEY_NEG_BD_ADDR_OFF 0
448 /* Remote OOB Data Request Reply */
449 extern BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c,
452 #define HCIC_PARAM_SIZE_REM_OOB_REPLY 38
454 #define HCI_REM_OOB_DATA_BD_ADDR_OFF 0
455 #define HCI_REM_OOB_DATA_C_OFF 6
456 #define HCI_REM_OOB_DATA_R_OFF 22
458 /* Remote OOB Data Request Negative Reply */
459 extern BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr);
461 #define HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY 6
463 #define HCI_REM_OOB_DATA_NEG_BD_ADDR_OFF 0
465 /* Read Tx Power Level */
466 extern BOOLEAN btsnd_hcic_read_inq_tx_power (void);
468 #define HCIC_PARAM_SIZE_R_TX_POWER 0
470 /* Write Tx Power Level */
471 extern BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 level);
473 #define HCIC_PARAM_SIZE_W_TX_POWER 1
475 #define HCIC_WRITE_TX_POWER_LEVEL_OFF 0
476 /* Read Default Erroneous Data Reporting */
477 extern BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void);
479 #define HCIC_PARAM_SIZE_R_ERR_DATA_RPT 0
481 #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
482 extern BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type);
484 #define HCIC_PARAM_SIZE_ENHANCED_FLUSH 3
488 extern BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif);
490 #define HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF 7
492 #define HCI_SEND_KEYPRESS_NOTIF_BD_ADDR_OFF 0
493 #define HCI_SEND_KEYPRESS_NOTIF_NOTIF_OFF 6
495 /**** end of Simple Pairing Commands ****/
497 /* Store Current Settings */
498 #define MAX_FILT_COND (sizeof (BD_ADDR) + 1)
500 extern BOOLEAN btsnd_hcic_set_event_filter(UINT8 filt_type,
501 UINT8 filt_cond_type,
503 UINT8 filt_cond_len);
505 #define HCIC_PARAM_SIZE_SET_EVT_FILTER 9
507 #define HCI_FILT_COND_FILT_TYPE_OFF 0
508 #define HCI_FILT_COND_COND_TYPE_OFF 1
509 #define HCI_FILT_COND_FILT_OFF 2
510 /* Set Event Filter */
512 /* Read Stored Key */
513 extern BOOLEAN btsnd_hcic_read_stored_key (BD_ADDR bd_addr,
514 BOOLEAN read_all_flag);
516 #define HCIC_PARAM_SIZE_READ_STORED_KEY 7
518 #define HCI_READ_KEY_BD_ADDR_OFF 0
519 #define HCI_READ_KEY_ALL_FLAG_OFF 6
520 /* Read Stored Key */
522 #define MAX_WRITE_KEYS 10
523 /* Write Stored Key */
524 extern BOOLEAN btsnd_hcic_write_stored_key (UINT8 num_keys, BD_ADDR *bd_addr,
527 #define HCIC_PARAM_SIZE_WRITE_STORED_KEY sizeof(btmsg_hcic_write_stored_key_t)
529 #define HCI_WRITE_KEY_NUM_KEYS_OFF 0
530 #define HCI_WRITE_KEY_BD_ADDR_OFF 1
531 #define HCI_WRITE_KEY_KEY_OFF 7
532 /* only 0x0b keys cab be sent in one HCI command */
533 #define HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD 0x0b
534 /* Write Stored Key */
536 /* Delete Stored Key */
537 extern BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag);
539 #define HCIC_PARAM_SIZE_DELETE_STORED_KEY 7
541 #define HCI_DELETE_KEY_BD_ADDR_OFF 0
542 #define HCI_DELETE_KEY_ALL_FLAG_OFF 6
543 /* Delete Stored Key */
545 /* Change Local Name */
546 extern BOOLEAN btsnd_hcic_change_name(BD_NAME name);
548 #define HCIC_PARAM_SIZE_CHANGE_NAME BD_NAME_LEN
550 #define HCI_CHANGE_NAME_NAME_OFF 0
551 /* Change Local Name */
554 #define HCIC_PARAM_SIZE_READ_CMD 0
556 #define HCIC_PARAM_SIZE_WRITE_PARAM1 1
558 #define HCIC_WRITE_PARAM1_PARAM_OFF 0
560 #define HCIC_PARAM_SIZE_WRITE_PARAM2 2
562 #define HCIC_WRITE_PARAM2_PARAM_OFF 0
564 #define HCIC_PARAM_SIZE_WRITE_PARAM3 3
566 #define HCIC_WRITE_PARAM3_PARAM_OFF 0
568 #define HCIC_PARAM_SIZE_SET_AFH_CHANNELS 10
570 extern BOOLEAN btsnd_hcic_write_pin_type(UINT8 type); /* Write PIN Type */
571 extern BOOLEAN btsnd_hcic_write_auto_accept(UINT8 flag); /* Write Auto Accept */
572 extern BOOLEAN btsnd_hcic_read_name (void); /* Read Local Name */
573 extern BOOLEAN btsnd_hcic_write_page_tout(UINT16 timeout); /* Write Page Timout */
574 extern BOOLEAN btsnd_hcic_write_scan_enable(UINT8 flag); /* Write Scan Enable */
575 extern BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval,
576 UINT16 window); /* Write Page Scan Activity */
578 #define HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG 4
580 #define HCI_SCAN_CFG_INTERVAL_OFF 0
581 #define HCI_SCAN_CFG_WINDOW_OFF 2
582 /* Write Page Scan Activity */
584 /* Write Inquiry Scan Activity */
585 extern BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window);
587 #define HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG 4
589 #define HCI_SCAN_CFG_INTERVAL_OFF 0
590 #define HCI_SCAN_CFG_WINDOW_OFF 2
591 /* Write Inquiry Scan Activity */
593 extern BOOLEAN btsnd_hcic_write_auth_enable(UINT8 flag); /* Write Authentication Enable */
594 extern BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev); /* Write Class of Device */
595 extern BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags); /* Write Voice Settings */
597 /* Host Controller to Host flow control */
598 #define HCI_HOST_FLOW_CTRL_OFF 0
599 #define HCI_HOST_FLOW_CTRL_ACL_ON 1
600 #define HCI_HOST_FLOW_CTRL_SCO_ON 2
601 #define HCI_HOST_FLOW_CTRL_BOTH_ON 3
603 extern BOOLEAN btsnd_hcic_write_auto_flush_tout(UINT16 handle,
604 UINT16 timeout); /* Write Retransmit Timout */
606 #define HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT 4
608 #define HCI_FLUSH_TOUT_HANDLE_OFF 0
609 #define HCI_FLUSH_TOUT_TOUT_OFF 2
611 extern BOOLEAN btsnd_hcic_read_tx_power(UINT16 handle, UINT8 type); /* Read Tx Power */
613 #define HCIC_PARAM_SIZE_READ_TX_POWER 3
615 #define HCI_READ_TX_POWER_HANDLE_OFF 0
616 #define HCI_READ_TX_POWER_TYPE_OFF 2
618 /* Read transmit power level parameter */
619 #define HCI_READ_CURRENT 0x00
620 #define HCI_READ_MAXIMUM 0x01
622 extern BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles,
624 UINT16 *num_pkts); /* Set Host Buffer Size */
626 #define HCIC_PARAM_SIZE_NUM_PKTS_DONE_SIZE sizeof(btmsg_hcic_num_pkts_done_t)
628 #define MAX_DATA_HANDLES 10
630 #define HCI_PKTS_DONE_NUM_HANDLES_OFF 0
631 #define HCI_PKTS_DONE_HANDLE_OFF 1
632 #define HCI_PKTS_DONE_NUM_PKTS_OFF 3
634 /* Write Link Supervision Timeout */
635 extern BOOLEAN btsnd_hcic_write_link_super_tout(UINT8 local_controller_id, UINT16 handle, UINT16 timeout);
637 #define HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT 4
639 #define HCI_LINK_SUPER_TOUT_HANDLE_OFF 0
640 #define HCI_LINK_SUPER_TOUT_TOUT_OFF 2
641 /* Write Link Supervision Timeout */
643 extern BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac,
644 LAP * const iac_lap); /* Write Current IAC LAP */
646 #define MAX_IAC_LAPS 0x40
648 #define HCI_WRITE_IAC_LAP_NUM_OFF 0
649 #define HCI_WRITE_IAC_LAP_LAP_OFF 1
650 /* Write Current IAC LAP */
652 extern BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle); /* Get Link Quality */
653 extern BOOLEAN btsnd_hcic_read_rssi (UINT16 handle); /* Read RSSI */
654 extern BOOLEAN btsnd_hcic_enable_test_mode (void); /* Enable Device Under Test Mode */
655 extern BOOLEAN btsnd_hcic_write_pagescan_type(UINT8 type); /* Write Page Scan Type */
656 extern BOOLEAN btsnd_hcic_write_inqscan_type(UINT8 type); /* Write Inquiry Scan Type */
657 extern BOOLEAN btsnd_hcic_write_inquiry_mode(UINT8 type); /* Write Inquiry Mode */
658 extern BOOLEAN btsnd_hcic_set_afh_channels (UINT8 first, UINT8 last);
659 extern BOOLEAN btsnd_hcic_write_afh_channel_assessment_mode (UINT8 mode);
661 #define HCI_DATA_HANDLE_MASK 0x0FFF
663 #define HCID_GET_HANDLE_EVENT(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \
664 (*((UINT8 *)((p) + 1) + p->offset + 1) << 8)))
666 #define HCID_GET_HANDLE(u16) (UINT16)((u16) & HCI_DATA_HANDLE_MASK)
668 #define HCI_DATA_EVENT_MASK 3
669 #define HCI_DATA_EVENT_OFFSET 12
670 #define HCID_GET_EVENT(u16) (UINT8)(((u16) >> HCI_DATA_EVENT_OFFSET) & HCI_DATA_EVENT_MASK)
672 #define HCI_DATA_BCAST_MASK 3
673 #define HCI_DATA_BCAST_OFFSET 10
674 #define HCID_GET_BCAST(u16) (UINT8)(((u16) >> HCI_DATA_BCAST_OFFSET) & HCI_DATA_BCAST_MASK)
676 #define HCID_GET_ACL_LEN(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset + 2) + \
677 (*((UINT8 *)((p) + 1) + p->offset + 3) << 8)))
679 #define HCID_HEADER_SIZE 4
681 #define HCID_GET_SCO_LEN(p) (*((UINT8 *)((p) + 1) + p->offset + 2))
683 extern void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
684 UINT8 len, UINT8 *p_data,
685 void *p_cmd_cplt_cback);
687 #if (BLE_INCLUDED == TRUE)
688 /********************************************************************************
690 ** Note: "local_controller_id" is for transport, not counted in HCI message size
691 *********************************************************************************/
692 #define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
693 #define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
694 #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
695 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
696 #define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
697 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
698 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE 2
699 #define HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN 25
700 #define HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL 0
701 #define HCIC_PARAM_SIZE_CLEAR_WHITE_LIST 0
702 #define HCIC_PARAM_SIZE_ADD_WHITE_LIST 7
703 #define HCIC_PARAM_SIZE_REMOVE_WHITE_LIST 7
704 #define HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS 14
705 #define HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS 5
706 #define HCIC_PARAM_SIZE_READ_CHNL_MAP 2
707 #define HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT 2
708 #define HCIC_PARAM_SIZE_BLE_ENCRYPT 32
709 #define HCIC_PARAM_SIZE_BLE_RAND 0
710 #define HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED 2
712 #define HCIC_BLE_RAND_DI_SIZE 8
713 #define HCIC_BLE_ENCRYT_KEY_SIZE 16
714 #define HCIC_PARAM_SIZE_BLE_START_ENC (4 + HCIC_BLE_RAND_DI_SIZE + HCIC_BLE_ENCRYT_KEY_SIZE)
715 #define HCIC_PARAM_SIZE_LTK_REQ_REPLY (2 + HCIC_BLE_ENCRYT_KEY_SIZE)
716 #define HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY 2
717 #define HCIC_BLE_CHNL_MAP_SIZE 5
718 #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31
720 /* ULP HCI command */
721 extern BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);
723 extern BOOLEAN btsnd_hcic_ble_read_buffer_size (void);
725 extern BOOLEAN btsnd_hcic_ble_read_local_spt_feat (void);
727 extern BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]);
729 extern BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr);
731 extern BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
732 UINT8 adv_type, UINT8 addr_type_own,
733 UINT8 addr_type_dir, BD_ADDR direct_bda,
734 UINT8 channel_map, UINT8 scan_filter_policy);
736 extern BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void);
738 extern BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data);
740 extern BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp);
742 extern BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable);
744 extern BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
745 UINT16 scan_int, UINT16 scan_win,
746 UINT8 addr_type, UINT8 scan_filter_policy);
748 extern BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate);
750 extern BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win,
751 UINT8 init_filter_policy, UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 addr_type_own,
752 UINT16 conn_int_min, UINT16 conn_int_max, UINT16 conn_latency, UINT16 conn_timeout,
753 UINT16 min_ce_len, UINT16 max_ce_len);
755 extern BOOLEAN btsnd_hcic_ble_create_conn_cancel (void);
757 extern BOOLEAN btsnd_hcic_ble_read_white_list_size (void);
759 extern BOOLEAN btsnd_hcic_ble_clear_white_list (void);
761 extern BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda);
763 extern BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda);
765 extern BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle, UINT16 conn_int_min, UINT16 conn_int_max,
766 UINT16 conn_latency, UINT16 conn_timeout, UINT16 min_len, UINT16 max_len);
768 extern BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]);
770 extern BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle);
772 extern BOOLEAN btsnd_hcic_ble_read_remote_feat ( UINT16 handle);
774 extern BOOLEAN btsnd_hcic_ble_encrypt (UINT8* key, UINT8 key_len, UINT8* plain_text, UINT8 pt_len, void *p_cmd_cplt_cback);
776 extern BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback);
778 extern BOOLEAN btsnd_hcic_ble_start_enc ( UINT16 handle,
779 UINT8 rand[HCIC_BLE_RAND_DI_SIZE],
780 UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
782 extern BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]);
784 extern BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle);
786 extern BOOLEAN btsnd_hcic_ble_read_supported_states (void);
788 extern BOOLEAN btsnd_hcic_ble_write_host_supported (UINT8 le_host_spt, UINT8 simul_le_host_spt);
790 extern BOOLEAN btsnd_hcic_ble_read_host_supported (void);
792 extern BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq);
794 extern BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len,
796 extern BOOLEAN btsnd_hcic_ble_test_end(void);
798 #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
800 #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14
801 extern BOOLEAN btsnd_hcic_ble_rc_param_req_reply(UINT16 handle,
802 UINT16 conn_int_min, UINT16 conn_int_max,
803 UINT16 conn_latency, UINT16 conn_timeout,
804 UINT16 min_ce_len, UINT16 max_ce_len);
806 #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3
807 extern BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason);
809 #endif /* BLE_LLT_INCLUDED */
812 #endif /* BLE_INCLUDED */