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 "gki.h"
28 #include "hcidefs.h"
29 #include "hcimsgs.h"
30 #include "hcidefs.h"
31 #include "btu.h"
32
33 #include <stddef.h>
34 #include <string.h>
35
36 #if defined (LMP_TEST)
37 #include <script.h>
38 #define btu_hcif_send_cmd(p1, p2) HCI_CMD_TO_LOWER((p2))
39 #else
40 #include "btm_int.h" /* Included for UIPC_* macro definitions */
41 #endif
42
btsnd_hcic_inquiry(const LAP inq_lap,UINT8 duration,UINT8 response_cnt)43 BOOLEAN btsnd_hcic_inquiry(const LAP inq_lap, UINT8 duration, UINT8 response_cnt)
44 {
45 BT_HDR *p;
46 UINT8 *pp;
47
48 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_INQUIRY)) == NULL)
49 return (FALSE);
50
51 pp = (UINT8 *)(p + 1);
52
53 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_INQUIRY;
54 p->offset = 0;
55
56 UINT16_TO_STREAM (pp, HCI_INQUIRY);
57 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_INQUIRY);
58
59 LAP_TO_STREAM (pp, inq_lap);
60 UINT8_TO_STREAM (pp, duration);
61 UINT8_TO_STREAM (pp, response_cnt);
62
63 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
64 return (TRUE);
65 }
66
btsnd_hcic_inq_cancel(void)67 BOOLEAN btsnd_hcic_inq_cancel(void)
68 {
69 BT_HDR *p;
70 UINT8 *pp;
71
72 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_INQ_CANCEL)) == NULL)
73 return (FALSE);
74
75 pp = (UINT8 *)(p + 1);
76
77 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_INQ_CANCEL;
78 p->offset = 0;
79 UINT16_TO_STREAM (pp, HCI_INQUIRY_CANCEL);
80 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_INQ_CANCEL);
81
82 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
83 return (TRUE);
84 }
85
btsnd_hcic_per_inq_mode(UINT16 max_period,UINT16 min_period,const LAP inq_lap,UINT8 duration,UINT8 response_cnt)86 BOOLEAN btsnd_hcic_per_inq_mode (UINT16 max_period, UINT16 min_period,
87 const LAP inq_lap, UINT8 duration, UINT8 response_cnt)
88 {
89 BT_HDR *p;
90 UINT8 *pp;
91
92 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PER_INQ_MODE)) == NULL)
93 return (FALSE);
94
95 pp = (UINT8 *)(p + 1);
96
97 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PER_INQ_MODE;
98 p->offset = 0;
99
100 UINT16_TO_STREAM (pp, HCI_PERIODIC_INQUIRY_MODE);
101 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_PER_INQ_MODE);
102
103 UINT16_TO_STREAM (pp, max_period);
104 UINT16_TO_STREAM (pp, min_period);
105 LAP_TO_STREAM (pp, inq_lap);
106 UINT8_TO_STREAM (pp, duration);
107 UINT8_TO_STREAM (pp, response_cnt);
108
109 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
110 return (TRUE);
111 }
112
btsnd_hcic_exit_per_inq(void)113 BOOLEAN btsnd_hcic_exit_per_inq (void)
114 {
115 BT_HDR *p;
116 UINT8 *pp;
117
118 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_EXIT_PER_INQ)) == NULL)
119 return (FALSE);
120
121 pp = (UINT8 *)(p + 1);
122
123 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_EXIT_PER_INQ;
124 p->offset = 0;
125 UINT16_TO_STREAM (pp, HCI_EXIT_PERIODIC_INQUIRY_MODE);
126 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_EXIT_PER_INQ);
127
128 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
129 return (TRUE);
130 }
131
132
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)133 BOOLEAN btsnd_hcic_create_conn(BD_ADDR dest, UINT16 packet_types,
134 UINT8 page_scan_rep_mode, UINT8 page_scan_mode,
135 UINT16 clock_offset, UINT8 allow_switch)
136 {
137 BT_HDR *p;
138 UINT8 *pp;
139
140 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CREATE_CONN)) == NULL)
141 return (FALSE);
142
143 pp = (UINT8 *)(p + 1);
144
145 #ifndef BT_10A
146 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CREATE_CONN;
147 #else
148 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CREATE_CONN - 1;
149 #endif
150 p->offset = 0;
151
152 UINT16_TO_STREAM (pp, HCI_CREATE_CONNECTION);
153 #ifndef BT_10A
154 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CREATE_CONN);
155 #else
156 UINT8_TO_STREAM (pp, (HCIC_PARAM_SIZE_CREATE_CONN - 1));
157 #endif
158 BDADDR_TO_STREAM (pp, dest);
159 UINT16_TO_STREAM (pp, packet_types);
160 UINT8_TO_STREAM (pp, page_scan_rep_mode);
161 UINT8_TO_STREAM (pp, page_scan_mode);
162 UINT16_TO_STREAM (pp, clock_offset);
163 #if !defined (BT_10A)
164 UINT8_TO_STREAM (pp, allow_switch);
165 #endif
166 /* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */
167 #if (!defined (LMP_TEST) && !defined(BTISE))
168 btm_acl_paging (p, dest);
169 #else
170 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
171 #endif
172 return (TRUE);
173 }
174
btsnd_hcic_disconnect(UINT16 handle,UINT8 reason)175 BOOLEAN btsnd_hcic_disconnect (UINT16 handle, UINT8 reason)
176 {
177 BT_HDR *p;
178 UINT8 *pp;
179
180 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_DISCONNECT)) == NULL)
181 return (FALSE);
182
183 pp = (UINT8 *)(p + 1);
184
185 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_DISCONNECT;
186 p->offset = 0;
187
188 UINT16_TO_STREAM (pp, HCI_DISCONNECT);
189 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_DISCONNECT);
190 UINT16_TO_STREAM (pp, handle);
191 UINT8_TO_STREAM (pp, reason);
192
193 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
194 /* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */
195 #if (!defined (LMP_TEST) && !defined(BTISE))
196 // btla-specific ++
197 // btm_acl_set_discing(TRUE);
198 // btla-specific --
199 #endif
200 return (TRUE);
201 }
202
203 #if BTM_SCO_INCLUDED == TRUE
btsnd_hcic_add_SCO_conn(UINT16 handle,UINT16 packet_types)204 BOOLEAN btsnd_hcic_add_SCO_conn (UINT16 handle, UINT16 packet_types)
205 {
206 BT_HDR *p;
207 UINT8 *pp;
208
209 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ADD_SCO_CONN)) == NULL)
210 return (FALSE);
211
212 pp = (UINT8 *)(p + 1);
213
214 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ADD_SCO_CONN;
215 p->offset = 0;
216
217 UINT16_TO_STREAM (pp, HCI_ADD_SCO_CONNECTION);
218 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_ADD_SCO_CONN);
219
220 UINT16_TO_STREAM (pp, handle);
221 UINT16_TO_STREAM (pp, packet_types);
222
223 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
224 return (TRUE);
225 }
226 #endif /* BTM_SCO_INCLUDED */
227
btsnd_hcic_create_conn_cancel(BD_ADDR dest)228 BOOLEAN btsnd_hcic_create_conn_cancel(BD_ADDR dest)
229 {
230 BT_HDR *p;
231 UINT8 *pp;
232
233 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CREATE_CONN_CANCEL)) == NULL)
234 return (FALSE);
235
236 pp = (UINT8 *)(p + 1);
237
238 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CREATE_CONN_CANCEL;
239 p->offset = 0;
240
241 UINT16_TO_STREAM (pp, HCI_CREATE_CONNECTION_CANCEL);
242 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CREATE_CONN_CANCEL);
243
244 BDADDR_TO_STREAM (pp, dest);
245
246 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
247 return (TRUE);
248 }
249
btsnd_hcic_accept_conn(BD_ADDR dest,UINT8 role)250 BOOLEAN btsnd_hcic_accept_conn (BD_ADDR dest, UINT8 role)
251 {
252 BT_HDR *p;
253 UINT8 *pp;
254
255 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ACCEPT_CONN)) == NULL)
256 return (FALSE);
257
258 pp = (UINT8 *)(p + 1);
259
260 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ACCEPT_CONN;
261 p->offset = 0;
262
263 UINT16_TO_STREAM (pp, HCI_ACCEPT_CONNECTION_REQUEST);
264 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_ACCEPT_CONN);
265 BDADDR_TO_STREAM (pp, dest);
266 UINT8_TO_STREAM (pp, role);
267
268 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
269 return (TRUE);
270 }
271
btsnd_hcic_reject_conn(BD_ADDR dest,UINT8 reason)272 BOOLEAN btsnd_hcic_reject_conn (BD_ADDR dest, UINT8 reason)
273 {
274 BT_HDR *p;
275 UINT8 *pp;
276
277 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REJECT_CONN)) == NULL)
278 return (FALSE);
279
280 pp = (UINT8 *)(p + 1);
281
282 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REJECT_CONN;
283 p->offset = 0;
284
285 UINT16_TO_STREAM (pp, HCI_REJECT_CONNECTION_REQUEST);
286 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_REJECT_CONN);
287
288 BDADDR_TO_STREAM (pp, dest);
289 UINT8_TO_STREAM (pp, reason);
290
291 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
292 return (TRUE);
293 }
294
btsnd_hcic_link_key_req_reply(BD_ADDR bd_addr,LINK_KEY link_key)295 BOOLEAN btsnd_hcic_link_key_req_reply (BD_ADDR bd_addr, LINK_KEY link_key)
296 {
297 BT_HDR *p;
298 UINT8 *pp;
299
300 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY)) == NULL)
301 return (FALSE);
302
303 pp = (UINT8 *)(p + 1);
304
305 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY;
306 p->offset = 0;
307
308 UINT16_TO_STREAM (pp, HCI_LINK_KEY_REQUEST_REPLY);
309 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LINK_KEY_REQ_REPLY);
310
311 BDADDR_TO_STREAM (pp, bd_addr);
312 ARRAY16_TO_STREAM (pp, link_key);
313
314 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
315 return (TRUE);
316 }
317
btsnd_hcic_link_key_neg_reply(BD_ADDR bd_addr)318 BOOLEAN btsnd_hcic_link_key_neg_reply (BD_ADDR bd_addr)
319 {
320 BT_HDR *p;
321 UINT8 *pp;
322
323 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY)) == NULL)
324 return (FALSE);
325
326 pp = (UINT8 *)(p + 1);
327
328 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY;
329 p->offset = 0;
330
331 UINT16_TO_STREAM (pp, HCI_LINK_KEY_REQUEST_NEG_REPLY);
332 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LINK_KEY_NEG_REPLY);
333
334 BDADDR_TO_STREAM (pp, bd_addr);
335
336 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
337 return (TRUE);
338 }
339
btsnd_hcic_pin_code_req_reply(BD_ADDR bd_addr,UINT8 pin_code_len,PIN_CODE pin_code)340 BOOLEAN btsnd_hcic_pin_code_req_reply (BD_ADDR bd_addr, UINT8 pin_code_len,
341 PIN_CODE pin_code)
342 {
343 BT_HDR *p;
344 UINT8 *pp;
345 int i;
346
347 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY)) == NULL)
348 return (FALSE);
349
350 pp = (UINT8 *)(p + 1);
351
352 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY;
353 p->offset = 0;
354
355 UINT16_TO_STREAM (pp, HCI_PIN_CODE_REQUEST_REPLY);
356 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_PIN_CODE_REQ_REPLY);
357
358 BDADDR_TO_STREAM (pp, bd_addr);
359 UINT8_TO_STREAM (pp, pin_code_len);
360
361 for (i = 0; i < pin_code_len; i++)
362 *pp++ = *pin_code++;
363
364 for (; i < PIN_CODE_LEN; i++)
365 *pp++ = 0;
366
367
368 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
369 return (TRUE);
370 }
371
btsnd_hcic_pin_code_neg_reply(BD_ADDR bd_addr)372 BOOLEAN btsnd_hcic_pin_code_neg_reply (BD_ADDR bd_addr)
373 {
374 BT_HDR *p;
375 UINT8 *pp;
376
377 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY)) == NULL)
378 return (FALSE);
379
380 pp = (UINT8 *)(p + 1);
381
382 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY;
383 p->offset = 0;
384
385 UINT16_TO_STREAM (pp, HCI_PIN_CODE_REQUEST_NEG_REPLY);
386 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_PIN_CODE_NEG_REPLY);
387
388 BDADDR_TO_STREAM (pp, bd_addr);
389
390 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
391 return (TRUE);
392 }
393
btsnd_hcic_change_conn_type(UINT16 handle,UINT16 packet_types)394 BOOLEAN btsnd_hcic_change_conn_type (UINT16 handle, UINT16 packet_types)
395 {
396 BT_HDR *p;
397 UINT8 *pp;
398
399 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CHANGE_CONN_TYPE)) == NULL)
400 return (FALSE);
401
402 pp = (UINT8 *)(p + 1);
403
404 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CHANGE_CONN_TYPE;
405 p->offset = 0;
406
407 UINT16_TO_STREAM (pp, HCI_CHANGE_CONN_PACKET_TYPE);
408 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CHANGE_CONN_TYPE);
409
410 UINT16_TO_STREAM (pp, handle);
411 UINT16_TO_STREAM (pp, packet_types);
412
413 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
414 return (TRUE);
415 }
416
btsnd_hcic_auth_request(UINT16 handle)417 BOOLEAN btsnd_hcic_auth_request (UINT16 handle)
418 {
419 BT_HDR *p;
420 UINT8 *pp;
421
422 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
423 return (FALSE);
424
425 pp = (UINT8 *)(p + 1);
426
427 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
428 p->offset = 0;
429
430 UINT16_TO_STREAM (pp, HCI_AUTHENTICATION_REQUESTED);
431 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
432
433 UINT16_TO_STREAM (pp, handle);
434
435 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
436 return (TRUE);
437 }
438
btsnd_hcic_set_conn_encrypt(UINT16 handle,BOOLEAN enable)439 BOOLEAN btsnd_hcic_set_conn_encrypt (UINT16 handle, BOOLEAN enable)
440 {
441 BT_HDR *p;
442 UINT8 *pp;
443
444 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_CONN_ENCRYPT)) == NULL)
445 return (FALSE);
446
447 pp = (UINT8 *)(p + 1);
448
449 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_CONN_ENCRYPT;
450 p->offset = 0;
451
452 UINT16_TO_STREAM (pp, HCI_SET_CONN_ENCRYPTION);
453 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_CONN_ENCRYPT);
454
455 UINT16_TO_STREAM (pp, handle);
456 UINT8_TO_STREAM (pp, enable);
457
458 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
459 return (TRUE);
460 }
461
btsnd_hcic_change_link_key(UINT16 handle)462 BOOLEAN btsnd_hcic_change_link_key (UINT16 handle)
463 {
464 BT_HDR *p;
465 UINT8 *pp;
466
467 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
468 return (FALSE);
469
470 pp = (UINT8 *)(p + 1);
471
472 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
473 p->offset = 0;
474
475 UINT16_TO_STREAM (pp, HCI_CHANGE_CONN_LINK_KEY);
476 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
477
478 UINT16_TO_STREAM (pp, handle);
479
480 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
481 return (TRUE);
482 }
483
btsnd_hcic_master_link_key(BOOLEAN key_flag)484 BOOLEAN btsnd_hcic_master_link_key (BOOLEAN key_flag)
485 {
486 BT_HDR *p;
487 UINT8 *pp;
488
489 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_MASTER_LINK_KEY)) == NULL)
490 return (FALSE);
491
492 pp = (UINT8 *)(p + 1);
493
494 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_MASTER_LINK_KEY;
495 p->offset = 0;
496
497 UINT16_TO_STREAM (pp, HCI_MASTER_LINK_KEY);
498 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_MASTER_LINK_KEY);
499
500 UINT8_TO_STREAM (pp, key_flag);
501
502 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
503 return (TRUE);
504 }
505
btsnd_hcic_rmt_name_req(BD_ADDR bd_addr,UINT8 page_scan_rep_mode,UINT8 page_scan_mode,UINT16 clock_offset)506 BOOLEAN btsnd_hcic_rmt_name_req (BD_ADDR bd_addr, UINT8 page_scan_rep_mode,
507 UINT8 page_scan_mode, UINT16 clock_offset)
508 {
509 BT_HDR *p;
510 UINT8 *pp;
511
512 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RMT_NAME_REQ)) == NULL)
513 return (FALSE);
514
515 pp = (UINT8 *)(p + 1);
516
517 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RMT_NAME_REQ;
518 p->offset = 0;
519
520 UINT16_TO_STREAM (pp, HCI_RMT_NAME_REQUEST);
521 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_RMT_NAME_REQ);
522
523 BDADDR_TO_STREAM (pp, bd_addr);
524 UINT8_TO_STREAM (pp, page_scan_rep_mode);
525 UINT8_TO_STREAM (pp, page_scan_mode);
526 UINT16_TO_STREAM (pp, clock_offset);
527
528 /* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */
529 #if (!defined (LMP_TEST) && !defined(BTISE))
530 btm_acl_paging (p, bd_addr);
531 #else
532 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
533 #endif
534 return (TRUE);
535 }
536
btsnd_hcic_rmt_name_req_cancel(BD_ADDR bd_addr)537 BOOLEAN btsnd_hcic_rmt_name_req_cancel (BD_ADDR bd_addr)
538 {
539 BT_HDR *p;
540 UINT8 *pp;
541
542 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL)) == NULL)
543 return (FALSE);
544
545 pp = (UINT8 *)(p + 1);
546
547 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL;
548 p->offset = 0;
549
550 UINT16_TO_STREAM (pp, HCI_RMT_NAME_REQUEST_CANCEL);
551 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_RMT_NAME_REQ_CANCEL);
552
553 BDADDR_TO_STREAM (pp, bd_addr);
554
555 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
556 return (TRUE);
557 }
558
btsnd_hcic_rmt_features_req(UINT16 handle)559 BOOLEAN btsnd_hcic_rmt_features_req (UINT16 handle)
560 {
561 BT_HDR *p;
562 UINT8 *pp;
563
564 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
565 return (FALSE);
566
567 pp = (UINT8 *)(p + 1);
568
569 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
570 p->offset = 0;
571
572 UINT16_TO_STREAM (pp, HCI_READ_RMT_FEATURES);
573 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
574
575 UINT16_TO_STREAM (pp, handle);
576
577 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
578 return (TRUE);
579 }
580
btsnd_hcic_rmt_ext_features(UINT16 handle,UINT8 page_num)581 BOOLEAN btsnd_hcic_rmt_ext_features (UINT16 handle, UINT8 page_num)
582 {
583 BT_HDR *p;
584 UINT8 *pp;
585
586 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RMT_EXT_FEATURES)) == NULL)
587 return (FALSE);
588
589 pp = (UINT8 *)(p + 1);
590
591 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RMT_EXT_FEATURES;
592 p->offset = 0;
593
594 UINT16_TO_STREAM (pp, HCI_READ_RMT_EXT_FEATURES);
595 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_RMT_EXT_FEATURES);
596
597 UINT16_TO_STREAM (pp, handle);
598 UINT8_TO_STREAM (pp, page_num);
599
600 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
601 return (TRUE);
602 }
603
btsnd_hcic_rmt_ver_req(UINT16 handle)604 BOOLEAN btsnd_hcic_rmt_ver_req (UINT16 handle)
605 {
606 BT_HDR *p;
607 UINT8 *pp;
608
609 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
610 return (FALSE);
611
612 pp = (UINT8 *)(p + 1);
613
614 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
615 p->offset = 0;
616
617 UINT16_TO_STREAM (pp, HCI_READ_RMT_VERSION_INFO);
618 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
619
620 UINT16_TO_STREAM (pp, handle);
621
622 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
623 return (TRUE);
624 }
625
btsnd_hcic_read_rmt_clk_offset(UINT16 handle)626 BOOLEAN btsnd_hcic_read_rmt_clk_offset (UINT16 handle)
627 {
628 BT_HDR *p;
629 UINT8 *pp;
630
631 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
632 return (FALSE);
633
634 pp = (UINT8 *)(p + 1);
635
636 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
637 p->offset = 0;
638
639 UINT16_TO_STREAM (pp, HCI_READ_RMT_CLOCK_OFFSET);
640 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
641
642 UINT16_TO_STREAM (pp, handle);
643
644 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
645 return (TRUE);
646 }
647
btsnd_hcic_read_lmp_handle(UINT16 handle)648 BOOLEAN btsnd_hcic_read_lmp_handle (UINT16 handle)
649 {
650 BT_HDR *p;
651 UINT8 *pp;
652
653 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
654 return (FALSE);
655
656 pp = (UINT8 *)(p + 1);
657
658 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
659 p->offset = 0;
660
661 UINT16_TO_STREAM (pp, HCI_READ_LMP_HANDLE);
662 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
663
664 UINT16_TO_STREAM (pp, handle);
665
666 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
667 return (TRUE);
668 }
669
btsnd_hcic_setup_esco_conn(UINT16 handle,UINT32 tx_bw,UINT32 rx_bw,UINT16 max_latency,UINT16 voice,UINT8 retrans_effort,UINT16 packet_types)670 BOOLEAN btsnd_hcic_setup_esco_conn (UINT16 handle, UINT32 tx_bw,
671 UINT32 rx_bw, UINT16 max_latency, UINT16 voice,
672 UINT8 retrans_effort, UINT16 packet_types)
673 {
674 BT_HDR *p;
675 UINT8 *pp;
676
677 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SETUP_ESCO)) == NULL)
678 return (FALSE);
679
680 pp = (UINT8 *)(p + 1);
681
682 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SETUP_ESCO;
683 p->offset = 0;
684
685 UINT16_TO_STREAM (pp, HCI_SETUP_ESCO_CONNECTION);
686 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SETUP_ESCO);
687
688 UINT16_TO_STREAM (pp, handle);
689 UINT32_TO_STREAM (pp, tx_bw);
690 UINT32_TO_STREAM (pp, rx_bw);
691 UINT16_TO_STREAM (pp, max_latency);
692 UINT16_TO_STREAM (pp, voice);
693 UINT8_TO_STREAM (pp, retrans_effort);
694 UINT16_TO_STREAM (pp, packet_types);
695
696 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
697 return (TRUE);
698 }
699
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)700 BOOLEAN btsnd_hcic_accept_esco_conn (BD_ADDR bd_addr, UINT32 tx_bw,
701 UINT32 rx_bw, UINT16 max_latency,
702 UINT16 content_fmt, UINT8 retrans_effort,
703 UINT16 packet_types)
704 {
705 BT_HDR *p;
706 UINT8 *pp;
707
708 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ACCEPT_ESCO)) == NULL)
709 return (FALSE);
710
711 pp = (UINT8 *)(p + 1);
712
713 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ACCEPT_ESCO;
714 p->offset = 0;
715
716 UINT16_TO_STREAM (pp, HCI_ACCEPT_ESCO_CONNECTION);
717 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_ACCEPT_ESCO);
718
719 BDADDR_TO_STREAM (pp, bd_addr);
720 UINT32_TO_STREAM (pp, tx_bw);
721 UINT32_TO_STREAM (pp, rx_bw);
722 UINT16_TO_STREAM (pp, max_latency);
723 UINT16_TO_STREAM (pp, content_fmt);
724 UINT8_TO_STREAM (pp, retrans_effort);
725 UINT16_TO_STREAM (pp, packet_types);
726
727 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
728 return (TRUE);
729 }
730
btsnd_hcic_reject_esco_conn(BD_ADDR bd_addr,UINT8 reason)731 BOOLEAN btsnd_hcic_reject_esco_conn (BD_ADDR bd_addr, UINT8 reason)
732 {
733 BT_HDR *p;
734 UINT8 *pp;
735
736 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REJECT_ESCO)) == NULL)
737 return (FALSE);
738
739 pp = (UINT8 *)(p + 1);
740
741 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REJECT_ESCO;
742 p->offset = 0;
743
744 UINT16_TO_STREAM (pp, HCI_REJECT_ESCO_CONNECTION);
745 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_REJECT_ESCO);
746
747 BDADDR_TO_STREAM (pp, bd_addr);
748 UINT8_TO_STREAM (pp, reason);
749
750 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
751 return (TRUE);
752 }
753
btsnd_hcic_hold_mode(UINT16 handle,UINT16 max_hold_period,UINT16 min_hold_period)754 BOOLEAN btsnd_hcic_hold_mode (UINT16 handle, UINT16 max_hold_period,
755 UINT16 min_hold_period)
756 {
757 BT_HDR *p;
758 UINT8 *pp;
759
760 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_HOLD_MODE)) == NULL)
761 return (FALSE);
762
763 pp = (UINT8 *)(p + 1);
764
765 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_HOLD_MODE;
766 p->offset = 0;
767
768 UINT16_TO_STREAM (pp, HCI_HOLD_MODE);
769 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_HOLD_MODE);
770
771 UINT16_TO_STREAM (pp, handle);
772 UINT16_TO_STREAM (pp, max_hold_period);
773 UINT16_TO_STREAM (pp, min_hold_period);
774
775 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
776 return (TRUE);
777 }
778
btsnd_hcic_sniff_mode(UINT16 handle,UINT16 max_sniff_period,UINT16 min_sniff_period,UINT16 sniff_attempt,UINT16 sniff_timeout)779 BOOLEAN btsnd_hcic_sniff_mode (UINT16 handle, UINT16 max_sniff_period,
780 UINT16 min_sniff_period, UINT16 sniff_attempt,
781 UINT16 sniff_timeout)
782 {
783 BT_HDR *p;
784 UINT8 *pp;
785
786 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SNIFF_MODE)) == NULL)
787 return (FALSE);
788
789 pp = (UINT8 *)(p + 1);
790
791 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SNIFF_MODE;
792 p->offset = 0;
793
794 UINT16_TO_STREAM (pp, HCI_SNIFF_MODE);
795 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SNIFF_MODE);
796
797 UINT16_TO_STREAM (pp, handle);
798 UINT16_TO_STREAM (pp, max_sniff_period);
799 UINT16_TO_STREAM (pp, min_sniff_period);
800 UINT16_TO_STREAM (pp, sniff_attempt);
801 UINT16_TO_STREAM (pp, sniff_timeout);
802
803 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
804 return (TRUE);
805 }
806
btsnd_hcic_exit_sniff_mode(UINT16 handle)807 BOOLEAN btsnd_hcic_exit_sniff_mode (UINT16 handle)
808 {
809 BT_HDR *p;
810 UINT8 *pp;
811
812 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
813 return (FALSE);
814
815 pp = (UINT8 *)(p + 1);
816
817 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
818 p->offset = 0;
819
820 UINT16_TO_STREAM (pp, HCI_EXIT_SNIFF_MODE);
821 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
822
823 UINT16_TO_STREAM (pp, handle);
824
825 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
826 return TRUE;
827 }
828
btsnd_hcic_park_mode(UINT16 handle,UINT16 beacon_max_interval,UINT16 beacon_min_interval)829 BOOLEAN btsnd_hcic_park_mode (UINT16 handle, UINT16 beacon_max_interval,
830 UINT16 beacon_min_interval)
831 {
832 BT_HDR *p;
833 UINT8 *pp;
834
835 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_PARK_MODE)) == NULL)
836 return (FALSE);
837
838 pp = (UINT8 *)(p + 1);
839
840 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PARK_MODE;
841 p->offset = 0;
842
843 UINT16_TO_STREAM (pp, HCI_PARK_MODE);
844 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_PARK_MODE);
845
846 UINT16_TO_STREAM (pp, handle);
847 UINT16_TO_STREAM (pp, beacon_max_interval);
848 UINT16_TO_STREAM (pp, beacon_min_interval);
849
850 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
851 return (TRUE);
852 }
853
btsnd_hcic_exit_park_mode(UINT16 handle)854 BOOLEAN btsnd_hcic_exit_park_mode (UINT16 handle)
855 {
856 BT_HDR *p;
857 UINT8 *pp;
858
859 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
860 return (FALSE);
861
862 pp = (UINT8 *)(p + 1);
863
864 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
865 p->offset = 0;
866
867 UINT16_TO_STREAM (pp, HCI_EXIT_PARK_MODE);
868 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
869
870 UINT16_TO_STREAM (pp, handle);
871
872 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
873 return TRUE;
874 }
875
btsnd_hcic_qos_setup(UINT16 handle,UINT8 flags,UINT8 service_type,UINT32 token_rate,UINT32 peak,UINT32 latency,UINT32 delay_var)876 BOOLEAN btsnd_hcic_qos_setup (UINT16 handle, UINT8 flags, UINT8 service_type,
877 UINT32 token_rate, UINT32 peak, UINT32 latency,
878 UINT32 delay_var)
879 {
880 BT_HDR *p;
881 UINT8 *pp;
882
883 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_QOS_SETUP)) == NULL)
884 return (FALSE);
885
886 pp = (UINT8 *)(p + 1);
887
888 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_QOS_SETUP;
889 p->offset = 0;
890
891 UINT16_TO_STREAM (pp, HCI_QOS_SETUP);
892 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_QOS_SETUP);
893
894 UINT16_TO_STREAM (pp, handle);
895 UINT8_TO_STREAM (pp, flags);
896 UINT8_TO_STREAM (pp, service_type);
897 UINT32_TO_STREAM (pp, token_rate);
898 UINT32_TO_STREAM (pp, peak);
899 UINT32_TO_STREAM (pp, latency);
900 UINT32_TO_STREAM (pp, delay_var);
901
902 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
903 return (TRUE);
904 }
905
btsnd_hcic_role_discovery(UINT16 handle)906 BOOLEAN btsnd_hcic_role_discovery (UINT16 handle)
907 {
908 BT_HDR *p;
909 UINT8 *pp;
910
911 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
912 return (FALSE);
913
914 pp = (UINT8 *)(p + 1);
915
916 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
917 p->offset = 0;
918
919 UINT16_TO_STREAM (pp, HCI_ROLE_DISCOVERY);
920 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
921
922 UINT16_TO_STREAM (pp, handle);
923
924 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
925 return (TRUE);
926 }
927
btsnd_hcic_switch_role(BD_ADDR bd_addr,UINT8 role)928 BOOLEAN btsnd_hcic_switch_role (BD_ADDR bd_addr, UINT8 role)
929 {
930 BT_HDR *p;
931 UINT8 *pp;
932
933 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SWITCH_ROLE)) == NULL)
934 return (FALSE);
935
936 pp = (UINT8 *)(p + 1);
937
938 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SWITCH_ROLE;
939 p->offset = 0;
940
941 UINT16_TO_STREAM (pp, HCI_SWITCH_ROLE);
942 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SWITCH_ROLE);
943
944 BDADDR_TO_STREAM (pp, bd_addr);
945 UINT8_TO_STREAM (pp, role);
946
947 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
948 return (TRUE);
949 }
950
btsnd_hcic_read_policy_set(UINT16 handle)951 BOOLEAN btsnd_hcic_read_policy_set (UINT16 handle)
952 {
953 BT_HDR *p;
954 UINT8 *pp;
955
956 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
957 return (FALSE);
958
959 pp = (UINT8 *)(p + 1);
960
961 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
962 p->offset = 0;
963
964 UINT16_TO_STREAM (pp, HCI_READ_POLICY_SETTINGS);
965 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
966
967 UINT16_TO_STREAM (pp, handle);
968
969 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
970 return (TRUE);
971 }
972
btsnd_hcic_write_policy_set(UINT16 handle,UINT16 settings)973 BOOLEAN btsnd_hcic_write_policy_set (UINT16 handle, UINT16 settings)
974 {
975 BT_HDR *p;
976 UINT8 *pp;
977
978 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_POLICY_SET)) == NULL)
979 return (FALSE);
980
981 pp = (UINT8 *)(p + 1);
982
983 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_POLICY_SET;
984 p->offset = 0;
985 UINT16_TO_STREAM (pp, HCI_WRITE_POLICY_SETTINGS);
986 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_POLICY_SET);
987
988 UINT16_TO_STREAM (pp, handle);
989 UINT16_TO_STREAM (pp, settings);
990
991 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
992 return (TRUE);
993 }
994
btsnd_hcic_read_def_policy_set(void)995 BOOLEAN btsnd_hcic_read_def_policy_set (void)
996 {
997 BT_HDR *p;
998 UINT8 *pp;
999
1000 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_DEF_POLICY_SET)) == NULL)
1001 return (FALSE);
1002
1003 pp = (UINT8 *)(p + 1);
1004
1005 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_DEF_POLICY_SET;
1006 p->offset = 0;
1007
1008 UINT16_TO_STREAM (pp, HCI_READ_DEF_POLICY_SETTINGS);
1009 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_DEF_POLICY_SET);
1010
1011 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1012 return (TRUE);
1013 }
1014
btsnd_hcic_write_def_policy_set(UINT16 settings)1015 BOOLEAN btsnd_hcic_write_def_policy_set (UINT16 settings)
1016 {
1017 BT_HDR *p;
1018 UINT8 *pp;
1019
1020 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET)) == NULL)
1021 return (FALSE);
1022
1023 pp = (UINT8 *)(p + 1);
1024
1025 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET;
1026 p->offset = 0;
1027 UINT16_TO_STREAM (pp, HCI_WRITE_DEF_POLICY_SETTINGS);
1028 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_DEF_POLICY_SET);
1029
1030 UINT16_TO_STREAM (pp, settings);
1031
1032 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1033 return (TRUE);
1034 }
1035
btsnd_hcic_flow_specification(UINT16 handle,UINT8 flags,UINT8 flow_direct,UINT8 service_type,UINT32 token_rate,UINT32 token_bucket_size,UINT32 peak,UINT32 latency)1036 BOOLEAN btsnd_hcic_flow_specification(UINT16 handle, UINT8 flags, UINT8 flow_direct,
1037 UINT8 service_type, UINT32 token_rate,
1038 UINT32 token_bucket_size, UINT32 peak,
1039 UINT32 latency)
1040 {
1041 BT_HDR *p;
1042 UINT8 *pp;
1043
1044 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_FLOW_SPEC)) == NULL)
1045 return (FALSE);
1046
1047 pp = (UINT8 *)(p + 1);
1048
1049 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_FLOW_SPEC;
1050 p->offset = 0;
1051
1052 UINT16_TO_STREAM (pp, HCI_FLOW_SPECIFICATION);
1053 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_FLOW_SPEC);
1054
1055 UINT16_TO_STREAM (pp, handle);
1056 UINT8_TO_STREAM (pp, flags);
1057 UINT8_TO_STREAM (pp, flow_direct);
1058 UINT8_TO_STREAM (pp, service_type);
1059 UINT32_TO_STREAM (pp, token_rate);
1060 UINT32_TO_STREAM (pp, token_bucket_size);
1061 UINT32_TO_STREAM (pp, peak);
1062 UINT32_TO_STREAM (pp, latency);
1063
1064 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1065 return (TRUE);
1066 }
1067
btsnd_hcic_set_event_mask(UINT8 local_controller_id,BT_EVENT_MASK event_mask)1068 BOOLEAN btsnd_hcic_set_event_mask(UINT8 local_controller_id, BT_EVENT_MASK event_mask)
1069 {
1070 BT_HDR *p;
1071 UINT8 *pp;
1072
1073 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_EVENT_MASK)) == NULL)
1074 return (FALSE);
1075
1076 pp = (UINT8 *)(p + 1);
1077
1078 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_EVENT_MASK;
1079 p->offset = 0;
1080
1081 UINT16_TO_STREAM (pp, HCI_SET_EVENT_MASK);
1082 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_EVENT_MASK);
1083 ARRAY8_TO_STREAM (pp, event_mask);
1084
1085 btu_hcif_send_cmd (local_controller_id, p);
1086 return (TRUE);
1087 }
1088
btsnd_hcic_set_event_mask_page_2(UINT8 local_controller_id,BT_EVENT_MASK event_mask)1089 BOOLEAN btsnd_hcic_set_event_mask_page_2 (UINT8 local_controller_id, BT_EVENT_MASK event_mask)
1090 {
1091 BT_HDR *p;
1092 UINT8 *pp;
1093
1094 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2)) == NULL)
1095 return (FALSE);
1096
1097 pp = (UINT8 *)(p + 1);
1098
1099 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2;
1100 p->offset = 0;
1101
1102 UINT16_TO_STREAM (pp, HCI_SET_EVENT_MASK_PAGE_2);
1103 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_EVENT_MASK_PAGE_2);
1104 ARRAY8_TO_STREAM (pp, event_mask);
1105
1106 btu_hcif_send_cmd (local_controller_id, p);
1107 return (TRUE);
1108 }
1109
btsnd_hcic_reset(UINT8 local_controller_id)1110 BOOLEAN btsnd_hcic_reset (UINT8 local_controller_id)
1111 {
1112 BT_HDR *p;
1113 UINT8 *pp;
1114
1115 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_RESET)) == NULL)
1116 return (FALSE);
1117
1118 pp = (UINT8 *)(p + 1);
1119
1120 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_RESET;
1121 p->offset = 0;
1122
1123 UINT16_TO_STREAM (pp, HCI_RESET);
1124 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_RESET);
1125
1126 btu_hcif_send_cmd (local_controller_id, p);
1127 /* If calling from LMP_TEST or ScriptEngine, then send HCI command immediately */
1128 #if (!defined (LMP_TEST) && !defined(BTISE))
1129 if (local_controller_id == LOCAL_BR_EDR_CONTROLLER_ID)
1130 {
1131 btm_acl_reset_paging ();
1132 btm_acl_set_discing (FALSE);
1133 }
1134 #endif
1135 return (TRUE);
1136 }
1137
btsnd_hcic_set_event_filter(UINT8 filt_type,UINT8 filt_cond_type,UINT8 * filt_cond,UINT8 filt_cond_len)1138 BOOLEAN btsnd_hcic_set_event_filter (UINT8 filt_type, UINT8 filt_cond_type,
1139 UINT8 *filt_cond, UINT8 filt_cond_len)
1140 {
1141 BT_HDR *p;
1142 UINT8 *pp;
1143
1144 /* Use buffer large enough to hold all sizes in this command */
1145 if ((p = HCI_GET_CMD_BUF(2 + filt_cond_len)) == NULL)
1146 return (FALSE);
1147
1148 pp = (UINT8 *)(p + 1);
1149
1150 p->offset = 0;
1151
1152 UINT16_TO_STREAM (pp, HCI_SET_EVENT_FILTER);
1153
1154 if (filt_type)
1155 {
1156 p->len = (UINT16)(HCIC_PREAMBLE_SIZE + 2 + filt_cond_len);
1157 UINT8_TO_STREAM (pp, (UINT8)(2 + filt_cond_len));
1158
1159 UINT8_TO_STREAM (pp, filt_type);
1160 UINT8_TO_STREAM (pp, filt_cond_type);
1161
1162 if (filt_cond_type == HCI_FILTER_COND_DEVICE_CLASS)
1163 {
1164 DEVCLASS_TO_STREAM (pp, filt_cond);
1165 filt_cond += DEV_CLASS_LEN;
1166 DEVCLASS_TO_STREAM (pp, filt_cond);
1167 filt_cond += DEV_CLASS_LEN;
1168
1169 filt_cond_len -= (2 * DEV_CLASS_LEN);
1170 }
1171 else if (filt_cond_type == HCI_FILTER_COND_BD_ADDR)
1172 {
1173 BDADDR_TO_STREAM (pp, filt_cond);
1174 filt_cond += BD_ADDR_LEN;
1175
1176 filt_cond_len -= BD_ADDR_LEN;
1177 }
1178
1179 if (filt_cond_len)
1180 ARRAY_TO_STREAM (pp, filt_cond, filt_cond_len);
1181 }
1182 else
1183 {
1184 p->len = (UINT16)(HCIC_PREAMBLE_SIZE + 1);
1185 UINT8_TO_STREAM (pp, 1);
1186
1187 UINT8_TO_STREAM (pp, filt_type);
1188 }
1189
1190 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1191 return (TRUE);
1192 }
1193
btsnd_hcic_flush(UINT8 local_controller_id,UINT16 handle)1194 BOOLEAN btsnd_hcic_flush (UINT8 local_controller_id, UINT16 handle)
1195 {
1196 BT_HDR *p;
1197 UINT8 *pp;
1198
1199 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
1200 return (FALSE);
1201
1202 pp = (UINT8 *)(p + 1);
1203
1204 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
1205 p->offset = 0;
1206 UINT16_TO_STREAM (pp, HCI_FLUSH);
1207 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
1208
1209 UINT16_TO_STREAM (pp, handle);
1210
1211 btu_hcif_send_cmd (local_controller_id, p);
1212 return (TRUE);
1213 }
1214
btsnd_hcic_read_pin_type(void)1215 BOOLEAN btsnd_hcic_read_pin_type (void)
1216 {
1217 BT_HDR *p;
1218 UINT8 *pp;
1219
1220 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1221 return (FALSE);
1222
1223 pp = (UINT8 *)(p + 1);
1224
1225 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1226 p->offset = 0;
1227
1228 UINT16_TO_STREAM (pp, HCI_READ_PIN_TYPE);
1229 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1230
1231 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1232 return (TRUE);
1233 }
1234
btsnd_hcic_write_pin_type(UINT8 type)1235 BOOLEAN btsnd_hcic_write_pin_type (UINT8 type)
1236 {
1237 BT_HDR *p;
1238 UINT8 *pp;
1239
1240 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1241 return (FALSE);
1242
1243 pp = (UINT8 *)(p + 1);
1244
1245 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1246 p->offset = 0;
1247
1248 UINT16_TO_STREAM (pp, HCI_WRITE_PIN_TYPE);
1249 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1250
1251 UINT8_TO_STREAM (pp, type);
1252
1253 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1254 return (TRUE);
1255 }
1256
btsnd_hcic_new_unit_key(void)1257 BOOLEAN btsnd_hcic_new_unit_key (void)
1258 {
1259 BT_HDR *p;
1260 UINT8 *pp;
1261
1262 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_NEW_UNIT_KEY)) == NULL)
1263 return (FALSE);
1264
1265 pp = (UINT8 *)(p + 1);
1266
1267 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_NEW_UNIT_KEY;
1268 p->offset = 0;
1269
1270 UINT16_TO_STREAM (pp, HCI_CREATE_NEW_UNIT_KEY);
1271 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_NEW_UNIT_KEY);
1272
1273 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1274 return (TRUE);
1275 }
1276
btsnd_hcic_read_stored_key(BD_ADDR bd_addr,BOOLEAN read_all_flag)1277 BOOLEAN btsnd_hcic_read_stored_key (BD_ADDR bd_addr, BOOLEAN read_all_flag)
1278 {
1279 BT_HDR *p;
1280 UINT8 *pp;
1281
1282 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_STORED_KEY)) == NULL)
1283 return (FALSE);
1284
1285 pp = (UINT8 *)(p + 1);
1286
1287 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_STORED_KEY;
1288 p->offset = 0;
1289
1290 UINT16_TO_STREAM (pp, HCI_READ_STORED_LINK_KEY);
1291 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_STORED_KEY);
1292
1293 BDADDR_TO_STREAM (pp, bd_addr);
1294 UINT8_TO_STREAM (pp, read_all_flag);
1295
1296 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1297 return (TRUE);
1298 }
1299
btsnd_hcic_write_stored_key(UINT8 num_keys,BD_ADDR * bd_addr,LINK_KEY * link_key)1300 BOOLEAN btsnd_hcic_write_stored_key (UINT8 num_keys, BD_ADDR *bd_addr,
1301 LINK_KEY *link_key)
1302 {
1303 BT_HDR *p;
1304 UINT8 *pp;
1305 int j;
1306
1307 if ((p = HCI_GET_CMD_BUF(1 + (num_keys * (BD_ADDR_LEN + LINK_KEY_LEN)))) == NULL)
1308 return (FALSE);
1309
1310 pp = (UINT8 *)(p + 1);
1311
1312
1313 p->len = HCIC_PREAMBLE_SIZE + 1 + (num_keys * (BD_ADDR_LEN + LINK_KEY_LEN));
1314 p->offset = 0;
1315
1316 UINT16_TO_STREAM (pp, HCI_WRITE_STORED_LINK_KEY);
1317 UINT8_TO_STREAM (pp, p->len - HCIC_PREAMBLE_SIZE);
1318
1319 if(num_keys > HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD)
1320 num_keys = HCI_MAX_NUM_OF_LINK_KEYS_PER_CMMD;
1321
1322 UINT8_TO_STREAM (pp, num_keys);
1323
1324 for (j = 0; j < num_keys; j++)
1325 {
1326 BDADDR_TO_STREAM (pp, bd_addr[j]);
1327 ARRAY16_TO_STREAM (pp, link_key[j]);
1328 }
1329
1330 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1331 return (TRUE);
1332 }
1333
btsnd_hcic_delete_stored_key(BD_ADDR bd_addr,BOOLEAN delete_all_flag)1334 BOOLEAN btsnd_hcic_delete_stored_key (BD_ADDR bd_addr, BOOLEAN delete_all_flag)
1335 {
1336 BT_HDR *p;
1337 UINT8 *pp;
1338
1339 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_DELETE_STORED_KEY)) == NULL)
1340 return (FALSE);
1341
1342 pp = (UINT8 *)(p + 1);
1343
1344 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_DELETE_STORED_KEY;
1345 p->offset = 0;
1346
1347 UINT16_TO_STREAM (pp, HCI_DELETE_STORED_LINK_KEY);
1348 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_DELETE_STORED_KEY);
1349
1350 BDADDR_TO_STREAM (pp, bd_addr);
1351 UINT8_TO_STREAM (pp, delete_all_flag);
1352
1353 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1354 return (TRUE);
1355 }
1356
btsnd_hcic_change_name(BD_NAME name)1357 BOOLEAN btsnd_hcic_change_name (BD_NAME name)
1358 {
1359 BT_HDR *p;
1360 UINT8 *pp;
1361 UINT16 len = strlen ((char *)name) + 1;
1362
1363 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CHANGE_NAME)) == NULL)
1364 return (FALSE);
1365
1366 pp = (UINT8 *)(p + 1);
1367
1368 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CHANGE_NAME;
1369 p->offset = 0;
1370
1371 UINT16_TO_STREAM (pp, HCI_CHANGE_LOCAL_NAME);
1372 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CHANGE_NAME);
1373
1374 ARRAY_TO_STREAM (pp, name, len);
1375
1376 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1377 return (TRUE);
1378 }
1379
btsnd_hcic_read_name(void)1380 BOOLEAN btsnd_hcic_read_name (void)
1381 {
1382 BT_HDR *p;
1383 UINT8 *pp;
1384
1385 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1386 return (FALSE);
1387
1388 pp = (UINT8 *)(p + 1);
1389
1390 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1391 p->offset = 0;
1392
1393 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_NAME);
1394 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1395
1396 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1397 return (TRUE);
1398 }
1399
btsnd_hcic_read_conn_acc_tout(UINT8 local_controller_id)1400 BOOLEAN btsnd_hcic_read_conn_acc_tout (UINT8 local_controller_id)
1401 {
1402 BT_HDR *p;
1403 UINT8 *pp;
1404
1405 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1406 return (FALSE);
1407
1408 pp = (UINT8 *)(p + 1);
1409
1410 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1411 p->offset = 0;
1412
1413 UINT16_TO_STREAM (pp, HCI_READ_CONN_ACCEPT_TOUT);
1414 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1415
1416 btu_hcif_send_cmd (local_controller_id, p);
1417 return (TRUE);
1418 }
1419
btsnd_hcic_write_conn_acc_tout(UINT8 local_controller_id,UINT16 timeout)1420 BOOLEAN btsnd_hcic_write_conn_acc_tout (UINT8 local_controller_id, UINT16 timeout)
1421 {
1422 BT_HDR *p;
1423 UINT8 *pp;
1424
1425 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1426 return (FALSE);
1427
1428 pp = (UINT8 *)(p + 1);
1429
1430 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1431 p->offset = 0;
1432
1433 UINT16_TO_STREAM (pp, HCI_WRITE_CONN_ACCEPT_TOUT);
1434 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1435
1436 UINT16_TO_STREAM (pp, timeout);
1437
1438 btu_hcif_send_cmd (local_controller_id, p);
1439 return (TRUE);
1440 }
1441
btsnd_hcic_read_page_tout(void)1442 BOOLEAN btsnd_hcic_read_page_tout (void)
1443 {
1444 BT_HDR *p;
1445 UINT8 *pp;
1446
1447 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1448 return (FALSE);
1449
1450 pp = (UINT8 *)(p + 1);
1451
1452 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1453 p->offset = 0;
1454
1455 UINT16_TO_STREAM (pp, HCI_READ_PAGE_TOUT);
1456 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1457
1458 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1459 return (TRUE);
1460 }
1461
btsnd_hcic_write_page_tout(UINT16 timeout)1462 BOOLEAN btsnd_hcic_write_page_tout (UINT16 timeout)
1463 {
1464 BT_HDR *p;
1465 UINT8 *pp;
1466
1467 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1468 return (FALSE);
1469
1470 pp = (UINT8 *)(p + 1);
1471
1472 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1473 p->offset = 0;
1474
1475 UINT16_TO_STREAM (pp, HCI_WRITE_PAGE_TOUT);
1476 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1477
1478 UINT16_TO_STREAM (pp, timeout);
1479
1480 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1481 return (TRUE);
1482 }
1483
btsnd_hcic_read_scan_enable(void)1484 BOOLEAN btsnd_hcic_read_scan_enable (void)
1485 {
1486 BT_HDR *p;
1487 UINT8 *pp;
1488
1489 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1490 return (FALSE);
1491
1492 pp = (UINT8 *)(p + 1);
1493
1494 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1495 p->offset = 0;
1496
1497 UINT16_TO_STREAM (pp, HCI_READ_SCAN_ENABLE);
1498 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1499
1500 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1501 return (TRUE);
1502 }
1503
btsnd_hcic_write_scan_enable(UINT8 flag)1504 BOOLEAN btsnd_hcic_write_scan_enable (UINT8 flag)
1505 {
1506 BT_HDR *p;
1507 UINT8 *pp;
1508
1509 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1510 return (FALSE);
1511
1512 pp = (UINT8 *)(p + 1);
1513
1514 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1515 p->offset = 0;
1516
1517 UINT16_TO_STREAM (pp, HCI_WRITE_SCAN_ENABLE);
1518 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1519
1520 UINT8_TO_STREAM (pp, flag);
1521
1522 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1523 return (TRUE);
1524 }
1525
btsnd_hcic_read_pagescan_cfg(void)1526 BOOLEAN btsnd_hcic_read_pagescan_cfg(void)
1527 {
1528 BT_HDR *p;
1529 UINT8 *pp;
1530
1531 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1532 return (FALSE);
1533
1534 pp = (UINT8 *)(p + 1);
1535
1536 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1537 p->offset = 0;
1538
1539 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_CFG);
1540 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1541
1542 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1543 return (TRUE);
1544 }
1545
btsnd_hcic_write_pagescan_cfg(UINT16 interval,UINT16 window)1546 BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, UINT16 window)
1547 {
1548 BT_HDR *p;
1549 UINT8 *pp;
1550
1551 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG)) == NULL)
1552 return (FALSE);
1553
1554 pp = (UINT8 *)(p + 1);
1555
1556 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG;
1557 p->offset = 0;
1558
1559 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_CFG);
1560 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG);
1561
1562 UINT16_TO_STREAM (pp, interval);
1563 UINT16_TO_STREAM (pp, window);
1564
1565 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1566 return (TRUE);
1567 }
1568
btsnd_hcic_read_inqscan_cfg(void)1569 BOOLEAN btsnd_hcic_read_inqscan_cfg(void)
1570 {
1571 BT_HDR *p;
1572 UINT8 *pp;
1573
1574 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1575 return (FALSE);
1576
1577 pp = (UINT8 *)(p + 1);
1578
1579 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1580 p->offset = 0;
1581
1582 UINT16_TO_STREAM (pp, HCI_READ_INQUIRYSCAN_CFG);
1583 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1584
1585 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1586 return (TRUE);
1587 }
1588
btsnd_hcic_write_inqscan_cfg(UINT16 interval,UINT16 window)1589 BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window)
1590 {
1591 BT_HDR *p;
1592 UINT8 *pp;
1593
1594 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG)) == NULL)
1595 return (FALSE);
1596
1597 pp = (UINT8 *)(p + 1);
1598
1599 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG;
1600 p->offset = 0;
1601
1602 UINT16_TO_STREAM (pp, HCI_WRITE_INQUIRYSCAN_CFG);
1603 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG);
1604
1605 UINT16_TO_STREAM (pp, interval);
1606 UINT16_TO_STREAM (pp, window);
1607
1608 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1609 return (TRUE);
1610 }
1611
btsnd_hcic_read_auth_enable(void)1612 BOOLEAN btsnd_hcic_read_auth_enable (void)
1613 {
1614 BT_HDR *p;
1615 UINT8 *pp;
1616
1617 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1618 return (FALSE);
1619
1620 pp = (UINT8 *)(p + 1);
1621
1622 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1623 p->offset = 0;
1624
1625 UINT16_TO_STREAM (pp, HCI_READ_AUTHENTICATION_ENABLE);
1626 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1627
1628 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1629 return (TRUE);
1630 }
1631
btsnd_hcic_write_auth_enable(UINT8 flag)1632 BOOLEAN btsnd_hcic_write_auth_enable (UINT8 flag)
1633 {
1634 BT_HDR *p;
1635 UINT8 *pp;
1636
1637 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1638 return (FALSE);
1639
1640 pp = (UINT8 *)(p + 1);
1641
1642 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1643 p->offset = 0;
1644
1645 UINT16_TO_STREAM (pp, HCI_WRITE_AUTHENTICATION_ENABLE);
1646 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1647
1648 UINT8_TO_STREAM (pp, flag);
1649
1650 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1651 return (TRUE);
1652 }
1653
btsnd_hcic_read_encr_mode(void)1654 BOOLEAN btsnd_hcic_read_encr_mode (void)
1655 {
1656 BT_HDR *p;
1657 UINT8 *pp;
1658
1659 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1660 return (FALSE);
1661
1662 pp = (UINT8 *)(p + 1);
1663
1664 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1665 p->offset = 0;
1666
1667 UINT16_TO_STREAM (pp, HCI_READ_ENCRYPTION_MODE);
1668 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1669
1670 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1671 return (TRUE);
1672 }
1673
btsnd_hcic_write_encr_mode(UINT8 mode)1674 BOOLEAN btsnd_hcic_write_encr_mode (UINT8 mode)
1675 {
1676 BT_HDR *p;
1677 UINT8 *pp;
1678
1679 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1680 return (FALSE);
1681
1682 pp = (UINT8 *)(p + 1);
1683
1684 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1685 p->offset = 0;
1686
1687 UINT16_TO_STREAM (pp, HCI_WRITE_ENCRYPTION_MODE);
1688 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1689
1690 UINT8_TO_STREAM (pp, mode);
1691
1692 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1693 return (TRUE);
1694 }
1695
btsnd_hcic_read_dev_class(void)1696 BOOLEAN btsnd_hcic_read_dev_class(void)
1697 {
1698 BT_HDR *p;
1699 UINT8 *pp;
1700
1701 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1702 return (FALSE);
1703
1704 pp = (UINT8 *)(p + 1);
1705
1706 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1707 p->offset = 0;
1708
1709 UINT16_TO_STREAM (pp, HCI_READ_CLASS_OF_DEVICE);
1710 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1711
1712 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1713 return (TRUE);
1714 }
1715
btsnd_hcic_write_dev_class(DEV_CLASS dev_class)1716 BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev_class)
1717 {
1718 BT_HDR *p;
1719 UINT8 *pp;
1720
1721 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM3)) == NULL)
1722 return (FALSE);
1723
1724 pp = (UINT8 *)(p + 1);
1725
1726 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3;
1727 p->offset = 0;
1728
1729 UINT16_TO_STREAM (pp, HCI_WRITE_CLASS_OF_DEVICE);
1730 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM3);
1731
1732 DEVCLASS_TO_STREAM (pp, dev_class);
1733
1734 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1735 return (TRUE);
1736 }
1737
btsnd_hcic_read_voice_settings(void)1738 BOOLEAN btsnd_hcic_read_voice_settings(void)
1739 {
1740 BT_HDR *p;
1741 UINT8 *pp;
1742
1743 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1744 return (FALSE);
1745
1746 pp = (UINT8 *)(p + 1);
1747
1748 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1749 p->offset = 0;
1750
1751 UINT16_TO_STREAM (pp, HCI_READ_VOICE_SETTINGS);
1752 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1753
1754 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1755 return (TRUE);
1756 }
1757
btsnd_hcic_write_voice_settings(UINT16 flags)1758 BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags)
1759 {
1760 BT_HDR *p;
1761 UINT8 *pp;
1762
1763 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1764 return (FALSE);
1765
1766 pp = (UINT8 *)(p + 1);
1767
1768 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1769 p->offset = 0;
1770
1771 UINT16_TO_STREAM (pp, HCI_WRITE_VOICE_SETTINGS);
1772 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1773
1774 UINT16_TO_STREAM (pp, flags);
1775
1776 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1777 return (TRUE);
1778 }
1779
btsnd_hcic_read_auto_flush_tout(UINT16 handle)1780 BOOLEAN btsnd_hcic_read_auto_flush_tout (UINT16 handle)
1781 {
1782 BT_HDR *p;
1783 UINT8 *pp;
1784
1785 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
1786 return (FALSE);
1787
1788 pp = (UINT8 *)(p + 1);
1789
1790 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
1791 p->offset = 0;
1792
1793 UINT16_TO_STREAM (pp, HCI_READ_AUTO_FLUSH_TOUT);
1794 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
1795
1796 UINT16_TO_STREAM (pp, handle);
1797
1798 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1799 return (TRUE);
1800 }
1801
btsnd_hcic_write_auto_flush_tout(UINT16 handle,UINT16 tout)1802 BOOLEAN btsnd_hcic_write_auto_flush_tout (UINT16 handle, UINT16 tout)
1803 {
1804 BT_HDR *p;
1805 UINT8 *pp;
1806
1807 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT)) == NULL)
1808 return (FALSE);
1809
1810 pp = (UINT8 *)(p + 1);
1811
1812 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT;
1813 p->offset = 0;
1814
1815 UINT16_TO_STREAM (pp, HCI_WRITE_AUTO_FLUSH_TOUT);
1816 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT);
1817
1818 UINT16_TO_STREAM (pp, handle);
1819 UINT16_TO_STREAM (pp, tout);
1820
1821 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1822 return (TRUE);
1823 }
1824
btsnd_hcic_read_num_bcast_xmit(void)1825 BOOLEAN btsnd_hcic_read_num_bcast_xmit (void)
1826 {
1827 BT_HDR *p;
1828 UINT8 *pp;
1829
1830 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1831 return (FALSE);
1832
1833 pp = (UINT8 *)(p + 1);
1834
1835 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1836 p->offset = 0;
1837
1838 UINT16_TO_STREAM (pp, HCI_READ_NUM_BCAST_REXMITS);
1839 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1840
1841 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1842 return (TRUE);
1843 }
1844
btsnd_hcic_write_num_bcast_xmit(UINT8 num)1845 BOOLEAN btsnd_hcic_write_num_bcast_xmit (UINT8 num)
1846 {
1847 BT_HDR *p;
1848 UINT8 *pp;
1849
1850 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1851 return (FALSE);
1852
1853 pp = (UINT8 *)(p + 1);
1854
1855 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1856 p->offset = 0;
1857
1858 UINT16_TO_STREAM (pp, HCI_WRITE_NUM_BCAST_REXMITS);
1859 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1860
1861 UINT8_TO_STREAM (pp, num);
1862
1863 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1864 return (TRUE);
1865 }
1866
btsnd_hcic_read_hold_mode_act(void)1867 BOOLEAN btsnd_hcic_read_hold_mode_act (void)
1868 {
1869 BT_HDR *p;
1870 UINT8 *pp;
1871
1872 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1873 return (FALSE);
1874
1875 pp = (UINT8 *)(p + 1);
1876
1877 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1878 p->offset = 0;
1879
1880 UINT16_TO_STREAM (pp, HCI_READ_HOLD_MODE_ACTIVITY);
1881 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1882
1883 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1884 return (TRUE);
1885 }
1886
btsnd_hcic_write_hold_mode_act(UINT8 flags)1887 BOOLEAN btsnd_hcic_write_hold_mode_act (UINT8 flags)
1888 {
1889 BT_HDR *p;
1890 UINT8 *pp;
1891
1892 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1893 return (FALSE);
1894
1895 pp = (UINT8 *)(p + 1);
1896
1897 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1898 p->offset = 0;
1899
1900 UINT16_TO_STREAM (pp, HCI_WRITE_HOLD_MODE_ACTIVITY);
1901 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1902
1903 UINT8_TO_STREAM (pp, flags);
1904
1905 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1906 return (TRUE);
1907 }
1908
btsnd_hcic_read_tx_power(UINT16 handle,UINT8 type)1909 BOOLEAN btsnd_hcic_read_tx_power (UINT16 handle, UINT8 type)
1910 {
1911 BT_HDR *p;
1912 UINT8 *pp;
1913
1914 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_TX_POWER)) == NULL)
1915 return (FALSE);
1916
1917 pp = (UINT8 *)(p + 1);
1918
1919 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_TX_POWER;
1920 p->offset = 0;
1921
1922 UINT16_TO_STREAM (pp, HCI_READ_TRANSMIT_POWER_LEVEL);
1923 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_TX_POWER);
1924
1925 UINT16_TO_STREAM (pp, handle);
1926 UINT8_TO_STREAM (pp, type);
1927
1928 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1929 return (TRUE);
1930 }
1931
btsnd_hcic_read_sco_flow_enable(void)1932 BOOLEAN btsnd_hcic_read_sco_flow_enable (void)
1933 {
1934 BT_HDR *p;
1935 UINT8 *pp;
1936
1937 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1938 return (FALSE);
1939
1940 pp = (UINT8 *)(p + 1);
1941
1942 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1943 p->offset = 0;
1944
1945 UINT16_TO_STREAM (pp, HCI_READ_SCO_FLOW_CTRL_ENABLE);
1946 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1947
1948 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1949 return (TRUE);
1950 }
1951
btsnd_hcic_write_sco_flow_enable(UINT8 flag)1952 BOOLEAN btsnd_hcic_write_sco_flow_enable (UINT8 flag)
1953 {
1954 BT_HDR *p;
1955 UINT8 *pp;
1956
1957 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1958 return (FALSE);
1959
1960 pp = (UINT8 *)(p + 1);
1961
1962 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1963 p->offset = 0;
1964
1965 UINT16_TO_STREAM (pp, HCI_WRITE_SCO_FLOW_CTRL_ENABLE);
1966 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1967
1968 UINT8_TO_STREAM (pp, flag);
1969
1970 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1971 return (TRUE);
1972 }
1973
btsnd_hcic_set_host_flow_ctrl(UINT8 value)1974 BOOLEAN btsnd_hcic_set_host_flow_ctrl (UINT8 value)
1975 {
1976 BT_HDR *p;
1977 UINT8 *pp;
1978
1979 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1980 return (FALSE);
1981
1982 pp = (UINT8 *)(p + 1);
1983
1984 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1985 p->offset = 0;
1986
1987 UINT16_TO_STREAM (pp, HCI_SET_HC_TO_HOST_FLOW_CTRL);
1988 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1989
1990 UINT8_TO_STREAM (pp, value);
1991
1992 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1993 return (TRUE);
1994 }
1995
btsnd_hcic_set_host_buf_size(UINT16 acl_len,UINT8 sco_len,UINT16 acl_num,UINT16 sco_num)1996 BOOLEAN btsnd_hcic_set_host_buf_size (UINT16 acl_len, UINT8 sco_len,
1997 UINT16 acl_num, UINT16 sco_num)
1998 {
1999 BT_HDR *p;
2000 UINT8 *pp;
2001
2002 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE)) == NULL)
2003 return (FALSE);
2004
2005 pp = (UINT8 *)(p + 1);
2006
2007 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE;
2008 p->offset = 0;
2009
2010 UINT16_TO_STREAM (pp, HCI_HOST_BUFFER_SIZE);
2011 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE);
2012
2013 UINT16_TO_STREAM (pp, acl_len);
2014 UINT8_TO_STREAM (pp, sco_len);
2015 UINT16_TO_STREAM (pp, acl_num);
2016 UINT16_TO_STREAM (pp, sco_num);
2017
2018 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2019 return (TRUE);
2020 }
2021
btsnd_hcic_host_num_xmitted_pkts(UINT8 num_handles,UINT16 * handle,UINT16 * num_pkts)2022 BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, UINT16 *handle,
2023 UINT16 *num_pkts)
2024 {
2025 BT_HDR *p;
2026 UINT8 *pp;
2027 int j;
2028
2029 if ((p = HCI_GET_CMD_BUF(1 + (num_handles * 4))) == NULL)
2030 return (FALSE);
2031
2032 pp = (UINT8 *)(p + 1);
2033
2034 p->len = HCIC_PREAMBLE_SIZE + 1 + (num_handles * 4);
2035 p->offset = 0;
2036
2037 UINT16_TO_STREAM (pp, HCI_HOST_NUM_PACKETS_DONE);
2038 UINT8_TO_STREAM (pp, p->len - HCIC_PREAMBLE_SIZE);
2039
2040 UINT8_TO_STREAM (pp, num_handles);
2041
2042 for (j = 0; j < num_handles; j++)
2043 {
2044 UINT16_TO_STREAM (pp, handle[j]);
2045 UINT16_TO_STREAM (pp, num_pkts[j]);
2046 }
2047
2048 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2049 return (TRUE);
2050 }
2051
btsnd_hcic_read_link_super_tout(UINT8 local_controller_id,UINT16 handle)2052 BOOLEAN btsnd_hcic_read_link_super_tout (UINT8 local_controller_id, UINT16 handle)
2053 {
2054 BT_HDR *p;
2055 UINT8 *pp;
2056
2057 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2058 return (FALSE);
2059
2060 pp = (UINT8 *)(p + 1);
2061
2062 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2063 p->offset = 0;
2064
2065 UINT16_TO_STREAM (pp, HCI_READ_LINK_SUPER_TOUT);
2066 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2067
2068 UINT16_TO_STREAM (pp, handle);
2069
2070 btu_hcif_send_cmd (local_controller_id, p);
2071 return (TRUE);
2072 }
2073
btsnd_hcic_write_link_super_tout(UINT8 local_controller_id,UINT16 handle,UINT16 timeout)2074 BOOLEAN btsnd_hcic_write_link_super_tout (UINT8 local_controller_id, UINT16 handle, UINT16 timeout)
2075 {
2076 BT_HDR *p;
2077 UINT8 *pp;
2078
2079 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT)) == NULL)
2080 return (FALSE);
2081
2082 pp = (UINT8 *)(p + 1);
2083
2084 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT;
2085 p->offset = 0;
2086
2087 UINT16_TO_STREAM (pp, HCI_WRITE_LINK_SUPER_TOUT);
2088 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT);
2089
2090 UINT16_TO_STREAM (pp, handle);
2091 UINT16_TO_STREAM (pp, timeout);
2092
2093 btu_hcif_send_cmd (local_controller_id, p);
2094 return (TRUE);
2095 }
2096
btsnd_hcic_read_max_iac(void)2097 BOOLEAN btsnd_hcic_read_max_iac (void)
2098 {
2099 BT_HDR *p;
2100 UINT8 *pp;
2101
2102 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2103 return (FALSE);
2104
2105 pp = (UINT8 *)(p + 1);
2106
2107 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2108 p->offset = 0;
2109
2110 UINT16_TO_STREAM (pp, HCI_READ_NUM_SUPPORTED_IAC);
2111 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2112
2113 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2114 return (TRUE);
2115 }
2116
btsnd_hcic_read_cur_iac_lap(void)2117 BOOLEAN btsnd_hcic_read_cur_iac_lap (void)
2118 {
2119 BT_HDR *p;
2120 UINT8 *pp;
2121
2122 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2123 return (FALSE);
2124
2125 pp = (UINT8 *)(p + 1);
2126
2127 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2128 p->offset = 0;
2129
2130 UINT16_TO_STREAM (pp, HCI_READ_CURRENT_IAC_LAP);
2131 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2132
2133 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2134 return (TRUE);
2135 }
2136
btsnd_hcic_write_cur_iac_lap(UINT8 num_cur_iac,LAP * const iac_lap)2137 BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, LAP * const iac_lap)
2138 {
2139 BT_HDR *p;
2140 UINT8 *pp;
2141 int i;
2142
2143 if ((p = HCI_GET_CMD_BUF(1 + (LAP_LEN * num_cur_iac))) == NULL)
2144 return (FALSE);
2145
2146 pp = (UINT8 *)(p + 1);
2147
2148 p->len = HCIC_PREAMBLE_SIZE + 1 + (LAP_LEN * num_cur_iac);
2149 p->offset = 0;
2150
2151 UINT16_TO_STREAM (pp, HCI_WRITE_CURRENT_IAC_LAP);
2152 UINT8_TO_STREAM (pp, p->len - HCIC_PREAMBLE_SIZE);
2153
2154 UINT8_TO_STREAM (pp, num_cur_iac);
2155
2156 for (i = 0; i < num_cur_iac; i++)
2157 LAP_TO_STREAM (pp, iac_lap[i]);
2158
2159 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2160 return (TRUE);
2161 }
2162
btsnd_hcic_read_page_scan_per(void)2163 BOOLEAN btsnd_hcic_read_page_scan_per (void)
2164 {
2165 BT_HDR *p;
2166 UINT8 *pp;
2167
2168 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2169 return (FALSE);
2170
2171 pp = (UINT8 *)(p + 1);
2172
2173 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2174 p->offset = 0;
2175
2176 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_PERIOD_MODE);
2177 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2178
2179 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2180 return (TRUE);
2181 }
2182
btsnd_hcic_write_page_scan_per(UINT8 mode)2183 BOOLEAN btsnd_hcic_write_page_scan_per (UINT8 mode)
2184 {
2185 BT_HDR *p;
2186 UINT8 *pp;
2187
2188 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
2189 return (FALSE);
2190
2191 pp = (UINT8 *)(p + 1);
2192
2193 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
2194 p->offset = 0;
2195
2196 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_PERIOD_MODE);
2197 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
2198
2199 UINT8_TO_STREAM (pp, mode);
2200
2201 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2202 return (TRUE);
2203 }
2204
btsnd_hcic_read_page_scan_mode(void)2205 BOOLEAN btsnd_hcic_read_page_scan_mode (void)
2206 {
2207 BT_HDR *p;
2208 UINT8 *pp;
2209
2210 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2211 return (FALSE);
2212
2213 pp = (UINT8 *)(p + 1);
2214
2215 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2216 p->offset = 0;
2217
2218 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_MODE);
2219 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2220
2221 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2222 return (TRUE);
2223 }
2224
btsnd_hcic_write_page_scan_mode(UINT8 mode)2225 BOOLEAN btsnd_hcic_write_page_scan_mode (UINT8 mode)
2226 {
2227 BT_HDR *p;
2228 UINT8 *pp;
2229
2230 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
2231 return (FALSE);
2232
2233 pp = (UINT8 *)(p + 1);
2234
2235 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
2236 p->offset = 0;
2237
2238 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_MODE);
2239 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
2240
2241 UINT8_TO_STREAM (pp, mode);
2242
2243 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2244 return (TRUE);
2245 }
2246
2247 /******************************************
2248 ** Lisbon Features
2249 *******************************************/
2250 #if BTM_SSR_INCLUDED == TRUE
2251
btsnd_hcic_sniff_sub_rate(UINT16 handle,UINT16 max_lat,UINT16 min_remote_lat,UINT16 min_local_lat)2252 BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
2253 UINT16 min_remote_lat, UINT16 min_local_lat)
2254 {
2255 BT_HDR *p;
2256 UINT8 *pp;
2257
2258 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SNIFF_SUB_RATE)) == NULL)
2259 return (FALSE);
2260
2261 pp = (UINT8 *)(p + 1);
2262
2263 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SNIFF_SUB_RATE;
2264 p->offset = 0;
2265
2266 UINT16_TO_STREAM (pp, HCI_SNIFF_SUB_RATE);
2267 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SNIFF_SUB_RATE);
2268
2269 UINT16_TO_STREAM (pp, handle);
2270 UINT16_TO_STREAM (pp, max_lat);
2271 UINT16_TO_STREAM (pp, min_remote_lat);
2272 UINT16_TO_STREAM (pp, min_local_lat);
2273
2274 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2275 return (TRUE);
2276 }
2277 #endif /* BTM_SSR_INCLUDED */
2278
2279 #if (BTM_EIR_SERVER_INCLUDED == TRUE)
2280 /**** Extended Inquiry Response Commands ****/
btsnd_hcic_read_ext_inquiry_response(void)2281 BOOLEAN btsnd_hcic_read_ext_inquiry_response (void)
2282 {
2283 BT_HDR *p;
2284 UINT8 *pp;
2285
2286 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2287 return (FALSE);
2288
2289 pp = (UINT8 *)(p + 1);
2290
2291 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2292 p->offset = 0;
2293
2294 UINT16_TO_STREAM (pp, HCI_READ_EXT_INQ_RESPONSE);
2295 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2296
2297 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2298 return (TRUE);
2299 }
2300
btsnd_hcic_write_ext_inquiry_response(void * buffer,UINT8 fec_req)2301 void btsnd_hcic_write_ext_inquiry_response (void *buffer, UINT8 fec_req)
2302 {
2303 BT_HDR *p = (BT_HDR *)buffer;
2304 UINT8 *pp = (UINT8 *)(p + 1);
2305
2306 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_EXT_INQ_RESP;
2307 p->offset = 0;
2308
2309 UINT16_TO_STREAM (pp, HCI_WRITE_EXT_INQ_RESPONSE);
2310 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_EXT_INQ_RESP);
2311
2312 UINT8_TO_STREAM (pp, fec_req);
2313
2314 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2315 }
2316 #endif /* BTM_EIR_SERVER_INCLUDED == TRUE */
2317
2318 /**** Simple Pairing Commands ****/
btsnd_hcic_write_simple_pairing_mode(UINT8 mode)2319 BOOLEAN btsnd_hcic_write_simple_pairing_mode (UINT8 mode)
2320 {
2321 BT_HDR *p;
2322 UINT8 *pp;
2323
2324 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_SIMP_PAIR)) == NULL)
2325 return (FALSE);
2326
2327 pp = (UINT8 *)(p + 1);
2328
2329 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_SIMP_PAIR;
2330 p->offset = 0;
2331
2332 UINT16_TO_STREAM (pp, HCI_WRITE_SIMPLE_PAIRING_MODE);
2333 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_SIMP_PAIR);
2334
2335 UINT8_TO_STREAM (pp, mode);
2336
2337 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2338 return (TRUE);
2339 }
2340
btsnd_hcic_read_simple_pairing_mode(void)2341 BOOLEAN btsnd_hcic_read_simple_pairing_mode (void)
2342 {
2343 BT_HDR *p;
2344 UINT8 *pp;
2345
2346 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_SIMP_PAIR)) == NULL)
2347 return (FALSE);
2348
2349 pp = (UINT8 *)(p + 1);
2350
2351 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_SIMP_PAIR;
2352 p->offset = 0;
2353
2354 UINT16_TO_STREAM (pp, HCI_READ_SIMPLE_PAIRING_MODE);
2355 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_SIMP_PAIR);
2356
2357 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2358 return (TRUE);
2359 }
2360
btsnd_hcic_write_simp_pair_debug_mode(UINT8 debug_mode)2361 BOOLEAN btsnd_hcic_write_simp_pair_debug_mode(UINT8 debug_mode)
2362 {
2363 BT_HDR *p;
2364 UINT8 *pp;
2365
2366 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SIMP_PAIR_DBUG)) == NULL)
2367 return (FALSE);
2368
2369 pp = (UINT8 *)(p + 1);
2370
2371 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SIMP_PAIR_DBUG;
2372 p->offset = 0;
2373
2374 UINT16_TO_STREAM (pp, HCI_WRITE_SIMP_PAIR_DEBUG_MODE);
2375 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SIMP_PAIR_DBUG);
2376
2377 UINT8_TO_STREAM (pp, debug_mode);
2378
2379 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2380 return (TRUE);
2381 }
2382
btsnd_hcic_io_cap_req_reply(BD_ADDR bd_addr,UINT8 capability,UINT8 oob_present,UINT8 auth_req)2383 BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability,
2384 UINT8 oob_present, UINT8 auth_req)
2385 {
2386 BT_HDR *p;
2387 UINT8 *pp;
2388
2389 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_IO_CAP_RESP)) == NULL)
2390 return (FALSE);
2391
2392 pp = (UINT8 *)(p + 1);
2393
2394 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_IO_CAP_RESP;
2395 p->offset = 0;
2396
2397 UINT16_TO_STREAM (pp, HCI_IO_CAPABILITY_RESPONSE);
2398 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_IO_CAP_RESP);
2399
2400 BDADDR_TO_STREAM (pp, bd_addr);
2401 UINT8_TO_STREAM (pp, capability);
2402 UINT8_TO_STREAM (pp, oob_present);
2403 UINT8_TO_STREAM (pp, auth_req);
2404
2405 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2406 return (TRUE);
2407 }
2408
btsnd_hcic_io_cap_req_neg_reply(BD_ADDR bd_addr,UINT8 err_code)2409 BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code)
2410 {
2411 BT_HDR *p;
2412 UINT8 *pp;
2413
2414 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY)) == NULL)
2415 return (FALSE);
2416
2417 pp = (UINT8 *)(p + 1);
2418
2419 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY;
2420 p->offset = 0;
2421
2422 UINT16_TO_STREAM (pp, HCI_IO_CAP_REQ_NEG_REPLY);
2423 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY);
2424
2425 BDADDR_TO_STREAM (pp, bd_addr);
2426 UINT8_TO_STREAM (pp, err_code);
2427
2428 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2429 return (TRUE);
2430 }
2431
btsnd_hcic_read_local_oob_data(void)2432 BOOLEAN btsnd_hcic_read_local_oob_data (void)
2433 {
2434 BT_HDR *p;
2435 UINT8 *pp;
2436
2437 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_LOCAL_OOB)) == NULL)
2438 return (FALSE);
2439
2440 pp = (UINT8 *)(p + 1);
2441
2442 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_LOCAL_OOB;
2443 p->offset = 0;
2444
2445 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_OOB_DATA);
2446 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_LOCAL_OOB);
2447
2448 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2449 return (TRUE);
2450 }
2451
btsnd_hcic_user_conf_reply(BD_ADDR bd_addr,BOOLEAN is_yes)2452 BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes)
2453 {
2454 BT_HDR *p;
2455 UINT8 *pp;
2456
2457 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_UCONF_REPLY)) == NULL)
2458 return (FALSE);
2459
2460 pp = (UINT8 *)(p + 1);
2461
2462 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_UCONF_REPLY;
2463 p->offset = 0;
2464
2465 if (!is_yes)
2466 {
2467 /* Negative reply */
2468 UINT16_TO_STREAM (pp, HCI_USER_CONF_VALUE_NEG_REPLY);
2469 }
2470 else
2471 {
2472 /* Confirmation */
2473 UINT16_TO_STREAM (pp, HCI_USER_CONF_REQUEST_REPLY);
2474 }
2475
2476 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_UCONF_REPLY);
2477
2478 BDADDR_TO_STREAM (pp, bd_addr);
2479
2480 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2481 return (TRUE);
2482 }
2483
btsnd_hcic_user_passkey_reply(BD_ADDR bd_addr,UINT32 value)2484 BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value)
2485 {
2486 BT_HDR *p;
2487 UINT8 *pp;
2488
2489 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_U_PKEY_REPLY)) == NULL)
2490 return (FALSE);
2491
2492 pp = (UINT8 *)(p + 1);
2493
2494 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_U_PKEY_REPLY;
2495 p->offset = 0;
2496
2497 UINT16_TO_STREAM (pp, HCI_USER_PASSKEY_REQ_REPLY);
2498 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_U_PKEY_REPLY);
2499
2500 BDADDR_TO_STREAM (pp, bd_addr);
2501 UINT32_TO_STREAM (pp, value);
2502
2503 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2504 return (TRUE);
2505 }
2506
btsnd_hcic_user_passkey_neg_reply(BD_ADDR bd_addr)2507 BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr)
2508 {
2509 BT_HDR *p;
2510 UINT8 *pp;
2511
2512 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY)) == NULL)
2513 return (FALSE);
2514
2515 pp = (UINT8 *)(p + 1);
2516
2517 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY;
2518 p->offset = 0;
2519
2520 UINT16_TO_STREAM (pp, HCI_USER_PASSKEY_REQ_NEG_REPLY);
2521 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY);
2522
2523 BDADDR_TO_STREAM (pp, bd_addr);
2524
2525 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2526 return (TRUE);
2527 }
2528
btsnd_hcic_rem_oob_reply(BD_ADDR bd_addr,UINT8 * p_c,UINT8 * p_r)2529 BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c, UINT8 *p_r)
2530 {
2531 BT_HDR *p;
2532 UINT8 *pp;
2533
2534 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REM_OOB_REPLY)) == NULL)
2535 return (FALSE);
2536
2537 pp = (UINT8 *)(p + 1);
2538
2539 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REM_OOB_REPLY;
2540 p->offset = 0;
2541
2542 UINT16_TO_STREAM (pp, HCI_REM_OOB_DATA_REQ_REPLY);
2543 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_REM_OOB_REPLY);
2544
2545 BDADDR_TO_STREAM (pp, bd_addr);
2546 ARRAY16_TO_STREAM (pp, p_c);
2547 ARRAY16_TO_STREAM (pp, p_r);
2548
2549 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2550 return (TRUE);
2551 }
2552
btsnd_hcic_rem_oob_neg_reply(BD_ADDR bd_addr)2553 BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr)
2554 {
2555 BT_HDR *p;
2556 UINT8 *pp;
2557
2558 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY)) == NULL)
2559 return (FALSE);
2560
2561 pp = (UINT8 *)(p + 1);
2562
2563 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY;
2564 p->offset = 0;
2565
2566 UINT16_TO_STREAM (pp, HCI_REM_OOB_DATA_REQ_NEG_REPLY);
2567 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY);
2568
2569 BDADDR_TO_STREAM (pp, bd_addr);
2570
2571 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2572 return (TRUE);
2573 }
2574
2575
btsnd_hcic_read_inq_tx_power(void)2576 BOOLEAN btsnd_hcic_read_inq_tx_power (void)
2577 {
2578 BT_HDR *p;
2579 UINT8 *pp;
2580
2581 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_TX_POWER)) == NULL)
2582 return (FALSE);
2583
2584 pp = (UINT8 *)(p + 1);
2585
2586 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_TX_POWER;
2587 p->offset = 0;
2588
2589 UINT16_TO_STREAM (pp, HCI_READ_INQ_TX_POWER_LEVEL);
2590 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_TX_POWER);
2591
2592 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2593 return (TRUE);
2594 }
2595
btsnd_hcic_write_inq_tx_power(INT8 level)2596 BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 level)
2597 {
2598 BT_HDR *p;
2599 UINT8 *pp;
2600
2601 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_TX_POWER)) == NULL)
2602 return (FALSE);
2603
2604 pp = (UINT8 *)(p + 1);
2605
2606 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_TX_POWER;
2607 p->offset = 0;
2608
2609 UINT16_TO_STREAM (pp, HCI_WRITE_INQ_TX_POWER_LEVEL);
2610 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_TX_POWER);
2611
2612 INT8_TO_STREAM (pp, level);
2613
2614 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2615 return (TRUE);
2616 }
2617
2618 #if 0 /* currently not been used */
2619 BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void)
2620 {
2621 BT_HDR *p;
2622 UINT8 *pp;
2623
2624 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_ERR_DATA_RPT)) == NULL)
2625 return (FALSE);
2626
2627 pp = (UINT8 *)(p + 1);
2628
2629 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_ERR_DATA_RPT;
2630 p->offset = 0;
2631
2632 UINT16_TO_STREAM (pp, HCI_READ_ERRONEOUS_DATA_RPT);
2633 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_ERR_DATA_RPT);
2634
2635 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2636 return (TRUE);
2637 }
2638 #endif
2639
btsnd_hcic_write_default_erroneous_data_rpt(UINT8 flag)2640 BOOLEAN btsnd_hcic_write_default_erroneous_data_rpt (UINT8 flag)
2641 {
2642 BT_HDR *p;
2643 UINT8 *pp;
2644
2645 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_ERR_DATA_RPT)) == NULL)
2646 return (FALSE);
2647
2648 pp = (UINT8 *)(p + 1);
2649
2650 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_ERR_DATA_RPT;
2651 p->offset = 0;
2652
2653 UINT16_TO_STREAM (pp, HCI_WRITE_ERRONEOUS_DATA_RPT);
2654 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_ERR_DATA_RPT);
2655
2656 UINT8_TO_STREAM (pp, flag);
2657
2658 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2659 return (TRUE);
2660 }
2661
btsnd_hcic_send_keypress_notif(BD_ADDR bd_addr,UINT8 notif)2662 BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif)
2663 {
2664 BT_HDR *p;
2665 UINT8 *pp;
2666
2667 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF)) == NULL)
2668 return (FALSE);
2669
2670 pp = (UINT8 *)(p + 1);
2671
2672 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF;
2673 p->offset = 0;
2674
2675 UINT16_TO_STREAM (pp, HCI_SEND_KEYPRESS_NOTIF);
2676 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF);
2677
2678 BDADDR_TO_STREAM (pp, bd_addr);
2679 UINT8_TO_STREAM (pp, notif);
2680
2681 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2682 return (TRUE);
2683 }
2684
2685 /**** end of Simple Pairing Commands ****/
2686
2687 #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
btsnd_hcic_enhanced_flush(UINT16 handle,UINT8 packet_type)2688 BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type)
2689 {
2690 BT_HDR *p;
2691 UINT8 *pp;
2692
2693 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ENHANCED_FLUSH)) == NULL)
2694 return (FALSE);
2695
2696 pp = (UINT8 *)(p + 1);
2697
2698 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ENHANCED_FLUSH;
2699 p->offset = 0;
2700 UINT16_TO_STREAM (pp, HCI_ENHANCED_FLUSH);
2701 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_ENHANCED_FLUSH);
2702
2703 UINT16_TO_STREAM (pp, handle);
2704 UINT8_TO_STREAM (pp, packet_type);
2705
2706 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2707 return (TRUE);
2708 }
2709 #endif
2710
2711
btsnd_hcic_refresh_encryption_key(UINT16 handle)2712 BOOLEAN btsnd_hcic_refresh_encryption_key (UINT16 handle)
2713 {
2714 BT_HDR *p;
2715 UINT8 *pp;
2716
2717 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2718 return (FALSE);
2719
2720 pp = (UINT8 *)(p + 1);
2721
2722 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2723 p->offset = 0;
2724 UINT16_TO_STREAM (pp, HCI_REFRESH_ENCRYPTION_KEY);
2725 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2726
2727 UINT16_TO_STREAM (pp, handle);
2728
2729 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2730 return (TRUE);
2731 }
2732 /*************************
2733 ** End of Lisbon Commands
2734 **************************/
2735
btsnd_hcic_read_local_ver(UINT8 local_controller_id)2736 BOOLEAN btsnd_hcic_read_local_ver (UINT8 local_controller_id)
2737 {
2738 BT_HDR *p;
2739 UINT8 *pp;
2740
2741 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2742 return (FALSE);
2743
2744 pp = (UINT8 *)(p + 1);
2745
2746 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2747 p->offset = 0;
2748
2749 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_VERSION_INFO);
2750 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2751
2752 btu_hcif_send_cmd (local_controller_id, p);
2753 return (TRUE);
2754 }
2755
btsnd_hcic_read_local_supported_cmds(UINT8 local_controller_id)2756 BOOLEAN btsnd_hcic_read_local_supported_cmds (UINT8 local_controller_id)
2757 {
2758 BT_HDR *p;
2759 UINT8 *pp;
2760
2761 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2762 return (FALSE);
2763
2764 pp = (UINT8 *)(p + 1);
2765
2766 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2767 p->offset = 0;
2768
2769 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_SUPPORTED_CMDS);
2770 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2771
2772 btu_hcif_send_cmd (local_controller_id, p);
2773 return (TRUE);
2774 }
2775
btsnd_hcic_read_local_features(void)2776 BOOLEAN btsnd_hcic_read_local_features (void)
2777 {
2778 BT_HDR *p;
2779 UINT8 *pp;
2780
2781 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2782 return (FALSE);
2783
2784 pp = (UINT8 *)(p + 1);
2785
2786 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2787 p->offset = 0;
2788
2789 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_FEATURES);
2790 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2791
2792 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2793 return (TRUE);
2794 }
2795
btsnd_hcic_read_local_ext_features(UINT8 page_num)2796 BOOLEAN btsnd_hcic_read_local_ext_features (UINT8 page_num)
2797 {
2798 BT_HDR *p;
2799 UINT8 *pp;
2800
2801 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES)) == NULL)
2802 return (FALSE);
2803
2804 pp = (UINT8 *)(p + 1);
2805
2806 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES;
2807 p->offset = 0;
2808
2809 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_EXT_FEATURES);
2810 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES);
2811
2812 UINT8_TO_STREAM (pp, page_num);
2813
2814 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2815 return (TRUE);
2816 }
2817
btsnd_hcic_read_buffer_size(void)2818 BOOLEAN btsnd_hcic_read_buffer_size (void)
2819 {
2820 BT_HDR *p;
2821 UINT8 *pp;
2822
2823 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2824 return (FALSE);
2825
2826 pp = (UINT8 *)(p + 1);
2827
2828 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2829 p->offset = 0;
2830
2831 UINT16_TO_STREAM (pp, HCI_READ_BUFFER_SIZE);
2832 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2833
2834 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2835 return (TRUE);
2836 }
2837
btsnd_hcic_read_country_code(void)2838 BOOLEAN btsnd_hcic_read_country_code (void)
2839 {
2840 BT_HDR *p;
2841 UINT8 *pp;
2842
2843 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2844 return (FALSE);
2845
2846 pp = (UINT8 *)(p + 1);
2847
2848 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2849 p->offset = 0;
2850
2851 UINT16_TO_STREAM (pp, HCI_READ_COUNTRY_CODE);
2852 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2853
2854 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2855 return (TRUE);
2856 }
2857
btsnd_hcic_read_bd_addr(void)2858 BOOLEAN btsnd_hcic_read_bd_addr (void)
2859 {
2860 BT_HDR *p;
2861 UINT8 *pp;
2862
2863 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2864 return (FALSE);
2865
2866 pp = (UINT8 *)(p + 1);
2867
2868 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2869 p->offset = 0;
2870
2871 UINT16_TO_STREAM (pp, HCI_READ_BD_ADDR);
2872 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2873
2874 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2875 return (TRUE);
2876 }
2877
btsnd_hcic_read_fail_contact_count(UINT8 local_controller_id,UINT16 handle)2878 BOOLEAN btsnd_hcic_read_fail_contact_count (UINT8 local_controller_id, UINT16 handle)
2879 {
2880 BT_HDR *p;
2881 UINT8 *pp;
2882
2883 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2884 return (FALSE);
2885
2886 pp = (UINT8 *)(p + 1);
2887
2888 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2889 p->offset = 0;
2890
2891 UINT16_TO_STREAM (pp, HCI_READ_FAILED_CONTACT_COUNT);
2892 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2893
2894 UINT16_TO_STREAM (pp, handle);
2895
2896 btu_hcif_send_cmd (local_controller_id, p);
2897 return (TRUE);
2898 }
2899
btsnd_hcic_reset_fail_contact_count(UINT8 local_controller_id,UINT16 handle)2900 BOOLEAN btsnd_hcic_reset_fail_contact_count (UINT8 local_controller_id, UINT16 handle)
2901 {
2902 BT_HDR *p;
2903 UINT8 *pp;
2904
2905 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2906 return (FALSE);
2907
2908 pp = (UINT8 *)(p + 1);
2909
2910 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2911 p->offset = 0;
2912
2913 UINT16_TO_STREAM (pp, HCI_RESET_FAILED_CONTACT_COUNT);
2914 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2915
2916 UINT16_TO_STREAM (pp, handle);
2917
2918 btu_hcif_send_cmd (local_controller_id, p);
2919 return (TRUE);
2920 }
2921
btsnd_hcic_get_link_quality(UINT16 handle)2922 BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle)
2923 {
2924 BT_HDR *p;
2925 UINT8 *pp;
2926
2927 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2928 return (FALSE);
2929
2930 pp = (UINT8 *)(p + 1);
2931
2932 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2933 p->offset = 0;
2934
2935 UINT16_TO_STREAM (pp, HCI_GET_LINK_QUALITY);
2936 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2937
2938 UINT16_TO_STREAM (pp, handle);
2939
2940 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2941 return (TRUE);
2942 }
2943
btsnd_hcic_read_rssi(UINT16 handle)2944 BOOLEAN btsnd_hcic_read_rssi (UINT16 handle)
2945 {
2946 BT_HDR *p;
2947 UINT8 *pp;
2948
2949 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2950 return (FALSE);
2951
2952 pp = (UINT8 *)(p + 1);
2953
2954 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2955 p->offset = 0;
2956
2957 UINT16_TO_STREAM (pp, HCI_READ_RSSI);
2958 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2959
2960 UINT16_TO_STREAM (pp, handle);
2961
2962 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2963 return (TRUE);
2964 }
2965
btsnd_hcic_read_loopback_mode(void)2966 BOOLEAN btsnd_hcic_read_loopback_mode (void)
2967 {
2968 BT_HDR *p;
2969 UINT8 *pp;
2970
2971 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2972 return (FALSE);
2973
2974 pp = (UINT8 *)(p + 1);
2975
2976 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2977 p->offset = 0;
2978
2979 UINT16_TO_STREAM (pp, HCI_READ_LOOPBACK_MODE);
2980 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2981
2982 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2983 return (TRUE);
2984 }
2985
btsnd_hcic_write_loopback_mode(UINT8 mode)2986 BOOLEAN btsnd_hcic_write_loopback_mode (UINT8 mode)
2987 {
2988 BT_HDR *p;
2989 UINT8 *pp;
2990
2991 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
2992 return (FALSE);
2993
2994 pp = (UINT8 *)(p + 1);
2995
2996 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
2997 p->offset = 0;
2998
2999 UINT16_TO_STREAM (pp, HCI_WRITE_LOOPBACK_MODE);
3000 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3001
3002 UINT8_TO_STREAM (pp, mode);
3003
3004 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3005 return (TRUE);
3006 }
3007
btsnd_hcic_enable_test_mode(void)3008 BOOLEAN btsnd_hcic_enable_test_mode (void)
3009 {
3010 BT_HDR *p;
3011 UINT8 *pp;
3012
3013 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3014 return (FALSE);
3015
3016 pp = (UINT8 *)(p + 1);
3017
3018 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3019 p->offset = 0;
3020
3021 UINT16_TO_STREAM (pp, HCI_ENABLE_DEV_UNDER_TEST_MODE);
3022 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3023
3024 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3025 return (TRUE);
3026 }
3027
btsnd_hcic_write_afh_channel_assessment_mode(UINT8 mode)3028 BOOLEAN btsnd_hcic_write_afh_channel_assessment_mode (UINT8 mode)
3029 {
3030 BT_HDR *p;
3031 UINT8 *pp;
3032
3033 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3034 return (FALSE);
3035
3036 pp = (UINT8 *)(p + 1);
3037
3038 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3039 p->offset = 0;
3040
3041 UINT16_TO_STREAM (pp, HCI_WRITE_AFH_ASSESSMENT_MODE);
3042 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3043
3044 UINT8_TO_STREAM (pp, mode);
3045
3046 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3047 return (TRUE);
3048 }
3049
btsnd_hcic_read_afh_channel_assessment_mode(void)3050 BOOLEAN btsnd_hcic_read_afh_channel_assessment_mode(void)
3051 {
3052 BT_HDR *p;
3053 UINT8 *pp;
3054
3055 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3056 return (FALSE);
3057
3058 pp = (UINT8 *)(p + 1);
3059
3060 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3061 p->offset = 0;
3062
3063 UINT16_TO_STREAM (pp, HCI_READ_AFH_ASSESSMENT_MODE);
3064 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3065
3066 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3067 return (TRUE);
3068 }
3069
btsnd_hcic_set_afh_channels(UINT8 first,UINT8 last)3070 BOOLEAN btsnd_hcic_set_afh_channels (UINT8 first, UINT8 last)
3071 {
3072 BT_HDR *p;
3073 UINT8 *pp;
3074 UINT8 channels[10] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F};
3075 int i;
3076
3077 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_AFH_CHANNELS)) == NULL)
3078 return (FALSE);
3079
3080 pp = (UINT8 *)(p + 1);
3081
3082 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_AFH_CHANNELS;
3083 p->offset = 0;
3084
3085 UINT16_TO_STREAM (pp, HCI_SET_AFH_CHANNELS);
3086 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_AFH_CHANNELS);
3087
3088 /* Just make sure that caller did not exceed 79 Bluetooth channels */
3089 if ((first <= last) && (last <= 78))
3090 {
3091 for (i = first; i <= last; i++)
3092 {
3093 int byte_offset = i / 8;
3094 int bit_offset = i % 8;
3095 channels[byte_offset] &= ~(1 << bit_offset);
3096 }
3097 }
3098 for (i = 0; i < 10; i++)
3099 *pp++ = channels[i];
3100
3101 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3102 return (TRUE);
3103 }
3104
btsnd_hcic_set_afh_host_channel_class(UINT8 * p_afhchannelmap)3105 BOOLEAN btsnd_hcic_set_afh_host_channel_class (UINT8 *p_afhchannelmap)
3106 {
3107 BT_HDR *p;
3108 UINT8 *pp;
3109 int i;
3110
3111 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_AFH_CHANNELS)) == NULL)
3112 return (FALSE);
3113
3114 pp = (UINT8 *)(p + 1);
3115
3116 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_AFH_CHANNELS;
3117 p->offset = 0;
3118
3119 UINT16_TO_STREAM (pp, HCI_SET_AFH_CHANNELS);
3120 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_AFH_CHANNELS);
3121
3122 /* Copy and convert */
3123 for (i = 0; i < 10; i++)
3124 *pp++ = p_afhchannelmap[9-i];
3125
3126 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3127 return (TRUE);
3128 }
3129
btsnd_hcic_read_afh_channel_map(UINT16 handle)3130 BOOLEAN btsnd_hcic_read_afh_channel_map (UINT16 handle)
3131 {
3132 BT_HDR *p;
3133 UINT8 *pp;
3134
3135 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
3136 return (FALSE);
3137
3138 pp = (UINT8 *)(p + 1);
3139
3140 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
3141 p->offset = 0;
3142
3143 UINT16_TO_STREAM (pp, HCI_READ_AFH_CH_MAP);
3144 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
3145
3146 UINT16_TO_STREAM (pp, handle);
3147
3148 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3149 return (TRUE);
3150 }
3151
btsnd_hcic_read_clock(UINT16 handle,UINT8 which_clock)3152 BOOLEAN btsnd_hcic_read_clock (UINT16 handle, UINT8 which_clock)
3153 {
3154 BT_HDR *p;
3155 UINT8 *pp;
3156
3157 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CLOCK)) == NULL)
3158 return (FALSE);
3159
3160 pp = (UINT8 *)(p + 1);
3161
3162 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CLOCK;
3163 p->offset = 0;
3164
3165 UINT16_TO_STREAM (pp, HCI_READ_CLOCK);
3166 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CLOCK);
3167
3168 UINT16_TO_STREAM (pp, handle);
3169 UINT8_TO_STREAM (pp, which_clock);
3170
3171 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3172 return (TRUE);
3173 }
3174
btsnd_hcic_read_inqscan_type(void)3175 BOOLEAN btsnd_hcic_read_inqscan_type(void)
3176 {
3177 BT_HDR *p;
3178 UINT8 *pp;
3179
3180 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3181 return (FALSE);
3182
3183 pp = (UINT8 *)(p + 1);
3184
3185 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3186 p->offset = 0;
3187
3188 UINT16_TO_STREAM (pp, HCI_READ_INQSCAN_TYPE);
3189 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3190
3191 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3192 return (TRUE);
3193 }
3194
btsnd_hcic_write_inqscan_type(UINT8 type)3195 BOOLEAN btsnd_hcic_write_inqscan_type (UINT8 type)
3196 {
3197 BT_HDR *p;
3198 UINT8 *pp;
3199
3200 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3201 return (FALSE);
3202
3203 pp = (UINT8 *)(p + 1);
3204
3205 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3206 p->offset = 0;
3207
3208 UINT16_TO_STREAM (pp, HCI_WRITE_INQSCAN_TYPE);
3209 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3210
3211 UINT8_TO_STREAM (pp, type);
3212
3213 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3214 return (TRUE);
3215 }
3216
btsnd_hcic_read_inquiry_mode(void)3217 BOOLEAN btsnd_hcic_read_inquiry_mode (void)
3218 {
3219 BT_HDR *p;
3220 UINT8 *pp;
3221
3222 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3223 return (FALSE);
3224
3225 pp = (UINT8 *)(p + 1);
3226
3227 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3228 p->offset = 0;
3229
3230 UINT16_TO_STREAM (pp, HCI_READ_INQUIRY_MODE);
3231 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3232
3233 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3234 return (TRUE);
3235 }
3236
btsnd_hcic_write_inquiry_mode(UINT8 mode)3237 BOOLEAN btsnd_hcic_write_inquiry_mode (UINT8 mode)
3238 {
3239 BT_HDR *p;
3240 UINT8 *pp;
3241
3242 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3243 return (FALSE);
3244
3245 pp = (UINT8 *)(p + 1);
3246
3247 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3248 p->offset = 0;
3249
3250 UINT16_TO_STREAM (pp, HCI_WRITE_INQUIRY_MODE);
3251 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3252
3253 UINT8_TO_STREAM (pp, mode);
3254
3255 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3256 return (TRUE);
3257 }
3258
btsnd_hcic_read_pagescan_type(void)3259 BOOLEAN btsnd_hcic_read_pagescan_type (void)
3260 {
3261 BT_HDR *p;
3262 UINT8 *pp;
3263
3264 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3265 return (FALSE);
3266
3267 pp = (UINT8 *)(p + 1);
3268
3269 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3270 p->offset = 0;
3271
3272 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_TYPE);
3273 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3274
3275 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3276 return (TRUE);
3277 }
3278
btsnd_hcic_write_pagescan_type(UINT8 type)3279 BOOLEAN btsnd_hcic_write_pagescan_type (UINT8 type)
3280 {
3281 BT_HDR *p;
3282 UINT8 *pp;
3283
3284 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3285 return (FALSE);
3286
3287 pp = (UINT8 *)(p + 1);
3288
3289 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3290 p->offset = 0;
3291
3292 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_TYPE);
3293 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3294
3295 UINT8_TO_STREAM (pp, type);
3296
3297 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3298 return (TRUE);
3299 }
3300
3301 /* Must have room to store BT_HDR + max VSC length + callback pointer */
3302 #if !defined (LMP_TEST) && (HCI_CMD_POOL_BUF_SIZE < 268)
3303 #error "HCI_CMD_POOL_BUF_SIZE must be larger than 268"
3304 #endif
3305
btsnd_hcic_vendor_spec_cmd(void * buffer,UINT16 opcode,UINT8 len,UINT8 * p_data,void * p_cmd_cplt_cback)3306 void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, UINT8 len,
3307 UINT8 *p_data, void *p_cmd_cplt_cback)
3308 {
3309 BT_HDR *p = (BT_HDR *)buffer;
3310 UINT8 *pp = (UINT8 *)(p + 1);
3311
3312 p->len = HCIC_PREAMBLE_SIZE + len;
3313 p->offset = sizeof(void *);
3314
3315 *((void **)pp) = p_cmd_cplt_cback; /* Store command complete callback in buffer */
3316 pp += sizeof(void *); /* Skip over callback pointer */
3317
3318 UINT16_TO_STREAM (pp, HCI_GRP_VENDOR_SPECIFIC | opcode);
3319 UINT8_TO_STREAM (pp, len);
3320 ARRAY_TO_STREAM (pp, p_data, len);
3321
3322 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3323 }
3324
btsnd_hcic_data(BT_HDR * p_buf,UINT16 len,UINT16 handle,UINT8 boundary,UINT8 broadcast)3325 void btsnd_hcic_data (BT_HDR *p_buf, UINT16 len, UINT16 handle, UINT8 boundary, UINT8 broadcast)
3326 {
3327 UINT8 *p;
3328
3329 /* Higher layer should have left 4 bytes for us to fill the header */
3330 p_buf->offset -= 4;
3331 p_buf->len += 4;
3332
3333 /* Find the pointer to the beginning of the data */
3334 p = (UINT8 *)(p_buf + 1) + p_buf->offset;
3335
3336 UINT16_TO_STREAM (p, handle | ((boundary & 3) << 12) | ((broadcast & 3) << 14));
3337 UINT16_TO_STREAM (p, len);
3338
3339 HCI_ACL_DATA_TO_LOWER (p_buf);
3340 }
3341
btsnd_hcic_nop(void)3342 BOOLEAN btsnd_hcic_nop (void)
3343 {
3344 BT_HDR *p;
3345 UINT8 *pp;
3346
3347 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3348 return (FALSE);
3349
3350 pp = (UINT8 *)(p + 1);
3351
3352 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3353 p->offset = 0;
3354
3355 UINT16_TO_STREAM (pp, HCI_COMMAND_NONE);
3356 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3357
3358 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3359 return (TRUE);
3360 }
3361
3362