1 /******************************************************************************
2 *
3 * Copyright 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 <base/functional/bind.h>
27 #include <bluetooth/log.h>
28 #include <stddef.h>
29 #include <string.h>
30
31 #include <bitset>
32
33 #include "hcidefs.h"
34 #include "hcimsgs.h"
35 #include "internal_include/bt_target.h"
36 #include "osi/include/allocator.h"
37 #include "stack/include/bt_hdr.h"
38 #include "stack/include/bt_octets.h"
39 #include "stack/include/bt_types.h"
40 #include "stack/include/btu_hcif.h"
41 #include "types/raw_address.h"
42
43 /*******************************************************************************
44 * BLE Commands
45 * Note: "local_controller_id" is for transport, not counted in HCI
46 * message size
47 ******************************************************************************/
48 #define HCIC_BLE_RAND_DI_SIZE 8
49 #define HCIC_BLE_IRK_SIZE 16
50
51 #define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
52 #define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
53 #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
54 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
55 #define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
56 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
57 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE 2
58 #define HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN 25
59 #define HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL 0
60 #define HCIC_PARAM_SIZE_CLEAR_ACCEPTLIST 0
61 #define HCIC_PARAM_SIZE_ADD_ACCEPTLIST 7
62 #define HCIC_PARAM_SIZE_REMOVE_ACCEPTLIST 7
63 #define HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS 14
64 #define HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS 5
65 #define HCIC_PARAM_SIZE_READ_CHNL_MAP 2
66 #define HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT 2
67 #define HCIC_PARAM_SIZE_BLE_ENCRYPT 32
68 #define HCIC_PARAM_SIZE_WRITE_LE_HOST_SUPPORTED 2
69
70 #define HCIC_BLE_RAND_DI_SIZE 8
71 #define HCIC_BLE_ENCRYPT_KEY_SIZE 16
72 #define HCIC_PARAM_SIZE_BLE_START_ENC \
73 (4 + HCIC_BLE_RAND_DI_SIZE + HCIC_BLE_ENCRYPT_KEY_SIZE)
74 #define HCIC_PARAM_SIZE_LTK_REQ_REPLY (2 + HCIC_BLE_ENCRYPT_KEY_SIZE)
75 #define HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY 2
76 #define HCIC_BLE_CHNL_MAP_SIZE 5
77 #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA 31
78
79 #define HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST (7 + HCIC_BLE_IRK_SIZE * 2)
80 #define HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST 7
81 #define HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE 8
82 #define HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST 0
83 #define HCIC_PARAM_SIZE_BLE_READ_RESOLVING_LIST_SIZE 0
84 #define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER 7
85 #define HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL 7
86 #define HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE 1
87 #define HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT 2
88
89 #define HCIC_PARAM_SIZE_BLE_READ_PHY 2
90 #define HCIC_PARAM_SIZE_BLE_SET_DEFAULT_PHY 3
91 #define HCIC_PARAM_SIZE_BLE_SET_PHY 7
92 #define HCIC_PARAM_SIZE_BLE_ENH_RX_TEST 3
93 #define HCIC_PARAM_SIZE_BLE_ENH_TX_TEST 4
94
95 #define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
96 #define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
97
98 #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY 14
99 #define HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY 3
100
101 #define HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_CREATE_SYNC 14
102 #define HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL 0
103 #define HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_TERMINATE_SYNC 2
104 #define HCIC_PARAM_SIZE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST 8
105 #define HCIC_PARAM_SIZE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST 8
106 #define HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADVERTISER_LIST 0
107 #define HCIC_PARAM_SIZE_READ_PERIODIC_ADVERTISER_LIST_SIZE 0
108 #define HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE 3
109 #define HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SYNC_TRANSFER 6
110 #define HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER 5
111 #define HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS 8
112 #define HCIC_PARAM_SIZE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS 8
113
btsnd_hcic_ble_write_adv_params(uint16_t adv_int_min,uint16_t adv_int_max,uint8_t adv_type,tBLE_ADDR_TYPE addr_type_own,tBLE_ADDR_TYPE addr_type_dir,const RawAddress & direct_bda,uint8_t channel_map,uint8_t adv_filter_policy)114 void btsnd_hcic_ble_write_adv_params(uint16_t adv_int_min, uint16_t adv_int_max,
115 uint8_t adv_type,
116 tBLE_ADDR_TYPE addr_type_own,
117 tBLE_ADDR_TYPE addr_type_dir,
118 const RawAddress& direct_bda,
119 uint8_t channel_map,
120 uint8_t adv_filter_policy) {
121 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
122 uint8_t* pp = (uint8_t*)(p + 1);
123
124 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS;
125 p->offset = 0;
126
127 UINT16_TO_STREAM(pp, HCI_BLE_WRITE_ADV_PARAMS);
128 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS);
129
130 UINT16_TO_STREAM(pp, adv_int_min);
131 UINT16_TO_STREAM(pp, adv_int_max);
132 UINT8_TO_STREAM(pp, adv_type);
133 UINT8_TO_STREAM(pp, addr_type_own);
134 UINT8_TO_STREAM(pp, addr_type_dir);
135 BDADDR_TO_STREAM(pp, direct_bda);
136 UINT8_TO_STREAM(pp, channel_map);
137 UINT8_TO_STREAM(pp, adv_filter_policy);
138
139 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
140 }
btsnd_hcic_ble_read_adv_chnl_tx_power(void)141 void btsnd_hcic_ble_read_adv_chnl_tx_power(void) {
142 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
143 uint8_t* pp = (uint8_t*)(p + 1);
144
145 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
146 p->offset = 0;
147
148 UINT16_TO_STREAM(pp, HCI_BLE_READ_ADV_CHNL_TX_POWER);
149 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_CMD);
150
151 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
152 }
153
btsnd_hcic_ble_set_adv_data(uint8_t data_len,uint8_t * p_data)154 void btsnd_hcic_ble_set_adv_data(uint8_t data_len, uint8_t* p_data) {
155 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
156 uint8_t* pp = (uint8_t*)(p + 1);
157
158 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1;
159 p->offset = 0;
160
161 UINT16_TO_STREAM(pp, HCI_BLE_WRITE_ADV_DATA);
162 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1);
163
164 memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA);
165
166 if (p_data != NULL && data_len > 0) {
167 if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA)
168 data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA;
169
170 UINT8_TO_STREAM(pp, data_len);
171
172 ARRAY_TO_STREAM(pp, p_data, data_len);
173 }
174 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
175 }
176
btsnd_hcic_ble_set_adv_enable(uint8_t adv_enable)177 void btsnd_hcic_ble_set_adv_enable(uint8_t adv_enable) {
178 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
179 uint8_t* pp = (uint8_t*)(p + 1);
180
181 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_ADV_ENABLE;
182 p->offset = 0;
183
184 UINT16_TO_STREAM(pp, HCI_BLE_WRITE_ADV_ENABLE);
185 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_ADV_ENABLE);
186
187 UINT8_TO_STREAM(pp, adv_enable);
188
189 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
190 }
btsnd_hcic_ble_set_scan_params(uint8_t scan_type,uint16_t scan_int,uint16_t scan_win,uint8_t addr_type_own,uint8_t scan_filter_policy)191 void btsnd_hcic_ble_set_scan_params(uint8_t scan_type, uint16_t scan_int,
192 uint16_t scan_win, uint8_t addr_type_own,
193 uint8_t scan_filter_policy) {
194 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
195 uint8_t* pp = (uint8_t*)(p + 1);
196
197 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM;
198 p->offset = 0;
199
200 UINT16_TO_STREAM(pp, HCI_BLE_WRITE_SCAN_PARAMS);
201 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM);
202
203 UINT8_TO_STREAM(pp, scan_type);
204 UINT16_TO_STREAM(pp, scan_int);
205 UINT16_TO_STREAM(pp, scan_win);
206 UINT8_TO_STREAM(pp, addr_type_own);
207 UINT8_TO_STREAM(pp, scan_filter_policy);
208
209 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
210 }
211
btsnd_hcic_ble_set_scan_enable(uint8_t scan_enable,uint8_t duplicate)212 void btsnd_hcic_ble_set_scan_enable(uint8_t scan_enable, uint8_t duplicate) {
213 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
214 uint8_t* pp = (uint8_t*)(p + 1);
215
216 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE;
217 p->offset = 0;
218
219 UINT16_TO_STREAM(pp, HCI_BLE_WRITE_SCAN_ENABLE);
220 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE);
221
222 UINT8_TO_STREAM(pp, scan_enable);
223 UINT8_TO_STREAM(pp, duplicate);
224
225 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
226 }
227
btsnd_hcic_ble_read_remote_feat(uint16_t handle)228 void btsnd_hcic_ble_read_remote_feat(uint16_t handle) {
229 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
230 uint8_t* pp = (uint8_t*)(p + 1);
231
232 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT;
233 p->offset = 0;
234
235 UINT16_TO_STREAM(pp, HCI_BLE_READ_REMOTE_FEAT);
236 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT);
237
238 UINT16_TO_STREAM(pp, handle);
239
240 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
241 }
242
btsnd_hcic_ble_rand(base::Callback<void (BT_OCTET8)> cb)243 void btsnd_hcic_ble_rand(base::Callback<void(BT_OCTET8)> cb) {
244 btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_RAND, nullptr, 0,
245 base::Bind(
246 [](base::Callback<void(BT_OCTET8)> cb,
247 uint8_t* param, uint16_t /* param_len */) {
248 bluetooth::log::assert_that(
249 param[0] == 0,
250 "LE Rand return status must be zero");
251 cb.Run(param + 1 /* skip status */);
252 },
253 std::move(cb)));
254 }
255
btsnd_hcic_ble_start_enc(uint16_t handle,uint8_t rand[HCIC_BLE_RAND_DI_SIZE],uint16_t ediv,const Octet16 & ltk)256 void btsnd_hcic_ble_start_enc(uint16_t handle,
257 uint8_t rand[HCIC_BLE_RAND_DI_SIZE],
258 uint16_t ediv, const Octet16& ltk) {
259 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
260 uint8_t* pp = (uint8_t*)(p + 1);
261
262 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_START_ENC;
263 p->offset = 0;
264
265 UINT16_TO_STREAM(pp, HCI_BLE_START_ENC);
266 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_START_ENC);
267
268 UINT16_TO_STREAM(pp, handle);
269 ARRAY_TO_STREAM(pp, rand, HCIC_BLE_RAND_DI_SIZE);
270 UINT16_TO_STREAM(pp, ediv);
271 ARRAY_TO_STREAM(pp, ltk.data(), HCIC_BLE_ENCRYPT_KEY_SIZE);
272
273 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
274 }
275
btsnd_hcic_ble_ltk_req_reply(uint16_t handle,const Octet16 & ltk)276 void btsnd_hcic_ble_ltk_req_reply(uint16_t handle, const Octet16& ltk) {
277 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
278 uint8_t* pp = (uint8_t*)(p + 1);
279
280 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_REPLY;
281 p->offset = 0;
282
283 UINT16_TO_STREAM(pp, HCI_BLE_LTK_REQ_REPLY);
284 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_LTK_REQ_REPLY);
285
286 UINT16_TO_STREAM(pp, handle);
287 ARRAY_TO_STREAM(pp, ltk.data(), HCIC_BLE_ENCRYPT_KEY_SIZE);
288
289 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
290 }
291
btsnd_hcic_ble_ltk_req_neg_reply(uint16_t handle)292 void btsnd_hcic_ble_ltk_req_neg_reply(uint16_t handle) {
293 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
294 uint8_t* pp = (uint8_t*)(p + 1);
295
296 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY;
297 p->offset = 0;
298
299 UINT16_TO_STREAM(pp, HCI_BLE_LTK_REQ_NEG_REPLY);
300 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY);
301
302 UINT16_TO_STREAM(pp, handle);
303
304 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
305 }
306
btsnd_hcic_ble_receiver_test(uint8_t rx_freq)307 void btsnd_hcic_ble_receiver_test(uint8_t rx_freq) {
308 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
309 uint8_t* pp = (uint8_t*)(p + 1);
310
311 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1;
312 p->offset = 0;
313
314 UINT16_TO_STREAM(pp, HCI_BLE_RECEIVER_TEST);
315 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_PARAM1);
316
317 UINT8_TO_STREAM(pp, rx_freq);
318
319 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
320 }
321
btsnd_hcic_ble_transmitter_test(uint8_t tx_freq,uint8_t test_data_len,uint8_t payload)322 void btsnd_hcic_ble_transmitter_test(uint8_t tx_freq, uint8_t test_data_len,
323 uint8_t payload) {
324 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
325 uint8_t* pp = (uint8_t*)(p + 1);
326
327 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3;
328 p->offset = 0;
329
330 UINT16_TO_STREAM(pp, HCI_BLE_TRANSMITTER_TEST);
331 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_PARAM3);
332
333 UINT8_TO_STREAM(pp, tx_freq);
334 UINT8_TO_STREAM(pp, test_data_len);
335 UINT8_TO_STREAM(pp, payload);
336
337 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
338 }
339
btsnd_hcic_ble_test_end(void)340 void btsnd_hcic_ble_test_end(void) {
341 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
342 uint8_t* pp = (uint8_t*)(p + 1);
343
344 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD;
345 p->offset = 0;
346
347 UINT16_TO_STREAM(pp, HCI_BLE_TEST_END);
348 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_CMD);
349
350 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
351 }
352
btsnd_hcic_ble_read_resolvable_addr_peer(uint8_t addr_type_peer,const RawAddress & bda_peer)353 void btsnd_hcic_ble_read_resolvable_addr_peer(uint8_t addr_type_peer,
354 const RawAddress& bda_peer) {
355 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
356 uint8_t* pp = (uint8_t*)(p + 1);
357
358 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER;
359 p->offset = 0;
360
361 UINT16_TO_STREAM(pp, HCI_BLE_READ_RESOLVABLE_ADDR_PEER);
362 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER);
363 UINT8_TO_STREAM(pp, addr_type_peer);
364 BDADDR_TO_STREAM(pp, bda_peer);
365
366 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
367 }
368
btsnd_hcic_ble_set_rand_priv_addr_timeout(uint16_t rpa_timout)369 void btsnd_hcic_ble_set_rand_priv_addr_timeout(uint16_t rpa_timout) {
370 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
371 uint8_t* pp = (uint8_t*)(p + 1);
372
373 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT;
374 p->offset = 0;
375
376 UINT16_TO_STREAM(pp, HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT);
377 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT);
378 UINT16_TO_STREAM(pp, rpa_timout);
379
380 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
381 }
382
btsnd_hcic_ble_set_data_length(uint16_t conn_handle,uint16_t tx_octets,uint16_t tx_time)383 void btsnd_hcic_ble_set_data_length(uint16_t conn_handle, uint16_t tx_octets,
384 uint16_t tx_time) {
385 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
386 uint8_t* pp = (uint8_t*)(p + 1);
387
388 p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH;
389 p->offset = 0;
390
391 UINT16_TO_STREAM(pp, HCI_BLE_SET_DATA_LENGTH);
392 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH);
393
394 UINT16_TO_STREAM(pp, conn_handle);
395 UINT16_TO_STREAM(pp, tx_octets);
396 UINT16_TO_STREAM(pp, tx_time);
397
398 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
399 }
400
btsnd_hcic_ble_set_extended_scan_params(uint8_t own_address_type,uint8_t scanning_filter_policy,uint8_t scanning_phys,scanning_phy_cfg * phy_cfg)401 void btsnd_hcic_ble_set_extended_scan_params(uint8_t own_address_type,
402 uint8_t scanning_filter_policy,
403 uint8_t scanning_phys,
404 scanning_phy_cfg* phy_cfg) {
405 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
406 uint8_t* pp = (uint8_t*)(p + 1);
407
408 int phy_cnt =
409 std::bitset<std::numeric_limits<uint8_t>::digits>(scanning_phys).count();
410
411 uint16_t param_len = 3 + (5 * phy_cnt);
412 p->len = HCIC_PREAMBLE_SIZE + param_len;
413 p->offset = 0;
414
415 UINT16_TO_STREAM(pp, HCI_LE_SET_EXTENDED_SCAN_PARAMETERS);
416 UINT8_TO_STREAM(pp, param_len);
417
418 UINT8_TO_STREAM(pp, own_address_type);
419 UINT8_TO_STREAM(pp, scanning_filter_policy);
420 UINT8_TO_STREAM(pp, scanning_phys);
421
422 for (int i = 0; i < phy_cnt; i++) {
423 UINT8_TO_STREAM(pp, phy_cfg[i].scan_type);
424 UINT16_TO_STREAM(pp, phy_cfg[i].scan_int);
425 UINT16_TO_STREAM(pp, phy_cfg[i].scan_win);
426 }
427
428 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
429 }
430
btsnd_hcic_ble_set_extended_scan_enable(uint8_t enable,uint8_t filter_duplicates,uint16_t duration,uint16_t period)431 void btsnd_hcic_ble_set_extended_scan_enable(uint8_t enable,
432 uint8_t filter_duplicates,
433 uint16_t duration,
434 uint16_t period) {
435 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
436 uint8_t* pp = (uint8_t*)(p + 1);
437
438 const int param_len = 6;
439 p->len = HCIC_PREAMBLE_SIZE + param_len;
440 p->offset = 0;
441
442 UINT16_TO_STREAM(pp, HCI_LE_SET_EXTENDED_SCAN_ENABLE);
443 UINT8_TO_STREAM(pp, param_len);
444
445 UINT8_TO_STREAM(pp, enable);
446 UINT8_TO_STREAM(pp, filter_duplicates);
447 UINT16_TO_STREAM(pp, duration);
448 UINT16_TO_STREAM(pp, period);
449
450 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
451 }
452
btsnd_hcic_set_cig_params(uint8_t cig_id,uint32_t sdu_itv_mtos,uint32_t sdu_itv_stom,uint8_t sca,uint8_t packing,uint8_t framing,uint16_t max_trans_lat_stom,uint16_t max_trans_lat_mtos,uint8_t cis_cnt,const EXT_CIS_CFG * cis_cfg,base::OnceCallback<void (uint8_t *,uint16_t)> cb)453 void btsnd_hcic_set_cig_params(
454 uint8_t cig_id, uint32_t sdu_itv_mtos, uint32_t sdu_itv_stom, uint8_t sca,
455 uint8_t packing, uint8_t framing, uint16_t max_trans_lat_stom,
456 uint16_t max_trans_lat_mtos, uint8_t cis_cnt, const EXT_CIS_CFG* cis_cfg,
457 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
458 const int params_len = 15 + cis_cnt * 9;
459 uint8_t param[params_len];
460 uint8_t* pp = param;
461
462 UINT8_TO_STREAM(pp, cig_id);
463 UINT24_TO_STREAM(pp, sdu_itv_mtos);
464 UINT24_TO_STREAM(pp, sdu_itv_stom);
465 UINT8_TO_STREAM(pp, sca);
466 UINT8_TO_STREAM(pp, packing);
467 UINT8_TO_STREAM(pp, framing);
468 UINT16_TO_STREAM(pp, max_trans_lat_mtos);
469 UINT16_TO_STREAM(pp, max_trans_lat_stom);
470 UINT8_TO_STREAM(pp, cis_cnt);
471
472 for (int i = 0; i < cis_cnt; i++) {
473 UINT8_TO_STREAM(pp, cis_cfg[i].cis_id);
474 UINT16_TO_STREAM(pp, cis_cfg[i].max_sdu_size_mtos);
475 UINT16_TO_STREAM(pp, cis_cfg[i].max_sdu_size_stom);
476 UINT8_TO_STREAM(pp, cis_cfg[i].phy_mtos);
477 UINT8_TO_STREAM(pp, cis_cfg[i].phy_stom);
478 UINT8_TO_STREAM(pp, cis_cfg[i].rtn_mtos);
479 UINT8_TO_STREAM(pp, cis_cfg[i].rtn_stom);
480 }
481
482 btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_SET_CIG_PARAMS, param, params_len,
483 std::move(cb));
484 }
485
btsnd_hcic_create_cis(uint8_t num_cis,const EXT_CIS_CREATE_CFG * cis_cfg,base::OnceCallback<void (uint8_t *,uint16_t)> cb)486 void btsnd_hcic_create_cis(uint8_t num_cis, const EXT_CIS_CREATE_CFG* cis_cfg,
487 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
488 const int params_len = 1 + num_cis * 4;
489 uint8_t param[params_len];
490 uint8_t* pp = param;
491
492 UINT8_TO_STREAM(pp, num_cis);
493
494 for (int i = 0; i < num_cis; i++) {
495 UINT16_TO_STREAM(pp, cis_cfg[i].cis_conn_handle);
496 UINT16_TO_STREAM(pp, cis_cfg[i].acl_conn_handle);
497 }
498
499 btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_CREATE_CIS, param, params_len,
500 std::move(cb));
501 }
502
btsnd_hcic_remove_cig(uint8_t cig_id,base::OnceCallback<void (uint8_t *,uint16_t)> cb)503 void btsnd_hcic_remove_cig(uint8_t cig_id,
504 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
505 const int params_len = 1;
506 uint8_t param[params_len];
507 uint8_t* pp = param;
508
509 UINT8_TO_STREAM(pp, cig_id);
510
511 btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_REMOVE_CIG, param, params_len,
512 std::move(cb));
513 }
514
btsnd_hcic_req_peer_sca(uint16_t conn_handle)515 void btsnd_hcic_req_peer_sca(uint16_t conn_handle) {
516 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
517 uint8_t* pp = (uint8_t*)(p + 1);
518
519 const int param_len = 2;
520 p->len = HCIC_PREAMBLE_SIZE + param_len;
521 p->offset = 0;
522
523 UINT16_TO_STREAM(pp, HCI_LE_REQ_PEER_SCA);
524 UINT8_TO_STREAM(pp, param_len);
525 UINT16_TO_STREAM(pp, conn_handle);
526
527 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
528 }
529
btsnd_hcic_create_big(uint8_t big_handle,uint8_t adv_handle,uint8_t num_bis,uint32_t sdu_itv,uint16_t max_sdu_size,uint16_t transport_latency,uint8_t rtn,uint8_t phy,uint8_t packing,uint8_t framing,uint8_t enc,std::array<uint8_t,16> bcst_code)530 void btsnd_hcic_create_big(uint8_t big_handle, uint8_t adv_handle,
531 uint8_t num_bis, uint32_t sdu_itv,
532 uint16_t max_sdu_size, uint16_t transport_latency,
533 uint8_t rtn, uint8_t phy, uint8_t packing,
534 uint8_t framing, uint8_t enc,
535 std::array<uint8_t, 16> bcst_code) {
536 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
537 uint8_t* pp = (uint8_t*)(p + 1);
538
539 const int param_len = 31;
540 p->len = HCIC_PREAMBLE_SIZE + param_len;
541 p->offset = 0;
542
543 UINT16_TO_STREAM(pp, HCI_LE_CREATE_BIG);
544 UINT8_TO_STREAM(pp, param_len);
545
546 UINT8_TO_STREAM(pp, big_handle);
547 UINT8_TO_STREAM(pp, adv_handle);
548 UINT8_TO_STREAM(pp, num_bis);
549 UINT24_TO_STREAM(pp, sdu_itv);
550 UINT16_TO_STREAM(pp, max_sdu_size);
551 UINT16_TO_STREAM(pp, transport_latency);
552 UINT8_TO_STREAM(pp, rtn);
553 UINT8_TO_STREAM(pp, phy);
554 UINT8_TO_STREAM(pp, packing);
555 UINT8_TO_STREAM(pp, framing);
556 UINT8_TO_STREAM(pp, enc);
557
558 uint8_t* buf_ptr = bcst_code.data();
559 ARRAY_TO_STREAM(pp, buf_ptr, 16);
560
561 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
562 }
563
btsnd_hcic_term_big(uint8_t big_handle,uint8_t reason)564 void btsnd_hcic_term_big(uint8_t big_handle, uint8_t reason) {
565 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
566 uint8_t* pp = (uint8_t*)(p + 1);
567
568 const int param_len = 2;
569 p->len = HCIC_PREAMBLE_SIZE + param_len;
570 p->offset = 0;
571
572 UINT16_TO_STREAM(pp, HCI_LE_TERM_BIG);
573 UINT8_TO_STREAM(pp, param_len);
574
575 UINT8_TO_STREAM(pp, big_handle);
576 UINT8_TO_STREAM(pp, reason);
577
578 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
579 }
580
btsnd_hcic_setup_iso_data_path(uint16_t iso_handle,uint8_t data_path_dir,uint8_t data_path_id,uint8_t codec_id_format,uint16_t codec_id_company,uint16_t codec_id_vendor,uint32_t controller_delay,std::vector<uint8_t> codec_conf,base::OnceCallback<void (uint8_t *,uint16_t)> cb)581 void btsnd_hcic_setup_iso_data_path(
582 uint16_t iso_handle, uint8_t data_path_dir, uint8_t data_path_id,
583 uint8_t codec_id_format, uint16_t codec_id_company,
584 uint16_t codec_id_vendor, uint32_t controller_delay,
585 std::vector<uint8_t> codec_conf,
586 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
587 const int params_len = 13 + codec_conf.size();
588 uint8_t param[params_len];
589 uint8_t* pp = param;
590
591 UINT16_TO_STREAM(pp, iso_handle);
592 UINT8_TO_STREAM(pp, data_path_dir);
593 UINT8_TO_STREAM(pp, data_path_id);
594 UINT8_TO_STREAM(pp, codec_id_format);
595 UINT16_TO_STREAM(pp, codec_id_company);
596 UINT16_TO_STREAM(pp, codec_id_vendor);
597 UINT24_TO_STREAM(pp, controller_delay);
598 UINT8_TO_STREAM(pp, codec_conf.size());
599 ARRAY_TO_STREAM(pp, codec_conf.data(), static_cast<int>(codec_conf.size()));
600
601 btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_SETUP_ISO_DATA_PATH, param,
602 params_len, std::move(cb));
603 }
604
btsnd_hcic_remove_iso_data_path(uint16_t iso_handle,uint8_t data_path_dir,base::OnceCallback<void (uint8_t *,uint16_t)> cb)605 void btsnd_hcic_remove_iso_data_path(
606 uint16_t iso_handle, uint8_t data_path_dir,
607 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
608 const int params_len = 3;
609 uint8_t param[params_len];
610 uint8_t* pp = param;
611
612 UINT16_TO_STREAM(pp, iso_handle);
613 UINT8_TO_STREAM(pp, data_path_dir);
614
615 btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_REMOVE_ISO_DATA_PATH, param,
616 params_len, std::move(cb));
617 }
618
btsnd_hcic_read_iso_link_quality(uint16_t iso_handle,base::OnceCallback<void (uint8_t *,uint16_t)> cb)619 void btsnd_hcic_read_iso_link_quality(
620 uint16_t iso_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
621 const int params_len = 2;
622 uint8_t param[params_len];
623 uint8_t* pp = param;
624
625 UINT16_TO_STREAM(pp, iso_handle);
626
627 btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_READ_ISO_LINK_QUALITY, param,
628 params_len, std::move(cb));
629 }
630
btsnd_hcic_ble_periodic_advertising_create_sync(uint8_t options,uint8_t adv_sid,uint8_t adv_addr_type,const RawAddress & adv_addr,uint16_t skip_num,uint16_t sync_timeout,uint8_t sync_cte_type)631 void btsnd_hcic_ble_periodic_advertising_create_sync(
632 uint8_t options, uint8_t adv_sid, uint8_t adv_addr_type,
633 const RawAddress& adv_addr, uint16_t skip_num, uint16_t sync_timeout,
634 uint8_t sync_cte_type) {
635 BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE);
636 uint8_t* pp = (uint8_t*)(p + 1);
637
638 p->len =
639 HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_CREATE_SYNC;
640 p->offset = 0;
641
642 UINT16_TO_STREAM(pp, HCI_BLE_PERIODIC_ADVERTISING_CREATE_SYNC);
643 UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_CREATE_SYNC);
644 UINT8_TO_STREAM(pp, options);
645 UINT8_TO_STREAM(pp, adv_sid);
646 UINT8_TO_STREAM(pp, adv_addr_type);
647 BDADDR_TO_STREAM(pp, adv_addr);
648 UINT16_TO_STREAM(pp, skip_num);
649 UINT16_TO_STREAM(pp, sync_timeout);
650 UINT8_TO_STREAM(pp, sync_cte_type);
651
652 btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
653 }
654
btsnd_hcic_ble_periodic_advertising_create_sync_cancel(base::OnceCallback<void (uint8_t *,uint16_t)> cb)655 void btsnd_hcic_ble_periodic_advertising_create_sync_cancel(
656 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
657 btu_hcif_send_cmd_with_cb(
658 FROM_HERE, HCI_BLE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL, nullptr,
659 HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL, std::move(cb));
660 }
661
btsnd_hcic_ble_periodic_advertising_terminate_sync(uint16_t sync_handle,base::OnceCallback<void (uint8_t *,uint16_t)> cb)662 void btsnd_hcic_ble_periodic_advertising_terminate_sync(
663 uint16_t sync_handle, base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
664 uint8_t param[HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_TERMINATE_SYNC];
665 uint8_t* pp = param;
666
667 UINT16_TO_STREAM(pp, sync_handle);
668
669 btu_hcif_send_cmd_with_cb(
670 FROM_HERE, HCI_BLE_PERIODIC_ADVERTISING_TERMINATE_SYNC, param,
671 HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_TERMINATE_SYNC, std::move(cb));
672 }
673
btsnd_hci_ble_add_device_to_periodic_advertiser_list(uint8_t adv_addr_type,const RawAddress & adv_addr,uint8_t adv_sid,base::OnceCallback<void (uint8_t *,uint16_t)> cb)674 void btsnd_hci_ble_add_device_to_periodic_advertiser_list(
675 uint8_t adv_addr_type, const RawAddress& adv_addr, uint8_t adv_sid,
676 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
677 uint8_t param[HCIC_PARAM_SIZE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST];
678 uint8_t* pp = param;
679
680 UINT8_TO_STREAM(pp, adv_addr_type);
681 BDADDR_TO_STREAM(pp, adv_addr);
682 UINT8_TO_STREAM(pp, adv_sid);
683
684 btu_hcif_send_cmd_with_cb(
685 FROM_HERE, HCI_BLE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST, param,
686 HCIC_PARAM_SIZE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST, std::move(cb));
687 }
688
btsnd_hci_ble_remove_device_from_periodic_advertiser_list(uint8_t adv_addr_type,const RawAddress & adv_addr,uint8_t adv_sid,base::OnceCallback<void (uint8_t *,uint16_t)> cb)689 void btsnd_hci_ble_remove_device_from_periodic_advertiser_list(
690 uint8_t adv_addr_type, const RawAddress& adv_addr, uint8_t adv_sid,
691 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
692 uint8_t param[HCIC_PARAM_SIZE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST];
693 uint8_t* pp = param;
694
695 UINT8_TO_STREAM(pp, adv_addr_type);
696 BDADDR_TO_STREAM(pp, adv_addr);
697 UINT8_TO_STREAM(pp, adv_sid);
698
699 btu_hcif_send_cmd_with_cb(
700 FROM_HERE, HCI_BLE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST, param,
701 HCIC_PARAM_SIZE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST,
702 std::move(cb));
703 }
704
btsnd_hci_ble_clear_periodic_advertiser_list(base::OnceCallback<void (uint8_t *,uint16_t)> cb)705 void btsnd_hci_ble_clear_periodic_advertiser_list(
706 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
707 btu_hcif_send_cmd_with_cb(
708 FROM_HERE, HCI_BLE_CLEAR_PERIODIC_ADVERTISER_LIST, nullptr,
709 HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADVERTISER_LIST, std::move(cb));
710 }
711
btsnd_hcic_ble_set_periodic_advertising_receive_enable(uint16_t sync_handle,bool enable,base::OnceCallback<void (uint8_t *,uint16_t)> cb)712 void btsnd_hcic_ble_set_periodic_advertising_receive_enable(
713 uint16_t sync_handle, bool enable,
714 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
715 uint8_t param[HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE];
716 uint8_t* pp = param;
717
718 UINT16_TO_STREAM(pp, sync_handle);
719 UINT8_TO_STREAM(pp, (enable ? 0x01 : 0x00));
720
721 btu_hcif_send_cmd_with_cb(
722 FROM_HERE, HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE, param,
723 HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE, std::move(cb));
724 }
725
btsnd_hcic_ble_periodic_advertising_sync_transfer(uint16_t conn_handle,uint16_t service_data,uint16_t sync_handle,base::OnceCallback<void (uint8_t *,uint16_t)> cb)726 void btsnd_hcic_ble_periodic_advertising_sync_transfer(
727 uint16_t conn_handle, uint16_t service_data, uint16_t sync_handle,
728 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
729 uint8_t param[HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SYNC_TRANSFER];
730 uint8_t* pp = param;
731
732 UINT16_TO_STREAM(pp, conn_handle);
733 UINT16_TO_STREAM(pp, service_data);
734 UINT16_TO_STREAM(pp, sync_handle);
735
736 btu_hcif_send_cmd_with_cb(
737 FROM_HERE, HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER, param,
738 HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SYNC_TRANSFER, std::move(cb));
739 }
740
btsnd_hcic_ble_periodic_advertising_set_info_transfer(uint16_t conn_handle,uint16_t service_data,uint8_t adv_handle,base::OnceCallback<void (uint8_t *,uint16_t)> cb)741 void btsnd_hcic_ble_periodic_advertising_set_info_transfer(
742 uint16_t conn_handle, uint16_t service_data, uint8_t adv_handle,
743 base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
744 uint8_t param[HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER];
745 uint8_t* pp = param;
746
747 UINT16_TO_STREAM(pp, conn_handle);
748 UINT16_TO_STREAM(pp, service_data);
749 UINT8_TO_STREAM(pp, adv_handle);
750
751 btu_hcif_send_cmd_with_cb(
752 FROM_HERE, HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER, param,
753 HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER, std::move(cb));
754 }
755
btsnd_hcic_ble_set_periodic_advertising_sync_transfer_params(uint16_t conn_handle,uint8_t mode,uint16_t skip,uint16_t sync_timeout,uint8_t cte_type,base::OnceCallback<void (uint8_t *,uint16_t)> cb)756 void btsnd_hcic_ble_set_periodic_advertising_sync_transfer_params(
757 uint16_t conn_handle, uint8_t mode, uint16_t skip, uint16_t sync_timeout,
758 uint8_t cte_type, base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
759 uint8_t param[HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS];
760 uint8_t* pp = param;
761
762 UINT16_TO_STREAM(pp, conn_handle);
763 UINT8_TO_STREAM(pp, mode);
764 UINT16_TO_STREAM(pp, skip);
765 UINT16_TO_STREAM(pp, sync_timeout);
766 UINT8_TO_STREAM(pp, cte_type);
767
768 btu_hcif_send_cmd_with_cb(
769 FROM_HERE, HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAM, param,
770 HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS,
771 std::move(cb));
772 }
773
btsnd_hcic_ble_set_default_periodic_advertising_sync_transfer_params(uint16_t conn_handle,uint8_t mode,uint16_t skip,uint16_t sync_timeout,uint8_t cte_type,base::OnceCallback<void (uint8_t *,uint16_t)> cb)774 void btsnd_hcic_ble_set_default_periodic_advertising_sync_transfer_params(
775 uint16_t conn_handle, uint8_t mode, uint16_t skip, uint16_t sync_timeout,
776 uint8_t cte_type, base::OnceCallback<void(uint8_t*, uint16_t)> cb) {
777 uint8_t param
778 [HCIC_PARAM_SIZE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS];
779 uint8_t* pp = param;
780
781 UINT16_TO_STREAM(pp, conn_handle);
782 UINT8_TO_STREAM(pp, mode);
783 UINT16_TO_STREAM(pp, skip);
784 UINT16_TO_STREAM(pp, sync_timeout);
785 UINT8_TO_STREAM(pp, cte_type);
786
787 btu_hcif_send_cmd_with_cb(
788 FROM_HERE, HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAM,
789 param,
790 HCIC_PARAM_SIZE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS,
791 std::move(cb));
792 }
793