• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This file contains function of the HCIC unit to format and send HCI
22  *  commands.
23  *
24  ******************************************************************************/
25 
26 #include "bt_target.h"
27 #include "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 BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
37 
btsnd_hcic_ble_set_local_used_feat(UINT8 feat_set[8])38 BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8])
39 {
40     BT_HDR *p;
41     UINT8 *pp;
42 
43     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_USED_FEAT_CMD)) == NULL)
44         return (FALSE);
45 
46     pp = (UINT8 *)(p + 1);
47 
48     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_USED_FEAT_CMD;
49     p->offset = 0;
50 
51     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_LOCAL_SPT_FEAT);
52     ARRAY_TO_STREAM (pp, feat_set, HCIC_PARAM_SIZE_SET_USED_FEAT_CMD);
53 
54     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
55     return (TRUE);
56 }
57 
btsnd_hcic_ble_set_random_addr(BD_ADDR random_bda)58 BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_bda)
59 {
60     BT_HDR *p;
61     UINT8 *pp;
62 
63     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD)) == NULL)
64         return (FALSE);
65 
66     pp = (UINT8 *)(p + 1);
67 
68     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD;
69     p->offset = 0;
70 
71     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_RANDOM_ADDR);
72     UINT8_TO_STREAM  (pp,  HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD);
73 
74     BDADDR_TO_STREAM (pp, random_bda);
75 
76     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
77     return (TRUE);
78 }
79 
btsnd_hcic_ble_write_adv_params(UINT16 adv_int_min,UINT16 adv_int_max,UINT8 adv_type,UINT8 addr_type_own,UINT8 addr_type_dir,BD_ADDR direct_bda,UINT8 channel_map,UINT8 adv_filter_policy)80 BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
81                                        UINT8 adv_type, UINT8 addr_type_own,
82                                        UINT8 addr_type_dir, BD_ADDR direct_bda,
83                                        UINT8 channel_map, UINT8 adv_filter_policy)
84 {
85     BT_HDR *p;
86     UINT8 *pp;
87 
88     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS)) == NULL)
89         return (FALSE);
90 
91     pp = (UINT8 *)(p + 1);
92 
93     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS ;
94     p->offset = 0;
95 
96     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_PARAMS);
97     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS );
98 
99     UINT16_TO_STREAM (pp, adv_int_min);
100     UINT16_TO_STREAM (pp, adv_int_max);
101     UINT8_TO_STREAM (pp, adv_type);
102     UINT8_TO_STREAM (pp, addr_type_own);
103     UINT8_TO_STREAM (pp, addr_type_dir);
104     BDADDR_TO_STREAM (pp, direct_bda);
105     UINT8_TO_STREAM (pp, channel_map);
106     UINT8_TO_STREAM (pp, adv_filter_policy);
107 
108     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
109     return (TRUE);
110 }
btsnd_hcic_ble_read_adv_chnl_tx_power(void)111 BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void)
112 {
113     BT_HDR *p;
114     UINT8 *pp;
115 
116     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
117         return (FALSE);
118 
119     pp = (UINT8 *)(p + 1);
120 
121     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
122     p->offset = 0;
123 
124     UINT16_TO_STREAM (pp, HCI_BLE_READ_ADV_CHNL_TX_POWER);
125     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CMD);
126 
127     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
128     return (TRUE);
129 
130 }
131 
btsnd_hcic_ble_set_adv_data(UINT8 data_len,UINT8 * p_data)132 BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data)
133 {
134     BT_HDR *p;
135     UINT8 *pp;
136 
137     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1)) == NULL)
138         return (FALSE);
139 
140     pp = (UINT8 *)(p + 1);
141 
142     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1;
143     p->offset = 0;
144 
145     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_DATA);
146     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1);
147 
148     memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA);
149 
150     if (p_data != NULL && data_len > 0)
151     {
152         if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA)
153             data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA;
154 
155         UINT8_TO_STREAM (pp, data_len);
156 
157         ARRAY_TO_STREAM (pp, p_data, data_len);
158     }
159     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
160 
161     return (TRUE);
162 }
btsnd_hcic_ble_set_scan_rsp_data(UINT8 data_len,UINT8 * p_scan_rsp)163 BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp)
164 {
165     BT_HDR *p;
166     UINT8 *pp;
167 
168     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1)) == NULL)
169         return (FALSE);
170 
171     pp = (UINT8 *)(p + 1);
172 
173     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1;
174     p->offset = 0;
175 
176     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_RSP_DATA);
177     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1);
178 
179     memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP);
180 
181     if (p_scan_rsp != NULL && data_len > 0)
182     {
183 
184         if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP )
185             data_len = HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP;
186 
187         UINT8_TO_STREAM (pp, data_len);
188 
189         ARRAY_TO_STREAM (pp, p_scan_rsp, data_len);
190     }
191 
192     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
193 
194     return (TRUE);
195 }
196 
btsnd_hcic_ble_set_adv_enable(UINT8 adv_enable)197 BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable)
198 {
199     BT_HDR *p;
200     UINT8 *pp;
201 
202     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_ADV_ENABLE)) == NULL)
203         return (FALSE);
204 
205     pp = (UINT8 *)(p + 1);
206 
207     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_ADV_ENABLE;
208     p->offset = 0;
209 
210     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_ENABLE);
211     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_ADV_ENABLE);
212 
213     UINT8_TO_STREAM (pp, adv_enable);
214 
215     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
216     return (TRUE);
217 }
btsnd_hcic_ble_set_scan_params(UINT8 scan_type,UINT16 scan_int,UINT16 scan_win,UINT8 addr_type_own,UINT8 scan_filter_policy)218 BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
219                                           UINT16 scan_int, UINT16 scan_win,
220                                           UINT8 addr_type_own, UINT8 scan_filter_policy)
221 {
222     BT_HDR *p;
223     UINT8 *pp;
224 
225     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM)) == NULL)
226         return (FALSE);
227 
228     pp = (UINT8 *)(p + 1);
229 
230     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM;
231     p->offset = 0;
232 
233     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_PARAMS);
234     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM);
235 
236     UINT8_TO_STREAM (pp, scan_type);
237     UINT16_TO_STREAM (pp, scan_int);
238     UINT16_TO_STREAM (pp, scan_win);
239     UINT8_TO_STREAM (pp, addr_type_own);
240     UINT8_TO_STREAM (pp, scan_filter_policy);
241 
242     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
243     return (TRUE);
244 }
245 
btsnd_hcic_ble_set_scan_enable(UINT8 scan_enable,UINT8 duplicate)246 BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate)
247 {
248     BT_HDR *p;
249     UINT8 *pp;
250 
251     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE)) == NULL)
252         return (FALSE);
253 
254     pp = (UINT8 *)(p + 1);
255 
256     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE;
257     p->offset = 0;
258 
259     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_ENABLE);
260     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE);
261 
262     UINT8_TO_STREAM (pp, scan_enable);
263     UINT8_TO_STREAM (pp, duplicate);
264 
265     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
266     return (TRUE);
267 }
268 
269 /* link layer connection management commands */
btsnd_hcic_ble_create_ll_conn(UINT16 scan_int,UINT16 scan_win,UINT8 init_filter_policy,UINT8 addr_type_peer,BD_ADDR bda_peer,UINT8 addr_type_own,UINT16 conn_int_min,UINT16 conn_int_max,UINT16 conn_latency,UINT16 conn_timeout,UINT16 min_ce_len,UINT16 max_ce_len)270 BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win,
271                                        UINT8 init_filter_policy,
272                                        UINT8 addr_type_peer, BD_ADDR bda_peer,
273                                        UINT8 addr_type_own,
274                                        UINT16 conn_int_min, UINT16 conn_int_max,
275                                        UINT16 conn_latency, UINT16 conn_timeout,
276                                        UINT16 min_ce_len, UINT16 max_ce_len)
277 {
278     BT_HDR *p;
279     UINT8 *pp;
280 
281     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN)) == NULL)
282         return (FALSE);
283 
284     pp = (UINT8 *)(p + 1);
285 
286     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN;
287     p->offset = 0;
288 
289     UINT16_TO_STREAM (pp, HCI_BLE_CREATE_LL_CONN);
290     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN);
291 
292     UINT16_TO_STREAM (pp, scan_int);
293     UINT16_TO_STREAM (pp, scan_win);
294     UINT8_TO_STREAM (pp, init_filter_policy);
295 
296     UINT8_TO_STREAM (pp, addr_type_peer);
297     BDADDR_TO_STREAM (pp, bda_peer);
298     UINT8_TO_STREAM (pp, addr_type_own);
299 
300     UINT16_TO_STREAM (pp, conn_int_min);
301     UINT16_TO_STREAM (pp, conn_int_max);
302     UINT16_TO_STREAM (pp, conn_latency);
303     UINT16_TO_STREAM (pp, conn_timeout);
304 
305     UINT16_TO_STREAM (pp, min_ce_len);
306     UINT16_TO_STREAM (pp, max_ce_len);
307 
308     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
309     return (TRUE);
310 }
311 
btsnd_hcic_ble_create_conn_cancel(void)312 BOOLEAN btsnd_hcic_ble_create_conn_cancel (void)
313 {
314     BT_HDR *p;
315     UINT8 *pp;
316 
317     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL)) == NULL)
318         return (FALSE);
319 
320     pp = (UINT8 *)(p + 1);
321 
322     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL;
323     p->offset = 0;
324 
325     UINT16_TO_STREAM (pp, HCI_BLE_CREATE_CONN_CANCEL);
326     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL);
327 
328     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
329     return (TRUE);
330 }
331 
btsnd_hcic_ble_clear_white_list(void)332 BOOLEAN btsnd_hcic_ble_clear_white_list (void)
333 {
334     BT_HDR *p;
335     UINT8 *pp;
336 
337     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CLEAR_WHITE_LIST)) == NULL)
338         return (FALSE);
339 
340     pp = (UINT8 *)(p + 1);
341 
342     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CLEAR_WHITE_LIST;
343     p->offset = 0;
344 
345     UINT16_TO_STREAM (pp, HCI_BLE_CLEAR_WHITE_LIST);
346     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CLEAR_WHITE_LIST);
347 
348     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
349     return (TRUE);
350 }
351 
btsnd_hcic_ble_add_white_list(UINT8 addr_type,BD_ADDR bda)352 BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda)
353 {
354     BT_HDR *p;
355     UINT8 *pp;
356 
357     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ADD_WHITE_LIST)) == NULL)
358         return (FALSE);
359 
360     pp = (UINT8 *)(p + 1);
361 
362     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ADD_WHITE_LIST;
363     p->offset = 0;
364 
365     UINT16_TO_STREAM (pp, HCI_BLE_ADD_WHITE_LIST);
366     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_ADD_WHITE_LIST);
367 
368     UINT8_TO_STREAM (pp, addr_type);
369     BDADDR_TO_STREAM (pp, bda);
370 
371     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
372     return (TRUE);
373 }
374 
btsnd_hcic_ble_remove_from_white_list(UINT8 addr_type,BD_ADDR bda)375 BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda)
376 {
377     BT_HDR *p;
378     UINT8 *pp;
379 
380     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REMOVE_WHITE_LIST)) == NULL)
381         return (FALSE);
382 
383     pp = (UINT8 *)(p + 1);
384 
385     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REMOVE_WHITE_LIST;
386     p->offset = 0;
387 
388     UINT16_TO_STREAM (pp, HCI_BLE_REMOVE_WHITE_LIST);
389     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_REMOVE_WHITE_LIST);
390 
391     UINT8_TO_STREAM (pp, addr_type);
392     BDADDR_TO_STREAM (pp, bda);
393 
394     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
395     return (TRUE);
396 }
397 
btsnd_hcic_ble_upd_ll_conn_params(UINT16 handle,UINT16 conn_int_min,UINT16 conn_int_max,UINT16 conn_latency,UINT16 conn_timeout,UINT16 min_ce_len,UINT16 max_ce_len)398 BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle,
399                                            UINT16 conn_int_min, UINT16 conn_int_max,
400                                            UINT16 conn_latency, UINT16 conn_timeout,
401                                            UINT16 min_ce_len, UINT16 max_ce_len)
402 {
403     BT_HDR *p;
404     UINT8 *pp;
405 
406     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS)) == NULL)
407         return (FALSE);
408 
409     pp = (UINT8 *)(p + 1);
410 
411     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS;
412     p->offset = 0;
413 
414     UINT16_TO_STREAM (pp, HCI_BLE_UPD_LL_CONN_PARAMS);
415     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS);
416 
417     UINT16_TO_STREAM (pp, handle);
418 
419     UINT16_TO_STREAM (pp, conn_int_min);
420     UINT16_TO_STREAM (pp, conn_int_max);
421     UINT16_TO_STREAM (pp, conn_latency);
422     UINT16_TO_STREAM (pp, conn_timeout);
423     UINT16_TO_STREAM (pp, min_ce_len);
424     UINT16_TO_STREAM (pp, max_ce_len);
425 
426     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
427     return (TRUE);
428 }
429 
btsnd_hcic_ble_set_host_chnl_class(UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE])430 BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8  chnl_map[HCIC_BLE_CHNL_MAP_SIZE])
431 {
432     BT_HDR *p;
433     UINT8 *pp;
434 
435     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS)) == NULL)
436         return (FALSE);
437 
438     pp = (UINT8 *)(p + 1);
439 
440     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS;
441     p->offset = 0;
442 
443     UINT16_TO_STREAM (pp, HCI_BLE_SET_HOST_CHNL_CLASS);
444     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS);
445 
446     ARRAY_TO_STREAM (pp, chnl_map, HCIC_BLE_CHNL_MAP_SIZE);
447 
448     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
449     return (TRUE);
450 }
451 
btsnd_hcic_ble_read_chnl_map(UINT16 handle)452 BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle)
453 {
454     BT_HDR *p;
455     UINT8 *pp;
456 
457     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CHNL_MAP)) == NULL)
458         return (FALSE);
459 
460     pp = (UINT8 *)(p + 1);
461 
462     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CHNL_MAP;
463     p->offset = 0;
464 
465     UINT16_TO_STREAM (pp, HCI_BLE_READ_CHNL_MAP);
466     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CHNL_MAP);
467 
468     UINT16_TO_STREAM (pp, handle);
469 
470     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
471     return (TRUE);
472 }
473 
btsnd_hcic_ble_read_remote_feat(UINT16 handle)474 BOOLEAN btsnd_hcic_ble_read_remote_feat (UINT16 handle)
475 {
476     BT_HDR *p;
477     UINT8 *pp;
478 
479     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT)) == NULL)
480         return (FALSE);
481 
482     pp = (UINT8 *)(p + 1);
483 
484     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT;
485     p->offset = 0;
486 
487     UINT16_TO_STREAM (pp, HCI_BLE_READ_REMOTE_FEAT);
488     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT);
489 
490     UINT16_TO_STREAM (pp, handle);
491 
492     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
493     return (TRUE);
494 }
495 
496 /* security management commands */
btsnd_hcic_ble_encrypt(UINT8 * key,UINT8 key_len,UINT8 * plain_text,UINT8 pt_len,void * p_cmd_cplt_cback)497 BOOLEAN btsnd_hcic_ble_encrypt (UINT8 *key, UINT8 key_len,
498                                 UINT8 *plain_text, UINT8 pt_len,
499                                 void *p_cmd_cplt_cback)
500 {
501     BT_HDR *p;
502     UINT8 *pp;
503 
504     if ((p = HCI_GET_CMD_BUF(sizeof(BT_HDR) + sizeof (void *) +
505                             HCIC_PARAM_SIZE_BLE_ENCRYPT)) == NULL)
506         return (FALSE);
507 
508     pp = (UINT8 *)(p + 1);
509 
510     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ENCRYPT;
511     p->offset = sizeof(void *);
512 
513     *((void **)pp) = p_cmd_cplt_cback;  /* Store command complete callback in buffer */
514     pp += sizeof(void *);               /* Skip over callback pointer */
515 
516 
517     UINT16_TO_STREAM (pp, HCI_BLE_ENCRYPT);
518     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_ENCRYPT);
519 
520     memset(pp, 0, HCIC_PARAM_SIZE_BLE_ENCRYPT);
521 
522     if (key_len > HCIC_BLE_ENCRYT_KEY_SIZE) key_len = HCIC_BLE_ENCRYT_KEY_SIZE;
523     if (pt_len > HCIC_BLE_ENCRYT_KEY_SIZE) pt_len = HCIC_BLE_ENCRYT_KEY_SIZE;
524 
525     ARRAY_TO_STREAM (pp, key, key_len);
526     pp += (HCIC_BLE_ENCRYT_KEY_SIZE - key_len);
527     ARRAY_TO_STREAM (pp, plain_text, pt_len);
528 
529     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
530     return (TRUE);
531 }
532 
btsnd_hcic_ble_rand(void * p_cmd_cplt_cback)533 BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback)
534 {
535     BT_HDR *p;
536     UINT8 *pp;
537 
538     if ((p = HCI_GET_CMD_BUF(sizeof(BT_HDR) + sizeof (void *) +
539                         HCIC_PARAM_SIZE_BLE_RAND)) == NULL)
540         return (FALSE);
541 
542     pp = (UINT8 *)(p + 1);
543 
544     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RAND;
545     p->offset = sizeof(void *);
546 
547     *((void **)pp) = p_cmd_cplt_cback;  /* Store command complete callback in buffer */
548     pp += sizeof(void *);               /* Skip over callback pointer */
549 
550     UINT16_TO_STREAM (pp, HCI_BLE_RAND);
551     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_RAND);
552 
553     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
554     return (TRUE);
555 }
556 
btsnd_hcic_ble_start_enc(UINT16 handle,UINT8 rand[HCIC_BLE_RAND_DI_SIZE],UINT16 ediv,UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])557 BOOLEAN btsnd_hcic_ble_start_enc (UINT16 handle, UINT8 rand[HCIC_BLE_RAND_DI_SIZE],
558                                 UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])
559 {
560     BT_HDR *p;
561     UINT8 *pp;
562 
563     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_START_ENC)) == NULL)
564         return (FALSE);
565 
566     pp = (UINT8 *)(p + 1);
567 
568     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_START_ENC;
569     p->offset = 0;
570 
571     UINT16_TO_STREAM (pp, HCI_BLE_START_ENC);
572     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_START_ENC);
573 
574     UINT16_TO_STREAM (pp, handle);
575     ARRAY_TO_STREAM (pp, rand, HCIC_BLE_RAND_DI_SIZE);
576     UINT16_TO_STREAM (pp, ediv);
577     ARRAY_TO_STREAM (pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE);
578 
579     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
580     return (TRUE);
581 }
582 
btsnd_hcic_ble_ltk_req_reply(UINT16 handle,UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])583 BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])
584 {
585     BT_HDR *p;
586     UINT8 *pp;
587 
588     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LTK_REQ_REPLY)) == NULL)
589         return (FALSE);
590 
591     pp = (UINT8 *)(p + 1);
592 
593     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_REPLY;
594     p->offset = 0;
595 
596     UINT16_TO_STREAM (pp, HCI_BLE_LTK_REQ_REPLY);
597     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_LTK_REQ_REPLY);
598 
599     UINT16_TO_STREAM (pp, handle);
600     ARRAY_TO_STREAM (pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE);
601 
602     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
603     return (TRUE);
604 }
605 
btsnd_hcic_ble_ltk_req_neg_reply(UINT16 handle)606 BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle)
607 {
608     BT_HDR *p;
609     UINT8 *pp;
610 
611     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY)) == NULL)
612         return (FALSE);
613 
614     pp = (UINT8 *)(p + 1);
615 
616     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY;
617     p->offset = 0;
618 
619     UINT16_TO_STREAM (pp, HCI_BLE_LTK_REQ_NEG_REPLY);
620     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY);
621 
622     UINT16_TO_STREAM (pp, handle);
623 
624     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
625     return (TRUE);
626 }
627 
btsnd_hcic_ble_receiver_test(UINT8 rx_freq)628 BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq)
629 {
630     BT_HDR *p;
631     UINT8 *pp;
632 
633     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL)
634         return (FALSE);
635 
636     pp = (UINT8 *)(p + 1);
637 
638     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
639     p->offset = 0;
640 
641     UINT16_TO_STREAM (pp, HCI_BLE_RECEIVER_TEST);
642     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
643 
644     UINT8_TO_STREAM (pp, rx_freq);
645 
646     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
647     return (TRUE);
648 }
649 
btsnd_hcic_ble_transmitter_test(UINT8 tx_freq,UINT8 test_data_len,UINT8 payload)650 BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len, UINT8 payload)
651 {
652     BT_HDR *p;
653     UINT8 *pp;
654 
655     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM3)) == NULL)
656         return (FALSE);
657 
658     pp = (UINT8 *)(p + 1);
659 
660     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3;
661     p->offset = 0;
662 
663     UINT16_TO_STREAM (pp, HCI_BLE_TRANSMITTER_TEST);
664     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM3);
665 
666     UINT8_TO_STREAM (pp, tx_freq);
667     UINT8_TO_STREAM (pp, test_data_len);
668     UINT8_TO_STREAM (pp, payload);
669 
670     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
671     return (TRUE);
672 }
673 
btsnd_hcic_ble_test_end(void)674 BOOLEAN btsnd_hcic_ble_test_end(void)
675 {
676     BT_HDR *p;
677     UINT8 *pp;
678 
679     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
680         return (FALSE);
681 
682     pp = (UINT8 *)(p + 1);
683 
684     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
685     p->offset = 0;
686 
687     UINT16_TO_STREAM (pp, HCI_BLE_TEST_END);
688     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CMD);
689 
690     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
691     return (TRUE);
692 }
693 
btsnd_hcic_ble_read_host_supported(void)694 BOOLEAN btsnd_hcic_ble_read_host_supported (void)
695 {
696     BT_HDR *p;
697     UINT8 *pp;
698 
699     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL)
700         return (FALSE);
701 
702     pp = (UINT8 *)(p + 1);
703 
704     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
705     p->offset = 0;
706 
707     UINT16_TO_STREAM (pp, HCI_READ_LE_HOST_SUPPORT);
708     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CMD);
709 
710     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
711     return (TRUE);
712 }
713 
714 #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
715 
btsnd_hcic_ble_rc_param_req_reply(UINT16 handle,UINT16 conn_int_min,UINT16 conn_int_max,UINT16 conn_latency,UINT16 conn_timeout,UINT16 min_ce_len,UINT16 max_ce_len)716 BOOLEAN btsnd_hcic_ble_rc_param_req_reply(  UINT16 handle,
717                                             UINT16 conn_int_min, UINT16 conn_int_max,
718                                             UINT16 conn_latency, UINT16 conn_timeout,
719                                             UINT16 min_ce_len, UINT16 max_ce_len  )
720 {
721     BT_HDR *p;
722     UINT8 *pp;
723 
724     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY)) == NULL)
725         return (FALSE);
726 
727     pp = (UINT8 *)(p + 1);
728 
729     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY;
730     p->offset = 0;
731 
732     UINT16_TO_STREAM (pp, HCI_BLE_RC_PARAM_REQ_REPLY);
733     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY);
734 
735     UINT16_TO_STREAM (pp, handle);
736     UINT16_TO_STREAM (pp, conn_int_min);
737     UINT16_TO_STREAM (pp, conn_int_max);
738     UINT16_TO_STREAM (pp, conn_latency);
739     UINT16_TO_STREAM (pp, conn_timeout);
740     UINT16_TO_STREAM (pp, min_ce_len);
741     UINT16_TO_STREAM (pp, max_ce_len);
742 
743     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
744     return (TRUE);
745 }
746 
btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle,UINT8 reason)747 BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason)
748 {
749     BT_HDR *p;
750     UINT8 *pp;
751 
752     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY)) == NULL)
753         return (FALSE);
754 
755     pp = (UINT8 *)(p + 1);
756 
757     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY;
758     p->offset = 0;
759 
760     UINT16_TO_STREAM (pp, HCI_BLE_RC_PARAM_REQ_NEG_REPLY);
761     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY);
762 
763     UINT16_TO_STREAM (pp, handle);
764     UINT8_TO_STREAM (pp, reason);
765 
766     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
767     return (TRUE);
768 }
769 #endif
770 
btsnd_hcic_ble_add_device_resolving_list(UINT8 addr_type_peer,BD_ADDR bda_peer,UINT8 irk_peer[HCIC_BLE_IRK_SIZE],UINT8 irk_local[HCIC_BLE_IRK_SIZE])771 BOOLEAN btsnd_hcic_ble_add_device_resolving_list (UINT8 addr_type_peer, BD_ADDR bda_peer,
772     UINT8 irk_peer[HCIC_BLE_IRK_SIZE],
773     UINT8 irk_local[HCIC_BLE_IRK_SIZE])
774 {
775     BT_HDR *p;
776     UINT8 *pp;
777 
778     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST)) == NULL)
779         return (FALSE);
780 
781     pp = (UINT8 *)(p + 1);
782 
783     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST;
784     p->offset = 0;
785 
786     UINT16_TO_STREAM (pp, HCI_BLE_ADD_DEV_RESOLVING_LIST);
787     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST);
788     UINT8_TO_STREAM (pp, addr_type_peer);
789     BDADDR_TO_STREAM (pp, bda_peer);
790     ARRAY_TO_STREAM (pp, irk_peer, HCIC_BLE_ENCRYT_KEY_SIZE);
791     ARRAY_TO_STREAM (pp, irk_local, HCIC_BLE_ENCRYT_KEY_SIZE);
792 
793     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
794 
795     return (TRUE);
796 }
797 
btsnd_hcic_ble_rm_device_resolving_list(UINT8 addr_type_peer,BD_ADDR bda_peer)798 BOOLEAN btsnd_hcic_ble_rm_device_resolving_list (UINT8 addr_type_peer, BD_ADDR bda_peer)
799 {
800     BT_HDR *p;
801     UINT8 *pp;
802 
803     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST)) == NULL)
804         return (FALSE);
805 
806     pp = (UINT8 *)(p + 1);
807 
808     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST;
809     p->offset = 0;
810 
811     UINT16_TO_STREAM (pp, HCI_BLE_RM_DEV_RESOLVING_LIST);
812     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST);
813     UINT8_TO_STREAM (pp, addr_type_peer);
814     BDADDR_TO_STREAM (pp, bda_peer);
815 
816     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
817 
818     return (TRUE);
819 }
820 
btsnd_hcic_ble_clear_resolving_list(void)821 BOOLEAN btsnd_hcic_ble_clear_resolving_list (void)
822 {
823     BT_HDR *p;
824     UINT8 *pp;
825 
826     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST)) == NULL)
827         return (FALSE);
828 
829     pp = (UINT8 *)(p + 1);
830 
831     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST;
832     p->offset = 0;
833 
834     UINT16_TO_STREAM (pp, HCI_BLE_CLEAR_RESOLVING_LIST);
835     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST);
836 
837     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
838 
839     return (TRUE);
840 }
841 
btsnd_hcic_ble_read_resolvable_addr_peer(UINT8 addr_type_peer,BD_ADDR bda_peer)842 BOOLEAN btsnd_hcic_ble_read_resolvable_addr_peer (UINT8 addr_type_peer, BD_ADDR bda_peer)
843 {
844     BT_HDR *p;
845     UINT8 *pp;
846 
847     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER)) == NULL)
848         return (FALSE);
849 
850     pp = (UINT8 *)(p + 1);
851 
852     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER;
853     p->offset = 0;
854 
855     UINT16_TO_STREAM (pp, HCI_BLE_READ_RESOLVABLE_ADDR_PEER);
856     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER);
857     UINT8_TO_STREAM (pp, addr_type_peer);
858     BDADDR_TO_STREAM (pp, bda_peer);
859 
860     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
861 
862     return (TRUE);
863 }
864 
btsnd_hcic_ble_read_resolvable_addr_local(UINT8 addr_type_peer,BD_ADDR bda_peer)865 BOOLEAN btsnd_hcic_ble_read_resolvable_addr_local (UINT8 addr_type_peer, BD_ADDR bda_peer)
866 {
867     BT_HDR *p;
868     UINT8 *pp;
869 
870     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL)) == NULL)
871         return (FALSE);
872 
873     pp = (UINT8 *)(p + 1);
874 
875     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL;
876     p->offset = 0;
877 
878     UINT16_TO_STREAM (pp, HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL);
879     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL);
880     UINT8_TO_STREAM (pp, addr_type_peer);
881     BDADDR_TO_STREAM (pp, bda_peer);
882 
883     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
884 
885     return (TRUE);
886 }
887 
btsnd_hcic_ble_set_addr_resolution_enable(UINT8 addr_resolution_enable)888 BOOLEAN btsnd_hcic_ble_set_addr_resolution_enable (UINT8 addr_resolution_enable)
889 {
890     BT_HDR *p;
891     UINT8 *pp;
892 
893     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE)) == NULL)
894         return (FALSE);
895 
896     pp = (UINT8 *)(p + 1);
897 
898     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE;
899     p->offset = 0;
900 
901     UINT16_TO_STREAM (pp, HCI_BLE_SET_ADDR_RESOLUTION_ENABLE);
902     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE);
903     UINT8_TO_STREAM (pp, addr_resolution_enable);
904 
905     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
906 
907     return (TRUE);
908 }
909 
btsnd_hcic_ble_set_rand_priv_addr_timeout(UINT16 rpa_timout)910 BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout)
911 {
912     BT_HDR *p;
913     UINT8 *pp;
914 
915     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT)) == NULL)
916         return (FALSE);
917 
918     pp = (UINT8 *)(p + 1);
919 
920     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT;
921     p->offset = 0;
922 
923     UINT16_TO_STREAM (pp, HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT);
924     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT);
925     UINT16_TO_STREAM (pp, rpa_timout);
926 
927     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
928 
929     return (TRUE);
930 }
931 
btsnd_hcic_ble_set_data_length(UINT16 conn_handle,UINT16 tx_octets,UINT16 tx_time)932 BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets, UINT16 tx_time)
933 {
934     BT_HDR *p;
935     UINT8 *pp;
936 
937     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH)) == NULL)
938         return FALSE;
939 
940     pp = p->data;
941 
942     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH;
943     p->offset = 0;
944 
945     UINT16_TO_STREAM(pp, HCI_BLE_SET_DATA_LENGTH);
946     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH);
947 
948     UINT16_TO_STREAM(pp, conn_handle);
949     UINT16_TO_STREAM(pp, tx_octets);
950     UINT16_TO_STREAM(pp, tx_time);
951 
952     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
953     return TRUE;
954 }
955 
956 #endif
957 
958