• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /******************************************************************************
20  *
21  *  This file contains function of the HCIC unit to format and send HCI
22  *  commands.
23  *
24  ******************************************************************************/
25 
26 #include "bt_target.h"
27 #include "btcore/include/counter.h"
28 #include "gki.h"
29 #include "hcidefs.h"
30 #include "hcimsgs.h"
31 #include "hcidefs.h"
32 #include "btu.h"
33 
34 #include <stddef.h>
35 #include <string.h>
36 
37 #include "btm_int.h"    /* Included for UIPC_* macro definitions */
38 
btsnd_hcic_inquiry(const LAP inq_lap,UINT8 duration,UINT8 response_cnt)39 BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration, UINT8 response_cnt)
40 {
41     BT_HDR *p;
42     UINT8 *pp;
43 
44     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_INQUIRY)) == NULL)
45         return (FALSE);
46 
47     pp = (UINT8 *)(p + 1);
48 
49     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_INQUIRY;
50     p->offset = 0;
51 
52     UINT16_TO_STREAM (pp, HCI_INQUIRY);
53     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_INQUIRY);
54 
55     LAP_TO_STREAM   (pp, inq_lap);
56     UINT8_TO_STREAM (pp, duration);
57     UINT8_TO_STREAM (pp, response_cnt);
58 
59     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
60     return (TRUE);
61 }
62 
btsnd_hcic_inq_cancel(void)63 BOOLEAN btsnd_hcic_inq_cancel(void)
64 {
65     BT_HDR *p;
66     UINT8 *pp;
67 
68     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_INQ_CANCEL)) == NULL)
69         return (FALSE);
70 
71     pp = (UINT8 *)(p + 1);
72 
73     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_INQ_CANCEL;
74     p->offset = 0;
75     UINT16_TO_STREAM (pp, HCI_INQUIRY_CANCEL);
76     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_INQ_CANCEL);
77 
78     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
79     return (TRUE);
80 }
81 
btsnd_hcic_per_inq_mode(UINT16 max_period,UINT16 min_period,const LAP inq_lap,UINT8 duration,UINT8 response_cnt)82 BOOLEAN btsnd_hcic_per_inq_mode (UINT16 max_period, UINT16 min_period,
83                                  const LAP inq_lap, UINT8 duration, UINT8 response_cnt)
84 {
85     BT_HDR *p;
86     UINT8 *pp;
87 
88     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PER_INQ_MODE)) == NULL)
89         return (FALSE);
90 
91     pp = (UINT8 *)(p + 1);
92 
93     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PER_INQ_MODE;
94     p->offset = 0;
95 
96     UINT16_TO_STREAM (pp, HCI_PERIODIC_INQUIRY_MODE);
97     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_PER_INQ_MODE);
98 
99     UINT16_TO_STREAM (pp, max_period);
100     UINT16_TO_STREAM (pp, min_period);
101     LAP_TO_STREAM    (pp, inq_lap);
102     UINT8_TO_STREAM  (pp, duration);
103     UINT8_TO_STREAM  (pp, response_cnt);
104 
105     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
106     return (TRUE);
107 }
108 
btsnd_hcic_exit_per_inq(void)109 BOOLEAN btsnd_hcic_exit_per_inq (void)
110 {
111     BT_HDR *p;
112     UINT8 *pp;
113 
114     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_EXIT_PER_INQ)) == NULL)
115         return (FALSE);
116 
117     pp = (UINT8 *)(p + 1);
118 
119     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_EXIT_PER_INQ;
120     p->offset = 0;
121     UINT16_TO_STREAM (pp, HCI_EXIT_PERIODIC_INQUIRY_MODE);
122     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_EXIT_PER_INQ);
123 
124     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
125     return (TRUE);
126 }
127 
128 
btsnd_hcic_create_conn(BD_ADDR dest,UINT16 packet_types,UINT8 page_scan_rep_mode,UINT8 page_scan_mode,UINT16 clock_offset,UINT8 allow_switch)129 BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types,
130                                UINT8 page_scan_rep_mode, UINT8 page_scan_mode,
131                                UINT16 clock_offset, UINT8 allow_switch)
132 {
133     BT_HDR *p;
134     UINT8 *pp;
135 
136     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CREATE_CONN)) == NULL)
137         return (FALSE);
138 
139     pp = (UINT8 *)(p + 1);
140 
141 #ifndef BT_10A
142     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CREATE_CONN;
143 #else
144     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CREATE_CONN - 1;
145 #endif
146     p->offset = 0;
147 
148     UINT16_TO_STREAM (pp, HCI_CREATE_CONNECTION);
149 #ifndef BT_10A
150     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CREATE_CONN);
151 #else
152     UINT8_TO_STREAM  (pp, (HCIC_PARAM_SIZE_CREATE_CONN - 1));
153 #endif
154     BDADDR_TO_STREAM (pp, dest);
155     UINT16_TO_STREAM (pp, packet_types);
156     UINT8_TO_STREAM  (pp, page_scan_rep_mode);
157     UINT8_TO_STREAM  (pp, page_scan_mode);
158     UINT16_TO_STREAM (pp, clock_offset);
159 #if !defined (BT_10A)
160     UINT8_TO_STREAM  (pp, allow_switch);
161 #endif
162     btm_acl_paging (p, dest);
163     return (TRUE);
164 }
165 
btsnd_hcic_disconnect(UINT16 handle,UINT8 reason)166 BOOLEAN btsnd_hcic_disconnect (UINT16 handle, UINT8 reason)
167 {
168     BT_HDR *p;
169     UINT8 *pp;
170 
171     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_DISCONNECT)) == NULL)
172         return (FALSE);
173 
174     pp = (UINT8 *)(p + 1);
175 
176     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_DISCONNECT;
177     p->offset = 0;
178 
179     UINT16_TO_STREAM (pp, HCI_DISCONNECT);
180     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_DISCONNECT);
181     UINT16_TO_STREAM (pp, handle);
182     UINT8_TO_STREAM  (pp, reason);
183 
184     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
185     return (TRUE);
186 }
187 
188 #if BTM_SCO_INCLUDED == TRUE
btsnd_hcic_add_SCO_conn(UINT16 handle,UINT16 packet_types)189 BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types)
190 {
191     BT_HDR *p;
192     UINT8 *pp;
193 
194     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ADD_SCO_CONN)) == NULL)
195         return (FALSE);
196 
197     pp = (UINT8 *)(p + 1);
198 
199     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ADD_SCO_CONN;
200     p->offset = 0;
201 
202     UINT16_TO_STREAM (pp, HCI_ADD_SCO_CONNECTION);
203     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_ADD_SCO_CONN);
204 
205     UINT16_TO_STREAM (pp, handle);
206     UINT16_TO_STREAM (pp, packet_types);
207 
208     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
209     return (TRUE);
210 }
211 #endif /* BTM_SCO_INCLUDED */
212 
btsnd_hcic_create_conn_cancel(BD_ADDR dest)213 BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest)
214 {
215     BT_HDR *p;
216     UINT8 *pp;
217 
218     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CREATE_CONN_CANCEL)) == NULL)
219         return (FALSE);
220 
221     pp = (UINT8 *)(p + 1);
222 
223     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CREATE_CONN_CANCEL;
224     p->offset = 0;
225 
226     UINT16_TO_STREAM (pp, HCI_CREATE_CONNECTION_CANCEL);
227     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CREATE_CONN_CANCEL);
228 
229     BDADDR_TO_STREAM (pp, dest);
230 
231     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
232     return (TRUE);
233 }
234 
btsnd_hcic_accept_conn(BD_ADDR dest,UINT8 role)235 BOOLEAN btsnd_hcic_accept_conn (BD_ADDR dest, UINT8 role)
236 {
237     BT_HDR *p;
238     UINT8 *pp;
239 
240     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ACCEPT_CONN)) == NULL)
241         return (FALSE);
242 
243     pp = (UINT8 *)(p + 1);
244 
245     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ACCEPT_CONN;
246     p->offset = 0;
247 
248     UINT16_TO_STREAM (pp, HCI_ACCEPT_CONNECTION_REQUEST);
249     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_ACCEPT_CONN);
250     BDADDR_TO_STREAM (pp, dest);
251     UINT8_TO_STREAM  (pp, role);
252 
253     counter_add("hci.conn.accept", 1);
254 
255     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
256     return (TRUE);
257 }
258 
btsnd_hcic_reject_conn(BD_ADDR dest,UINT8 reason)259 BOOLEAN btsnd_hcic_reject_conn (BD_ADDR dest, UINT8 reason)
260 {
261     BT_HDR *p;
262     UINT8 *pp;
263 
264     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REJECT_CONN)) == NULL)
265         return (FALSE);
266 
267     pp = (UINT8 *)(p + 1);
268 
269     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REJECT_CONN;
270     p->offset = 0;
271 
272     UINT16_TO_STREAM (pp, HCI_REJECT_CONNECTION_REQUEST);
273     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_REJECT_CONN);
274 
275     BDADDR_TO_STREAM (pp, dest);
276     UINT8_TO_STREAM (pp, reason);
277 
278     counter_add("hci.conn.reject", 1);
279 
280     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
281     return (TRUE);
282 }
283 
btsnd_hcic_link_key_req_reply(BD_ADDR bd_addr,LINK_KEY link_key)284 BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr, LINK_KEY link_key)
285 {
286     BT_HDR *p;
287     UINT8 *pp;
288 
289     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY)) == NULL)
290         return (FALSE);
291 
292     pp = (UINT8 *)(p + 1);
293 
294     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY;
295     p->offset = 0;
296 
297     UINT16_TO_STREAM  (pp, HCI_LINK_KEY_REQUEST_REPLY);
298     UINT8_TO_STREAM   (pp, HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY);
299 
300     BDADDR_TO_STREAM  (pp, bd_addr);
301     ARRAY16_TO_STREAM (pp, link_key);
302 
303     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
304     return (TRUE);
305 }
306 
btsnd_hcic_link_key_neg_reply(BD_ADDR bd_addr)307 BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr)
308 {
309     BT_HDR *p;
310     UINT8 *pp;
311 
312     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY)) == NULL)
313         return (FALSE);
314 
315     pp = (UINT8 *)(p + 1);
316 
317     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY;
318     p->offset = 0;
319 
320     UINT16_TO_STREAM (pp, HCI_LINK_KEY_REQUEST_NEG_REPLY);
321     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY);
322 
323     BDADDR_TO_STREAM (pp, bd_addr);
324 
325     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
326     return (TRUE);
327 }
328 
btsnd_hcic_pin_code_req_reply(BD_ADDR bd_addr,UINT8 pin_code_len,PIN_CODE pin_code)329 BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr, UINT8 pin_code_len,
330                                     PIN_CODE pin_code)
331 {
332     BT_HDR *p;
333     UINT8  *pp;
334     int     i;
335 
336     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY)) == NULL)
337         return (FALSE);
338 
339     pp = (UINT8 *)(p + 1);
340 
341     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY;
342     p->offset = 0;
343 
344     UINT16_TO_STREAM  (pp, HCI_PIN_CODE_REQUEST_REPLY);
345     UINT8_TO_STREAM   (pp, HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY);
346 
347     BDADDR_TO_STREAM  (pp, bd_addr);
348     UINT8_TO_STREAM   (pp, pin_code_len);
349 
350     for (i = 0; i < pin_code_len; i++)
351         *pp++ = *pin_code++;
352 
353     for (; i < PIN_CODE_LEN; i++)
354         *pp++ = 0;
355 
356 
357     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
358     return (TRUE);
359 }
360 
btsnd_hcic_pin_code_neg_reply(BD_ADDR bd_addr)361 BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr)
362 {
363     BT_HDR *p;
364     UINT8 *pp;
365 
366     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY)) == NULL)
367         return (FALSE);
368 
369     pp = (UINT8 *)(p + 1);
370 
371     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY;
372     p->offset = 0;
373 
374     UINT16_TO_STREAM (pp, HCI_PIN_CODE_REQUEST_NEG_REPLY);
375     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY);
376 
377     BDADDR_TO_STREAM (pp, bd_addr);
378 
379     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
380     return (TRUE);
381 }
382 
btsnd_hcic_change_conn_type(UINT16 handle,UINT16 packet_types)383 BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types)
384 {
385     BT_HDR *p;
386     UINT8 *pp;
387 
388     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CHANGE_CONN_TYPE)) == NULL)
389         return (FALSE);
390 
391     pp = (UINT8 *)(p + 1);
392 
393     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CHANGE_CONN_TYPE;
394     p->offset = 0;
395 
396     UINT16_TO_STREAM (pp, HCI_CHANGE_CONN_PACKET_TYPE);
397     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CHANGE_CONN_TYPE);
398 
399     UINT16_TO_STREAM (pp, handle);
400     UINT16_TO_STREAM (pp, packet_types);
401 
402     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
403     return (TRUE);
404 }
405 
btsnd_hcic_auth_request(UINT16 handle)406 BOOLEAN btsnd_hcic_auth_request (UINT16 handle)
407 {
408     BT_HDR *p;
409     UINT8 *pp;
410 
411     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
412         return (FALSE);
413 
414     pp = (UINT8 *)(p + 1);
415 
416     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
417     p->offset = 0;
418 
419     UINT16_TO_STREAM (pp, HCI_AUTHENTICATION_REQUESTED);
420     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
421 
422     UINT16_TO_STREAM (pp, handle);
423 
424     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
425     return (TRUE);
426 }
427 
btsnd_hcic_set_conn_encrypt(UINT16 handle,BOOLEAN enable)428 BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable)
429 {
430     BT_HDR *p;
431     UINT8 *pp;
432 
433     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_CONN_ENCRYPT)) == NULL)
434         return (FALSE);
435 
436     pp = (UINT8 *)(p + 1);
437 
438     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_CONN_ENCRYPT;
439     p->offset = 0;
440 
441     UINT16_TO_STREAM (pp, HCI_SET_CONN_ENCRYPTION);
442     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SET_CONN_ENCRYPT);
443 
444     UINT16_TO_STREAM (pp, handle);
445     UINT8_TO_STREAM  (pp, enable);
446 
447     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
448     return (TRUE);
449 }
450 
btsnd_hcic_rmt_name_req(BD_ADDR bd_addr,UINT8 page_scan_rep_mode,UINT8 page_scan_mode,UINT16 clock_offset)451 BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, UINT8 page_scan_rep_mode,
452                                  UINT8 page_scan_mode, UINT16 clock_offset)
453 {
454     BT_HDR *p;
455     UINT8 *pp;
456 
457     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RMT_NAME_REQ)) == NULL)
458         return (FALSE);
459 
460     pp = (UINT8 *)(p + 1);
461 
462     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RMT_NAME_REQ;
463     p->offset = 0;
464 
465     UINT16_TO_STREAM (pp, HCI_RMT_NAME_REQUEST);
466     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_RMT_NAME_REQ);
467 
468     BDADDR_TO_STREAM (pp, bd_addr);
469     UINT8_TO_STREAM  (pp, page_scan_rep_mode);
470     UINT8_TO_STREAM  (pp, page_scan_mode);
471     UINT16_TO_STREAM (pp, clock_offset);
472 
473     btm_acl_paging (p, bd_addr);
474     return (TRUE);
475 }
476 
btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr)477 BOOLEAN btsnd_hcic_rmt_name_req_cancel (BD_ADDR bd_addr)
478 {
479     BT_HDR *p;
480     UINT8 *pp;
481 
482     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL)) == NULL)
483         return (FALSE);
484 
485     pp = (UINT8 *)(p + 1);
486 
487     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL;
488     p->offset = 0;
489 
490     UINT16_TO_STREAM (pp, HCI_RMT_NAME_REQUEST_CANCEL);
491     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL);
492 
493     BDADDR_TO_STREAM (pp, bd_addr);
494 
495     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
496     return (TRUE);
497 }
498 
btsnd_hcic_rmt_features_req(UINT16 handle)499 BOOLEAN btsnd_hcic_rmt_features_req (UINT16 handle)
500 {
501     BT_HDR *p;
502     UINT8 *pp;
503 
504     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
505         return (FALSE);
506 
507     pp = (UINT8 *)(p + 1);
508 
509     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
510     p->offset = 0;
511 
512     UINT16_TO_STREAM (pp, HCI_READ_RMT_FEATURES);
513     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
514 
515     UINT16_TO_STREAM (pp, handle);
516 
517     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
518     return (TRUE);
519 }
520 
btsnd_hcic_rmt_ext_features(UINT16 handle,UINT8 page_num)521 BOOLEAN btsnd_hcic_rmt_ext_features (UINT16 handle, UINT8 page_num)
522 {
523     BT_HDR *p;
524     UINT8 *pp;
525 
526     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RMT_EXT_FEATURES)) == NULL)
527         return (FALSE);
528 
529     pp = (UINT8 *)(p + 1);
530 
531     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RMT_EXT_FEATURES;
532     p->offset = 0;
533 
534     UINT16_TO_STREAM (pp, HCI_READ_RMT_EXT_FEATURES);
535     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_RMT_EXT_FEATURES);
536 
537     UINT16_TO_STREAM (pp, handle);
538     UINT8_TO_STREAM (pp, page_num);
539 
540     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
541     return (TRUE);
542 }
543 
btsnd_hcic_rmt_ver_req(UINT16 handle)544 BOOLEAN btsnd_hcic_rmt_ver_req (UINT16 handle)
545 {
546     BT_HDR *p;
547     UINT8 *pp;
548 
549     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
550         return (FALSE);
551 
552     pp = (UINT8 *)(p + 1);
553 
554     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
555     p->offset = 0;
556 
557     UINT16_TO_STREAM (pp, HCI_READ_RMT_VERSION_INFO);
558     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
559 
560     UINT16_TO_STREAM (pp, handle);
561 
562     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
563     return (TRUE);
564 }
565 
btsnd_hcic_read_rmt_clk_offset(UINT16 handle)566 BOOLEAN btsnd_hcic_read_rmt_clk_offset (UINT16 handle)
567 {
568     BT_HDR *p;
569     UINT8 *pp;
570 
571     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
572         return (FALSE);
573 
574     pp = (UINT8 *)(p + 1);
575 
576     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
577     p->offset = 0;
578 
579     UINT16_TO_STREAM (pp, HCI_READ_RMT_CLOCK_OFFSET);
580     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
581 
582     UINT16_TO_STREAM (pp, handle);
583 
584     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
585     return (TRUE);
586 }
587 
btsnd_hcic_read_lmp_handle(UINT16 handle)588 BOOLEAN btsnd_hcic_read_lmp_handle (UINT16 handle)
589 {
590     BT_HDR *p;
591     UINT8 *pp;
592 
593     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
594         return (FALSE);
595 
596     pp = (UINT8 *)(p + 1);
597 
598     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
599     p->offset = 0;
600 
601     UINT16_TO_STREAM (pp, HCI_READ_LMP_HANDLE);
602     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
603 
604     UINT16_TO_STREAM (pp, handle);
605 
606     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
607     return (TRUE);
608 }
609 
btsnd_hcic_setup_esco_conn(UINT16 handle,UINT32 tx_bw,UINT32 rx_bw,UINT16 max_latency,UINT16 voice,UINT8 retrans_effort,UINT16 packet_types)610 BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle, UINT32 tx_bw,
611                                     UINT32 rx_bw, UINT16 max_latency, UINT16 voice,
612                                     UINT8 retrans_effort, UINT16 packet_types)
613 {
614     BT_HDR *p;
615     UINT8 *pp;
616 
617     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SETUP_ESCO)) == NULL)
618         return (FALSE);
619 
620     pp = (UINT8 *)(p + 1);
621 
622     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SETUP_ESCO;
623     p->offset = 0;
624 
625     UINT16_TO_STREAM (pp, HCI_SETUP_ESCO_CONNECTION);
626     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SETUP_ESCO);
627 
628     UINT16_TO_STREAM (pp, handle);
629     UINT32_TO_STREAM (pp, tx_bw);
630     UINT32_TO_STREAM (pp, rx_bw);
631     UINT16_TO_STREAM (pp, max_latency);
632     UINT16_TO_STREAM (pp, voice);
633     UINT8_TO_STREAM  (pp, retrans_effort);
634     UINT16_TO_STREAM (pp, packet_types);
635 
636     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
637     return (TRUE);
638 }
639 
btsnd_hcic_accept_esco_conn(BD_ADDR bd_addr,UINT32 tx_bw,UINT32 rx_bw,UINT16 max_latency,UINT16 content_fmt,UINT8 retrans_effort,UINT16 packet_types)640 BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr, UINT32 tx_bw,
641                                      UINT32 rx_bw, UINT16 max_latency,
642                                      UINT16 content_fmt, UINT8 retrans_effort,
643                                      UINT16 packet_types)
644 {
645     BT_HDR *p;
646     UINT8 *pp;
647 
648     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ACCEPT_ESCO)) == NULL)
649         return (FALSE);
650 
651     pp = (UINT8 *)(p + 1);
652 
653     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ACCEPT_ESCO;
654     p->offset = 0;
655 
656     UINT16_TO_STREAM (pp, HCI_ACCEPT_ESCO_CONNECTION);
657     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_ACCEPT_ESCO);
658 
659     BDADDR_TO_STREAM (pp, bd_addr);
660     UINT32_TO_STREAM (pp, tx_bw);
661     UINT32_TO_STREAM (pp, rx_bw);
662     UINT16_TO_STREAM (pp, max_latency);
663     UINT16_TO_STREAM (pp, content_fmt);
664     UINT8_TO_STREAM  (pp, retrans_effort);
665     UINT16_TO_STREAM (pp, packet_types);
666 
667     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
668     return (TRUE);
669 }
670 
btsnd_hcic_reject_esco_conn(BD_ADDR bd_addr,UINT8 reason)671 BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason)
672 {
673     BT_HDR *p;
674     UINT8 *pp;
675 
676     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REJECT_ESCO)) == NULL)
677         return (FALSE);
678 
679     pp = (UINT8 *)(p + 1);
680 
681     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REJECT_ESCO;
682     p->offset = 0;
683 
684     UINT16_TO_STREAM (pp, HCI_REJECT_ESCO_CONNECTION);
685     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_REJECT_ESCO);
686 
687     BDADDR_TO_STREAM (pp, bd_addr);
688     UINT8_TO_STREAM  (pp, reason);
689 
690     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
691     return (TRUE);
692 }
693 
btsnd_hcic_hold_mode(UINT16 handle,UINT16 max_hold_period,UINT16 min_hold_period)694 BOOLEAN btsnd_hcic_hold_mode (UINT16 handle, UINT16 max_hold_period,
695                               UINT16 min_hold_period)
696 {
697     BT_HDR *p;
698     UINT8 *pp;
699 
700     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_HOLD_MODE)) == NULL)
701         return (FALSE);
702 
703     pp = (UINT8 *)(p + 1);
704 
705     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_HOLD_MODE;
706     p->offset = 0;
707 
708     UINT16_TO_STREAM (pp, HCI_HOLD_MODE);
709     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_HOLD_MODE);
710 
711     UINT16_TO_STREAM (pp, handle);
712     UINT16_TO_STREAM (pp, max_hold_period);
713     UINT16_TO_STREAM (pp, min_hold_period);
714 
715     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
716     return (TRUE);
717 }
718 
btsnd_hcic_sniff_mode(UINT16 handle,UINT16 max_sniff_period,UINT16 min_sniff_period,UINT16 sniff_attempt,UINT16 sniff_timeout)719 BOOLEAN btsnd_hcic_sniff_mode (UINT16 handle, UINT16 max_sniff_period,
720                                UINT16 min_sniff_period, UINT16 sniff_attempt,
721                                UINT16 sniff_timeout)
722 {
723     BT_HDR *p;
724     UINT8 *pp;
725 
726     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SNIFF_MODE)) == NULL)
727         return (FALSE);
728 
729     pp = (UINT8 *)(p + 1);
730 
731     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SNIFF_MODE;
732     p->offset = 0;
733 
734     UINT16_TO_STREAM (pp, HCI_SNIFF_MODE);
735     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SNIFF_MODE);
736 
737     UINT16_TO_STREAM (pp, handle);
738     UINT16_TO_STREAM (pp, max_sniff_period);
739     UINT16_TO_STREAM (pp, min_sniff_period);
740     UINT16_TO_STREAM (pp, sniff_attempt);
741     UINT16_TO_STREAM (pp, sniff_timeout);
742 
743     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
744     return (TRUE);
745 }
746 
btsnd_hcic_exit_sniff_mode(UINT16 handle)747 BOOLEAN btsnd_hcic_exit_sniff_mode (UINT16 handle)
748 {
749     BT_HDR *p;
750     UINT8 *pp;
751 
752     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
753         return (FALSE);
754 
755     pp = (UINT8 *)(p + 1);
756 
757     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
758     p->offset = 0;
759 
760     UINT16_TO_STREAM (pp, HCI_EXIT_SNIFF_MODE);
761     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
762 
763     UINT16_TO_STREAM (pp, handle);
764 
765     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
766     return TRUE;
767 }
768 
btsnd_hcic_park_mode(UINT16 handle,UINT16 beacon_max_interval,UINT16 beacon_min_interval)769 BOOLEAN btsnd_hcic_park_mode (UINT16 handle, UINT16 beacon_max_interval,
770                               UINT16 beacon_min_interval)
771 {
772     BT_HDR *p;
773     UINT8 *pp;
774 
775     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PARK_MODE)) == NULL)
776         return (FALSE);
777 
778     pp = (UINT8 *)(p + 1);
779 
780     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PARK_MODE;
781     p->offset = 0;
782 
783     UINT16_TO_STREAM (pp, HCI_PARK_MODE);
784     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_PARK_MODE);
785 
786     UINT16_TO_STREAM (pp, handle);
787     UINT16_TO_STREAM (pp, beacon_max_interval);
788     UINT16_TO_STREAM (pp, beacon_min_interval);
789 
790     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
791     return (TRUE);
792 }
793 
btsnd_hcic_exit_park_mode(UINT16 handle)794 BOOLEAN btsnd_hcic_exit_park_mode (UINT16 handle)
795 {
796     BT_HDR *p;
797     UINT8 *pp;
798 
799     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
800         return (FALSE);
801 
802     pp = (UINT8 *)(p + 1);
803 
804     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
805     p->offset = 0;
806 
807     UINT16_TO_STREAM (pp, HCI_EXIT_PARK_MODE);
808     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
809 
810     UINT16_TO_STREAM (pp, handle);
811 
812     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
813     return TRUE;
814 }
815 
btsnd_hcic_qos_setup(UINT16 handle,UINT8 flags,UINT8 service_type,UINT32 token_rate,UINT32 peak,UINT32 latency,UINT32 delay_var)816 BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags, UINT8 service_type,
817                               UINT32 token_rate, UINT32 peak, UINT32 latency,
818                               UINT32 delay_var)
819 {
820     BT_HDR *p;
821     UINT8 *pp;
822 
823     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_QOS_SETUP)) == NULL)
824         return (FALSE);
825 
826     pp = (UINT8 *)(p + 1);
827 
828     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_QOS_SETUP;
829     p->offset = 0;
830 
831     UINT16_TO_STREAM (pp, HCI_QOS_SETUP);
832     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_QOS_SETUP);
833 
834     UINT16_TO_STREAM (pp, handle);
835     UINT8_TO_STREAM  (pp, flags);
836     UINT8_TO_STREAM  (pp, service_type);
837     UINT32_TO_STREAM (pp, token_rate);
838     UINT32_TO_STREAM (pp, peak);
839     UINT32_TO_STREAM (pp, latency);
840     UINT32_TO_STREAM (pp, delay_var);
841 
842     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
843     return (TRUE);
844 }
845 
btsnd_hcic_switch_role(BD_ADDR bd_addr,UINT8 role)846 BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role)
847 {
848     BT_HDR *p;
849     UINT8 *pp;
850 
851     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SWITCH_ROLE)) == NULL)
852         return (FALSE);
853 
854     pp = (UINT8 *)(p + 1);
855 
856     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SWITCH_ROLE;
857     p->offset = 0;
858 
859     UINT16_TO_STREAM (pp, HCI_SWITCH_ROLE);
860     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SWITCH_ROLE);
861 
862     BDADDR_TO_STREAM (pp, bd_addr);
863     UINT8_TO_STREAM  (pp, role);
864 
865     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
866     return (TRUE);
867 }
868 
btsnd_hcic_write_policy_set(UINT16 handle,UINT16 settings)869 BOOLEAN btsnd_hcic_write_policy_set (UINT16 handle, UINT16 settings)
870 {
871     BT_HDR *p;
872     UINT8 *pp;
873 
874     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_POLICY_SET)) == NULL)
875         return (FALSE);
876 
877     pp = (UINT8 *)(p + 1);
878 
879     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_POLICY_SET;
880     p->offset = 0;
881     UINT16_TO_STREAM (pp, HCI_WRITE_POLICY_SETTINGS);
882     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_POLICY_SET);
883 
884     UINT16_TO_STREAM (pp, handle);
885     UINT16_TO_STREAM (pp, settings);
886 
887     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
888     return (TRUE);
889 }
890 
btsnd_hcic_write_def_policy_set(UINT16 settings)891 BOOLEAN btsnd_hcic_write_def_policy_set (UINT16 settings)
892 {
893     BT_HDR *p;
894     UINT8 *pp;
895 
896     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET)) == NULL)
897         return (FALSE);
898 
899     pp = (UINT8 *)(p + 1);
900 
901     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET;
902     p->offset = 0;
903     UINT16_TO_STREAM (pp, HCI_WRITE_DEF_POLICY_SETTINGS);
904     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET);
905 
906     UINT16_TO_STREAM (pp, settings);
907 
908     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
909     return (TRUE);
910 }
911 
btsnd_hcic_set_event_filter(UINT8 filt_type,UINT8 filt_cond_type,UINT8 * filt_cond,UINT8 filt_cond_len)912 BOOLEAN btsnd_hcic_set_event_filter (UINT8 filt_type, UINT8 filt_cond_type,
913                                      UINT8 *filt_cond, UINT8 filt_cond_len)
914 {
915     BT_HDR *p;
916     UINT8 *pp;
917 
918     /* Use buffer large enough to hold all sizes in this command */
919     if ((p = HCI_GET_CMD_BUF(2 + filt_cond_len)) == NULL)
920         return (FALSE);
921 
922     pp = (UINT8 *)(p + 1);
923 
924     p->offset = 0;
925 
926     UINT16_TO_STREAM (pp, HCI_SET_EVENT_FILTER);
927 
928     if (filt_type)
929     {
930         p->len = (UINT16)(HCIC_PREAMBLE_SIZE + 2 + filt_cond_len);
931         UINT8_TO_STREAM (pp, (UINT8)(2 + filt_cond_len));
932 
933         UINT8_TO_STREAM (pp, filt_type);
934         UINT8_TO_STREAM (pp, filt_cond_type);
935 
936         if (filt_cond_type == HCI_FILTER_COND_DEVICE_CLASS)
937         {
938             DEVCLASS_TO_STREAM (pp, filt_cond);
939             filt_cond += DEV_CLASS_LEN;
940             DEVCLASS_TO_STREAM (pp, filt_cond);
941             filt_cond += DEV_CLASS_LEN;
942 
943             filt_cond_len -= (2 * DEV_CLASS_LEN);
944         }
945         else if (filt_cond_type == HCI_FILTER_COND_BD_ADDR)
946         {
947             BDADDR_TO_STREAM (pp, filt_cond);
948             filt_cond += BD_ADDR_LEN;
949 
950             filt_cond_len -= BD_ADDR_LEN;
951         }
952 
953         if (filt_cond_len)
954             ARRAY_TO_STREAM (pp, filt_cond, filt_cond_len);
955     }
956     else
957     {
958         p->len = (UINT16)(HCIC_PREAMBLE_SIZE + 1);
959         UINT8_TO_STREAM (pp, 1);
960 
961         UINT8_TO_STREAM (pp, filt_type);
962     }
963 
964     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
965     return (TRUE);
966 }
967 
btsnd_hcic_write_pin_type(UINT8 type)968 BOOLEAN btsnd_hcic_write_pin_type (UINT8 type)
969 {
970     BT_HDR *p;
971     UINT8 *pp;
972 
973     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
974         return (FALSE);
975 
976     pp = (UINT8 *)(p + 1);
977 
978     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
979     p->offset = 0;
980 
981     UINT16_TO_STREAM (pp, HCI_WRITE_PIN_TYPE);
982     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
983 
984     UINT8_TO_STREAM (pp, type);
985 
986     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
987     return (TRUE);
988 }
989 
btsnd_hcic_delete_stored_key(BD_ADDR bd_addr,BOOLEAN delete_all_flag)990 BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag)
991 {
992     BT_HDR *p;
993     UINT8 *pp;
994 
995     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_DELETE_STORED_KEY)) == NULL)
996         return (FALSE);
997 
998     pp = (UINT8 *)(p + 1);
999 
1000     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_DELETE_STORED_KEY;
1001     p->offset = 0;
1002 
1003     UINT16_TO_STREAM (pp, HCI_DELETE_STORED_LINK_KEY);
1004     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_DELETE_STORED_KEY);
1005 
1006     BDADDR_TO_STREAM (pp, bd_addr);
1007     UINT8_TO_STREAM  (pp, delete_all_flag);
1008 
1009     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1010     return (TRUE);
1011 }
1012 
btsnd_hcic_change_name(BD_NAME name)1013 BOOLEAN btsnd_hcic_change_name (BD_NAME name)
1014 {
1015     BT_HDR *p;
1016     UINT8 *pp;
1017     UINT16 len = strlen ((char *)name) + 1;
1018 
1019     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CHANGE_NAME)) == NULL)
1020         return (FALSE);
1021 
1022     pp = (UINT8 *)(p + 1);
1023     memset(pp, 0, HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CHANGE_NAME);
1024 
1025     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CHANGE_NAME;
1026     p->offset = 0;
1027 
1028     UINT16_TO_STREAM (pp, HCI_CHANGE_LOCAL_NAME);
1029     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CHANGE_NAME);
1030 
1031     if (len > HCIC_PARAM_SIZE_CHANGE_NAME)
1032         len = HCIC_PARAM_SIZE_CHANGE_NAME;
1033 
1034     ARRAY_TO_STREAM (pp, name, len);
1035 
1036     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1037     return (TRUE);
1038 }
1039 
btsnd_hcic_read_name(void)1040 BOOLEAN btsnd_hcic_read_name (void)
1041 {
1042     BT_HDR *p;
1043     UINT8 *pp;
1044 
1045     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1046         return (FALSE);
1047 
1048     pp = (UINT8 *)(p + 1);
1049 
1050     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1051     p->offset = 0;
1052 
1053     UINT16_TO_STREAM (pp, HCI_READ_LOCAL_NAME);
1054     UINT8_TO_STREAM  (pp,  HCIC_PARAM_SIZE_READ_CMD);
1055 
1056     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1057     return (TRUE);
1058 }
1059 
btsnd_hcic_write_page_tout(UINT16 timeout)1060 BOOLEAN btsnd_hcic_write_page_tout (UINT16 timeout)
1061 {
1062     BT_HDR *p;
1063     UINT8 *pp;
1064 
1065     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1066         return (FALSE);
1067 
1068     pp = (UINT8 *)(p + 1);
1069 
1070     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1071     p->offset = 0;
1072 
1073     UINT16_TO_STREAM (pp, HCI_WRITE_PAGE_TOUT);
1074     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1075 
1076     UINT16_TO_STREAM  (pp, timeout);
1077 
1078     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1079     return (TRUE);
1080 }
1081 
btsnd_hcic_write_scan_enable(UINT8 flag)1082 BOOLEAN btsnd_hcic_write_scan_enable (UINT8 flag)
1083 {
1084     BT_HDR *p;
1085     UINT8 *pp;
1086 
1087     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1088         return (FALSE);
1089 
1090     pp = (UINT8 *)(p + 1);
1091 
1092     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1093     p->offset = 0;
1094 
1095     UINT16_TO_STREAM (pp, HCI_WRITE_SCAN_ENABLE);
1096     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1097 
1098     UINT8_TO_STREAM  (pp, flag);
1099 
1100     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1101     return (TRUE);
1102 }
1103 
btsnd_hcic_write_pagescan_cfg(UINT16 interval,UINT16 window)1104 BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, UINT16 window)
1105 {
1106     BT_HDR *p;
1107     UINT8 *pp;
1108 
1109     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG)) == NULL)
1110         return (FALSE);
1111 
1112     pp = (UINT8 *)(p + 1);
1113 
1114     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG;
1115     p->offset = 0;
1116 
1117     UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_CFG);
1118     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG);
1119 
1120     UINT16_TO_STREAM (pp, interval);
1121     UINT16_TO_STREAM (pp, window);
1122 
1123     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1124     return (TRUE);
1125 }
1126 
btsnd_hcic_write_inqscan_cfg(UINT16 interval,UINT16 window)1127 BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window)
1128 {
1129     BT_HDR *p;
1130     UINT8 *pp;
1131 
1132     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG)) == NULL)
1133         return (FALSE);
1134 
1135     pp = (UINT8 *)(p + 1);
1136 
1137     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG;
1138     p->offset = 0;
1139 
1140     UINT16_TO_STREAM (pp, HCI_WRITE_INQUIRYSCAN_CFG);
1141     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG);
1142 
1143     UINT16_TO_STREAM (pp, interval);
1144     UINT16_TO_STREAM (pp, window);
1145 
1146     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1147     return (TRUE);
1148 }
1149 
btsnd_hcic_write_auth_enable(UINT8 flag)1150 BOOLEAN btsnd_hcic_write_auth_enable (UINT8 flag)
1151 {
1152     BT_HDR *p;
1153     UINT8 *pp;
1154 
1155     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1156         return (FALSE);
1157 
1158     pp = (UINT8 *)(p + 1);
1159 
1160     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1161     p->offset = 0;
1162 
1163     UINT16_TO_STREAM (pp, HCI_WRITE_AUTHENTICATION_ENABLE);
1164     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1165 
1166     UINT8_TO_STREAM (pp, flag);
1167 
1168     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1169     return (TRUE);
1170 }
1171 
btsnd_hcic_write_dev_class(DEV_CLASS dev_class)1172 BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev_class)
1173 {
1174     BT_HDR *p;
1175     UINT8 *pp;
1176 
1177     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM3)) == NULL)
1178         return (FALSE);
1179 
1180     pp = (UINT8 *)(p + 1);
1181 
1182     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3;
1183     p->offset = 0;
1184 
1185     UINT16_TO_STREAM (pp, HCI_WRITE_CLASS_OF_DEVICE);
1186     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM3);
1187 
1188     DEVCLASS_TO_STREAM (pp, dev_class);
1189 
1190     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1191     return (TRUE);
1192 }
1193 
btsnd_hcic_write_voice_settings(UINT16 flags)1194 BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags)
1195 {
1196     BT_HDR *p;
1197     UINT8 *pp;
1198 
1199     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1200         return (FALSE);
1201 
1202     pp = (UINT8 *)(p + 1);
1203 
1204     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1205     p->offset = 0;
1206 
1207     UINT16_TO_STREAM (pp, HCI_WRITE_VOICE_SETTINGS);
1208     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1209 
1210     UINT16_TO_STREAM (pp, flags);
1211 
1212     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1213     return (TRUE);
1214 }
1215 
btsnd_hcic_write_auto_flush_tout(UINT16 handle,UINT16 tout)1216 BOOLEAN btsnd_hcic_write_auto_flush_tout (UINT16 handle, UINT16 tout)
1217 {
1218     BT_HDR *p;
1219     UINT8 *pp;
1220 
1221     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT)) == NULL)
1222         return (FALSE);
1223 
1224     pp = (UINT8 *)(p + 1);
1225 
1226     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT;
1227     p->offset = 0;
1228 
1229     UINT16_TO_STREAM (pp, HCI_WRITE_AUTO_FLUSH_TOUT);
1230     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT);
1231 
1232     UINT16_TO_STREAM (pp, handle);
1233     UINT16_TO_STREAM (pp, tout);
1234 
1235     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1236     return (TRUE);
1237 }
1238 
btsnd_hcic_read_tx_power(UINT16 handle,UINT8 type)1239 BOOLEAN btsnd_hcic_read_tx_power (UINT16 handle, UINT8 type)
1240 {
1241     BT_HDR *p;
1242     UINT8 *pp;
1243 
1244     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_TX_POWER)) == NULL)
1245         return (FALSE);
1246 
1247     pp = (UINT8 *)(p + 1);
1248 
1249     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_TX_POWER;
1250     p->offset = 0;
1251 
1252     UINT16_TO_STREAM (pp, HCI_READ_TRANSMIT_POWER_LEVEL);
1253     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_TX_POWER);
1254 
1255     UINT16_TO_STREAM (pp, handle);
1256     UINT8_TO_STREAM  (pp, type);
1257 
1258     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1259     return (TRUE);
1260 }
1261 
btsnd_hcic_host_num_xmitted_pkts(UINT8 num_handles,UINT16 * handle,UINT16 * num_pkts)1262 BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, UINT16 *handle,
1263                                           UINT16 *num_pkts)
1264 {
1265     BT_HDR *p;
1266     UINT8 *pp;
1267     int j;
1268 
1269     if ((p = HCI_GET_CMD_BUF(1 + (num_handles * 4))) == NULL)
1270         return (FALSE);
1271 
1272     pp = (UINT8 *)(p + 1);
1273 
1274     p->len    = HCIC_PREAMBLE_SIZE + 1 + (num_handles * 4);
1275     p->offset = 0;
1276 
1277     UINT16_TO_STREAM (pp, HCI_HOST_NUM_PACKETS_DONE);
1278     UINT8_TO_STREAM  (pp, p->len - HCIC_PREAMBLE_SIZE);
1279 
1280     UINT8_TO_STREAM (pp, num_handles);
1281 
1282     for (j = 0; j < num_handles; j++)
1283     {
1284         UINT16_TO_STREAM (pp, handle[j]);
1285         UINT16_TO_STREAM (pp, num_pkts[j]);
1286     }
1287 
1288     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1289     return (TRUE);
1290 }
1291 
btsnd_hcic_write_link_super_tout(UINT8 local_controller_id,UINT16 handle,UINT16 timeout)1292 BOOLEAN btsnd_hcic_write_link_super_tout (UINT8 local_controller_id, UINT16 handle, UINT16 timeout)
1293 {
1294     BT_HDR *p;
1295     UINT8 *pp;
1296 
1297     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT)) == NULL)
1298         return (FALSE);
1299 
1300     pp = (UINT8 *)(p + 1);
1301 
1302     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT;
1303     p->offset = 0;
1304 
1305     UINT16_TO_STREAM (pp, HCI_WRITE_LINK_SUPER_TOUT);
1306     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT);
1307 
1308     UINT16_TO_STREAM (pp, handle);
1309     UINT16_TO_STREAM (pp, timeout);
1310 
1311     btu_hcif_send_cmd (local_controller_id,  p);
1312     return (TRUE);
1313 }
1314 
btsnd_hcic_write_cur_iac_lap(UINT8 num_cur_iac,LAP * const iac_lap)1315 BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, LAP * const iac_lap)
1316 {
1317     BT_HDR *p;
1318     UINT8 *pp;
1319     int i;
1320 
1321     if ((p = HCI_GET_CMD_BUF(1 + (LAP_LEN * num_cur_iac))) == NULL)
1322         return (FALSE);
1323 
1324     pp = (UINT8 *)(p + 1);
1325 
1326     p->len    = HCIC_PREAMBLE_SIZE + 1 + (LAP_LEN * num_cur_iac);
1327     p->offset = 0;
1328 
1329     UINT16_TO_STREAM (pp, HCI_WRITE_CURRENT_IAC_LAP);
1330     UINT8_TO_STREAM  (pp, p->len - HCIC_PREAMBLE_SIZE);
1331 
1332     UINT8_TO_STREAM (pp, num_cur_iac);
1333 
1334     for (i = 0; i < num_cur_iac; i++)
1335         LAP_TO_STREAM (pp, iac_lap[i]);
1336 
1337     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1338     return (TRUE);
1339 }
1340 
1341 /******************************************
1342 **    Lisbon Features
1343 *******************************************/
1344 #if BTM_SSR_INCLUDED == TRUE
1345 
btsnd_hcic_sniff_sub_rate(UINT16 handle,UINT16 max_lat,UINT16 min_remote_lat,UINT16 min_local_lat)1346 BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
1347                                   UINT16 min_remote_lat, UINT16 min_local_lat)
1348 {
1349     BT_HDR *p;
1350     UINT8 *pp;
1351 
1352     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SNIFF_SUB_RATE)) == NULL)
1353         return (FALSE);
1354 
1355     pp = (UINT8 *)(p + 1);
1356 
1357     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SNIFF_SUB_RATE;
1358     p->offset = 0;
1359 
1360     UINT16_TO_STREAM (pp, HCI_SNIFF_SUB_RATE);
1361     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SNIFF_SUB_RATE);
1362 
1363     UINT16_TO_STREAM  (pp, handle);
1364     UINT16_TO_STREAM  (pp, max_lat);
1365     UINT16_TO_STREAM  (pp, min_remote_lat);
1366     UINT16_TO_STREAM  (pp, min_local_lat);
1367 
1368     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1369     return (TRUE);
1370 }
1371 #endif /* BTM_SSR_INCLUDED */
1372 
1373 /**** Extended Inquiry Response Commands ****/
btsnd_hcic_write_ext_inquiry_response(void * buffer,UINT8 fec_req)1374 void btsnd_hcic_write_ext_inquiry_response (void *buffer, UINT8 fec_req)
1375 {
1376     BT_HDR *p = (BT_HDR *)buffer;
1377     UINT8 *pp = (UINT8 *)(p + 1);
1378 
1379     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_EXT_INQ_RESP;
1380     p->offset = 0;
1381 
1382     UINT16_TO_STREAM (pp, HCI_WRITE_EXT_INQ_RESPONSE);
1383     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_EXT_INQ_RESP);
1384 
1385     UINT8_TO_STREAM (pp, fec_req);
1386 
1387     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1388 }
1389 
btsnd_hcic_io_cap_req_reply(BD_ADDR bd_addr,UINT8 capability,UINT8 oob_present,UINT8 auth_req)1390 BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability,
1391                                 UINT8 oob_present, UINT8 auth_req)
1392 {
1393     BT_HDR *p;
1394     UINT8 *pp;
1395 
1396     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_IO_CAP_RESP)) == NULL)
1397         return (FALSE);
1398 
1399     pp = (UINT8 *)(p + 1);
1400 
1401     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_IO_CAP_RESP;
1402     p->offset = 0;
1403 
1404     UINT16_TO_STREAM (pp, HCI_IO_CAPABILITY_REQUEST_REPLY);
1405     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_IO_CAP_RESP);
1406 
1407     BDADDR_TO_STREAM (pp, bd_addr);
1408     UINT8_TO_STREAM  (pp, capability);
1409     UINT8_TO_STREAM  (pp, oob_present);
1410     UINT8_TO_STREAM  (pp, auth_req);
1411 
1412     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1413     return (TRUE);
1414 }
1415 
btsnd_hcic_io_cap_req_neg_reply(BD_ADDR bd_addr,UINT8 err_code)1416 BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code)
1417 {
1418     BT_HDR *p;
1419     UINT8 *pp;
1420 
1421     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY)) == NULL)
1422         return (FALSE);
1423 
1424     pp = (UINT8 *)(p + 1);
1425 
1426     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY;
1427     p->offset = 0;
1428 
1429     UINT16_TO_STREAM (pp, HCI_IO_CAP_REQ_NEG_REPLY);
1430     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY);
1431 
1432     BDADDR_TO_STREAM (pp, bd_addr);
1433     UINT8_TO_STREAM  (pp, err_code);
1434 
1435     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1436     return (TRUE);
1437 }
1438 
btsnd_hcic_read_local_oob_data(void)1439 BOOLEAN btsnd_hcic_read_local_oob_data (void)
1440 {
1441     BT_HDR *p;
1442     UINT8 *pp;
1443 
1444     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_LOCAL_OOB)) == NULL)
1445         return (FALSE);
1446 
1447     pp = (UINT8 *)(p + 1);
1448 
1449     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_LOCAL_OOB;
1450     p->offset = 0;
1451 
1452     UINT16_TO_STREAM (pp, HCI_READ_LOCAL_OOB_DATA);
1453     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_R_LOCAL_OOB);
1454 
1455     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1456     return (TRUE);
1457 }
1458 
btsnd_hcic_user_conf_reply(BD_ADDR bd_addr,BOOLEAN is_yes)1459 BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes)
1460 {
1461     BT_HDR *p;
1462     UINT8 *pp;
1463 
1464     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_UCONF_REPLY)) == NULL)
1465         return (FALSE);
1466 
1467     pp = (UINT8 *)(p + 1);
1468 
1469     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_UCONF_REPLY;
1470     p->offset = 0;
1471 
1472     if (!is_yes)
1473     {
1474         /* Negative reply */
1475         UINT16_TO_STREAM (pp, HCI_USER_CONF_VALUE_NEG_REPLY);
1476     }
1477     else
1478     {
1479         /* Confirmation */
1480         UINT16_TO_STREAM (pp, HCI_USER_CONF_REQUEST_REPLY);
1481     }
1482 
1483     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_UCONF_REPLY);
1484 
1485     BDADDR_TO_STREAM (pp, bd_addr);
1486 
1487     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1488     return (TRUE);
1489 }
1490 
btsnd_hcic_user_passkey_reply(BD_ADDR bd_addr,UINT32 value)1491 BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value)
1492 {
1493     BT_HDR *p;
1494     UINT8 *pp;
1495 
1496     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_U_PKEY_REPLY)) == NULL)
1497         return (FALSE);
1498 
1499     pp = (UINT8 *)(p + 1);
1500 
1501     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_U_PKEY_REPLY;
1502     p->offset = 0;
1503 
1504     UINT16_TO_STREAM (pp, HCI_USER_PASSKEY_REQ_REPLY);
1505     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_U_PKEY_REPLY);
1506 
1507     BDADDR_TO_STREAM (pp, bd_addr);
1508     UINT32_TO_STREAM (pp, value);
1509 
1510     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1511     return (TRUE);
1512 }
1513 
btsnd_hcic_user_passkey_neg_reply(BD_ADDR bd_addr)1514 BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr)
1515 {
1516     BT_HDR *p;
1517     UINT8 *pp;
1518 
1519     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY)) == NULL)
1520         return (FALSE);
1521 
1522     pp = (UINT8 *)(p + 1);
1523 
1524     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY;
1525     p->offset = 0;
1526 
1527     UINT16_TO_STREAM (pp, HCI_USER_PASSKEY_REQ_NEG_REPLY);
1528     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY);
1529 
1530     BDADDR_TO_STREAM (pp, bd_addr);
1531 
1532     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1533     return (TRUE);
1534 }
1535 
btsnd_hcic_rem_oob_reply(BD_ADDR bd_addr,UINT8 * p_c,UINT8 * p_r)1536 BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c, UINT8 *p_r)
1537 {
1538     BT_HDR *p;
1539     UINT8 *pp;
1540 
1541     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REM_OOB_REPLY)) == NULL)
1542         return (FALSE);
1543 
1544     pp = (UINT8 *)(p + 1);
1545 
1546     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REM_OOB_REPLY;
1547     p->offset = 0;
1548 
1549     UINT16_TO_STREAM (pp, HCI_REM_OOB_DATA_REQ_REPLY);
1550     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_REM_OOB_REPLY);
1551 
1552     BDADDR_TO_STREAM (pp, bd_addr);
1553     ARRAY16_TO_STREAM (pp, p_c);
1554     ARRAY16_TO_STREAM (pp, p_r);
1555 
1556     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1557     return (TRUE);
1558 }
1559 
btsnd_hcic_rem_oob_neg_reply(BD_ADDR bd_addr)1560 BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr)
1561 {
1562     BT_HDR *p;
1563     UINT8 *pp;
1564 
1565     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY)) == NULL)
1566         return (FALSE);
1567 
1568     pp = (UINT8 *)(p + 1);
1569 
1570     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY;
1571     p->offset = 0;
1572 
1573     UINT16_TO_STREAM (pp, HCI_REM_OOB_DATA_REQ_NEG_REPLY);
1574     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY);
1575 
1576     BDADDR_TO_STREAM (pp, bd_addr);
1577 
1578     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1579     return (TRUE);
1580 }
1581 
1582 
btsnd_hcic_read_inq_tx_power(void)1583 BOOLEAN btsnd_hcic_read_inq_tx_power (void)
1584 {
1585     BT_HDR *p;
1586     UINT8 *pp;
1587 
1588     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_TX_POWER)) == NULL)
1589         return (FALSE);
1590 
1591     pp = (UINT8 *)(p + 1);
1592 
1593     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_TX_POWER;
1594     p->offset = 0;
1595 
1596     UINT16_TO_STREAM (pp, HCI_READ_INQ_TX_POWER_LEVEL);
1597     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_R_TX_POWER);
1598 
1599     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1600     return (TRUE);
1601 }
1602 
btsnd_hcic_send_keypress_notif(BD_ADDR bd_addr,UINT8 notif)1603 BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif)
1604 {
1605     BT_HDR *p;
1606     UINT8 *pp;
1607 
1608     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF)) == NULL)
1609         return (FALSE);
1610 
1611     pp = (UINT8 *)(p + 1);
1612 
1613     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF;
1614     p->offset = 0;
1615 
1616     UINT16_TO_STREAM (pp, HCI_SEND_KEYPRESS_NOTIF);
1617     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF);
1618 
1619     BDADDR_TO_STREAM (pp, bd_addr);
1620     UINT8_TO_STREAM (pp, notif);
1621 
1622     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1623     return (TRUE);
1624 }
1625 
1626 /**** end of Simple Pairing Commands ****/
1627 
1628 #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
btsnd_hcic_enhanced_flush(UINT16 handle,UINT8 packet_type)1629 BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type)
1630 {
1631     BT_HDR *p;
1632     UINT8 *pp;
1633 
1634     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ENHANCED_FLUSH)) == NULL)
1635         return (FALSE);
1636 
1637     pp = (UINT8 *)(p + 1);
1638 
1639     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ENHANCED_FLUSH;
1640     p->offset = 0;
1641     UINT16_TO_STREAM (pp, HCI_ENHANCED_FLUSH);
1642     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_ENHANCED_FLUSH);
1643 
1644     UINT16_TO_STREAM (pp, handle);
1645     UINT8_TO_STREAM  (pp, packet_type);
1646 
1647     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1648     return (TRUE);
1649 }
1650 #endif
1651 
1652 /*************************
1653 ** End of Lisbon Commands
1654 **************************/
1655 
btsnd_hcic_get_link_quality(UINT16 handle)1656 BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle)
1657 {
1658     BT_HDR *p;
1659     UINT8 *pp;
1660 
1661     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
1662         return (FALSE);
1663 
1664     pp = (UINT8 *)(p + 1);
1665 
1666     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
1667     p->offset = 0;
1668 
1669     UINT16_TO_STREAM (pp, HCI_GET_LINK_QUALITY);
1670     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
1671 
1672     UINT16_TO_STREAM (pp, handle);
1673 
1674     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1675     return (TRUE);
1676 }
1677 
btsnd_hcic_read_rssi(UINT16 handle)1678 BOOLEAN btsnd_hcic_read_rssi (UINT16 handle)
1679 {
1680     BT_HDR *p;
1681     UINT8 *pp;
1682 
1683     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
1684         return (FALSE);
1685 
1686     pp = (UINT8 *)(p + 1);
1687 
1688     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
1689     p->offset = 0;
1690 
1691     UINT16_TO_STREAM (pp, HCI_READ_RSSI);
1692     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
1693 
1694     UINT16_TO_STREAM (pp, handle);
1695 
1696     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1697     return (TRUE);
1698 }
1699 
btsnd_hcic_enable_test_mode(void)1700 BOOLEAN btsnd_hcic_enable_test_mode (void)
1701 {
1702     BT_HDR *p;
1703     UINT8 *pp;
1704 
1705     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1706         return (FALSE);
1707 
1708     pp = (UINT8 *)(p + 1);
1709 
1710     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1711     p->offset = 0;
1712 
1713     UINT16_TO_STREAM (pp, HCI_ENABLE_DEV_UNDER_TEST_MODE);
1714     UINT8_TO_STREAM  (pp,  HCIC_PARAM_SIZE_READ_CMD);
1715 
1716     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1717     return (TRUE);
1718 }
1719 
btsnd_hcic_write_inqscan_type(UINT8 type)1720 BOOLEAN btsnd_hcic_write_inqscan_type (UINT8 type)
1721 {
1722     BT_HDR *p;
1723     UINT8 *pp;
1724 
1725     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1726         return (FALSE);
1727 
1728     pp = (UINT8 *)(p + 1);
1729 
1730     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1731     p->offset = 0;
1732 
1733     UINT16_TO_STREAM (pp, HCI_WRITE_INQSCAN_TYPE);
1734     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1735 
1736     UINT8_TO_STREAM  (pp, type);
1737 
1738     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1739     return (TRUE);
1740 }
1741 
btsnd_hcic_write_inquiry_mode(UINT8 mode)1742 BOOLEAN btsnd_hcic_write_inquiry_mode (UINT8 mode)
1743 {
1744     BT_HDR *p;
1745     UINT8 *pp;
1746 
1747     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1748         return (FALSE);
1749 
1750     pp = (UINT8 *)(p + 1);
1751 
1752     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1753     p->offset = 0;
1754 
1755     UINT16_TO_STREAM (pp, HCI_WRITE_INQUIRY_MODE);
1756     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1757 
1758     UINT8_TO_STREAM  (pp, mode);
1759 
1760     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1761     return (TRUE);
1762 }
1763 
btsnd_hcic_write_pagescan_type(UINT8 type)1764 BOOLEAN btsnd_hcic_write_pagescan_type (UINT8 type)
1765 {
1766     BT_HDR *p;
1767     UINT8 *pp;
1768 
1769     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1770         return (FALSE);
1771 
1772     pp = (UINT8 *)(p + 1);
1773 
1774     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1775     p->offset = 0;
1776 
1777     UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_TYPE);
1778     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1779 
1780     UINT8_TO_STREAM  (pp, type);
1781 
1782     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1783     return (TRUE);
1784 }
1785 
1786 /* Must have room to store BT_HDR + max VSC length + callback pointer */
1787 #if (HCI_CMD_POOL_BUF_SIZE < 268)
1788 #error "HCI_CMD_POOL_BUF_SIZE must be larger than 268"
1789 #endif
1790 
btsnd_hcic_vendor_spec_cmd(void * buffer,UINT16 opcode,UINT8 len,UINT8 * p_data,void * p_cmd_cplt_cback)1791 void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, UINT8 len,
1792                                  UINT8 *p_data, void *p_cmd_cplt_cback)
1793 {
1794     BT_HDR *p = (BT_HDR *)buffer;
1795     UINT8 *pp = (UINT8 *)(p + 1);
1796 
1797     p->len    = HCIC_PREAMBLE_SIZE + len;
1798     p->offset = sizeof(void *);
1799 
1800     *((void **)pp) = p_cmd_cplt_cback;  /* Store command complete callback in buffer */
1801     pp += sizeof(void *);               /* Skip over callback pointer */
1802 
1803     UINT16_TO_STREAM (pp, HCI_GRP_VENDOR_SPECIFIC | opcode);
1804     UINT8_TO_STREAM  (pp, len);
1805     ARRAY_TO_STREAM  (pp, p_data, len);
1806 
1807     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1808 }
1809