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 if (len > HCIC_PARAM_SIZE_CHANGE_NAME)
1375 len = HCIC_PARAM_SIZE_CHANGE_NAME;
1376
1377 ARRAY_TO_STREAM (pp, name, len);
1378
1379 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1380 return (TRUE);
1381 }
1382
btsnd_hcic_read_name(void)1383 BOOLEAN btsnd_hcic_read_name (void)
1384 {
1385 BT_HDR *p;
1386 UINT8 *pp;
1387
1388 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1389 return (FALSE);
1390
1391 pp = (UINT8 *)(p + 1);
1392
1393 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1394 p->offset = 0;
1395
1396 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_NAME);
1397 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1398
1399 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1400 return (TRUE);
1401 }
1402
btsnd_hcic_read_conn_acc_tout(UINT8 local_controller_id)1403 BOOLEAN btsnd_hcic_read_conn_acc_tout (UINT8 local_controller_id)
1404 {
1405 BT_HDR *p;
1406 UINT8 *pp;
1407
1408 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1409 return (FALSE);
1410
1411 pp = (UINT8 *)(p + 1);
1412
1413 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1414 p->offset = 0;
1415
1416 UINT16_TO_STREAM (pp, HCI_READ_CONN_ACCEPT_TOUT);
1417 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1418
1419 btu_hcif_send_cmd (local_controller_id, p);
1420 return (TRUE);
1421 }
1422
btsnd_hcic_write_conn_acc_tout(UINT8 local_controller_id,UINT16 timeout)1423 BOOLEAN btsnd_hcic_write_conn_acc_tout (UINT8 local_controller_id, UINT16 timeout)
1424 {
1425 BT_HDR *p;
1426 UINT8 *pp;
1427
1428 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1429 return (FALSE);
1430
1431 pp = (UINT8 *)(p + 1);
1432
1433 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1434 p->offset = 0;
1435
1436 UINT16_TO_STREAM (pp, HCI_WRITE_CONN_ACCEPT_TOUT);
1437 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1438
1439 UINT16_TO_STREAM (pp, timeout);
1440
1441 btu_hcif_send_cmd (local_controller_id, p);
1442 return (TRUE);
1443 }
1444
btsnd_hcic_read_page_tout(void)1445 BOOLEAN btsnd_hcic_read_page_tout (void)
1446 {
1447 BT_HDR *p;
1448 UINT8 *pp;
1449
1450 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1451 return (FALSE);
1452
1453 pp = (UINT8 *)(p + 1);
1454
1455 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1456 p->offset = 0;
1457
1458 UINT16_TO_STREAM (pp, HCI_READ_PAGE_TOUT);
1459 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1460
1461 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1462 return (TRUE);
1463 }
1464
btsnd_hcic_write_page_tout(UINT16 timeout)1465 BOOLEAN btsnd_hcic_write_page_tout (UINT16 timeout)
1466 {
1467 BT_HDR *p;
1468 UINT8 *pp;
1469
1470 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1471 return (FALSE);
1472
1473 pp = (UINT8 *)(p + 1);
1474
1475 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1476 p->offset = 0;
1477
1478 UINT16_TO_STREAM (pp, HCI_WRITE_PAGE_TOUT);
1479 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1480
1481 UINT16_TO_STREAM (pp, timeout);
1482
1483 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1484 return (TRUE);
1485 }
1486
btsnd_hcic_read_scan_enable(void)1487 BOOLEAN btsnd_hcic_read_scan_enable (void)
1488 {
1489 BT_HDR *p;
1490 UINT8 *pp;
1491
1492 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1493 return (FALSE);
1494
1495 pp = (UINT8 *)(p + 1);
1496
1497 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1498 p->offset = 0;
1499
1500 UINT16_TO_STREAM (pp, HCI_READ_SCAN_ENABLE);
1501 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1502
1503 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1504 return (TRUE);
1505 }
1506
btsnd_hcic_write_scan_enable(UINT8 flag)1507 BOOLEAN btsnd_hcic_write_scan_enable (UINT8 flag)
1508 {
1509 BT_HDR *p;
1510 UINT8 *pp;
1511
1512 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1513 return (FALSE);
1514
1515 pp = (UINT8 *)(p + 1);
1516
1517 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1518 p->offset = 0;
1519
1520 UINT16_TO_STREAM (pp, HCI_WRITE_SCAN_ENABLE);
1521 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1522
1523 UINT8_TO_STREAM (pp, flag);
1524
1525 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1526 return (TRUE);
1527 }
1528
btsnd_hcic_read_pagescan_cfg(void)1529 BOOLEAN btsnd_hcic_read_pagescan_cfg(void)
1530 {
1531 BT_HDR *p;
1532 UINT8 *pp;
1533
1534 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1535 return (FALSE);
1536
1537 pp = (UINT8 *)(p + 1);
1538
1539 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1540 p->offset = 0;
1541
1542 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_CFG);
1543 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1544
1545 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1546 return (TRUE);
1547 }
1548
btsnd_hcic_write_pagescan_cfg(UINT16 interval,UINT16 window)1549 BOOLEAN btsnd_hcic_write_pagescan_cfg(UINT16 interval, UINT16 window)
1550 {
1551 BT_HDR *p;
1552 UINT8 *pp;
1553
1554 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG)) == NULL)
1555 return (FALSE);
1556
1557 pp = (UINT8 *)(p + 1);
1558
1559 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG;
1560 p->offset = 0;
1561
1562 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_CFG);
1563 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PAGESCAN_CFG);
1564
1565 UINT16_TO_STREAM (pp, interval);
1566 UINT16_TO_STREAM (pp, window);
1567
1568 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1569 return (TRUE);
1570 }
1571
btsnd_hcic_read_inqscan_cfg(void)1572 BOOLEAN btsnd_hcic_read_inqscan_cfg(void)
1573 {
1574 BT_HDR *p;
1575 UINT8 *pp;
1576
1577 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1578 return (FALSE);
1579
1580 pp = (UINT8 *)(p + 1);
1581
1582 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1583 p->offset = 0;
1584
1585 UINT16_TO_STREAM (pp, HCI_READ_INQUIRYSCAN_CFG);
1586 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1587
1588 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1589 return (TRUE);
1590 }
1591
btsnd_hcic_write_inqscan_cfg(UINT16 interval,UINT16 window)1592 BOOLEAN btsnd_hcic_write_inqscan_cfg(UINT16 interval, UINT16 window)
1593 {
1594 BT_HDR *p;
1595 UINT8 *pp;
1596
1597 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG)) == NULL)
1598 return (FALSE);
1599
1600 pp = (UINT8 *)(p + 1);
1601
1602 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG;
1603 p->offset = 0;
1604
1605 UINT16_TO_STREAM (pp, HCI_WRITE_INQUIRYSCAN_CFG);
1606 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_INQSCAN_CFG);
1607
1608 UINT16_TO_STREAM (pp, interval);
1609 UINT16_TO_STREAM (pp, window);
1610
1611 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1612 return (TRUE);
1613 }
1614
btsnd_hcic_read_auth_enable(void)1615 BOOLEAN btsnd_hcic_read_auth_enable (void)
1616 {
1617 BT_HDR *p;
1618 UINT8 *pp;
1619
1620 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1621 return (FALSE);
1622
1623 pp = (UINT8 *)(p + 1);
1624
1625 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1626 p->offset = 0;
1627
1628 UINT16_TO_STREAM (pp, HCI_READ_AUTHENTICATION_ENABLE);
1629 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1630
1631 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1632 return (TRUE);
1633 }
1634
btsnd_hcic_write_auth_enable(UINT8 flag)1635 BOOLEAN btsnd_hcic_write_auth_enable (UINT8 flag)
1636 {
1637 BT_HDR *p;
1638 UINT8 *pp;
1639
1640 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1641 return (FALSE);
1642
1643 pp = (UINT8 *)(p + 1);
1644
1645 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1646 p->offset = 0;
1647
1648 UINT16_TO_STREAM (pp, HCI_WRITE_AUTHENTICATION_ENABLE);
1649 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1650
1651 UINT8_TO_STREAM (pp, flag);
1652
1653 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1654 return (TRUE);
1655 }
1656
btsnd_hcic_read_encr_mode(void)1657 BOOLEAN btsnd_hcic_read_encr_mode (void)
1658 {
1659 BT_HDR *p;
1660 UINT8 *pp;
1661
1662 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1663 return (FALSE);
1664
1665 pp = (UINT8 *)(p + 1);
1666
1667 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1668 p->offset = 0;
1669
1670 UINT16_TO_STREAM (pp, HCI_READ_ENCRYPTION_MODE);
1671 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1672
1673 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1674 return (TRUE);
1675 }
1676
btsnd_hcic_write_encr_mode(UINT8 mode)1677 BOOLEAN btsnd_hcic_write_encr_mode (UINT8 mode)
1678 {
1679 BT_HDR *p;
1680 UINT8 *pp;
1681
1682 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1683 return (FALSE);
1684
1685 pp = (UINT8 *)(p + 1);
1686
1687 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1688 p->offset = 0;
1689
1690 UINT16_TO_STREAM (pp, HCI_WRITE_ENCRYPTION_MODE);
1691 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1692
1693 UINT8_TO_STREAM (pp, mode);
1694
1695 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1696 return (TRUE);
1697 }
1698
btsnd_hcic_read_dev_class(void)1699 BOOLEAN btsnd_hcic_read_dev_class(void)
1700 {
1701 BT_HDR *p;
1702 UINT8 *pp;
1703
1704 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1705 return (FALSE);
1706
1707 pp = (UINT8 *)(p + 1);
1708
1709 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1710 p->offset = 0;
1711
1712 UINT16_TO_STREAM (pp, HCI_READ_CLASS_OF_DEVICE);
1713 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1714
1715 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1716 return (TRUE);
1717 }
1718
btsnd_hcic_write_dev_class(DEV_CLASS dev_class)1719 BOOLEAN btsnd_hcic_write_dev_class(DEV_CLASS dev_class)
1720 {
1721 BT_HDR *p;
1722 UINT8 *pp;
1723
1724 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM3)) == NULL)
1725 return (FALSE);
1726
1727 pp = (UINT8 *)(p + 1);
1728
1729 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3;
1730 p->offset = 0;
1731
1732 UINT16_TO_STREAM (pp, HCI_WRITE_CLASS_OF_DEVICE);
1733 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM3);
1734
1735 DEVCLASS_TO_STREAM (pp, dev_class);
1736
1737 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1738 return (TRUE);
1739 }
1740
btsnd_hcic_read_voice_settings(void)1741 BOOLEAN btsnd_hcic_read_voice_settings(void)
1742 {
1743 BT_HDR *p;
1744 UINT8 *pp;
1745
1746 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1747 return (FALSE);
1748
1749 pp = (UINT8 *)(p + 1);
1750
1751 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1752 p->offset = 0;
1753
1754 UINT16_TO_STREAM (pp, HCI_READ_VOICE_SETTINGS);
1755 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1756
1757 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1758 return (TRUE);
1759 }
1760
btsnd_hcic_write_voice_settings(UINT16 flags)1761 BOOLEAN btsnd_hcic_write_voice_settings(UINT16 flags)
1762 {
1763 BT_HDR *p;
1764 UINT8 *pp;
1765
1766 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM2)) == NULL)
1767 return (FALSE);
1768
1769 pp = (UINT8 *)(p + 1);
1770
1771 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM2;
1772 p->offset = 0;
1773
1774 UINT16_TO_STREAM (pp, HCI_WRITE_VOICE_SETTINGS);
1775 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM2);
1776
1777 UINT16_TO_STREAM (pp, flags);
1778
1779 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1780 return (TRUE);
1781 }
1782
btsnd_hcic_read_auto_flush_tout(UINT16 handle)1783 BOOLEAN btsnd_hcic_read_auto_flush_tout (UINT16 handle)
1784 {
1785 BT_HDR *p;
1786 UINT8 *pp;
1787
1788 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
1789 return (FALSE);
1790
1791 pp = (UINT8 *)(p + 1);
1792
1793 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
1794 p->offset = 0;
1795
1796 UINT16_TO_STREAM (pp, HCI_READ_AUTO_FLUSH_TOUT);
1797 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
1798
1799 UINT16_TO_STREAM (pp, handle);
1800
1801 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1802 return (TRUE);
1803 }
1804
btsnd_hcic_write_auto_flush_tout(UINT16 handle,UINT16 tout)1805 BOOLEAN btsnd_hcic_write_auto_flush_tout (UINT16 handle, UINT16 tout)
1806 {
1807 BT_HDR *p;
1808 UINT8 *pp;
1809
1810 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT)) == NULL)
1811 return (FALSE);
1812
1813 pp = (UINT8 *)(p + 1);
1814
1815 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT;
1816 p->offset = 0;
1817
1818 UINT16_TO_STREAM (pp, HCI_WRITE_AUTO_FLUSH_TOUT);
1819 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_AUTO_FLUSH_TOUT);
1820
1821 UINT16_TO_STREAM (pp, handle);
1822 UINT16_TO_STREAM (pp, tout);
1823
1824 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1825 return (TRUE);
1826 }
1827
btsnd_hcic_read_num_bcast_xmit(void)1828 BOOLEAN btsnd_hcic_read_num_bcast_xmit (void)
1829 {
1830 BT_HDR *p;
1831 UINT8 *pp;
1832
1833 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1834 return (FALSE);
1835
1836 pp = (UINT8 *)(p + 1);
1837
1838 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1839 p->offset = 0;
1840
1841 UINT16_TO_STREAM (pp, HCI_READ_NUM_BCAST_REXMITS);
1842 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1843
1844 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1845 return (TRUE);
1846 }
1847
btsnd_hcic_write_num_bcast_xmit(UINT8 num)1848 BOOLEAN btsnd_hcic_write_num_bcast_xmit (UINT8 num)
1849 {
1850 BT_HDR *p;
1851 UINT8 *pp;
1852
1853 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1854 return (FALSE);
1855
1856 pp = (UINT8 *)(p + 1);
1857
1858 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1859 p->offset = 0;
1860
1861 UINT16_TO_STREAM (pp, HCI_WRITE_NUM_BCAST_REXMITS);
1862 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1863
1864 UINT8_TO_STREAM (pp, num);
1865
1866 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1867 return (TRUE);
1868 }
1869
btsnd_hcic_read_hold_mode_act(void)1870 BOOLEAN btsnd_hcic_read_hold_mode_act (void)
1871 {
1872 BT_HDR *p;
1873 UINT8 *pp;
1874
1875 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1876 return (FALSE);
1877
1878 pp = (UINT8 *)(p + 1);
1879
1880 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1881 p->offset = 0;
1882
1883 UINT16_TO_STREAM (pp, HCI_READ_HOLD_MODE_ACTIVITY);
1884 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1885
1886 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1887 return (TRUE);
1888 }
1889
btsnd_hcic_write_hold_mode_act(UINT8 flags)1890 BOOLEAN btsnd_hcic_write_hold_mode_act (UINT8 flags)
1891 {
1892 BT_HDR *p;
1893 UINT8 *pp;
1894
1895 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1896 return (FALSE);
1897
1898 pp = (UINT8 *)(p + 1);
1899
1900 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1901 p->offset = 0;
1902
1903 UINT16_TO_STREAM (pp, HCI_WRITE_HOLD_MODE_ACTIVITY);
1904 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1905
1906 UINT8_TO_STREAM (pp, flags);
1907
1908 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1909 return (TRUE);
1910 }
1911
btsnd_hcic_read_tx_power(UINT16 handle,UINT8 type)1912 BOOLEAN btsnd_hcic_read_tx_power (UINT16 handle, UINT8 type)
1913 {
1914 BT_HDR *p;
1915 UINT8 *pp;
1916
1917 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_TX_POWER)) == NULL)
1918 return (FALSE);
1919
1920 pp = (UINT8 *)(p + 1);
1921
1922 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_TX_POWER;
1923 p->offset = 0;
1924
1925 UINT16_TO_STREAM (pp, HCI_READ_TRANSMIT_POWER_LEVEL);
1926 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_TX_POWER);
1927
1928 UINT16_TO_STREAM (pp, handle);
1929 UINT8_TO_STREAM (pp, type);
1930
1931 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1932 return (TRUE);
1933 }
1934
btsnd_hcic_read_sco_flow_enable(void)1935 BOOLEAN btsnd_hcic_read_sco_flow_enable (void)
1936 {
1937 BT_HDR *p;
1938 UINT8 *pp;
1939
1940 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
1941 return (FALSE);
1942
1943 pp = (UINT8 *)(p + 1);
1944
1945 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
1946 p->offset = 0;
1947
1948 UINT16_TO_STREAM (pp, HCI_READ_SCO_FLOW_CTRL_ENABLE);
1949 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
1950
1951 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1952 return (TRUE);
1953 }
1954
btsnd_hcic_write_sco_flow_enable(UINT8 flag)1955 BOOLEAN btsnd_hcic_write_sco_flow_enable (UINT8 flag)
1956 {
1957 BT_HDR *p;
1958 UINT8 *pp;
1959
1960 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1961 return (FALSE);
1962
1963 pp = (UINT8 *)(p + 1);
1964
1965 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1966 p->offset = 0;
1967
1968 UINT16_TO_STREAM (pp, HCI_WRITE_SCO_FLOW_CTRL_ENABLE);
1969 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1970
1971 UINT8_TO_STREAM (pp, flag);
1972
1973 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1974 return (TRUE);
1975 }
1976
btsnd_hcic_set_host_flow_ctrl(UINT8 value)1977 BOOLEAN btsnd_hcic_set_host_flow_ctrl (UINT8 value)
1978 {
1979 BT_HDR *p;
1980 UINT8 *pp;
1981
1982 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
1983 return (FALSE);
1984
1985 pp = (UINT8 *)(p + 1);
1986
1987 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
1988 p->offset = 0;
1989
1990 UINT16_TO_STREAM (pp, HCI_SET_HC_TO_HOST_FLOW_CTRL);
1991 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
1992
1993 UINT8_TO_STREAM (pp, value);
1994
1995 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1996 return (TRUE);
1997 }
1998
btsnd_hcic_set_host_buf_size(UINT16 acl_len,UINT8 sco_len,UINT16 acl_num,UINT16 sco_num)1999 BOOLEAN btsnd_hcic_set_host_buf_size (UINT16 acl_len, UINT8 sco_len,
2000 UINT16 acl_num, UINT16 sco_num)
2001 {
2002 BT_HDR *p;
2003 UINT8 *pp;
2004
2005 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE)) == NULL)
2006 return (FALSE);
2007
2008 pp = (UINT8 *)(p + 1);
2009
2010 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE;
2011 p->offset = 0;
2012
2013 UINT16_TO_STREAM (pp, HCI_HOST_BUFFER_SIZE);
2014 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_HOST_BUF_SIZE);
2015
2016 UINT16_TO_STREAM (pp, acl_len);
2017 UINT8_TO_STREAM (pp, sco_len);
2018 UINT16_TO_STREAM (pp, acl_num);
2019 UINT16_TO_STREAM (pp, sco_num);
2020
2021 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2022 return (TRUE);
2023 }
2024
btsnd_hcic_host_num_xmitted_pkts(UINT8 num_handles,UINT16 * handle,UINT16 * num_pkts)2025 BOOLEAN btsnd_hcic_host_num_xmitted_pkts (UINT8 num_handles, UINT16 *handle,
2026 UINT16 *num_pkts)
2027 {
2028 BT_HDR *p;
2029 UINT8 *pp;
2030 int j;
2031
2032 if ((p = HCI_GET_CMD_BUF(1 + (num_handles * 4))) == NULL)
2033 return (FALSE);
2034
2035 pp = (UINT8 *)(p + 1);
2036
2037 p->len = HCIC_PREAMBLE_SIZE + 1 + (num_handles * 4);
2038 p->offset = 0;
2039
2040 UINT16_TO_STREAM (pp, HCI_HOST_NUM_PACKETS_DONE);
2041 UINT8_TO_STREAM (pp, p->len - HCIC_PREAMBLE_SIZE);
2042
2043 UINT8_TO_STREAM (pp, num_handles);
2044
2045 for (j = 0; j < num_handles; j++)
2046 {
2047 UINT16_TO_STREAM (pp, handle[j]);
2048 UINT16_TO_STREAM (pp, num_pkts[j]);
2049 }
2050
2051 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2052 return (TRUE);
2053 }
2054
btsnd_hcic_read_link_super_tout(UINT8 local_controller_id,UINT16 handle)2055 BOOLEAN btsnd_hcic_read_link_super_tout (UINT8 local_controller_id, UINT16 handle)
2056 {
2057 BT_HDR *p;
2058 UINT8 *pp;
2059
2060 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2061 return (FALSE);
2062
2063 pp = (UINT8 *)(p + 1);
2064
2065 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2066 p->offset = 0;
2067
2068 UINT16_TO_STREAM (pp, HCI_READ_LINK_SUPER_TOUT);
2069 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2070
2071 UINT16_TO_STREAM (pp, handle);
2072
2073 btu_hcif_send_cmd (local_controller_id, p);
2074 return (TRUE);
2075 }
2076
btsnd_hcic_write_link_super_tout(UINT8 local_controller_id,UINT16 handle,UINT16 timeout)2077 BOOLEAN btsnd_hcic_write_link_super_tout (UINT8 local_controller_id, UINT16 handle, UINT16 timeout)
2078 {
2079 BT_HDR *p;
2080 UINT8 *pp;
2081
2082 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT)) == NULL)
2083 return (FALSE);
2084
2085 pp = (UINT8 *)(p + 1);
2086
2087 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT;
2088 p->offset = 0;
2089
2090 UINT16_TO_STREAM (pp, HCI_WRITE_LINK_SUPER_TOUT);
2091 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_LINK_SUPER_TOUT);
2092
2093 UINT16_TO_STREAM (pp, handle);
2094 UINT16_TO_STREAM (pp, timeout);
2095
2096 btu_hcif_send_cmd (local_controller_id, p);
2097 return (TRUE);
2098 }
2099
btsnd_hcic_read_max_iac(void)2100 BOOLEAN btsnd_hcic_read_max_iac (void)
2101 {
2102 BT_HDR *p;
2103 UINT8 *pp;
2104
2105 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2106 return (FALSE);
2107
2108 pp = (UINT8 *)(p + 1);
2109
2110 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2111 p->offset = 0;
2112
2113 UINT16_TO_STREAM (pp, HCI_READ_NUM_SUPPORTED_IAC);
2114 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2115
2116 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2117 return (TRUE);
2118 }
2119
btsnd_hcic_read_cur_iac_lap(void)2120 BOOLEAN btsnd_hcic_read_cur_iac_lap (void)
2121 {
2122 BT_HDR *p;
2123 UINT8 *pp;
2124
2125 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2126 return (FALSE);
2127
2128 pp = (UINT8 *)(p + 1);
2129
2130 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2131 p->offset = 0;
2132
2133 UINT16_TO_STREAM (pp, HCI_READ_CURRENT_IAC_LAP);
2134 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2135
2136 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2137 return (TRUE);
2138 }
2139
btsnd_hcic_write_cur_iac_lap(UINT8 num_cur_iac,LAP * const iac_lap)2140 BOOLEAN btsnd_hcic_write_cur_iac_lap (UINT8 num_cur_iac, LAP * const iac_lap)
2141 {
2142 BT_HDR *p;
2143 UINT8 *pp;
2144 int i;
2145
2146 if ((p = HCI_GET_CMD_BUF(1 + (LAP_LEN * num_cur_iac))) == NULL)
2147 return (FALSE);
2148
2149 pp = (UINT8 *)(p + 1);
2150
2151 p->len = HCIC_PREAMBLE_SIZE + 1 + (LAP_LEN * num_cur_iac);
2152 p->offset = 0;
2153
2154 UINT16_TO_STREAM (pp, HCI_WRITE_CURRENT_IAC_LAP);
2155 UINT8_TO_STREAM (pp, p->len - HCIC_PREAMBLE_SIZE);
2156
2157 UINT8_TO_STREAM (pp, num_cur_iac);
2158
2159 for (i = 0; i < num_cur_iac; i++)
2160 LAP_TO_STREAM (pp, iac_lap[i]);
2161
2162 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2163 return (TRUE);
2164 }
2165
btsnd_hcic_read_page_scan_per(void)2166 BOOLEAN btsnd_hcic_read_page_scan_per (void)
2167 {
2168 BT_HDR *p;
2169 UINT8 *pp;
2170
2171 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2172 return (FALSE);
2173
2174 pp = (UINT8 *)(p + 1);
2175
2176 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2177 p->offset = 0;
2178
2179 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_PERIOD_MODE);
2180 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2181
2182 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2183 return (TRUE);
2184 }
2185
btsnd_hcic_write_page_scan_per(UINT8 mode)2186 BOOLEAN btsnd_hcic_write_page_scan_per (UINT8 mode)
2187 {
2188 BT_HDR *p;
2189 UINT8 *pp;
2190
2191 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
2192 return (FALSE);
2193
2194 pp = (UINT8 *)(p + 1);
2195
2196 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
2197 p->offset = 0;
2198
2199 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_PERIOD_MODE);
2200 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
2201
2202 UINT8_TO_STREAM (pp, mode);
2203
2204 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2205 return (TRUE);
2206 }
2207
btsnd_hcic_read_page_scan_mode(void)2208 BOOLEAN btsnd_hcic_read_page_scan_mode (void)
2209 {
2210 BT_HDR *p;
2211 UINT8 *pp;
2212
2213 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2214 return (FALSE);
2215
2216 pp = (UINT8 *)(p + 1);
2217
2218 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2219 p->offset = 0;
2220
2221 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_MODE);
2222 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2223
2224 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2225 return (TRUE);
2226 }
2227
btsnd_hcic_write_page_scan_mode(UINT8 mode)2228 BOOLEAN btsnd_hcic_write_page_scan_mode (UINT8 mode)
2229 {
2230 BT_HDR *p;
2231 UINT8 *pp;
2232
2233 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
2234 return (FALSE);
2235
2236 pp = (UINT8 *)(p + 1);
2237
2238 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
2239 p->offset = 0;
2240
2241 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_MODE);
2242 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
2243
2244 UINT8_TO_STREAM (pp, mode);
2245
2246 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2247 return (TRUE);
2248 }
2249
2250 /******************************************
2251 ** Lisbon Features
2252 *******************************************/
2253 #if BTM_SSR_INCLUDED == TRUE
2254
btsnd_hcic_sniff_sub_rate(UINT16 handle,UINT16 max_lat,UINT16 min_remote_lat,UINT16 min_local_lat)2255 BOOLEAN btsnd_hcic_sniff_sub_rate(UINT16 handle, UINT16 max_lat,
2256 UINT16 min_remote_lat, UINT16 min_local_lat)
2257 {
2258 BT_HDR *p;
2259 UINT8 *pp;
2260
2261 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SNIFF_SUB_RATE)) == NULL)
2262 return (FALSE);
2263
2264 pp = (UINT8 *)(p + 1);
2265
2266 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SNIFF_SUB_RATE;
2267 p->offset = 0;
2268
2269 UINT16_TO_STREAM (pp, HCI_SNIFF_SUB_RATE);
2270 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SNIFF_SUB_RATE);
2271
2272 UINT16_TO_STREAM (pp, handle);
2273 UINT16_TO_STREAM (pp, max_lat);
2274 UINT16_TO_STREAM (pp, min_remote_lat);
2275 UINT16_TO_STREAM (pp, min_local_lat);
2276
2277 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2278 return (TRUE);
2279 }
2280 #endif /* BTM_SSR_INCLUDED */
2281
2282 #if (BTM_EIR_SERVER_INCLUDED == TRUE)
2283 /**** Extended Inquiry Response Commands ****/
btsnd_hcic_read_ext_inquiry_response(void)2284 BOOLEAN btsnd_hcic_read_ext_inquiry_response (void)
2285 {
2286 BT_HDR *p;
2287 UINT8 *pp;
2288
2289 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2290 return (FALSE);
2291
2292 pp = (UINT8 *)(p + 1);
2293
2294 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2295 p->offset = 0;
2296
2297 UINT16_TO_STREAM (pp, HCI_READ_EXT_INQ_RESPONSE);
2298 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2299
2300 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2301 return (TRUE);
2302 }
2303
btsnd_hcic_write_ext_inquiry_response(void * buffer,UINT8 fec_req)2304 void btsnd_hcic_write_ext_inquiry_response (void *buffer, UINT8 fec_req)
2305 {
2306 BT_HDR *p = (BT_HDR *)buffer;
2307 UINT8 *pp = (UINT8 *)(p + 1);
2308
2309 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_EXT_INQ_RESP;
2310 p->offset = 0;
2311
2312 UINT16_TO_STREAM (pp, HCI_WRITE_EXT_INQ_RESPONSE);
2313 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_EXT_INQ_RESP);
2314
2315 UINT8_TO_STREAM (pp, fec_req);
2316
2317 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2318 }
2319 #endif /* BTM_EIR_SERVER_INCLUDED == TRUE */
2320
2321 /**** Simple Pairing Commands ****/
btsnd_hcic_write_simple_pairing_mode(UINT8 mode)2322 BOOLEAN btsnd_hcic_write_simple_pairing_mode (UINT8 mode)
2323 {
2324 BT_HDR *p;
2325 UINT8 *pp;
2326
2327 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_SIMP_PAIR)) == NULL)
2328 return (FALSE);
2329
2330 pp = (UINT8 *)(p + 1);
2331
2332 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_SIMP_PAIR;
2333 p->offset = 0;
2334
2335 UINT16_TO_STREAM (pp, HCI_WRITE_SIMPLE_PAIRING_MODE);
2336 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_SIMP_PAIR);
2337
2338 UINT8_TO_STREAM (pp, mode);
2339
2340 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2341 return (TRUE);
2342 }
2343
btsnd_hcic_read_simple_pairing_mode(void)2344 BOOLEAN btsnd_hcic_read_simple_pairing_mode (void)
2345 {
2346 BT_HDR *p;
2347 UINT8 *pp;
2348
2349 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_SIMP_PAIR)) == NULL)
2350 return (FALSE);
2351
2352 pp = (UINT8 *)(p + 1);
2353
2354 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_SIMP_PAIR;
2355 p->offset = 0;
2356
2357 UINT16_TO_STREAM (pp, HCI_READ_SIMPLE_PAIRING_MODE);
2358 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_SIMP_PAIR);
2359
2360 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2361 return (TRUE);
2362 }
2363
btsnd_hcic_write_simp_pair_debug_mode(UINT8 debug_mode)2364 BOOLEAN btsnd_hcic_write_simp_pair_debug_mode(UINT8 debug_mode)
2365 {
2366 BT_HDR *p;
2367 UINT8 *pp;
2368
2369 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SIMP_PAIR_DBUG)) == NULL)
2370 return (FALSE);
2371
2372 pp = (UINT8 *)(p + 1);
2373
2374 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SIMP_PAIR_DBUG;
2375 p->offset = 0;
2376
2377 UINT16_TO_STREAM (pp, HCI_WRITE_SIMP_PAIR_DEBUG_MODE);
2378 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SIMP_PAIR_DBUG);
2379
2380 UINT8_TO_STREAM (pp, debug_mode);
2381
2382 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2383 return (TRUE);
2384 }
2385
btsnd_hcic_io_cap_req_reply(BD_ADDR bd_addr,UINT8 capability,UINT8 oob_present,UINT8 auth_req)2386 BOOLEAN btsnd_hcic_io_cap_req_reply (BD_ADDR bd_addr, UINT8 capability,
2387 UINT8 oob_present, UINT8 auth_req)
2388 {
2389 BT_HDR *p;
2390 UINT8 *pp;
2391
2392 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_IO_CAP_RESP)) == NULL)
2393 return (FALSE);
2394
2395 pp = (UINT8 *)(p + 1);
2396
2397 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_IO_CAP_RESP;
2398 p->offset = 0;
2399
2400 UINT16_TO_STREAM (pp, HCI_IO_CAPABILITY_RESPONSE);
2401 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_IO_CAP_RESP);
2402
2403 BDADDR_TO_STREAM (pp, bd_addr);
2404 UINT8_TO_STREAM (pp, capability);
2405 UINT8_TO_STREAM (pp, oob_present);
2406 UINT8_TO_STREAM (pp, auth_req);
2407
2408 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2409 return (TRUE);
2410 }
2411
btsnd_hcic_io_cap_req_neg_reply(BD_ADDR bd_addr,UINT8 err_code)2412 BOOLEAN btsnd_hcic_io_cap_req_neg_reply (BD_ADDR bd_addr, UINT8 err_code)
2413 {
2414 BT_HDR *p;
2415 UINT8 *pp;
2416
2417 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY)) == NULL)
2418 return (FALSE);
2419
2420 pp = (UINT8 *)(p + 1);
2421
2422 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY;
2423 p->offset = 0;
2424
2425 UINT16_TO_STREAM (pp, HCI_IO_CAP_REQ_NEG_REPLY);
2426 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_IO_CAP_NEG_REPLY);
2427
2428 BDADDR_TO_STREAM (pp, bd_addr);
2429 UINT8_TO_STREAM (pp, err_code);
2430
2431 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2432 return (TRUE);
2433 }
2434
btsnd_hcic_read_local_oob_data(void)2435 BOOLEAN btsnd_hcic_read_local_oob_data (void)
2436 {
2437 BT_HDR *p;
2438 UINT8 *pp;
2439
2440 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_LOCAL_OOB)) == NULL)
2441 return (FALSE);
2442
2443 pp = (UINT8 *)(p + 1);
2444
2445 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_LOCAL_OOB;
2446 p->offset = 0;
2447
2448 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_OOB_DATA);
2449 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_LOCAL_OOB);
2450
2451 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2452 return (TRUE);
2453 }
2454
btsnd_hcic_user_conf_reply(BD_ADDR bd_addr,BOOLEAN is_yes)2455 BOOLEAN btsnd_hcic_user_conf_reply (BD_ADDR bd_addr, BOOLEAN is_yes)
2456 {
2457 BT_HDR *p;
2458 UINT8 *pp;
2459
2460 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_UCONF_REPLY)) == NULL)
2461 return (FALSE);
2462
2463 pp = (UINT8 *)(p + 1);
2464
2465 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_UCONF_REPLY;
2466 p->offset = 0;
2467
2468 if (!is_yes)
2469 {
2470 /* Negative reply */
2471 UINT16_TO_STREAM (pp, HCI_USER_CONF_VALUE_NEG_REPLY);
2472 }
2473 else
2474 {
2475 /* Confirmation */
2476 UINT16_TO_STREAM (pp, HCI_USER_CONF_REQUEST_REPLY);
2477 }
2478
2479 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_UCONF_REPLY);
2480
2481 BDADDR_TO_STREAM (pp, bd_addr);
2482
2483 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2484 return (TRUE);
2485 }
2486
btsnd_hcic_user_passkey_reply(BD_ADDR bd_addr,UINT32 value)2487 BOOLEAN btsnd_hcic_user_passkey_reply (BD_ADDR bd_addr, UINT32 value)
2488 {
2489 BT_HDR *p;
2490 UINT8 *pp;
2491
2492 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_U_PKEY_REPLY)) == NULL)
2493 return (FALSE);
2494
2495 pp = (UINT8 *)(p + 1);
2496
2497 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_U_PKEY_REPLY;
2498 p->offset = 0;
2499
2500 UINT16_TO_STREAM (pp, HCI_USER_PASSKEY_REQ_REPLY);
2501 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_U_PKEY_REPLY);
2502
2503 BDADDR_TO_STREAM (pp, bd_addr);
2504 UINT32_TO_STREAM (pp, value);
2505
2506 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2507 return (TRUE);
2508 }
2509
btsnd_hcic_user_passkey_neg_reply(BD_ADDR bd_addr)2510 BOOLEAN btsnd_hcic_user_passkey_neg_reply (BD_ADDR bd_addr)
2511 {
2512 BT_HDR *p;
2513 UINT8 *pp;
2514
2515 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY)) == NULL)
2516 return (FALSE);
2517
2518 pp = (UINT8 *)(p + 1);
2519
2520 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY;
2521 p->offset = 0;
2522
2523 UINT16_TO_STREAM (pp, HCI_USER_PASSKEY_REQ_NEG_REPLY);
2524 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_U_PKEY_NEG_REPLY);
2525
2526 BDADDR_TO_STREAM (pp, bd_addr);
2527
2528 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2529 return (TRUE);
2530 }
2531
btsnd_hcic_rem_oob_reply(BD_ADDR bd_addr,UINT8 * p_c,UINT8 * p_r)2532 BOOLEAN btsnd_hcic_rem_oob_reply (BD_ADDR bd_addr, UINT8 *p_c, UINT8 *p_r)
2533 {
2534 BT_HDR *p;
2535 UINT8 *pp;
2536
2537 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REM_OOB_REPLY)) == NULL)
2538 return (FALSE);
2539
2540 pp = (UINT8 *)(p + 1);
2541
2542 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REM_OOB_REPLY;
2543 p->offset = 0;
2544
2545 UINT16_TO_STREAM (pp, HCI_REM_OOB_DATA_REQ_REPLY);
2546 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_REM_OOB_REPLY);
2547
2548 BDADDR_TO_STREAM (pp, bd_addr);
2549 ARRAY16_TO_STREAM (pp, p_c);
2550 ARRAY16_TO_STREAM (pp, p_r);
2551
2552 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2553 return (TRUE);
2554 }
2555
btsnd_hcic_rem_oob_neg_reply(BD_ADDR bd_addr)2556 BOOLEAN btsnd_hcic_rem_oob_neg_reply (BD_ADDR bd_addr)
2557 {
2558 BT_HDR *p;
2559 UINT8 *pp;
2560
2561 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY)) == NULL)
2562 return (FALSE);
2563
2564 pp = (UINT8 *)(p + 1);
2565
2566 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY;
2567 p->offset = 0;
2568
2569 UINT16_TO_STREAM (pp, HCI_REM_OOB_DATA_REQ_NEG_REPLY);
2570 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_REM_OOB_NEG_REPLY);
2571
2572 BDADDR_TO_STREAM (pp, bd_addr);
2573
2574 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2575 return (TRUE);
2576 }
2577
2578
btsnd_hcic_read_inq_tx_power(void)2579 BOOLEAN btsnd_hcic_read_inq_tx_power (void)
2580 {
2581 BT_HDR *p;
2582 UINT8 *pp;
2583
2584 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_TX_POWER)) == NULL)
2585 return (FALSE);
2586
2587 pp = (UINT8 *)(p + 1);
2588
2589 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_TX_POWER;
2590 p->offset = 0;
2591
2592 UINT16_TO_STREAM (pp, HCI_READ_INQ_TX_POWER_LEVEL);
2593 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_TX_POWER);
2594
2595 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2596 return (TRUE);
2597 }
2598
btsnd_hcic_write_inq_tx_power(INT8 level)2599 BOOLEAN btsnd_hcic_write_inq_tx_power (INT8 level)
2600 {
2601 BT_HDR *p;
2602 UINT8 *pp;
2603
2604 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_TX_POWER)) == NULL)
2605 return (FALSE);
2606
2607 pp = (UINT8 *)(p + 1);
2608
2609 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_TX_POWER;
2610 p->offset = 0;
2611
2612 UINT16_TO_STREAM (pp, HCI_WRITE_INQ_TX_POWER_LEVEL);
2613 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_TX_POWER);
2614
2615 INT8_TO_STREAM (pp, level);
2616
2617 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2618 return (TRUE);
2619 }
2620
2621 #if 0 /* currently not been used */
2622 BOOLEAN btsnd_hcic_read_default_erroneous_data_rpt (void)
2623 {
2624 BT_HDR *p;
2625 UINT8 *pp;
2626
2627 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_R_ERR_DATA_RPT)) == NULL)
2628 return (FALSE);
2629
2630 pp = (UINT8 *)(p + 1);
2631
2632 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_R_ERR_DATA_RPT;
2633 p->offset = 0;
2634
2635 UINT16_TO_STREAM (pp, HCI_READ_ERRONEOUS_DATA_RPT);
2636 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_R_ERR_DATA_RPT);
2637
2638 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2639 return (TRUE);
2640 }
2641 #endif
2642
btsnd_hcic_write_default_erroneous_data_rpt(UINT8 flag)2643 BOOLEAN btsnd_hcic_write_default_erroneous_data_rpt (UINT8 flag)
2644 {
2645 BT_HDR *p;
2646 UINT8 *pp;
2647
2648 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_W_ERR_DATA_RPT)) == NULL)
2649 return (FALSE);
2650
2651 pp = (UINT8 *)(p + 1);
2652
2653 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_W_ERR_DATA_RPT;
2654 p->offset = 0;
2655
2656 UINT16_TO_STREAM (pp, HCI_WRITE_ERRONEOUS_DATA_RPT);
2657 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_W_ERR_DATA_RPT);
2658
2659 UINT8_TO_STREAM (pp, flag);
2660
2661 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2662 return (TRUE);
2663 }
2664
btsnd_hcic_send_keypress_notif(BD_ADDR bd_addr,UINT8 notif)2665 BOOLEAN btsnd_hcic_send_keypress_notif (BD_ADDR bd_addr, UINT8 notif)
2666 {
2667 BT_HDR *p;
2668 UINT8 *pp;
2669
2670 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF)) == NULL)
2671 return (FALSE);
2672
2673 pp = (UINT8 *)(p + 1);
2674
2675 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF;
2676 p->offset = 0;
2677
2678 UINT16_TO_STREAM (pp, HCI_SEND_KEYPRESS_NOTIF);
2679 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SEND_KEYPRESS_NOTIF);
2680
2681 BDADDR_TO_STREAM (pp, bd_addr);
2682 UINT8_TO_STREAM (pp, notif);
2683
2684 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2685 return (TRUE);
2686 }
2687
2688 /**** end of Simple Pairing Commands ****/
2689
2690 #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
btsnd_hcic_enhanced_flush(UINT16 handle,UINT8 packet_type)2691 BOOLEAN btsnd_hcic_enhanced_flush (UINT16 handle, UINT8 packet_type)
2692 {
2693 BT_HDR *p;
2694 UINT8 *pp;
2695
2696 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ENHANCED_FLUSH)) == NULL)
2697 return (FALSE);
2698
2699 pp = (UINT8 *)(p + 1);
2700
2701 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ENHANCED_FLUSH;
2702 p->offset = 0;
2703 UINT16_TO_STREAM (pp, HCI_ENHANCED_FLUSH);
2704 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_ENHANCED_FLUSH);
2705
2706 UINT16_TO_STREAM (pp, handle);
2707 UINT8_TO_STREAM (pp, packet_type);
2708
2709 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2710 return (TRUE);
2711 }
2712 #endif
2713
2714
btsnd_hcic_refresh_encryption_key(UINT16 handle)2715 BOOLEAN btsnd_hcic_refresh_encryption_key (UINT16 handle)
2716 {
2717 BT_HDR *p;
2718 UINT8 *pp;
2719
2720 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2721 return (FALSE);
2722
2723 pp = (UINT8 *)(p + 1);
2724
2725 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2726 p->offset = 0;
2727 UINT16_TO_STREAM (pp, HCI_REFRESH_ENCRYPTION_KEY);
2728 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2729
2730 UINT16_TO_STREAM (pp, handle);
2731
2732 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2733 return (TRUE);
2734 }
2735 /*************************
2736 ** End of Lisbon Commands
2737 **************************/
2738
btsnd_hcic_read_local_ver(UINT8 local_controller_id)2739 BOOLEAN btsnd_hcic_read_local_ver (UINT8 local_controller_id)
2740 {
2741 BT_HDR *p;
2742 UINT8 *pp;
2743
2744 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2745 return (FALSE);
2746
2747 pp = (UINT8 *)(p + 1);
2748
2749 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2750 p->offset = 0;
2751
2752 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_VERSION_INFO);
2753 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2754
2755 btu_hcif_send_cmd (local_controller_id, p);
2756 return (TRUE);
2757 }
2758
btsnd_hcic_read_local_supported_cmds(UINT8 local_controller_id)2759 BOOLEAN btsnd_hcic_read_local_supported_cmds (UINT8 local_controller_id)
2760 {
2761 BT_HDR *p;
2762 UINT8 *pp;
2763
2764 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2765 return (FALSE);
2766
2767 pp = (UINT8 *)(p + 1);
2768
2769 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2770 p->offset = 0;
2771
2772 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_SUPPORTED_CMDS);
2773 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2774
2775 btu_hcif_send_cmd (local_controller_id, p);
2776 return (TRUE);
2777 }
2778
btsnd_hcic_read_local_features(void)2779 BOOLEAN btsnd_hcic_read_local_features (void)
2780 {
2781 BT_HDR *p;
2782 UINT8 *pp;
2783
2784 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2785 return (FALSE);
2786
2787 pp = (UINT8 *)(p + 1);
2788
2789 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2790 p->offset = 0;
2791
2792 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_FEATURES);
2793 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2794
2795 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2796 return (TRUE);
2797 }
2798
btsnd_hcic_read_local_ext_features(UINT8 page_num)2799 BOOLEAN btsnd_hcic_read_local_ext_features (UINT8 page_num)
2800 {
2801 BT_HDR *p;
2802 UINT8 *pp;
2803
2804 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES)) == NULL)
2805 return (FALSE);
2806
2807 pp = (UINT8 *)(p + 1);
2808
2809 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES;
2810 p->offset = 0;
2811
2812 UINT16_TO_STREAM (pp, HCI_READ_LOCAL_EXT_FEATURES);
2813 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LOCAL_EXT_FEATURES);
2814
2815 UINT8_TO_STREAM (pp, page_num);
2816
2817 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2818 return (TRUE);
2819 }
2820
btsnd_hcic_read_buffer_size(void)2821 BOOLEAN btsnd_hcic_read_buffer_size (void)
2822 {
2823 BT_HDR *p;
2824 UINT8 *pp;
2825
2826 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2827 return (FALSE);
2828
2829 pp = (UINT8 *)(p + 1);
2830
2831 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2832 p->offset = 0;
2833
2834 UINT16_TO_STREAM (pp, HCI_READ_BUFFER_SIZE);
2835 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2836
2837 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2838 return (TRUE);
2839 }
2840
btsnd_hcic_read_country_code(void)2841 BOOLEAN btsnd_hcic_read_country_code (void)
2842 {
2843 BT_HDR *p;
2844 UINT8 *pp;
2845
2846 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2847 return (FALSE);
2848
2849 pp = (UINT8 *)(p + 1);
2850
2851 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2852 p->offset = 0;
2853
2854 UINT16_TO_STREAM (pp, HCI_READ_COUNTRY_CODE);
2855 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2856
2857 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2858 return (TRUE);
2859 }
2860
btsnd_hcic_read_bd_addr(void)2861 BOOLEAN btsnd_hcic_read_bd_addr (void)
2862 {
2863 BT_HDR *p;
2864 UINT8 *pp;
2865
2866 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2867 return (FALSE);
2868
2869 pp = (UINT8 *)(p + 1);
2870
2871 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2872 p->offset = 0;
2873
2874 UINT16_TO_STREAM (pp, HCI_READ_BD_ADDR);
2875 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2876
2877 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2878 return (TRUE);
2879 }
2880
btsnd_hcic_read_fail_contact_count(UINT8 local_controller_id,UINT16 handle)2881 BOOLEAN btsnd_hcic_read_fail_contact_count (UINT8 local_controller_id, UINT16 handle)
2882 {
2883 BT_HDR *p;
2884 UINT8 *pp;
2885
2886 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2887 return (FALSE);
2888
2889 pp = (UINT8 *)(p + 1);
2890
2891 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2892 p->offset = 0;
2893
2894 UINT16_TO_STREAM (pp, HCI_READ_FAILED_CONTACT_COUNT);
2895 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2896
2897 UINT16_TO_STREAM (pp, handle);
2898
2899 btu_hcif_send_cmd (local_controller_id, p);
2900 return (TRUE);
2901 }
2902
btsnd_hcic_reset_fail_contact_count(UINT8 local_controller_id,UINT16 handle)2903 BOOLEAN btsnd_hcic_reset_fail_contact_count (UINT8 local_controller_id, UINT16 handle)
2904 {
2905 BT_HDR *p;
2906 UINT8 *pp;
2907
2908 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2909 return (FALSE);
2910
2911 pp = (UINT8 *)(p + 1);
2912
2913 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2914 p->offset = 0;
2915
2916 UINT16_TO_STREAM (pp, HCI_RESET_FAILED_CONTACT_COUNT);
2917 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2918
2919 UINT16_TO_STREAM (pp, handle);
2920
2921 btu_hcif_send_cmd (local_controller_id, p);
2922 return (TRUE);
2923 }
2924
btsnd_hcic_get_link_quality(UINT16 handle)2925 BOOLEAN btsnd_hcic_get_link_quality (UINT16 handle)
2926 {
2927 BT_HDR *p;
2928 UINT8 *pp;
2929
2930 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2931 return (FALSE);
2932
2933 pp = (UINT8 *)(p + 1);
2934
2935 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2936 p->offset = 0;
2937
2938 UINT16_TO_STREAM (pp, HCI_GET_LINK_QUALITY);
2939 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2940
2941 UINT16_TO_STREAM (pp, handle);
2942
2943 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2944 return (TRUE);
2945 }
2946
btsnd_hcic_read_rssi(UINT16 handle)2947 BOOLEAN btsnd_hcic_read_rssi (UINT16 handle)
2948 {
2949 BT_HDR *p;
2950 UINT8 *pp;
2951
2952 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
2953 return (FALSE);
2954
2955 pp = (UINT8 *)(p + 1);
2956
2957 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
2958 p->offset = 0;
2959
2960 UINT16_TO_STREAM (pp, HCI_READ_RSSI);
2961 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
2962
2963 UINT16_TO_STREAM (pp, handle);
2964
2965 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2966 return (TRUE);
2967 }
2968
btsnd_hcic_read_loopback_mode(void)2969 BOOLEAN btsnd_hcic_read_loopback_mode (void)
2970 {
2971 BT_HDR *p;
2972 UINT8 *pp;
2973
2974 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
2975 return (FALSE);
2976
2977 pp = (UINT8 *)(p + 1);
2978
2979 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
2980 p->offset = 0;
2981
2982 UINT16_TO_STREAM (pp, HCI_READ_LOOPBACK_MODE);
2983 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
2984
2985 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
2986 return (TRUE);
2987 }
2988
btsnd_hcic_write_loopback_mode(UINT8 mode)2989 BOOLEAN btsnd_hcic_write_loopback_mode (UINT8 mode)
2990 {
2991 BT_HDR *p;
2992 UINT8 *pp;
2993
2994 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
2995 return (FALSE);
2996
2997 pp = (UINT8 *)(p + 1);
2998
2999 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3000 p->offset = 0;
3001
3002 UINT16_TO_STREAM (pp, HCI_WRITE_LOOPBACK_MODE);
3003 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3004
3005 UINT8_TO_STREAM (pp, mode);
3006
3007 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3008 return (TRUE);
3009 }
3010
btsnd_hcic_enable_test_mode(void)3011 BOOLEAN btsnd_hcic_enable_test_mode (void)
3012 {
3013 BT_HDR *p;
3014 UINT8 *pp;
3015
3016 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3017 return (FALSE);
3018
3019 pp = (UINT8 *)(p + 1);
3020
3021 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3022 p->offset = 0;
3023
3024 UINT16_TO_STREAM (pp, HCI_ENABLE_DEV_UNDER_TEST_MODE);
3025 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3026
3027 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3028 return (TRUE);
3029 }
3030
btsnd_hcic_write_afh_channel_assessment_mode(UINT8 mode)3031 BOOLEAN btsnd_hcic_write_afh_channel_assessment_mode (UINT8 mode)
3032 {
3033 BT_HDR *p;
3034 UINT8 *pp;
3035
3036 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3037 return (FALSE);
3038
3039 pp = (UINT8 *)(p + 1);
3040
3041 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3042 p->offset = 0;
3043
3044 UINT16_TO_STREAM (pp, HCI_WRITE_AFH_ASSESSMENT_MODE);
3045 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3046
3047 UINT8_TO_STREAM (pp, mode);
3048
3049 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3050 return (TRUE);
3051 }
3052
btsnd_hcic_read_afh_channel_assessment_mode(void)3053 BOOLEAN btsnd_hcic_read_afh_channel_assessment_mode(void)
3054 {
3055 BT_HDR *p;
3056 UINT8 *pp;
3057
3058 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3059 return (FALSE);
3060
3061 pp = (UINT8 *)(p + 1);
3062
3063 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3064 p->offset = 0;
3065
3066 UINT16_TO_STREAM (pp, HCI_READ_AFH_ASSESSMENT_MODE);
3067 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3068
3069 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3070 return (TRUE);
3071 }
3072
btsnd_hcic_set_afh_channels(UINT8 first,UINT8 last)3073 BOOLEAN btsnd_hcic_set_afh_channels (UINT8 first, UINT8 last)
3074 {
3075 BT_HDR *p;
3076 UINT8 *pp;
3077 UINT8 channels[10] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F};
3078 int i;
3079
3080 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_AFH_CHANNELS)) == NULL)
3081 return (FALSE);
3082
3083 pp = (UINT8 *)(p + 1);
3084
3085 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_AFH_CHANNELS;
3086 p->offset = 0;
3087
3088 UINT16_TO_STREAM (pp, HCI_SET_AFH_CHANNELS);
3089 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_AFH_CHANNELS);
3090
3091 /* Just make sure that caller did not exceed 79 Bluetooth channels */
3092 if ((first <= last) && (last <= 78))
3093 {
3094 for (i = first; i <= last; i++)
3095 {
3096 int byte_offset = i / 8;
3097 int bit_offset = i % 8;
3098 channels[byte_offset] &= ~(1 << bit_offset);
3099 }
3100 }
3101 for (i = 0; i < 10; i++)
3102 *pp++ = channels[i];
3103
3104 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3105 return (TRUE);
3106 }
3107
btsnd_hcic_set_afh_host_channel_class(UINT8 * p_afhchannelmap)3108 BOOLEAN btsnd_hcic_set_afh_host_channel_class (UINT8 *p_afhchannelmap)
3109 {
3110 BT_HDR *p;
3111 UINT8 *pp;
3112 int i;
3113
3114 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_AFH_CHANNELS)) == NULL)
3115 return (FALSE);
3116
3117 pp = (UINT8 *)(p + 1);
3118
3119 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_AFH_CHANNELS;
3120 p->offset = 0;
3121
3122 UINT16_TO_STREAM (pp, HCI_SET_AFH_CHANNELS);
3123 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_AFH_CHANNELS);
3124
3125 /* Copy and convert */
3126 for (i = 0; i < 10; i++)
3127 *pp++ = p_afhchannelmap[9-i];
3128
3129 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3130 return (TRUE);
3131 }
3132
btsnd_hcic_read_afh_channel_map(UINT16 handle)3133 BOOLEAN btsnd_hcic_read_afh_channel_map (UINT16 handle)
3134 {
3135 BT_HDR *p;
3136 UINT8 *pp;
3137
3138 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CMD_HANDLE)) == NULL)
3139 return (FALSE);
3140
3141 pp = (UINT8 *)(p + 1);
3142
3143 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CMD_HANDLE;
3144 p->offset = 0;
3145
3146 UINT16_TO_STREAM (pp, HCI_READ_AFH_CH_MAP);
3147 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CMD_HANDLE);
3148
3149 UINT16_TO_STREAM (pp, handle);
3150
3151 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3152 return (TRUE);
3153 }
3154
btsnd_hcic_read_clock(UINT16 handle,UINT8 which_clock)3155 BOOLEAN btsnd_hcic_read_clock (UINT16 handle, UINT8 which_clock)
3156 {
3157 BT_HDR *p;
3158 UINT8 *pp;
3159
3160 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CLOCK)) == NULL)
3161 return (FALSE);
3162
3163 pp = (UINT8 *)(p + 1);
3164
3165 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CLOCK;
3166 p->offset = 0;
3167
3168 UINT16_TO_STREAM (pp, HCI_READ_CLOCK);
3169 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CLOCK);
3170
3171 UINT16_TO_STREAM (pp, handle);
3172 UINT8_TO_STREAM (pp, which_clock);
3173
3174 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3175 return (TRUE);
3176 }
3177
btsnd_hcic_read_inqscan_type(void)3178 BOOLEAN btsnd_hcic_read_inqscan_type(void)
3179 {
3180 BT_HDR *p;
3181 UINT8 *pp;
3182
3183 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3184 return (FALSE);
3185
3186 pp = (UINT8 *)(p + 1);
3187
3188 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3189 p->offset = 0;
3190
3191 UINT16_TO_STREAM (pp, HCI_READ_INQSCAN_TYPE);
3192 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3193
3194 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3195 return (TRUE);
3196 }
3197
btsnd_hcic_write_inqscan_type(UINT8 type)3198 BOOLEAN btsnd_hcic_write_inqscan_type (UINT8 type)
3199 {
3200 BT_HDR *p;
3201 UINT8 *pp;
3202
3203 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3204 return (FALSE);
3205
3206 pp = (UINT8 *)(p + 1);
3207
3208 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3209 p->offset = 0;
3210
3211 UINT16_TO_STREAM (pp, HCI_WRITE_INQSCAN_TYPE);
3212 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3213
3214 UINT8_TO_STREAM (pp, type);
3215
3216 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3217 return (TRUE);
3218 }
3219
btsnd_hcic_read_inquiry_mode(void)3220 BOOLEAN btsnd_hcic_read_inquiry_mode (void)
3221 {
3222 BT_HDR *p;
3223 UINT8 *pp;
3224
3225 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3226 return (FALSE);
3227
3228 pp = (UINT8 *)(p + 1);
3229
3230 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3231 p->offset = 0;
3232
3233 UINT16_TO_STREAM (pp, HCI_READ_INQUIRY_MODE);
3234 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3235
3236 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3237 return (TRUE);
3238 }
3239
btsnd_hcic_write_inquiry_mode(UINT8 mode)3240 BOOLEAN btsnd_hcic_write_inquiry_mode (UINT8 mode)
3241 {
3242 BT_HDR *p;
3243 UINT8 *pp;
3244
3245 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3246 return (FALSE);
3247
3248 pp = (UINT8 *)(p + 1);
3249
3250 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3251 p->offset = 0;
3252
3253 UINT16_TO_STREAM (pp, HCI_WRITE_INQUIRY_MODE);
3254 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3255
3256 UINT8_TO_STREAM (pp, mode);
3257
3258 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3259 return (TRUE);
3260 }
3261
btsnd_hcic_read_pagescan_type(void)3262 BOOLEAN btsnd_hcic_read_pagescan_type (void)
3263 {
3264 BT_HDR *p;
3265 UINT8 *pp;
3266
3267 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3268 return (FALSE);
3269
3270 pp = (UINT8 *)(p + 1);
3271
3272 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3273 p->offset = 0;
3274
3275 UINT16_TO_STREAM (pp, HCI_READ_PAGESCAN_TYPE);
3276 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3277
3278 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3279 return (TRUE);
3280 }
3281
btsnd_hcic_write_pagescan_type(UINT8 type)3282 BOOLEAN btsnd_hcic_write_pagescan_type (UINT8 type)
3283 {
3284 BT_HDR *p;
3285 UINT8 *pp;
3286
3287 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
3288 return (FALSE);
3289
3290 pp = (UINT8 *)(p + 1);
3291
3292 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
3293 p->offset = 0;
3294
3295 UINT16_TO_STREAM (pp, HCI_WRITE_PAGESCAN_TYPE);
3296 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
3297
3298 UINT8_TO_STREAM (pp, type);
3299
3300 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3301 return (TRUE);
3302 }
3303
3304 /* Must have room to store BT_HDR + max VSC length + callback pointer */
3305 #if !defined (LMP_TEST) && (HCI_CMD_POOL_BUF_SIZE < 268)
3306 #error "HCI_CMD_POOL_BUF_SIZE must be larger than 268"
3307 #endif
3308
btsnd_hcic_vendor_spec_cmd(void * buffer,UINT16 opcode,UINT8 len,UINT8 * p_data,void * p_cmd_cplt_cback)3309 void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, UINT8 len,
3310 UINT8 *p_data, void *p_cmd_cplt_cback)
3311 {
3312 BT_HDR *p = (BT_HDR *)buffer;
3313 UINT8 *pp = (UINT8 *)(p + 1);
3314
3315 p->len = HCIC_PREAMBLE_SIZE + len;
3316 p->offset = sizeof(void *);
3317
3318 *((void **)pp) = p_cmd_cplt_cback; /* Store command complete callback in buffer */
3319 pp += sizeof(void *); /* Skip over callback pointer */
3320
3321 UINT16_TO_STREAM (pp, HCI_GRP_VENDOR_SPECIFIC | opcode);
3322 UINT8_TO_STREAM (pp, len);
3323 ARRAY_TO_STREAM (pp, p_data, len);
3324
3325 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3326 }
3327
btsnd_hcic_data(BT_HDR * p_buf,UINT16 len,UINT16 handle,UINT8 boundary,UINT8 broadcast)3328 void btsnd_hcic_data (BT_HDR *p_buf, UINT16 len, UINT16 handle, UINT8 boundary, UINT8 broadcast)
3329 {
3330 UINT8 *p;
3331
3332 /* Higher layer should have left 4 bytes for us to fill the header */
3333 p_buf->offset -= 4;
3334 p_buf->len += 4;
3335
3336 /* Find the pointer to the beginning of the data */
3337 p = (UINT8 *)(p_buf + 1) + p_buf->offset;
3338
3339 UINT16_TO_STREAM (p, handle | ((boundary & 3) << 12) | ((broadcast & 3) << 14));
3340 UINT16_TO_STREAM (p, len);
3341
3342 HCI_ACL_DATA_TO_LOWER (p_buf);
3343 }
3344
btsnd_hcic_nop(void)3345 BOOLEAN btsnd_hcic_nop (void)
3346 {
3347 BT_HDR *p;
3348 UINT8 *pp;
3349
3350 if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
3351 return (FALSE);
3352
3353 pp = (UINT8 *)(p + 1);
3354
3355 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
3356 p->offset = 0;
3357
3358 UINT16_TO_STREAM (pp, HCI_COMMAND_NONE);
3359 UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD);
3360
3361 btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
3362 return (TRUE);
3363 }
3364
3365