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