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 #define HCI_GET_CMD_BUF(paramlen)       ((BT_HDR *)osi_malloc(HCIC_PREAMBLE_SIZE + sizeof(BT_HDR) + paramlen))
37 #if (BLE_50_FEATURE_SUPPORT == TRUE)
38 static BlE_SYNC ble_sync_info;
39 
btsnd_hcic_ble_sync_sem_init(void)40 void btsnd_hcic_ble_sync_sem_init(void)
41 {
42     ble_sync_info.opcode = 0;
43     osi_sem_new(&ble_sync_info.sync_sem, 1, 0);
44 }
45 
btsnd_hcic_ble_sync_sem_deinit(void)46 void btsnd_hcic_ble_sync_sem_deinit(void)
47 {
48     ble_sync_info.opcode = 0;
49     osi_sem_free(&ble_sync_info.sync_sem);
50 }
51 
btsnd_hcic_ble_get_sync_info(void)52 BlE_SYNC *btsnd_hcic_ble_get_sync_info(void)
53 {
54     return &ble_sync_info;
55 }
56 
btsnd_hcic_ble_get_status(void)57 uint8_t btsnd_hcic_ble_get_status(void)
58 {
59     return ble_sync_info.status;
60 }
61 
btsnd_hci_ble_set_status(UINT8 hci_status)62 void btsnd_hci_ble_set_status(UINT8 hci_status)
63 {
64     ble_sync_info.status = hci_status;
65     return;
66 }
67 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
68 
69 #if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
70 
btsnd_hcic_ble_set_local_used_feat(UINT8 feat_set[8])71 BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8])
72 {
73     BT_HDR *p;
74     UINT8 *pp;
75 
76     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_USED_FEAT_CMD)) == NULL) {
77         return (FALSE);
78     }
79 
80     pp = (UINT8 *)(p + 1);
81 
82     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_USED_FEAT_CMD;
83     p->offset = 0;
84 
85     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_LOCAL_SPT_FEAT);
86     ARRAY_TO_STREAM (pp, feat_set, HCIC_PARAM_SIZE_SET_USED_FEAT_CMD);
87 
88     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
89     return (TRUE);
90 }
91 
btsnd_hcic_ble_set_random_addr(BD_ADDR random_bda)92 BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_bda)
93 {
94     BT_HDR *p;
95     UINT8 *pp;
96 
97     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD)) == NULL) {
98         return (FALSE);
99     }
100 
101     pp = (UINT8 *)(p + 1);
102 
103     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD;
104     p->offset = 0;
105 
106     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_RANDOM_ADDR);
107     UINT8_TO_STREAM  (pp,  HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD);
108 
109     BDADDR_TO_STREAM (pp, random_bda);
110 
111     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
112     return (TRUE);
113 }
114 
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)115 BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
116         UINT8 adv_type, UINT8 addr_type_own,
117         UINT8 addr_type_dir, BD_ADDR direct_bda,
118         UINT8 channel_map, UINT8 adv_filter_policy)
119 {
120     BT_HDR *p;
121     UINT8 *pp;
122     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS)) == NULL) {
123         return (FALSE);
124     }
125 
126     pp = (UINT8 *)(p + 1);
127 
128     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS ;
129     p->offset = 0;
130 
131     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_PARAMS);
132     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS );
133 
134     UINT16_TO_STREAM (pp, adv_int_min);
135     UINT16_TO_STREAM (pp, adv_int_max);
136     UINT8_TO_STREAM (pp, adv_type);
137     UINT8_TO_STREAM (pp, addr_type_own);
138     UINT8_TO_STREAM (pp, addr_type_dir);
139     BDADDR_TO_STREAM (pp, direct_bda);
140     UINT8_TO_STREAM (pp, channel_map);
141     UINT8_TO_STREAM (pp, adv_filter_policy);
142 
143     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
144     return (TRUE);
145 }
btsnd_hcic_ble_read_adv_chnl_tx_power(void)146 BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void)
147 {
148     BT_HDR *p;
149     UINT8 *pp;
150 
151     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) {
152         return (FALSE);
153     }
154 
155     pp = (UINT8 *)(p + 1);
156 
157     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
158     p->offset = 0;
159 
160     UINT16_TO_STREAM (pp, HCI_BLE_READ_ADV_CHNL_TX_POWER);
161     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CMD);
162 
163     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
164     return (TRUE);
165 
166 }
167 
btsnd_hcic_ble_set_adv_data(UINT8 data_len,UINT8 * p_data)168 BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data)
169 {
170     BT_HDR *p;
171     UINT8 *pp;
172 
173     for (int i = 0; i < data_len; i++) {
174         HCI_TRACE_DEBUG("p_data[%d] = %x\n", i, p_data[i]);
175     }
176 
177     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1)) == NULL) {
178         return (FALSE);
179     }
180 
181     pp = (UINT8 *)(p + 1);
182 
183     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1;
184     p->offset = 0;
185 
186     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_DATA);
187     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1);
188 
189     memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA);
190 
191     if (p_data != NULL && data_len > 0) {
192         if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA) {
193             data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA;
194             HCI_TRACE_WARNING("Data length exceeds 31 bytes, only the first 31 bytes are used.\n");
195         }
196 
197         UINT8_TO_STREAM (pp, data_len);
198 
199         ARRAY_TO_STREAM (pp, p_data, data_len);
200     }
201     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
202 
203     return (TRUE);
204 }
btsnd_hcic_ble_set_scan_rsp_data(UINT8 data_len,UINT8 * p_scan_rsp)205 BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp)
206 {
207     BT_HDR *p;
208     UINT8 *pp;
209 
210     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1)) == NULL) {
211         return (FALSE);
212     }
213 
214     pp = (UINT8 *)(p + 1);
215 
216     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1;
217     p->offset = 0;
218 
219     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_RSP_DATA);
220     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1);
221 
222     memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP);
223 
224     if (p_scan_rsp != NULL && data_len > 0) {
225 
226         if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP ) {
227             data_len = HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP;
228             HCI_TRACE_WARNING("Data length exceeds 31 bytes, only the first 31 bytes are used.\n");
229         }
230 
231         UINT8_TO_STREAM (pp, data_len);
232 
233         ARRAY_TO_STREAM (pp, p_scan_rsp, data_len);
234     }
235 
236     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
237 
238     return (TRUE);
239 }
240 
btsnd_hcic_ble_set_adv_enable(UINT8 adv_enable)241 BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable)
242 {
243     BT_HDR *p;
244     UINT8 *pp;
245 
246     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_ADV_ENABLE)) == NULL) {
247         return (FALSE);
248     }
249 
250     pp = (UINT8 *)(p + 1);
251 
252     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_ADV_ENABLE;
253     p->offset = 0;
254 
255     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_ENABLE);
256     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_ADV_ENABLE);
257 
258     UINT8_TO_STREAM (pp, adv_enable);
259 
260     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
261     return (TRUE);
262 }
btsnd_hcic_ble_set_scan_params(UINT8 scan_type,UINT16 scan_int,UINT16 scan_win,UINT8 addr_type_own,UINT8 scan_filter_policy)263 BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
264                                         UINT16 scan_int, UINT16 scan_win,
265                                         UINT8 addr_type_own, UINT8 scan_filter_policy)
266 {
267     BT_HDR *p;
268     UINT8 *pp;
269 
270     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM)) == NULL) {
271         return (FALSE);
272     }
273 
274     pp = (UINT8 *)(p + 1);
275 
276     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM;
277     p->offset = 0;
278 
279     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_PARAMS);
280     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM);
281 
282     UINT8_TO_STREAM (pp, scan_type);
283     UINT16_TO_STREAM (pp, scan_int);
284     UINT16_TO_STREAM (pp, scan_win);
285     UINT8_TO_STREAM (pp, addr_type_own);
286     UINT8_TO_STREAM (pp, scan_filter_policy);
287 
288     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
289     return (TRUE);
290 }
291 
btsnd_hcic_ble_set_scan_enable(UINT8 scan_enable,UINT8 duplicate)292 BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate)
293 {
294     BT_HDR *p;
295     UINT8 *pp;
296 
297     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE)) == NULL) {
298         return (FALSE);
299     }
300 
301     pp = (UINT8 *)(p + 1);
302 
303     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE;
304     p->offset = 0;
305 
306     UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_ENABLE);
307     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE);
308 
309     UINT8_TO_STREAM (pp, scan_enable);
310     UINT8_TO_STREAM (pp, duplicate);
311 
312     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
313     return (TRUE);
314 }
315 
316 /* 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)317 BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win,
318                                        UINT8 init_filter_policy,
319                                        UINT8 addr_type_peer, BD_ADDR bda_peer,
320                                        UINT8 addr_type_own,
321                                        UINT16 conn_int_min, UINT16 conn_int_max,
322                                        UINT16 conn_latency, UINT16 conn_timeout,
323                                        UINT16 min_ce_len, UINT16 max_ce_len)
324 {
325     BT_HDR *p;
326     UINT8 *pp;
327 
328     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN)) == NULL) {
329         return (FALSE);
330     }
331 
332     pp = (UINT8 *)(p + 1);
333 
334     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN;
335     p->offset = 0;
336 
337     UINT16_TO_STREAM (pp, HCI_BLE_CREATE_LL_CONN);
338     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN);
339 
340     UINT16_TO_STREAM (pp, scan_int);
341     UINT16_TO_STREAM (pp, scan_win);
342     UINT8_TO_STREAM (pp, init_filter_policy);
343 
344     UINT8_TO_STREAM (pp, addr_type_peer);
345     BDADDR_TO_STREAM (pp, bda_peer);
346     UINT8_TO_STREAM (pp, addr_type_own);
347 
348     UINT16_TO_STREAM (pp, conn_int_min);
349     UINT16_TO_STREAM (pp, conn_int_max);
350     UINT16_TO_STREAM (pp, conn_latency);
351     UINT16_TO_STREAM (pp, conn_timeout);
352 
353     UINT16_TO_STREAM (pp, min_ce_len);
354     UINT16_TO_STREAM (pp, max_ce_len);
355 
356     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
357     return (TRUE);
358 }
359 
btsnd_hcic_ble_create_conn_cancel(void)360 BOOLEAN btsnd_hcic_ble_create_conn_cancel (void)
361 {
362     BT_HDR *p;
363     UINT8 *pp;
364 
365     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL)) == NULL) {
366         return (FALSE);
367     }
368 
369     pp = (UINT8 *)(p + 1);
370 
371     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL;
372     p->offset = 0;
373 
374     UINT16_TO_STREAM (pp, HCI_BLE_CREATE_CONN_CANCEL);
375     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL);
376 
377     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
378     return (TRUE);
379 }
380 
btsnd_hcic_ble_clear_white_list(void)381 BOOLEAN btsnd_hcic_ble_clear_white_list (void)
382 {
383     BT_HDR *p;
384     UINT8 *pp;
385 
386     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_CLEAR_WHITE_LIST)) == NULL) {
387         return (FALSE);
388     }
389 
390     pp = (UINT8 *)(p + 1);
391 
392     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CLEAR_WHITE_LIST;
393     p->offset = 0;
394 
395     UINT16_TO_STREAM (pp, HCI_BLE_CLEAR_WHITE_LIST);
396     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_CLEAR_WHITE_LIST);
397 
398     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
399     return (TRUE);
400 }
401 
btsnd_hcic_ble_add_white_list(UINT8 addr_type,BD_ADDR bda)402 BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda)
403 {
404     BT_HDR *p;
405     UINT8 *pp;
406 
407     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_ADD_WHITE_LIST)) == NULL) {
408         return (FALSE);
409     }
410 
411     pp = (UINT8 *)(p + 1);
412 
413     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ADD_WHITE_LIST;
414     p->offset = 0;
415 
416     UINT16_TO_STREAM (pp, HCI_BLE_ADD_WHITE_LIST);
417     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_ADD_WHITE_LIST);
418 
419     UINT8_TO_STREAM (pp, addr_type);
420     BDADDR_TO_STREAM (pp, bda);
421 
422     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
423     return (TRUE);
424 }
425 
btsnd_hcic_ble_remove_from_white_list(UINT8 addr_type,BD_ADDR bda)426 BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda)
427 {
428     BT_HDR *p;
429     UINT8 *pp;
430 
431     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_REMOVE_WHITE_LIST)) == NULL) {
432         return (FALSE);
433     }
434 
435     pp = (UINT8 *)(p + 1);
436 
437     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REMOVE_WHITE_LIST;
438     p->offset = 0;
439 
440     UINT16_TO_STREAM (pp, HCI_BLE_REMOVE_WHITE_LIST);
441     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_REMOVE_WHITE_LIST);
442 
443     UINT8_TO_STREAM (pp, addr_type);
444     BDADDR_TO_STREAM (pp, bda);
445 
446     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
447     return (TRUE);
448 }
449 
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)450 BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle,
451         UINT16 conn_int_min, UINT16 conn_int_max,
452         UINT16 conn_latency, UINT16 conn_timeout,
453         UINT16 min_ce_len, UINT16 max_ce_len)
454 {
455     BT_HDR *p;
456     UINT8 *pp;
457 
458     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS)) == NULL) {
459         return (FALSE);
460     }
461 
462     pp = (UINT8 *)(p + 1);
463 
464     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS;
465     p->offset = 0;
466 
467     UINT16_TO_STREAM (pp, HCI_BLE_UPD_LL_CONN_PARAMS);
468     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS);
469 
470     UINT16_TO_STREAM (pp, handle);
471 
472     UINT16_TO_STREAM (pp, conn_int_min);
473     UINT16_TO_STREAM (pp, conn_int_max);
474     UINT16_TO_STREAM (pp, conn_latency);
475     UINT16_TO_STREAM (pp, conn_timeout);
476     UINT16_TO_STREAM (pp, min_ce_len);
477     UINT16_TO_STREAM (pp, max_ce_len);
478 
479     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
480     return (TRUE);
481 }
482 
btsnd_hcic_ble_set_host_chnl_class(UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE])483 BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8  chnl_map[HCIC_BLE_CHNL_MAP_SIZE])
484 {
485     BT_HDR *p;
486     UINT8 *pp;
487 
488     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS)) == NULL) {
489         return (FALSE);
490     }
491 
492     pp = (UINT8 *)(p + 1);
493 
494     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS;
495     p->offset = 0;
496 
497     UINT16_TO_STREAM (pp, HCI_BLE_SET_HOST_CHNL_CLASS);
498     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS);
499 
500     ARRAY_TO_STREAM (pp, chnl_map, HCIC_BLE_CHNL_MAP_SIZE);
501 
502     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
503     return (TRUE);
504 }
505 
btsnd_hcic_ble_read_chnl_map(UINT16 handle)506 BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle)
507 {
508     BT_HDR *p;
509     UINT8 *pp;
510 
511     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CHNL_MAP)) == NULL) {
512         return (FALSE);
513     }
514 
515     pp = (UINT8 *)(p + 1);
516 
517     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CHNL_MAP;
518     p->offset = 0;
519 
520     UINT16_TO_STREAM (pp, HCI_BLE_READ_CHNL_MAP);
521     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CHNL_MAP);
522 
523     UINT16_TO_STREAM (pp, handle);
524 
525     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
526     return (TRUE);
527 }
528 
btsnd_hcic_ble_read_remote_feat(UINT16 handle)529 BOOLEAN btsnd_hcic_ble_read_remote_feat (UINT16 handle)
530 {
531     BT_HDR *p;
532     UINT8 *pp;
533 
534     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT)) == NULL) {
535         return (FALSE);
536     }
537 
538     pp = (UINT8 *)(p + 1);
539 
540     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT;
541     p->offset = 0;
542 
543     UINT16_TO_STREAM (pp, HCI_BLE_READ_REMOTE_FEAT);
544     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT);
545 
546     UINT16_TO_STREAM (pp, handle);
547 
548     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
549     return (TRUE);
550 }
551 
552 /* security management commands */
btsnd_hcic_ble_encrypt(UINT8 * key,UINT8 key_len,UINT8 * plain_text,UINT8 pt_len,void * p_cmd_cplt_cback)553 BOOLEAN btsnd_hcic_ble_encrypt (UINT8 *key, UINT8 key_len,
554                                 UINT8 *plain_text, UINT8 pt_len,
555                                 void *p_cmd_cplt_cback)
556 {
557     BT_HDR *p;
558     UINT8 *pp;
559 
560     if ((p = HCI_GET_CMD_BUF(sizeof (void *) +
561                              HCIC_PARAM_SIZE_BLE_ENCRYPT)) == NULL) {
562         return (FALSE);
563     }
564 
565     pp = (UINT8 *)(p + 1);
566 
567     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ENCRYPT;
568     p->offset = sizeof(void *);
569 
570     *((void **)pp) = p_cmd_cplt_cback;  /* Store command complete callback in buffer */
571     pp += sizeof(void *);               /* Skip over callback pointer */
572 
573 
574     UINT16_TO_STREAM (pp, HCI_BLE_ENCRYPT);
575     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_ENCRYPT);
576 
577     memset(pp, 0, HCIC_PARAM_SIZE_BLE_ENCRYPT);
578 
579     if (key_len > HCIC_BLE_ENCRYT_KEY_SIZE) {
580         key_len = HCIC_BLE_ENCRYT_KEY_SIZE;
581     }
582     if (pt_len > HCIC_BLE_ENCRYT_KEY_SIZE) {
583         pt_len = HCIC_BLE_ENCRYT_KEY_SIZE;
584     }
585 
586     ARRAY_TO_STREAM (pp, key, key_len);
587     pp += (HCIC_BLE_ENCRYT_KEY_SIZE - key_len);
588     ARRAY_TO_STREAM (pp, plain_text, pt_len);
589 
590     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
591     return (TRUE);
592 }
593 
btsnd_hcic_ble_rand(void * p_cmd_cplt_cback)594 BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback)
595 {
596     BT_HDR *p;
597     UINT8 *pp;
598 
599     if ((p = HCI_GET_CMD_BUF(sizeof (void *) +
600                              HCIC_PARAM_SIZE_BLE_RAND)) == NULL) {
601         return (FALSE);
602     }
603 
604     pp = (UINT8 *)(p + 1);
605 
606     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RAND;
607     p->offset = sizeof(void *);
608 
609     *((void **)pp) = p_cmd_cplt_cback;  /* Store command complete callback in buffer */
610     pp += sizeof(void *);               /* Skip over callback pointer */
611 
612     UINT16_TO_STREAM (pp, HCI_BLE_RAND);
613     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_RAND);
614 
615     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
616     return (TRUE);
617 }
618 
btsnd_hcic_ble_start_enc(UINT16 handle,UINT8 rand[HCIC_BLE_RAND_DI_SIZE],UINT16 ediv,UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])619 BOOLEAN btsnd_hcic_ble_start_enc (UINT16 handle, UINT8 rand[HCIC_BLE_RAND_DI_SIZE],
620                                   UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])
621 {
622     BT_HDR *p;
623     UINT8 *pp;
624 
625     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_START_ENC)) == NULL) {
626         return (FALSE);
627     }
628 
629     pp = (UINT8 *)(p + 1);
630 
631     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_START_ENC;
632     p->offset = 0;
633 
634     UINT16_TO_STREAM (pp, HCI_BLE_START_ENC);
635     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_START_ENC);
636 
637     UINT16_TO_STREAM (pp, handle);
638     ARRAY_TO_STREAM (pp, rand, HCIC_BLE_RAND_DI_SIZE);
639     UINT16_TO_STREAM (pp, ediv);
640     ARRAY_TO_STREAM (pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE);
641 
642     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
643     return (TRUE);
644 }
645 
btsnd_hcic_ble_ltk_req_reply(UINT16 handle,UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])646 BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE])
647 {
648     BT_HDR *p;
649     UINT8 *pp;
650 
651     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LTK_REQ_REPLY)) == NULL) {
652         return (FALSE);
653     }
654 
655     pp = (UINT8 *)(p + 1);
656 
657     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_REPLY;
658     p->offset = 0;
659 
660     UINT16_TO_STREAM (pp, HCI_BLE_LTK_REQ_REPLY);
661     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_LTK_REQ_REPLY);
662 
663     UINT16_TO_STREAM (pp, handle);
664     ARRAY_TO_STREAM (pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE);
665 
666     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
667     return (TRUE);
668 }
669 
btsnd_hcic_ble_ltk_req_neg_reply(UINT16 handle)670 BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle)
671 {
672     BT_HDR *p;
673     UINT8 *pp;
674 
675     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY)) == NULL) {
676         return (FALSE);
677     }
678 
679     pp = (UINT8 *)(p + 1);
680 
681     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY;
682     p->offset = 0;
683 
684     UINT16_TO_STREAM (pp, HCI_BLE_LTK_REQ_NEG_REPLY);
685     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY);
686 
687     UINT16_TO_STREAM (pp, handle);
688 
689     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
690     return (TRUE);
691 }
692 
btsnd_hcic_ble_receiver_test(UINT8 rx_freq)693 BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq)
694 {
695     BT_HDR *p;
696     UINT8 *pp;
697 
698     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM1)) == NULL) {
699         return (FALSE);
700     }
701 
702     pp = (UINT8 *)(p + 1);
703 
704     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
705     p->offset = 0;
706 
707     UINT16_TO_STREAM (pp, HCI_BLE_RECEIVER_TEST);
708     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
709 
710     UINT8_TO_STREAM (pp, rx_freq);
711 
712     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
713     return (TRUE);
714 }
715 
btsnd_hcic_ble_transmitter_test(UINT8 tx_freq,UINT8 test_data_len,UINT8 payload)716 BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len, UINT8 payload)
717 {
718     BT_HDR *p;
719     UINT8 *pp;
720 
721     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_PARAM3)) == NULL) {
722         return (FALSE);
723     }
724 
725     pp = (UINT8 *)(p + 1);
726 
727     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3;
728     p->offset = 0;
729 
730     UINT16_TO_STREAM (pp, HCI_BLE_TRANSMITTER_TEST);
731     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_WRITE_PARAM3);
732 
733     UINT8_TO_STREAM (pp, tx_freq);
734     UINT8_TO_STREAM (pp, test_data_len);
735     UINT8_TO_STREAM (pp, payload);
736 
737     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
738     return (TRUE);
739 }
740 
btsnd_hcic_ble_test_end(void)741 BOOLEAN btsnd_hcic_ble_test_end(void)
742 {
743     BT_HDR *p;
744     UINT8 *pp;
745 
746     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) {
747         return (FALSE);
748     }
749 
750     pp = (UINT8 *)(p + 1);
751 
752     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
753     p->offset = 0;
754 
755     UINT16_TO_STREAM (pp, HCI_BLE_TEST_END);
756     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CMD);
757 
758     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
759     return (TRUE);
760 }
761 
btsnd_hcic_ble_read_host_supported(void)762 BOOLEAN btsnd_hcic_ble_read_host_supported (void)
763 {
764     BT_HDR *p;
765     UINT8 *pp;
766 
767     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_READ_CMD)) == NULL) {
768         return (FALSE);
769     }
770 
771     pp = (UINT8 *)(p + 1);
772 
773     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
774     p->offset = 0;
775 
776     UINT16_TO_STREAM (pp, HCI_READ_LE_HOST_SUPPORT);
777     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_READ_CMD);
778 
779     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
780     return (TRUE);
781 }
782 
783 #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
784 
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)785 BOOLEAN btsnd_hcic_ble_rc_param_req_reply(  UINT16 handle,
786         UINT16 conn_int_min, UINT16 conn_int_max,
787         UINT16 conn_latency, UINT16 conn_timeout,
788         UINT16 min_ce_len, UINT16 max_ce_len  )
789 {
790     BT_HDR *p;
791     UINT8 *pp;
792 
793     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY)) == NULL) {
794         return (FALSE);
795     }
796 
797     pp = (UINT8 *)(p + 1);
798 
799     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY;
800     p->offset = 0;
801 
802     UINT16_TO_STREAM (pp, HCI_BLE_RC_PARAM_REQ_REPLY);
803     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY);
804 
805     UINT16_TO_STREAM (pp, handle);
806     UINT16_TO_STREAM (pp, conn_int_min);
807     UINT16_TO_STREAM (pp, conn_int_max);
808     UINT16_TO_STREAM (pp, conn_latency);
809     UINT16_TO_STREAM (pp, conn_timeout);
810     UINT16_TO_STREAM (pp, min_ce_len);
811     UINT16_TO_STREAM (pp, max_ce_len);
812 
813     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
814     return (TRUE);
815 }
816 
btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle,UINT8 reason)817 BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason)
818 {
819     BT_HDR *p;
820     UINT8 *pp;
821 
822     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY)) == NULL) {
823         return (FALSE);
824     }
825 
826     pp = (UINT8 *)(p + 1);
827 
828     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY;
829     p->offset = 0;
830 
831     UINT16_TO_STREAM (pp, HCI_BLE_RC_PARAM_REQ_NEG_REPLY);
832     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY);
833 
834     UINT16_TO_STREAM (pp, handle);
835     UINT8_TO_STREAM (pp, reason);
836 
837     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
838     return (TRUE);
839 }
840 #endif
841 
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])842 BOOLEAN btsnd_hcic_ble_add_device_resolving_list (UINT8 addr_type_peer, BD_ADDR bda_peer,
843         UINT8 irk_peer[HCIC_BLE_IRK_SIZE],
844         UINT8 irk_local[HCIC_BLE_IRK_SIZE])
845 {
846     BT_HDR *p;
847     UINT8 *pp;
848 
849     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST)) == NULL) {
850         return (FALSE);
851     }
852 
853     pp = (UINT8 *)(p + 1);
854 
855     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST;
856     p->offset = 0;
857 
858     UINT16_TO_STREAM (pp, HCI_BLE_ADD_DEV_RESOLVING_LIST);
859     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST);
860     UINT8_TO_STREAM (pp, addr_type_peer);
861     BDADDR_TO_STREAM (pp, bda_peer);
862     ARRAY_TO_STREAM (pp, irk_peer, HCIC_BLE_ENCRYT_KEY_SIZE);
863     ARRAY_TO_STREAM (pp, irk_local, HCIC_BLE_ENCRYT_KEY_SIZE);
864 
865     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
866 
867     return (TRUE);
868 }
869 
btsnd_hcic_ble_rm_device_resolving_list(UINT8 addr_type_peer,BD_ADDR bda_peer)870 BOOLEAN btsnd_hcic_ble_rm_device_resolving_list (UINT8 addr_type_peer, BD_ADDR bda_peer)
871 {
872     BT_HDR *p;
873     UINT8 *pp;
874 
875     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST)) == NULL) {
876         return (FALSE);
877     }
878 
879     pp = (UINT8 *)(p + 1);
880 
881     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST;
882     p->offset = 0;
883 
884     UINT16_TO_STREAM (pp, HCI_BLE_RM_DEV_RESOLVING_LIST);
885     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST);
886     UINT8_TO_STREAM (pp, addr_type_peer);
887     BDADDR_TO_STREAM (pp, bda_peer);
888 
889     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
890 
891     return (TRUE);
892 }
893 
btsnd_hcic_ble_clear_resolving_list(void)894 BOOLEAN btsnd_hcic_ble_clear_resolving_list (void)
895 {
896     BT_HDR *p;
897     UINT8 *pp;
898 
899     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST)) == NULL) {
900         return (FALSE);
901     }
902 
903     pp = (UINT8 *)(p + 1);
904 
905     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST;
906     p->offset = 0;
907 
908     UINT16_TO_STREAM (pp, HCI_BLE_CLEAR_RESOLVING_LIST);
909     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST);
910 
911     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
912 
913     return (TRUE);
914 }
915 
btsnd_hcic_ble_read_resolvable_addr_peer(UINT8 addr_type_peer,BD_ADDR bda_peer)916 BOOLEAN btsnd_hcic_ble_read_resolvable_addr_peer (UINT8 addr_type_peer, BD_ADDR bda_peer)
917 {
918     BT_HDR *p;
919     UINT8 *pp;
920 
921     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER)) == NULL) {
922         return (FALSE);
923     }
924 
925     pp = (UINT8 *)(p + 1);
926 
927     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER;
928     p->offset = 0;
929 
930     UINT16_TO_STREAM (pp, HCI_BLE_READ_RESOLVABLE_ADDR_PEER);
931     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER);
932     UINT8_TO_STREAM (pp, addr_type_peer);
933     BDADDR_TO_STREAM (pp, bda_peer);
934 
935     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
936 
937     return (TRUE);
938 }
939 
btsnd_hcic_ble_read_resolvable_addr_local(UINT8 addr_type_peer,BD_ADDR bda_peer)940 BOOLEAN btsnd_hcic_ble_read_resolvable_addr_local (UINT8 addr_type_peer, BD_ADDR bda_peer)
941 {
942     BT_HDR *p;
943     UINT8 *pp;
944 
945     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL)) == NULL) {
946         return (FALSE);
947     }
948 
949     pp = (UINT8 *)(p + 1);
950 
951     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL;
952     p->offset = 0;
953 
954     UINT16_TO_STREAM (pp, HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL);
955     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL);
956     UINT8_TO_STREAM (pp, addr_type_peer);
957     BDADDR_TO_STREAM (pp, bda_peer);
958 
959     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
960 
961     return (TRUE);
962 }
963 
btsnd_hcic_ble_set_addr_resolution_enable(UINT8 addr_resolution_enable)964 BOOLEAN btsnd_hcic_ble_set_addr_resolution_enable (UINT8 addr_resolution_enable)
965 {
966     BT_HDR *p;
967     UINT8 *pp;
968 
969     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE)) == NULL) {
970         return (FALSE);
971     }
972 
973     pp = (UINT8 *)(p + 1);
974 
975     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE;
976     p->offset = 0;
977 
978     UINT16_TO_STREAM (pp, HCI_BLE_SET_ADDR_RESOLUTION_ENABLE);
979     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE);
980     UINT8_TO_STREAM (pp, addr_resolution_enable);
981 
982     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
983 
984     return (TRUE);
985 }
986 
btsnd_hcic_ble_set_rand_priv_addr_timeout(UINT16 rpa_timout)987 BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout)
988 {
989     BT_HDR *p;
990     UINT8 *pp;
991 
992     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT)) == NULL) {
993         return (FALSE);
994     }
995 
996     pp = (UINT8 *)(p + 1);
997 
998     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT;
999     p->offset = 0;
1000 
1001     UINT16_TO_STREAM (pp, HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT);
1002     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT);
1003     UINT16_TO_STREAM (pp, rpa_timout);
1004 
1005     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1006 
1007     return (TRUE);
1008 }
1009 
btsnd_hcic_ble_set_data_length(UINT16 conn_handle,UINT16 tx_octets,UINT16 tx_time)1010 BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets, UINT16 tx_time)
1011 {
1012     BT_HDR *p;
1013     UINT8 *pp;
1014 
1015     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH)) == NULL) {
1016         return FALSE;
1017     }
1018 
1019     pp = p->data;
1020 
1021     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH;
1022     p->offset = 0;
1023 
1024     UINT16_TO_STREAM(pp, HCI_BLE_SET_DATA_LENGTH);
1025     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH);
1026 
1027     UINT16_TO_STREAM(pp, conn_handle);
1028     UINT16_TO_STREAM(pp, tx_octets);
1029     UINT16_TO_STREAM(pp, tx_time);
1030 
1031     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1032     return TRUE;
1033 }
1034 
btsnd_hcic_ble_update_adv_report_flow_control(UINT16 num)1035 BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num)
1036 {
1037     BT_HDR *p;
1038     UINT8 *pp;
1039 
1040     if ((p = HCI_GET_CMD_BUF (HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL)) == NULL) {
1041         return (FALSE);
1042     }
1043 
1044     pp = (UINT8 *)(p + 1);
1045 
1046     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL;
1047     p->offset = 0;
1048 
1049     UINT16_TO_STREAM (pp, HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL);
1050     UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL);
1051     UINT16_TO_STREAM (pp, num);
1052 
1053     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
1054     return TRUE;
1055 }
1056 
btsnd_hcic_ble_set_channels(BLE_CHANNELS channels)1057 BOOLEAN btsnd_hcic_ble_set_channels (BLE_CHANNELS channels)
1058 {
1059     BT_HDR *p;
1060     UINT8 *pp;
1061 
1062     if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_SET_CHANNELS)) == NULL) {
1063         return (FALSE);
1064     }
1065 
1066     pp = (UINT8 *)(p + 1);
1067 
1068     p->len    = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_CHANNELS;
1069     p->offset = 0;
1070 
1071     UINT16_TO_STREAM (pp, HCI_BLE_SET_HOST_CHNL_CLASS);
1072     UINT8_TO_STREAM  (pp, HCIC_PARAM_SIZE_BLE_SET_CHANNELS);
1073 
1074     ARRAY_TO_STREAM  (pp, channels, HCIC_PARAM_SIZE_BLE_SET_CHANNELS);
1075 
1076     btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID,  p);
1077     return (TRUE);
1078 }
1079 
1080 #define HCIC_BLE_CMD_CREATED(p, pp, size) do{\
1081     if ((p = HCI_GET_CMD_BUF(size)) == NULL) { \
1082         return FALSE; \
1083     } \
1084     pp = p->data; \
1085     p->len = HCIC_PREAMBLE_SIZE + size;\
1086     p->offset = 0; \
1087 } while(0)
1088 
1089 #if (BLE_50_FEATURE_SUPPORT == TRUE)
1090 
btsnd_hcic_ble_read_phy(UINT16 conn_handle)1091 BOOLEAN btsnd_hcic_ble_read_phy(UINT16 conn_handle)
1092 {
1093     BT_HDR *p;
1094     UINT8 *pp;
1095 
1096     HCI_TRACE_EVENT("%s, conn_handle = %d", __func__, conn_handle);
1097     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BLE_READ_PHY);
1098 
1099     UINT16_TO_STREAM(pp, HCI_BLE_READ_PHY);
1100     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_READ_PHY);
1101     UINT16_TO_STREAM(pp, conn_handle);
1102 
1103     btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
1104     return TRUE;
1105 }
1106 
btsnd_hcic_ble_set_prefered_default_phy(UINT8 all_phys,UINT8 tx_phys,UINT8 rx_phys)1107 UINT8 btsnd_hcic_ble_set_prefered_default_phy(UINT8 all_phys,
1108                                                               UINT8 tx_phys,
1109                                                               UINT8 rx_phys)
1110 {
1111     BT_HDR *p;
1112     UINT8 *pp;
1113 
1114     HCI_TRACE_EVENT("%s, all_phys = %d, tx_phys = %d, rx_phys = %d", __func__, all_phys, tx_phys, rx_phys);
1115     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BLE_SET_DEF_PHY);
1116 
1117     UINT16_TO_STREAM(pp, HCI_BLE_SET_DEFAULT_PHY);
1118     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DEF_PHY);
1119 
1120     UINT8_TO_STREAM(pp, all_phys);
1121     UINT8_TO_STREAM(pp, tx_phys);
1122     UINT8_TO_STREAM(pp, rx_phys);
1123 
1124     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1125 }
1126 
btsnd_hcic_ble_set_phy(UINT16 conn_handle,UINT8 all_phys,UINT8 tx_phys,UINT8 rx_phys,UINT16 phy_options)1127 BOOLEAN btsnd_hcic_ble_set_phy(UINT16 conn_handle,
1128                                            UINT8 all_phys, UINT8 tx_phys,
1129                                            UINT8 rx_phys, UINT16 phy_options)
1130 {
1131     BT_HDR *p;
1132     UINT8 *pp;
1133     HCI_TRACE_EVENT("%s, conn_handle = %d, all_phys = %d, tx_phys = %d, rx_phys = %d, phy_options = %d", __func__,
1134         conn_handle, all_phys, tx_phys, rx_phys, phy_options);
1135     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BLE_SET_PHY);
1136 
1137     UINT16_TO_STREAM(pp, HCI_BLE_SET_PHY);
1138     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_PHY);
1139     UINT16_TO_STREAM(pp, conn_handle);
1140     UINT8_TO_STREAM(pp, all_phys);
1141     UINT8_TO_STREAM(pp, tx_phys);
1142     UINT8_TO_STREAM(pp, rx_phys);
1143     UINT16_TO_STREAM(pp, phy_options);
1144 
1145     btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
1146     return TRUE;
1147 }
1148 
btsnd_hcic_ble_enhand_rx_test(UINT8 rx_channel,UINT8 phy,UINT8 modulation_idx)1149 UINT8 btsnd_hcic_ble_enhand_rx_test(UINT8 rx_channel, UINT8 phy,
1150                                                          UINT8 modulation_idx)
1151 {
1152     BT_HDR *p;
1153     UINT8 *pp;
1154 
1155     HCI_TRACE_EVENT("%s, rx_channel = %d, phy = %d, modulation_idx = %d", __func__,
1156         rx_channel, phy, modulation_idx);
1157     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ENH_RX_TEST);
1158 
1159     UINT16_TO_STREAM(pp, HCI_BLE_ENH_RX_TEST);
1160     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ENH_RX_TEST);
1161     UINT8_TO_STREAM(pp, rx_channel);
1162     UINT8_TO_STREAM(pp, phy);
1163     UINT8_TO_STREAM(pp, modulation_idx);
1164 
1165     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1166 }
1167 
btsnd_hcic_ble_enhand_tx_test(UINT8 tx_channel,UINT8 len,UINT8 packect,UINT8 phy)1168 UINT8 btsnd_hcic_ble_enhand_tx_test(UINT8 tx_channel, UINT8 len,
1169                                                          UINT8 packect,
1170                                                          UINT8 phy)
1171 {
1172     BT_HDR *p;
1173     UINT8 *pp;
1174 
1175     HCI_TRACE_EVENT("%s, tx_channel = %d, len = %d, packect = %d, phy = %d", __func__,
1176             tx_channel, len, packect, phy);
1177 
1178     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ENH_TX_TEST);
1179 
1180     UINT16_TO_STREAM(pp, HCI_BLE_ENH_TX_TEST);
1181     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ENH_TX_TEST);
1182     UINT8_TO_STREAM(pp, tx_channel);
1183     UINT8_TO_STREAM(pp, len);
1184     UINT8_TO_STREAM(pp, packect);
1185     UINT8_TO_STREAM(pp, phy);
1186 
1187     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1188 }
1189 
btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle,BD_ADDR rand_addr)1190 UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr)
1191 {
1192     BT_HDR *p;
1193     UINT8 *pp;
1194     HCI_TRACE_EVENT("%s, adv_handle = %d", __func__, adv_handle);
1195 
1196     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_RAND_ADDR);
1197 
1198     UINT16_TO_STREAM (pp, HCI_BLE_SET_ADV_RAND_ADDR);
1199     UINT8_TO_STREAM  (pp,  HCIC_PARAM_SIZE_EXT_RAND_ADDR);
1200     UINT8_TO_STREAM(pp, adv_handle);
1201     BDADDR_TO_STREAM (pp, rand_addr);
1202 
1203     return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
1204 
1205 }
1206 
btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle,UINT16 properties,UINT32 interval_min,UINT32 interval_max,UINT8 channel_map,UINT8 own_addr_type,UINT8 peer_addr_type,BD_ADDR peer_addr,UINT8 adv_filter_policy,UINT8 adv_tx_power,UINT8 primary_adv_phy,UINT8 secondary_adv_max_skip,UINT8 secondary_adv_phy,UINT8 adv_sid,UINT8 scan_req_ntf_enable)1207 UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UINT32 interval_min,
1208                                           UINT32 interval_max, UINT8 channel_map, UINT8 own_addr_type,
1209                                           UINT8 peer_addr_type, BD_ADDR peer_addr,
1210                                           UINT8 adv_filter_policy, UINT8 adv_tx_power,
1211                                           UINT8 primary_adv_phy, UINT8 secondary_adv_max_skip,
1212                                           UINT8 secondary_adv_phy,
1213                                           UINT8 adv_sid, UINT8 scan_req_ntf_enable)
1214 {
1215     BT_HDR *p;
1216     UINT8 *pp;
1217 
1218 
1219     HCI_TRACE_EVENT("%s, adv_handle = %d, properties = %d, interval_min = %d, interval_max = %d, channel_map = %d,\n\
1220                      own_addr_type = %d, peer_addr_type = %d, adv_filter_policy = %d,\n\
1221                      adv_tx_power = %d, primary_adv_phy = %d, secondary_adv_max_skip = %d, secondary_adv_phy = %d,\n\
1222                      adv_sid = %d, scan_req_ntf_enable = %d", __func__, adv_handle, properties, interval_min, interval_max,
1223                      channel_map, own_addr_type, peer_addr_type, adv_filter_policy, adv_tx_power,
1224                      primary_adv_phy, secondary_adv_max_skip, secondary_adv_phy, adv_sid, scan_req_ntf_enable);
1225 
1226     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS);
1227 
1228     UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_PARAM);
1229     UINT8_TO_STREAM(pp,  HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS);
1230 
1231     UINT8_TO_STREAM(pp, adv_handle);
1232     UINT16_TO_STREAM(pp, properties);
1233     UINT24_TO_STREAM(pp, interval_min);
1234     UINT24_TO_STREAM(pp, interval_max);
1235     UINT8_TO_STREAM(pp, channel_map);
1236     UINT8_TO_STREAM(pp, own_addr_type);
1237     UINT8_TO_STREAM(pp, peer_addr_type);
1238     BDADDR_TO_STREAM (pp, peer_addr);
1239     UINT8_TO_STREAM(pp, adv_filter_policy);
1240     UINT8_TO_STREAM(pp, adv_tx_power);
1241     UINT8_TO_STREAM(pp, primary_adv_phy);
1242     UINT8_TO_STREAM(pp, secondary_adv_max_skip);
1243     UINT8_TO_STREAM(pp, secondary_adv_phy);
1244     UINT8_TO_STREAM(pp, adv_sid);
1245     UINT8_TO_STREAM(pp, scan_req_ntf_enable);
1246 
1247     return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
1248 }
1249 
1250 bool ext_adv_flag = false;
1251 
btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle,UINT8 operation,UINT8 fragment_prefrence,UINT8 data_len,UINT8 * p_data)1252 UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle,
1253                                       UINT8 operation, UINT8 fragment_prefrence,
1254                                       UINT8 data_len, UINT8 *p_data)
1255 {
1256     BT_HDR *p;
1257     UINT8 *pp;
1258     HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, fragment_prefrence = %d,\
1259                      data_len = %d", __func__, adv_handle, operation, fragment_prefrence, data_len);
1260     ext_adv_flag = true;
1261 
1262     HCIC_BLE_CMD_CREATED(p, pp,  data_len + 4);
1263     UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_DATA);
1264     UINT8_TO_STREAM(pp, data_len + 4);
1265     UINT8_TO_STREAM(pp, adv_handle);
1266     UINT8_TO_STREAM(pp, operation);
1267     UINT8_TO_STREAM(pp, fragment_prefrence);
1268 
1269     if (p_data != NULL && data_len > 0) {
1270         if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
1271             data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
1272         }
1273 
1274         UINT8_TO_STREAM (pp, data_len);
1275 
1276         ARRAY_TO_STREAM (pp, p_data, data_len);
1277     } else {
1278         return FALSE;
1279     }
1280     uint8_t status = btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
1281     return status;
1282 
1283 }
1284 
btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,UINT8 operation,UINT8 fragment_prefrence,UINT8 data_len,UINT8 * p_data)1285 UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,
1286                                                           UINT8 operation, UINT8 fragment_prefrence,
1287                                                           UINT8 data_len, UINT8 *p_data)
1288 {
1289     BT_HDR *p;
1290     UINT8 *pp;
1291 
1292     HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, fragment_prefrence = %d,\n\
1293                      data_len = %d", __func__, adv_handle, operation, fragment_prefrence, data_len);
1294 
1295     HCIC_BLE_CMD_CREATED(p, pp,  data_len + 4);
1296 
1297     UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_RSP_DATA);
1298     UINT8_TO_STREAM(pp, data_len + 4);
1299     UINT8_TO_STREAM(pp, adv_handle);
1300     UINT8_TO_STREAM(pp, operation);
1301     UINT8_TO_STREAM(pp, fragment_prefrence);
1302 
1303     memset(pp, 0, data_len);
1304 
1305     if (p_data != NULL && data_len > 0) {
1306         if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
1307             data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
1308         }
1309 
1310         UINT8_TO_STREAM (pp, data_len);
1311 
1312         ARRAY_TO_STREAM (pp, p_data, data_len);
1313     } else {
1314         return FALSE;
1315     }
1316 
1317     return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
1318 
1319 }
1320 
btsnd_hcic_ble_ext_adv_enable(UINT8 enable,UINT8 num_of_sets,UINT8 * adv_handle,UINT16 * duration,UINT8 * max_adv_evt)1321 UINT8 btsnd_hcic_ble_ext_adv_enable(UINT8 enable, UINT8 num_of_sets, UINT8 *adv_handle,
1322                                                        UINT16 *duration, UINT8 *max_adv_evt)
1323 {
1324     BT_HDR *p;
1325     UINT8 *pp;
1326     UINT8 ext_adv_size = num_of_sets*4 + 2;
1327     HCIC_BLE_CMD_CREATED(p, pp,  ext_adv_size);
1328 
1329     HCI_TRACE_EVENT("%s, enable = %d, num_of_sets = %d", __func__, enable, num_of_sets);
1330 
1331     for (int k = 0; k < num_of_sets; k++) {
1332         HCI_TRACE_EVENT("adv_handle[%d] = %d, duration[%d] = %d, max_adv_evt[%d] = %d", k, adv_handle[k],
1333             k, duration[k], k, max_adv_evt[k]);
1334     }
1335 
1336     UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_ENABLE);
1337     UINT8_TO_STREAM(pp, ext_adv_size);
1338     UINT8_TO_STREAM(pp, enable);
1339     UINT8_TO_STREAM(pp, num_of_sets);
1340 
1341     for (int i = 0; i < num_of_sets; i++) {
1342         UINT8_TO_STREAM(pp, adv_handle[i]);
1343         UINT16_TO_STREAM(pp, duration[i]);
1344         UINT8_TO_STREAM(pp, max_adv_evt[i]);
1345     }
1346 
1347     return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
1348 }
1349 
btsnd_hcic_ble_read_max_adv_len(void)1350 UINT8 btsnd_hcic_ble_read_max_adv_len(void)
1351 {
1352     BT_HDR *p;
1353     UINT8 *pp;
1354     HCI_TRACE_EVENT("%s", __func__);
1355 
1356     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE + 1);
1357 
1358     UINT16_TO_STREAM(pp, HCI_BLE_RD_MAX_ADV_DATA_LEN);
1359     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE);
1360 
1361     return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
1362 }
1363 
btsnd_hcic_ble_read_num_support_adv_set(void)1364 UINT8 btsnd_hcic_ble_read_num_support_adv_set(void)
1365 {
1366     BT_HDR *p;
1367     UINT8 *pp;
1368     HCI_TRACE_EVENT("%s", __func__);
1369 
1370     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET + 1);
1371 
1372     UINT16_TO_STREAM(pp, HCI_BLE_RD_NUM_OF_ADV_SETS);
1373     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET);
1374 
1375     return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
1376 }
1377 
btsnd_hcic_ble_remove_adv_set(UINT8 adv_handle)1378 UINT8 btsnd_hcic_ble_remove_adv_set(UINT8 adv_handle)
1379 {
1380     BT_HDR *p;
1381     UINT8 *pp;
1382     HCI_TRACE_EVENT("%s, adv_handle = %d", __func__, adv_handle);
1383 
1384     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_REMOVE_ADV_SET + 1);
1385 
1386     UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_ADV_SET);
1387     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_REMOVE_ADV_SET);
1388     UINT8_TO_STREAM(pp, adv_handle);
1389 
1390     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1391 }
1392 
btsnd_hcic_ble_clear_adv_set(void)1393 UINT8 btsnd_hcic_ble_clear_adv_set(void)
1394 {
1395     BT_HDR *p;
1396     UINT8 *pp;
1397     HCI_TRACE_EVENT("%s", __func__);
1398 
1399     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_CLEAR_ADV_SET + 1);
1400 
1401     UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_ADV_SETS);
1402     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_ADV_SET);
1403 
1404     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1405 
1406 }
1407 
btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle,UINT16 interval_min,UINT16 interval_max,UINT8 propertics)1408 UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle,
1409                                                                      UINT16 interval_min,
1410                                                                      UINT16 interval_max,
1411                                                                      UINT8 propertics)
1412 {
1413     BT_HDR *p;
1414     UINT8 *pp;
1415     HCI_TRACE_EVENT("%s, adv_handle = %d, interval_min = %d, interval_max = %d, propertics = %d",
1416                    __func__, adv_handle, interval_min, interval_max, propertics);
1417 
1418     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS);
1419 
1420     UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_PARAMS);
1421     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS);
1422 
1423     UINT8_TO_STREAM(pp, adv_handle);
1424     UINT16_TO_STREAM(pp, interval_min);
1425     UINT16_TO_STREAM(pp, interval_max);
1426     UINT16_TO_STREAM(pp, propertics);
1427 
1428     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1429 
1430 }
1431 
btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle,UINT8 operation,UINT8 len,UINT8 * p_data)1432 UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle,
1433                                                                   UINT8 operation,
1434                                                                   UINT8 len,
1435                                                                   UINT8 *p_data)
1436 {
1437     BT_HDR *p;
1438     UINT8 *pp;
1439     HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, len = %d",
1440                        __func__, adv_handle, operation, len);
1441 
1442     HCIC_BLE_CMD_CREATED(p, pp,  len + 3);
1443 
1444     UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_DATA);
1445     UINT8_TO_STREAM(pp, len + 3);
1446     UINT8_TO_STREAM(pp, adv_handle);
1447     UINT8_TO_STREAM(pp, operation);
1448 
1449     //memset(pp, 0, len);
1450 
1451     if (p_data != NULL && len > 0) {
1452         if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) {
1453             len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA;
1454         }
1455 
1456         UINT8_TO_STREAM (pp, len);
1457 
1458         ARRAY_TO_STREAM (pp, p_data, len);
1459     } else {
1460         return FALSE;
1461     }
1462 
1463     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1464 
1465 }
1466 
btsnd_hcic_ble_periodic_adv_enable(UINT8 enable,UINT8 adv_handle)1467 UINT8 btsnd_hcic_ble_periodic_adv_enable(UINT8 enable, UINT8 adv_handle)
1468 {
1469     BT_HDR *p;
1470     UINT8 *pp;
1471     HCI_TRACE_EVENT("%s, enable = %d, adv_handle = %d",
1472                            __func__, enable, adv_handle);
1473 
1474     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE);
1475 
1476     UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_ENABLE);
1477     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE);
1478     UINT8_TO_STREAM(pp, enable);
1479     UINT8_TO_STREAM(pp, adv_handle);
1480 
1481     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1482 
1483 }
1484 
btsnd_hcic_ble_set_ext_scan_params(UINT8 own_addr_type,UINT8 filter_policy,UINT8 phy_mask,UINT8 phy_count,tHCI_EXT_SCAN_PARAMS * params)1485 UINT8 btsnd_hcic_ble_set_ext_scan_params(UINT8 own_addr_type, UINT8 filter_policy,
1486                                                                UINT8 phy_mask, UINT8 phy_count,
1487                                                                tHCI_EXT_SCAN_PARAMS *params)
1488 {
1489     BT_HDR *p;
1490     UINT8 *pp;
1491     HCI_TRACE_EVENT("%s, own_addr_type = %d, filter_policy = %d, phy_mask = %d, phy_count = %d",
1492                            __func__, own_addr_type, filter_policy, phy_mask, phy_count);
1493     UINT8 params_size = HCIC_PARAM_SIZE_SET_EXT_SCAN_PARAMS + phy_count*5;
1494 
1495     HCIC_BLE_CMD_CREATED(p, pp,  params_size);
1496 
1497     UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_PARAMS);
1498     UINT8_TO_STREAM(pp, params_size);
1499     UINT8_TO_STREAM(pp, own_addr_type);
1500     UINT8_TO_STREAM(pp, filter_policy);
1501     UINT8_TO_STREAM(pp, phy_mask);
1502 
1503     for (int i = 0; i < phy_count; i++) {
1504         UINT8_TO_STREAM(pp, params[i].scan_type);
1505         UINT16_TO_STREAM(pp, params[i].scan_interval);
1506         UINT16_TO_STREAM(pp, params[i].scan_window);
1507     }
1508 
1509     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1510 
1511 }
1512 
btsnd_hcic_ble_ext_scan_enable(UINT8 enable,UINT8 filter_dups,UINT16 duration,UINT16 period)1513 UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups,
1514                                                          UINT16 duration, UINT16 period)
1515 {
1516     BT_HDR *p;
1517     UINT8 *pp;
1518     HCI_TRACE_EVENT("%s, enable = %d, filter_dups = %d, duration = %d, period = %d",
1519                                __func__, enable, filter_dups, duration, period);
1520 
1521     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_EXT_SCAN_ENABLE);
1522 
1523     UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_ENABLE);
1524     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_EXT_SCAN_ENABLE);
1525     UINT8_TO_STREAM(pp, enable);
1526     UINT8_TO_STREAM(pp, filter_dups);
1527     UINT16_TO_STREAM(pp, duration);
1528     UINT16_TO_STREAM(pp, period);
1529 
1530     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1531 }
1532 
btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn * p_conn)1533 BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn)
1534 {
1535     BT_HDR *p;
1536     UINT8 *pp;
1537     tHCI_ExtConnParams *params;
1538     HCI_TRACE_EVENT("%s", __func__);
1539     uint8_t size = HCIC_PARAM_SIZE_EXT_CONN_CREATE_BASE;
1540 
1541     if (p_conn->init_phy_mask & 0x01) {
1542         size += sizeof(tHCI_ExtConnParams);
1543     }
1544 
1545     if (p_conn->init_phy_mask & 0x02) {
1546         size += sizeof(tHCI_ExtConnParams);
1547     }
1548 
1549     if (p_conn->init_phy_mask & 0x04) {
1550         size += sizeof(tHCI_ExtConnParams);
1551     }
1552 
1553     HCIC_BLE_CMD_CREATED(p, pp,  size);
1554 
1555     UINT16_TO_STREAM(pp, HCI_BLE_EXT_CREATE_CONN);
1556     UINT8_TO_STREAM(pp, size);
1557     UINT8_TO_STREAM(pp, p_conn->filter_policy);
1558     UINT8_TO_STREAM(pp, p_conn->own_addr_type);
1559     UINT8_TO_STREAM(pp, p_conn->peer_addr_type);
1560     BDADDR_TO_STREAM(pp, p_conn->peer_addr);
1561     UINT8_TO_STREAM(pp, p_conn->init_phy_mask);
1562 
1563     if (p_conn->init_phy_mask & 0x01) {
1564         params = &p_conn->params[0];
1565         UINT16_TO_STREAM(pp, params->scan_interval);
1566         UINT16_TO_STREAM(pp, params->scan_window);
1567         UINT16_TO_STREAM(pp, params->conn_interval_min);
1568         UINT16_TO_STREAM(pp, params->conn_interval_max);
1569         UINT16_TO_STREAM(pp, params->conn_latency);
1570         UINT16_TO_STREAM(pp, params->sup_timeout);
1571         UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN);
1572         UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN);
1573     }
1574 
1575     if (p_conn->init_phy_mask & 0x02) {
1576         params = &p_conn->params[1];
1577         UINT16_TO_STREAM(pp, params->scan_interval);
1578         UINT16_TO_STREAM(pp, params->scan_window);
1579         UINT16_TO_STREAM(pp, params->conn_interval_min);
1580         UINT16_TO_STREAM(pp, params->conn_interval_max);
1581         UINT16_TO_STREAM(pp, params->conn_latency);
1582         UINT16_TO_STREAM(pp, params->sup_timeout);
1583         UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN);
1584         UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN);
1585     }
1586 
1587     if (p_conn->init_phy_mask & 0x04) {
1588         params = &p_conn->params[2];
1589         UINT16_TO_STREAM(pp, params->scan_interval);
1590         UINT16_TO_STREAM(pp, params->scan_window);
1591         UINT16_TO_STREAM(pp, params->conn_interval_min);
1592         UINT16_TO_STREAM(pp, params->conn_interval_max);
1593         UINT16_TO_STREAM(pp, params->conn_latency);
1594         UINT16_TO_STREAM(pp, params->sup_timeout);
1595         UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN);
1596         UINT16_TO_STREAM(pp, BLE_CE_LEN_MIN);
1597     }
1598 
1599     btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
1600     return TRUE;
1601 
1602 }
1603 
btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy,UINT8 adv_sid,UINT8 adv_addr_type,BD_ADDR adv_addr,UINT16 sync_timeout,UINT8 unused)1604 BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid,
1605                                                                        UINT8 adv_addr_type, BD_ADDR adv_addr,
1606                                                                        UINT16 sync_timeout, UINT8 unused)
1607 {
1608     BT_HDR *p;
1609     UINT8 *pp;
1610     HCI_TRACE_EVENT("%s, filter_policy = %d, adv_sid = %d, adv_addr_type = %d, sync_timeout = %d, unused = %d",
1611                                    __func__, filter_policy, adv_sid, adv_addr_type, sync_timeout, unused);
1612 
1613     HCI_TRACE_EVENT("addr %02x %02x %02x %02x %02x %02x", adv_addr[0], adv_addr[1], adv_addr[2], adv_addr[3], adv_addr[4], adv_addr[5]);
1614     uint16_t skip = 0;
1615     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC + 2);
1616 
1617     UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_CREATE_SYNC);
1618     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC + 2);
1619     UINT8_TO_STREAM(pp, filter_policy);
1620     UINT8_TO_STREAM(pp, adv_sid);
1621     UINT8_TO_STREAM(pp, adv_addr_type);
1622     BDADDR_TO_STREAM(pp, adv_addr);
1623     UINT16_TO_STREAM(pp, skip);
1624     UINT16_TO_STREAM(pp, sync_timeout);
1625     UINT8_TO_STREAM(pp, unused);
1626 
1627     btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
1628     return TRUE;
1629 }
1630 
btsnd_hcic_ble_periodic_adv_create_sync_cancel(void)1631 UINT8 btsnd_hcic_ble_periodic_adv_create_sync_cancel(void)
1632 {
1633     BT_HDR *p;
1634     UINT8 *pp;
1635     HCI_TRACE_EVENT("%s", __func__);
1636 
1637     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL);
1638 
1639     UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_CREATE_SYNC_CANCEL);
1640     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL);
1641 
1642     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1643 }
1644 
btsnd_hcic_ble_periodic_adv_term_sync(UINT16 sync_handle)1645 UINT8 btsnd_hcic_ble_periodic_adv_term_sync(UINT16 sync_handle)
1646 {
1647     BT_HDR *p;
1648     UINT8 *pp;
1649     HCI_TRACE_EVENT("%s, sync_handle = %d", __func__, sync_handle);
1650 
1651     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC);
1652 
1653     UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_TERM_SYNC);
1654     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC);
1655 
1656     UINT16_TO_STREAM(pp, sync_handle);
1657 
1658     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1659 }
1660 
btsnd_hcic_ble_add_dev_to_periodic_adv_list(UINT8 adv_addr_type,BD_ADDR adv_addr,UINT8 adv_sid)1661 UINT8 btsnd_hcic_ble_add_dev_to_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
1662                                                                              UINT8 adv_sid)
1663 {
1664     BT_HDR *p;
1665     UINT8 *pp;
1666     HCI_TRACE_EVENT("%s, adv_addr_type = %d, adv_sid = %d", __func__, adv_addr_type, adv_sid);
1667     esp_log_buffer_hex_internal("addr", adv_addr, sizeof(BD_ADDR), ESP_LOG_WARN);
1668 
1669     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST);
1670 
1671     UINT16_TO_STREAM(pp, HCI_BLE_ADV_DEV_TO_PERIOD_ADV_LIST);
1672     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST);
1673     UINT8_TO_STREAM(pp, adv_addr_type);
1674     BDADDR_TO_STREAM(pp, adv_addr);
1675     UINT8_TO_STREAM(pp, adv_sid);
1676 
1677     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1678 }
1679 
btsnd_hcic_ble_rm_dev_from_periodic_adv_list(UINT8 adv_addr_type,BD_ADDR adv_addr,UINT8 adv_sid)1680 UINT8 btsnd_hcic_ble_rm_dev_from_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
1681                                                                              UINT8 adv_sid)
1682 {
1683     BT_HDR *p;
1684     UINT8 *pp;
1685     HCI_TRACE_EVENT("%s, adv_addr_type = %d, adv_sid = %d", __func__, adv_addr_type, adv_sid);
1686     esp_log_buffer_hex_internal("addr", adv_addr, sizeof(BD_ADDR), ESP_LOG_WARN);
1687 
1688     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST);
1689 
1690     UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_DEV_FROM_PERIOD_ADV_LIST);
1691     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST);
1692     UINT8_TO_STREAM(pp, adv_addr_type);
1693     BDADDR_TO_STREAM(pp, adv_addr);
1694     UINT8_TO_STREAM(pp, adv_sid);
1695 
1696     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1697 
1698 }
1699 
btsnd_hcic_ble_clear_periodic_adv_list(void)1700 UINT8 btsnd_hcic_ble_clear_periodic_adv_list(void)
1701 {
1702     BT_HDR *p;
1703     UINT8 *pp;
1704     HCI_TRACE_EVENT("%s", __func__);
1705 
1706     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST);
1707 
1708     UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_PERIOD_ADV_LIST);
1709     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST);
1710 
1711     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1712 }
1713 
btsnd_hcic_ble_read_periodic_adv_list_size(void)1714 UINT8 btsnd_hcic_ble_read_periodic_adv_list_size(void)
1715 {
1716     BT_HDR *p;
1717     UINT8 *pp;
1718     HCI_TRACE_EVENT("%s", __func__);
1719 
1720     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST);
1721 
1722     UINT16_TO_STREAM(pp, HCI_BLE_RD_PERIOD_ADV_LIST_SIZE);
1723     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST);
1724 
1725     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1726 }
1727 
btsnd_hcic_ble_read_trans_power(void)1728 UINT8 btsnd_hcic_ble_read_trans_power(void)
1729 {
1730     BT_HDR *p;
1731     UINT8 *pp;
1732     HCI_TRACE_EVENT("%s", __func__);
1733 
1734     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_READ_TRANS_POWER);
1735 
1736     UINT16_TO_STREAM(pp, HCI_BLE_RD_TRANSMIT_POWER);
1737     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_TRANS_POWER);
1738 
1739     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1740 }
1741 
btsnd_hcic_ble_read_rf_path_compensation(void)1742 UINT8 btsnd_hcic_ble_read_rf_path_compensation(void)
1743 {
1744     BT_HDR *p;
1745     UINT8 *pp;
1746     HCI_TRACE_EVENT("%s", __func__);
1747 
1748     HCIC_BLE_CMD_CREATED(p, pp,  HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
1749 
1750     UINT16_TO_STREAM(pp, HCI_BLE_RD_RF_PATH_COMPENSATION);
1751     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
1752 
1753     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1754 }
1755 
btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path,UINT16 rf_rx_path)1756 UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_path)
1757 {
1758     BT_HDR *p;
1759     UINT8 *pp;
1760     HCI_TRACE_EVENT("%s, rf_tx_path = %d, rf_rx_path = %d", __func__, rf_tx_path, rf_rx_path);
1761 
1762     HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
1763 
1764     pp = (UINT8 *)(p + 1);
1765 
1766     p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION;
1767     p->offset = 0;
1768 
1769     UINT16_TO_STREAM(pp, HCI_BLE_WR_RF_PATH_COMPENSATION);
1770     UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION);
1771 
1772     UINT16_TO_STREAM(pp, rf_tx_path);
1773     UINT16_TO_STREAM(pp, rf_tx_path);
1774 
1775     return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
1776 }
1777 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
1778 #endif
1779