The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 1999-2012 Broadcom Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | /****************************************************************************** |
| 20 | * |
| 21 | * This file contains function of the HCIC unit to format and send HCI |
| 22 | * commands. |
| 23 | * |
| 24 | ******************************************************************************/ |
| 25 | |
| 26 | #include "bt_target.h" |
Pavlin Radoslavov | a11035b | 2015-09-27 20:59:05 -0700 | [diff] [blame] | 27 | #include "bt_common.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 28 | #include "hcidefs.h" |
| 29 | #include "hcimsgs.h" |
| 30 | #include "hcidefs.h" |
| 31 | #include "btu.h" |
| 32 | |
| 33 | #include <stddef.h> |
| 34 | #include <string.h> |
| 35 | |
| 36 | #if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) |
| 37 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 38 | BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]) |
| 39 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 40 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 41 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 42 | |
| 43 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_USED_FEAT_CMD; |
| 44 | p->offset = 0; |
| 45 | |
| 46 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_LOCAL_SPT_FEAT); |
| 47 | ARRAY_TO_STREAM (pp, feat_set, HCIC_PARAM_SIZE_SET_USED_FEAT_CMD); |
| 48 | |
| 49 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 50 | return (TRUE); |
| 51 | } |
| 52 | |
| 53 | BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_bda) |
| 54 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 55 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 56 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 57 | |
| 58 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD; |
| 59 | p->offset = 0; |
| 60 | |
| 61 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_RANDOM_ADDR); |
| 62 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD); |
| 63 | |
| 64 | BDADDR_TO_STREAM (pp, random_bda); |
| 65 | |
| 66 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 67 | return (TRUE); |
| 68 | } |
| 69 | |
| 70 | BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max, |
| 71 | UINT8 adv_type, UINT8 addr_type_own, |
| 72 | UINT8 addr_type_dir, BD_ADDR direct_bda, |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 73 | UINT8 channel_map, UINT8 adv_filter_policy) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 74 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 75 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 76 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 77 | |
| 78 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS ; |
| 79 | p->offset = 0; |
| 80 | |
| 81 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_PARAMS); |
| 82 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS ); |
| 83 | |
| 84 | UINT16_TO_STREAM (pp, adv_int_min); |
| 85 | UINT16_TO_STREAM (pp, adv_int_max); |
| 86 | UINT8_TO_STREAM (pp, adv_type); |
| 87 | UINT8_TO_STREAM (pp, addr_type_own); |
| 88 | UINT8_TO_STREAM (pp, addr_type_dir); |
| 89 | BDADDR_TO_STREAM (pp, direct_bda); |
| 90 | UINT8_TO_STREAM (pp, channel_map); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 91 | UINT8_TO_STREAM (pp, adv_filter_policy); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 92 | |
| 93 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 94 | return (TRUE); |
| 95 | } |
| 96 | BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void) |
| 97 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 98 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 99 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 100 | |
| 101 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; |
| 102 | p->offset = 0; |
| 103 | |
| 104 | UINT16_TO_STREAM (pp, HCI_BLE_READ_ADV_CHNL_TX_POWER); |
| 105 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); |
| 106 | |
| 107 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 108 | return (TRUE); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data) |
| 113 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 114 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 115 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 116 | |
| 117 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1; |
| 118 | p->offset = 0; |
| 119 | |
| 120 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_DATA); |
| 121 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1); |
| 122 | |
| 123 | memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA); |
| 124 | |
| 125 | if (p_data != NULL && data_len > 0) |
| 126 | { |
| 127 | if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA) |
| 128 | data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA; |
| 129 | |
| 130 | UINT8_TO_STREAM (pp, data_len); |
| 131 | |
| 132 | ARRAY_TO_STREAM (pp, p_data, data_len); |
| 133 | } |
| 134 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 135 | |
| 136 | return (TRUE); |
| 137 | } |
| 138 | BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp) |
| 139 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 140 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 141 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 142 | |
| 143 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1; |
| 144 | p->offset = 0; |
| 145 | |
| 146 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_RSP_DATA); |
| 147 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1); |
| 148 | |
| 149 | memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP); |
| 150 | |
| 151 | if (p_scan_rsp != NULL && data_len > 0) |
| 152 | { |
| 153 | |
| 154 | if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP ) |
| 155 | data_len = HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP; |
| 156 | |
| 157 | UINT8_TO_STREAM (pp, data_len); |
| 158 | |
| 159 | ARRAY_TO_STREAM (pp, p_scan_rsp, data_len); |
| 160 | } |
| 161 | |
| 162 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 163 | |
| 164 | return (TRUE); |
| 165 | } |
| 166 | |
| 167 | BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable) |
| 168 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 169 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 170 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 171 | |
| 172 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_ADV_ENABLE; |
| 173 | p->offset = 0; |
| 174 | |
| 175 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_ADV_ENABLE); |
| 176 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_ADV_ENABLE); |
| 177 | |
| 178 | UINT8_TO_STREAM (pp, adv_enable); |
| 179 | |
| 180 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 181 | return (TRUE); |
| 182 | } |
| 183 | BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type, |
| 184 | UINT16 scan_int, UINT16 scan_win, |
| 185 | UINT8 addr_type_own, UINT8 scan_filter_policy) |
| 186 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 187 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 188 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 189 | |
| 190 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM; |
| 191 | p->offset = 0; |
| 192 | |
| 193 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_PARAMS); |
| 194 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM); |
| 195 | |
| 196 | UINT8_TO_STREAM (pp, scan_type); |
| 197 | UINT16_TO_STREAM (pp, scan_int); |
| 198 | UINT16_TO_STREAM (pp, scan_win); |
| 199 | UINT8_TO_STREAM (pp, addr_type_own); |
| 200 | UINT8_TO_STREAM (pp, scan_filter_policy); |
| 201 | |
| 202 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 203 | return (TRUE); |
| 204 | } |
| 205 | |
| 206 | BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate) |
| 207 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 208 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 209 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 210 | |
| 211 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE; |
| 212 | p->offset = 0; |
| 213 | |
| 214 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_SCAN_ENABLE); |
| 215 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE); |
| 216 | |
| 217 | UINT8_TO_STREAM (pp, scan_enable); |
| 218 | UINT8_TO_STREAM (pp, duplicate); |
| 219 | |
| 220 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 221 | return (TRUE); |
| 222 | } |
| 223 | |
Subramanian Srinivasan | 9c9c752 | 2016-07-11 13:01:37 -0700 | [diff] [blame] | 224 | BOOLEAN btsnd_hcic_ble_set_extended_scan_params (UINT8 scan_phys, |
| 225 | UINT8 scan_type, |
| 226 | UINT16 scan_int, UINT16 scan_win, |
| 227 | UINT16 scan_int_coded, UINT16 scan_win_coded, |
| 228 | UINT8 addr_type_own, UINT8 scan_filter_policy) |
| 229 | { |
| 230 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 231 | UINT8 *pp = (UINT8 *)(p + 1); |
| 232 | |
| 233 | if(scan_phys == 0) |
| 234 | scan_phys = HCIC_SCAN_PHY_LE_1M; |
| 235 | |
| 236 | p->offset = 0; |
| 237 | |
| 238 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_EXT_SCAN_PARAMS); |
| 239 | |
| 240 | if((scan_phys == HCIC_SCAN_PHY_LE_1M) || (scan_phys == HCIC_SCAN_PHY_LE_CODED)) |
| 241 | { |
| 242 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_EXT_SCAN_PARAM; |
| 243 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_EXT_SCAN_PARAM); |
| 244 | } |
| 245 | else if(scan_phys == HCIC_SCAN_PHY_LE_1M_CODED) |
| 246 | { |
| 247 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_EXT_SCAN_PARAM + 5; |
| 248 | UINT8_TO_STREAM (pp, (HCIC_PARAM_SIZE_BLE_WRITE_EXT_SCAN_PARAM + 5)); |
| 249 | } |
| 250 | UINT8_TO_STREAM (pp, addr_type_own); |
| 251 | UINT8_TO_STREAM (pp, scan_filter_policy); |
| 252 | UINT8_TO_STREAM (pp, scan_phys); |
| 253 | UINT8_TO_STREAM (pp, scan_type); |
| 254 | UINT16_TO_STREAM (pp, scan_int); |
| 255 | UINT16_TO_STREAM (pp, scan_win); |
| 256 | |
| 257 | |
| 258 | if(scan_phys == HCIC_SCAN_PHY_LE_1M_CODED) |
| 259 | { |
| 260 | UINT8_TO_STREAM (pp, scan_type); |
| 261 | UINT16_TO_STREAM (pp, scan_int_coded); |
| 262 | UINT16_TO_STREAM (pp, scan_win_coded); |
| 263 | } |
| 264 | |
| 265 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 266 | return (TRUE); |
| 267 | } |
| 268 | |
| 269 | BOOLEAN btsnd_hcic_ble_set_extended_scan_enable (UINT8 scan_enable, UINT8 duplicate, |
| 270 | UINT16 duraton, UINT16 period) |
| 271 | { |
| 272 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 273 | UINT8 *pp = (UINT8 *)(p + 1); |
| 274 | |
| 275 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_EXT_SCAN_ENABLE; |
| 276 | p->offset = 0; |
| 277 | |
| 278 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_EXT_SCAN_ENABLE); |
| 279 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_EXT_SCAN_ENABLE); |
| 280 | |
| 281 | UINT8_TO_STREAM (pp, scan_enable); |
| 282 | UINT8_TO_STREAM (pp, duplicate); |
| 283 | UINT16_TO_STREAM (pp, duraton); |
| 284 | UINT16_TO_STREAM (pp, period); |
| 285 | |
| 286 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 287 | return (TRUE); |
| 288 | } |
| 289 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 290 | /* link layer connection management commands */ |
| 291 | BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win, |
| 292 | UINT8 init_filter_policy, |
| 293 | UINT8 addr_type_peer, BD_ADDR bda_peer, |
| 294 | UINT8 addr_type_own, |
| 295 | UINT16 conn_int_min, UINT16 conn_int_max, |
| 296 | UINT16 conn_latency, UINT16 conn_timeout, |
| 297 | UINT16 min_ce_len, UINT16 max_ce_len) |
| 298 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 299 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 300 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 301 | |
| 302 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN; |
| 303 | p->offset = 0; |
| 304 | |
| 305 | UINT16_TO_STREAM (pp, HCI_BLE_CREATE_LL_CONN); |
| 306 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN); |
| 307 | |
| 308 | UINT16_TO_STREAM (pp, scan_int); |
| 309 | UINT16_TO_STREAM (pp, scan_win); |
| 310 | UINT8_TO_STREAM (pp, init_filter_policy); |
| 311 | |
| 312 | UINT8_TO_STREAM (pp, addr_type_peer); |
| 313 | BDADDR_TO_STREAM (pp, bda_peer); |
| 314 | UINT8_TO_STREAM (pp, addr_type_own); |
| 315 | |
| 316 | UINT16_TO_STREAM (pp, conn_int_min); |
| 317 | UINT16_TO_STREAM (pp, conn_int_max); |
| 318 | UINT16_TO_STREAM (pp, conn_latency); |
| 319 | UINT16_TO_STREAM (pp, conn_timeout); |
| 320 | |
| 321 | UINT16_TO_STREAM (pp, min_ce_len); |
| 322 | UINT16_TO_STREAM (pp, max_ce_len); |
| 323 | |
| 324 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 325 | return (TRUE); |
| 326 | } |
| 327 | |
Subramanian Srinivasan | 9c9c752 | 2016-07-11 13:01:37 -0700 | [diff] [blame] | 328 | BOOLEAN btsnd_hcic_ble_ext_create_ll_conn (UINT8 ini_phy, UINT16 scan_int, UINT16 scan_win, |
| 329 | UINT8 init_filter_policy, |
| 330 | UINT8 addr_type_peer, BD_ADDR bda_peer, |
| 331 | UINT8 addr_type_own, |
| 332 | UINT16 conn_int_min, UINT16 conn_int_max, |
| 333 | UINT16 conn_latency, UINT16 conn_timeout, |
| 334 | UINT16 min_ce_len, UINT16 max_ce_len) |
| 335 | { |
| 336 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 337 | UINT8 *pp = (UINT8 *)(p + 1); |
| 338 | |
| 339 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_EXT_CREATE_LL_CONN; |
| 340 | p->offset = 0; |
| 341 | |
| 342 | UINT16_TO_STREAM (pp, HCI_BLE_EXT_CREATE_LL_CONN); |
| 343 | if(ini_phy == HCIC_SCAN_PHY_LE_1M || ini_phy == HCIC_SCAN_PHY_LE_CODED) |
| 344 | { |
| 345 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_EXT_CREATE_LL_CONN; |
| 346 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_EXT_CREATE_LL_CONN); |
| 347 | } |
| 348 | else if(ini_phy == HCIC_SCAN_PHY_LE_1M_CODED) |
| 349 | { |
| 350 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_EXT_CREATE_LL_CONN + 16; |
| 351 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_EXT_CREATE_LL_CONN + 16); |
| 352 | } |
| 353 | |
| 354 | UINT8_TO_STREAM (pp, init_filter_policy); |
| 355 | UINT8_TO_STREAM (pp, addr_type_own); |
| 356 | UINT8_TO_STREAM (pp, addr_type_peer); |
| 357 | BDADDR_TO_STREAM (pp, bda_peer); |
| 358 | UINT8_TO_STREAM (pp, ini_phy); |
| 359 | |
| 360 | UINT16_TO_STREAM (pp, scan_int); |
| 361 | UINT16_TO_STREAM (pp, scan_win); |
| 362 | UINT16_TO_STREAM (pp, conn_int_min); |
| 363 | UINT16_TO_STREAM (pp, conn_int_max); |
| 364 | UINT16_TO_STREAM (pp, conn_latency); |
| 365 | UINT16_TO_STREAM (pp, conn_timeout); |
| 366 | UINT16_TO_STREAM (pp, min_ce_len); |
| 367 | UINT16_TO_STREAM (pp, max_ce_len); |
| 368 | |
| 369 | if(ini_phy == HCIC_SCAN_PHY_LE_1M_CODED) |
| 370 | { |
| 371 | UINT16_TO_STREAM (pp, scan_int); |
| 372 | UINT16_TO_STREAM (pp, scan_win); |
| 373 | UINT16_TO_STREAM (pp, conn_int_min); |
| 374 | UINT16_TO_STREAM (pp, conn_int_max); |
| 375 | UINT16_TO_STREAM (pp, conn_latency); |
| 376 | UINT16_TO_STREAM (pp, conn_timeout); |
| 377 | UINT16_TO_STREAM (pp, min_ce_len); |
| 378 | UINT16_TO_STREAM (pp, max_ce_len); |
| 379 | } |
| 380 | |
| 381 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 382 | return (TRUE); |
| 383 | } |
| 384 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 385 | BOOLEAN btsnd_hcic_ble_create_conn_cancel (void) |
| 386 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 387 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 388 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 389 | |
| 390 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL; |
| 391 | p->offset = 0; |
| 392 | |
| 393 | UINT16_TO_STREAM (pp, HCI_BLE_CREATE_CONN_CANCEL); |
| 394 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL); |
| 395 | |
| 396 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 397 | return (TRUE); |
| 398 | } |
| 399 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 400 | BOOLEAN btsnd_hcic_ble_clear_white_list (void) |
| 401 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 402 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 403 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 404 | |
| 405 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CLEAR_WHITE_LIST; |
| 406 | p->offset = 0; |
| 407 | |
| 408 | UINT16_TO_STREAM (pp, HCI_BLE_CLEAR_WHITE_LIST); |
| 409 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_CLEAR_WHITE_LIST); |
| 410 | |
| 411 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 412 | return (TRUE); |
| 413 | } |
| 414 | |
| 415 | BOOLEAN btsnd_hcic_ble_add_white_list (UINT8 addr_type, BD_ADDR bda) |
| 416 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 417 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 418 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 419 | |
| 420 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ADD_WHITE_LIST; |
| 421 | p->offset = 0; |
| 422 | |
| 423 | UINT16_TO_STREAM (pp, HCI_BLE_ADD_WHITE_LIST); |
| 424 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_ADD_WHITE_LIST); |
| 425 | |
| 426 | UINT8_TO_STREAM (pp, addr_type); |
| 427 | BDADDR_TO_STREAM (pp, bda); |
| 428 | |
| 429 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 430 | return (TRUE); |
| 431 | } |
| 432 | |
| 433 | BOOLEAN btsnd_hcic_ble_remove_from_white_list (UINT8 addr_type, BD_ADDR bda) |
| 434 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 435 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 436 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 437 | |
| 438 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REMOVE_WHITE_LIST; |
| 439 | p->offset = 0; |
| 440 | |
| 441 | UINT16_TO_STREAM (pp, HCI_BLE_REMOVE_WHITE_LIST); |
| 442 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_REMOVE_WHITE_LIST); |
| 443 | |
| 444 | UINT8_TO_STREAM (pp, addr_type); |
| 445 | BDADDR_TO_STREAM (pp, bda); |
| 446 | |
| 447 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 448 | return (TRUE); |
| 449 | } |
| 450 | |
| 451 | BOOLEAN btsnd_hcic_ble_upd_ll_conn_params (UINT16 handle, |
| 452 | UINT16 conn_int_min, UINT16 conn_int_max, |
| 453 | UINT16 conn_latency, UINT16 conn_timeout, |
| 454 | UINT16 min_ce_len, UINT16 max_ce_len) |
| 455 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 456 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 457 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 458 | |
| 459 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS; |
| 460 | p->offset = 0; |
| 461 | |
| 462 | UINT16_TO_STREAM (pp, HCI_BLE_UPD_LL_CONN_PARAMS); |
| 463 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS); |
| 464 | |
| 465 | UINT16_TO_STREAM (pp, handle); |
| 466 | |
| 467 | UINT16_TO_STREAM (pp, conn_int_min); |
| 468 | UINT16_TO_STREAM (pp, conn_int_max); |
| 469 | UINT16_TO_STREAM (pp, conn_latency); |
| 470 | UINT16_TO_STREAM (pp, conn_timeout); |
| 471 | UINT16_TO_STREAM (pp, min_ce_len); |
| 472 | UINT16_TO_STREAM (pp, max_ce_len); |
| 473 | |
| 474 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 475 | return (TRUE); |
| 476 | } |
| 477 | |
| 478 | BOOLEAN btsnd_hcic_ble_set_host_chnl_class (UINT8 chnl_map[HCIC_BLE_CHNL_MAP_SIZE]) |
| 479 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 480 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 481 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 482 | |
| 483 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS; |
| 484 | p->offset = 0; |
| 485 | |
| 486 | UINT16_TO_STREAM (pp, HCI_BLE_SET_HOST_CHNL_CLASS); |
| 487 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS); |
| 488 | |
| 489 | ARRAY_TO_STREAM (pp, chnl_map, HCIC_BLE_CHNL_MAP_SIZE); |
| 490 | |
| 491 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 492 | return (TRUE); |
| 493 | } |
| 494 | |
| 495 | BOOLEAN btsnd_hcic_ble_read_chnl_map (UINT16 handle) |
| 496 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 497 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 498 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 499 | |
| 500 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CHNL_MAP; |
| 501 | p->offset = 0; |
| 502 | |
| 503 | UINT16_TO_STREAM (pp, HCI_BLE_READ_CHNL_MAP); |
| 504 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CHNL_MAP); |
| 505 | |
| 506 | UINT16_TO_STREAM (pp, handle); |
| 507 | |
| 508 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 509 | return (TRUE); |
| 510 | } |
| 511 | |
| 512 | BOOLEAN btsnd_hcic_ble_read_remote_feat (UINT16 handle) |
| 513 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 514 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 515 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 516 | |
| 517 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT; |
| 518 | p->offset = 0; |
| 519 | |
| 520 | UINT16_TO_STREAM (pp, HCI_BLE_READ_REMOTE_FEAT); |
| 521 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT); |
| 522 | |
| 523 | UINT16_TO_STREAM (pp, handle); |
| 524 | |
| 525 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 526 | return (TRUE); |
| 527 | } |
| 528 | |
| 529 | /* security management commands */ |
| 530 | BOOLEAN btsnd_hcic_ble_encrypt (UINT8 *key, UINT8 key_len, |
| 531 | UINT8 *plain_text, UINT8 pt_len, |
| 532 | void *p_cmd_cplt_cback) |
| 533 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 534 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 535 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 536 | |
| 537 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ENCRYPT; |
| 538 | p->offset = sizeof(void *); |
| 539 | |
| 540 | *((void **)pp) = p_cmd_cplt_cback; /* Store command complete callback in buffer */ |
| 541 | pp += sizeof(void *); /* Skip over callback pointer */ |
| 542 | |
| 543 | |
| 544 | UINT16_TO_STREAM (pp, HCI_BLE_ENCRYPT); |
| 545 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_ENCRYPT); |
| 546 | |
| 547 | memset(pp, 0, HCIC_PARAM_SIZE_BLE_ENCRYPT); |
| 548 | |
| 549 | if (key_len > HCIC_BLE_ENCRYT_KEY_SIZE) key_len = HCIC_BLE_ENCRYT_KEY_SIZE; |
| 550 | if (pt_len > HCIC_BLE_ENCRYT_KEY_SIZE) pt_len = HCIC_BLE_ENCRYT_KEY_SIZE; |
| 551 | |
| 552 | ARRAY_TO_STREAM (pp, key, key_len); |
| 553 | pp += (HCIC_BLE_ENCRYT_KEY_SIZE - key_len); |
| 554 | ARRAY_TO_STREAM (pp, plain_text, pt_len); |
| 555 | |
| 556 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 557 | return (TRUE); |
| 558 | } |
| 559 | |
| 560 | BOOLEAN btsnd_hcic_ble_rand (void *p_cmd_cplt_cback) |
| 561 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 562 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 563 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 564 | |
| 565 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RAND; |
| 566 | p->offset = sizeof(void *); |
| 567 | |
| 568 | *((void **)pp) = p_cmd_cplt_cback; /* Store command complete callback in buffer */ |
| 569 | pp += sizeof(void *); /* Skip over callback pointer */ |
| 570 | |
| 571 | UINT16_TO_STREAM (pp, HCI_BLE_RAND); |
| 572 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_RAND); |
| 573 | |
| 574 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 575 | return (TRUE); |
| 576 | } |
| 577 | |
| 578 | BOOLEAN btsnd_hcic_ble_start_enc (UINT16 handle, UINT8 rand[HCIC_BLE_RAND_DI_SIZE], |
| 579 | UINT16 ediv, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]) |
| 580 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 581 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 582 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 583 | |
| 584 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_START_ENC; |
| 585 | p->offset = 0; |
| 586 | |
| 587 | UINT16_TO_STREAM (pp, HCI_BLE_START_ENC); |
| 588 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_START_ENC); |
| 589 | |
| 590 | UINT16_TO_STREAM (pp, handle); |
| 591 | ARRAY_TO_STREAM (pp, rand, HCIC_BLE_RAND_DI_SIZE); |
| 592 | UINT16_TO_STREAM (pp, ediv); |
| 593 | ARRAY_TO_STREAM (pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE); |
| 594 | |
| 595 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 596 | return (TRUE); |
| 597 | } |
| 598 | |
| 599 | BOOLEAN btsnd_hcic_ble_ltk_req_reply (UINT16 handle, UINT8 ltk[HCIC_BLE_ENCRYT_KEY_SIZE]) |
| 600 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 601 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 602 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 603 | |
| 604 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_REPLY; |
| 605 | p->offset = 0; |
| 606 | |
| 607 | UINT16_TO_STREAM (pp, HCI_BLE_LTK_REQ_REPLY); |
| 608 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LTK_REQ_REPLY); |
| 609 | |
| 610 | UINT16_TO_STREAM (pp, handle); |
| 611 | ARRAY_TO_STREAM (pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE); |
| 612 | |
| 613 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 614 | return (TRUE); |
| 615 | } |
| 616 | |
| 617 | BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle) |
| 618 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 619 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 620 | UINT8 *pp = (UINT8 *)(p + 1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 621 | |
| 622 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY; |
| 623 | p->offset = 0; |
| 624 | |
| 625 | UINT16_TO_STREAM (pp, HCI_BLE_LTK_REQ_NEG_REPLY); |
| 626 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY); |
| 627 | |
| 628 | UINT16_TO_STREAM (pp, handle); |
| 629 | |
| 630 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 631 | return (TRUE); |
| 632 | } |
| 633 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 634 | BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq) |
| 635 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 636 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 637 | UINT8 *pp = (UINT8 *)(p + 1); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 638 | |
| 639 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; |
| 640 | p->offset = 0; |
| 641 | |
| 642 | UINT16_TO_STREAM (pp, HCI_BLE_RECEIVER_TEST); |
| 643 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM1); |
| 644 | |
| 645 | UINT8_TO_STREAM (pp, rx_freq); |
| 646 | |
| 647 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 648 | return (TRUE); |
| 649 | } |
| 650 | |
Sunny Kapdi | 3d5a283 | 2017-04-05 17:32:01 -0700 | [diff] [blame] | 651 | BOOLEAN btsnd_hcic_ble_enh_receiver_test(UINT8 rx_freq, UINT8 phy, UINT8 mod_index) |
| 652 | { |
| 653 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 654 | UINT8 *pp = (UINT8 *)(p + 1); |
| 655 | |
| 656 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3; |
| 657 | p->offset = 0; |
| 658 | |
| 659 | UINT16_TO_STREAM (pp, HCI_BLE_ENH_RECEIVER_TEST); |
| 660 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM3); |
| 661 | |
| 662 | UINT8_TO_STREAM (pp, rx_freq); |
| 663 | UINT8_TO_STREAM (pp, phy); |
| 664 | UINT8_TO_STREAM (pp, mod_index); |
| 665 | |
| 666 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 667 | return (TRUE); |
| 668 | } |
| 669 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 670 | BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len, UINT8 payload) |
| 671 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 672 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 673 | UINT8 *pp = (UINT8 *)(p + 1); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 674 | |
| 675 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3; |
| 676 | p->offset = 0; |
| 677 | |
| 678 | UINT16_TO_STREAM (pp, HCI_BLE_TRANSMITTER_TEST); |
| 679 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM3); |
| 680 | |
| 681 | UINT8_TO_STREAM (pp, tx_freq); |
| 682 | UINT8_TO_STREAM (pp, test_data_len); |
| 683 | UINT8_TO_STREAM (pp, payload); |
| 684 | |
| 685 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 686 | return (TRUE); |
| 687 | } |
| 688 | |
Sunny Kapdi | 3d5a283 | 2017-04-05 17:32:01 -0700 | [diff] [blame] | 689 | BOOLEAN btsnd_hcic_ble_enh_transmitter_test(UINT8 tx_freq, UINT8 test_data_len, UINT8 payload, UINT8 phy) |
| 690 | { |
| 691 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 692 | UINT8 *pp = (UINT8 *)(p + 1); |
| 693 | |
| 694 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM4; |
| 695 | p->offset = 0; |
| 696 | |
| 697 | UINT16_TO_STREAM (pp, HCI_BLE_ENH_TRANSMITTER_TEST); |
| 698 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_PARAM4); |
| 699 | |
| 700 | UINT8_TO_STREAM (pp, tx_freq); |
| 701 | UINT8_TO_STREAM (pp, test_data_len); |
| 702 | UINT8_TO_STREAM (pp, payload); |
| 703 | UINT8_TO_STREAM (pp, phy); |
| 704 | |
| 705 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 706 | return (TRUE); |
| 707 | } |
| 708 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 709 | BOOLEAN btsnd_hcic_ble_test_end(void) |
| 710 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 711 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 712 | UINT8 *pp = (UINT8 *)(p + 1); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 713 | |
| 714 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; |
| 715 | p->offset = 0; |
| 716 | |
| 717 | UINT16_TO_STREAM (pp, HCI_BLE_TEST_END); |
| 718 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); |
| 719 | |
| 720 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 721 | return (TRUE); |
| 722 | } |
| 723 | |
| 724 | BOOLEAN btsnd_hcic_ble_read_host_supported (void) |
| 725 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 726 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 727 | UINT8 *pp = (UINT8 *)(p + 1); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 728 | |
| 729 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; |
| 730 | p->offset = 0; |
| 731 | |
Zach Johnson | 30e5806 | 2014-09-26 21:14:34 -0700 | [diff] [blame] | 732 | UINT16_TO_STREAM (pp, HCI_READ_LE_HOST_SUPPORT); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 733 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); |
| 734 | |
| 735 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 736 | return (TRUE); |
| 737 | } |
| 738 | |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 739 | #if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE) |
| 740 | |
| 741 | BOOLEAN btsnd_hcic_ble_rc_param_req_reply( UINT16 handle, |
| 742 | UINT16 conn_int_min, UINT16 conn_int_max, |
| 743 | UINT16 conn_latency, UINT16 conn_timeout, |
| 744 | UINT16 min_ce_len, UINT16 max_ce_len ) |
| 745 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 746 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 747 | UINT8 *pp = (UINT8 *)(p + 1); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 748 | |
| 749 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY; |
| 750 | p->offset = 0; |
| 751 | |
| 752 | UINT16_TO_STREAM (pp, HCI_BLE_RC_PARAM_REQ_REPLY); |
| 753 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY); |
| 754 | |
| 755 | UINT16_TO_STREAM (pp, handle); |
| 756 | UINT16_TO_STREAM (pp, conn_int_min); |
| 757 | UINT16_TO_STREAM (pp, conn_int_max); |
| 758 | UINT16_TO_STREAM (pp, conn_latency); |
| 759 | UINT16_TO_STREAM (pp, conn_timeout); |
| 760 | UINT16_TO_STREAM (pp, min_ce_len); |
| 761 | UINT16_TO_STREAM (pp, max_ce_len); |
| 762 | |
| 763 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 764 | return (TRUE); |
| 765 | } |
| 766 | |
| 767 | BOOLEAN btsnd_hcic_ble_rc_param_req_neg_reply(UINT16 handle, UINT8 reason) |
| 768 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 769 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 770 | UINT8 *pp = (UINT8 *)(p + 1); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 771 | |
| 772 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY; |
| 773 | p->offset = 0; |
| 774 | |
| 775 | UINT16_TO_STREAM (pp, HCI_BLE_RC_PARAM_REQ_NEG_REPLY); |
| 776 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY); |
| 777 | |
| 778 | UINT16_TO_STREAM (pp, handle); |
| 779 | UINT8_TO_STREAM (pp, reason); |
| 780 | |
| 781 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 782 | return (TRUE); |
| 783 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 784 | #endif |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 785 | |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 786 | BOOLEAN btsnd_hcic_ble_add_device_resolving_list (UINT8 addr_type_peer, BD_ADDR bda_peer, |
| 787 | UINT8 irk_peer[HCIC_BLE_IRK_SIZE], |
| 788 | UINT8 irk_local[HCIC_BLE_IRK_SIZE]) |
| 789 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 790 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 791 | UINT8 *pp = (UINT8 *)(p + 1); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 792 | |
| 793 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST; |
| 794 | p->offset = 0; |
| 795 | |
| 796 | UINT16_TO_STREAM (pp, HCI_BLE_ADD_DEV_RESOLVING_LIST); |
| 797 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST); |
| 798 | UINT8_TO_STREAM (pp, addr_type_peer); |
| 799 | BDADDR_TO_STREAM (pp, bda_peer); |
| 800 | ARRAY_TO_STREAM (pp, irk_peer, HCIC_BLE_ENCRYT_KEY_SIZE); |
| 801 | ARRAY_TO_STREAM (pp, irk_local, HCIC_BLE_ENCRYT_KEY_SIZE); |
| 802 | |
| 803 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 804 | |
| 805 | return (TRUE); |
| 806 | } |
| 807 | |
| 808 | BOOLEAN btsnd_hcic_ble_rm_device_resolving_list (UINT8 addr_type_peer, BD_ADDR bda_peer) |
| 809 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 810 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 811 | UINT8 *pp = (UINT8 *)(p + 1); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 812 | |
| 813 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST; |
| 814 | p->offset = 0; |
| 815 | |
| 816 | UINT16_TO_STREAM (pp, HCI_BLE_RM_DEV_RESOLVING_LIST); |
| 817 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST); |
| 818 | UINT8_TO_STREAM (pp, addr_type_peer); |
| 819 | BDADDR_TO_STREAM (pp, bda_peer); |
| 820 | |
| 821 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 822 | |
| 823 | return (TRUE); |
| 824 | } |
| 825 | |
Nitin Arora | 36fa3c5 | 2016-11-02 15:26:09 -0700 | [diff] [blame] | 826 | BOOLEAN btsnd_hcic_ble_set_privacy_mode (UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 privacy_type) |
| 827 | { |
| 828 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 829 | UINT8 *pp = (UINT8 *)(p + 1); |
| 830 | |
| 831 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE; |
| 832 | p->offset = 0; |
| 833 | |
| 834 | UINT16_TO_STREAM (pp, HCI_BLE_SET_PRIVACY_MODE); |
| 835 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_PRIVACY_MODE); |
| 836 | UINT8_TO_STREAM (pp, addr_type_peer); |
| 837 | BDADDR_TO_STREAM (pp, bda_peer); |
| 838 | UINT8_TO_STREAM (pp, privacy_type); |
| 839 | |
| 840 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 841 | |
| 842 | return (TRUE); |
| 843 | } |
| 844 | |
| 845 | |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 846 | BOOLEAN btsnd_hcic_ble_clear_resolving_list (void) |
| 847 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 848 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 849 | UINT8 *pp = (UINT8 *)(p + 1); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 850 | |
| 851 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST; |
| 852 | p->offset = 0; |
| 853 | |
| 854 | UINT16_TO_STREAM (pp, HCI_BLE_CLEAR_RESOLVING_LIST); |
| 855 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST); |
| 856 | |
| 857 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 858 | |
| 859 | return (TRUE); |
| 860 | } |
| 861 | |
| 862 | BOOLEAN btsnd_hcic_ble_read_resolvable_addr_peer (UINT8 addr_type_peer, BD_ADDR bda_peer) |
| 863 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 864 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 865 | UINT8 *pp = (UINT8 *)(p + 1); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 866 | |
| 867 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER; |
| 868 | p->offset = 0; |
| 869 | |
| 870 | UINT16_TO_STREAM (pp, HCI_BLE_READ_RESOLVABLE_ADDR_PEER); |
| 871 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER); |
| 872 | UINT8_TO_STREAM (pp, addr_type_peer); |
| 873 | BDADDR_TO_STREAM (pp, bda_peer); |
| 874 | |
| 875 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 876 | |
| 877 | return (TRUE); |
| 878 | } |
| 879 | |
| 880 | BOOLEAN btsnd_hcic_ble_read_resolvable_addr_local (UINT8 addr_type_peer, BD_ADDR bda_peer) |
| 881 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 882 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 883 | UINT8 *pp = (UINT8 *)(p + 1); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 884 | |
| 885 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL; |
| 886 | p->offset = 0; |
| 887 | |
| 888 | UINT16_TO_STREAM (pp, HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL); |
| 889 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL); |
| 890 | UINT8_TO_STREAM (pp, addr_type_peer); |
| 891 | BDADDR_TO_STREAM (pp, bda_peer); |
| 892 | |
| 893 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 894 | |
| 895 | return (TRUE); |
| 896 | } |
| 897 | |
| 898 | BOOLEAN btsnd_hcic_ble_set_addr_resolution_enable (UINT8 addr_resolution_enable) |
| 899 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 900 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 901 | UINT8 *pp = (UINT8 *)(p + 1); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 902 | |
| 903 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE; |
| 904 | p->offset = 0; |
| 905 | |
| 906 | UINT16_TO_STREAM (pp, HCI_BLE_SET_ADDR_RESOLUTION_ENABLE); |
| 907 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE); |
| 908 | UINT8_TO_STREAM (pp, addr_resolution_enable); |
| 909 | |
| 910 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 911 | |
| 912 | return (TRUE); |
| 913 | } |
| 914 | |
| 915 | BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout) |
| 916 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 917 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 918 | UINT8 *pp = (UINT8 *)(p + 1); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 919 | |
| 920 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT; |
| 921 | p->offset = 0; |
| 922 | |
| 923 | UINT16_TO_STREAM (pp, HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT); |
| 924 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT); |
| 925 | UINT16_TO_STREAM (pp, rpa_timout); |
| 926 | |
| 927 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 928 | |
| 929 | return (TRUE); |
| 930 | } |
| 931 | |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 932 | BOOLEAN btsnd_hcic_ble_set_data_length(UINT16 conn_handle, UINT16 tx_octets, UINT16 tx_time) |
| 933 | { |
Pavlin Radoslavov | c980130 | 2016-02-16 18:16:59 -0800 | [diff] [blame] | 934 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 935 | UINT8 *pp = (UINT8 *)(p + 1); |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 936 | |
| 937 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH; |
| 938 | p->offset = 0; |
| 939 | |
| 940 | UINT16_TO_STREAM(pp, HCI_BLE_SET_DATA_LENGTH); |
| 941 | UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH); |
| 942 | |
| 943 | UINT16_TO_STREAM(pp, conn_handle); |
| 944 | UINT16_TO_STREAM(pp, tx_octets); |
| 945 | UINT16_TO_STREAM(pp, tx_time); |
| 946 | |
| 947 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 948 | return TRUE; |
| 949 | } |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 950 | |
Nitin Arora | 6bcfadd | 2015-10-29 18:21:35 -0700 | [diff] [blame] | 951 | BOOLEAN btsnd_hcic_ble_set_default_data_rate(UINT8 all_phy, UINT8 tx_phy, UINT8 rx_phy) |
| 952 | { |
| 953 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 954 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 955 | |
| 956 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_DEFAULT_PHY; |
| 957 | p->offset = 0; |
| 958 | |
| 959 | UINT16_TO_STREAM(pp, HCI_BLE_SET_DEFAULT_PHY_RATE); |
| 960 | UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_DEFAULT_PHY); |
| 961 | |
| 962 | UINT8_TO_STREAM(pp, all_phy); |
| 963 | UINT8_TO_STREAM(pp, tx_phy); |
| 964 | UINT8_TO_STREAM(pp, rx_phy); |
| 965 | |
| 966 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 967 | return TRUE; |
| 968 | } |
| 969 | |
| 970 | BOOLEAN btsnd_hcic_ble_set_data_rate(UINT16 handle, UINT8 all_phy, UINT8 tx_phy, |
| 971 | UINT8 rx_phy, UINT16 phy_options) |
| 972 | { |
| 973 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 974 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 975 | |
| 976 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_PHY; |
| 977 | p->offset = 0; |
| 978 | |
| 979 | UINT16_TO_STREAM(pp, HCI_BLE_SET_PHY_RATE); |
| 980 | UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_PHY); |
| 981 | |
| 982 | UINT16_TO_STREAM(pp, handle); |
| 983 | UINT8_TO_STREAM(pp, all_phy); |
| 984 | UINT8_TO_STREAM(pp, tx_phy); |
| 985 | UINT8_TO_STREAM(pp, rx_phy); |
| 986 | UINT16_TO_STREAM(pp, phy_options); |
| 987 | |
| 988 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 989 | return TRUE; |
| 990 | } |
| 991 | |
Nitin Arora | bd46d60 | 2016-02-24 18:15:44 -0800 | [diff] [blame] | 992 | BOOLEAN btsnd_hcic_ble_set_extended_adv_params (UINT8 set_id, UINT16 event_properties, |
| 993 | UINT32 adv_int_min, UINT32 adv_int_max, |
| 994 | UINT8 channel_map, UINT8 addr_type_own, |
| 995 | UINT8 addr_type_dir, BD_ADDR direct_bda, |
| 996 | UINT8 adv_filter_policy, UINT8 adv_tx_power, |
| 997 | UINT8 primary_adv_phy, UINT8 secondary_max_skip, |
| 998 | UINT8 secondary_adv_phy, UINT8 advertising_sid, |
| 999 | UINT8 scan_req_not_enb) |
| 1000 | { |
| 1001 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 1002 | UINT8 *pp = (UINT8 *)(p + 1);; |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 1003 | |
Nitin Arora | bd46d60 | 2016-02-24 18:15:44 -0800 | [diff] [blame] | 1004 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_ADV_PARAMS ; |
| 1005 | p->offset = 0; |
| 1006 | |
| 1007 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_EXTENDED_ADV_PARAMS); |
| 1008 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_ADV_PARAMS); |
| 1009 | UINT8_TO_STREAM (pp, set_id); |
| 1010 | UINT16_TO_STREAM (pp, event_properties); |
| 1011 | UINT24_TO_STREAM (pp, adv_int_min); |
| 1012 | UINT24_TO_STREAM (pp, adv_int_max); |
| 1013 | UINT8_TO_STREAM (pp, channel_map); |
| 1014 | UINT8_TO_STREAM (pp, addr_type_own); |
| 1015 | UINT8_TO_STREAM (pp, addr_type_dir); |
| 1016 | BDADDR_TO_STREAM (pp, direct_bda); |
| 1017 | UINT8_TO_STREAM (pp, adv_filter_policy); |
| 1018 | UINT8_TO_STREAM (pp, adv_tx_power); |
| 1019 | UINT8_TO_STREAM (pp, primary_adv_phy); |
| 1020 | UINT8_TO_STREAM (pp, secondary_max_skip); |
| 1021 | UINT8_TO_STREAM (pp, secondary_adv_phy); |
| 1022 | UINT8_TO_STREAM (pp, advertising_sid); |
| 1023 | UINT8_TO_STREAM (pp, scan_req_not_enb); |
| 1024 | |
| 1025 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 1026 | return (TRUE); |
| 1027 | } |
| 1028 | |
| 1029 | BOOLEAN btsnd_hcic_ble_set_extended_adv_data (UINT8 set_id, UINT8 operation, UINT8 fragment_pref, |
| 1030 | UINT8 data_len, UINT8 *p_data) |
| 1031 | { |
| 1032 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 1033 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 1034 | |
| 1035 | p->len = HCIC_PREAMBLE_SIZE + data_len + 4; |
| 1036 | p->offset = 0; |
| 1037 | |
| 1038 | if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_ADV_DATA) |
| 1039 | data_len = HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_ADV_DATA; |
| 1040 | |
| 1041 | |
| 1042 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_EXTENDED_ADV_DATA); |
| 1043 | UINT8_TO_STREAM (pp, data_len + 4); |
| 1044 | UINT8_TO_STREAM (pp, set_id); |
| 1045 | UINT8_TO_STREAM (pp, operation); |
| 1046 | UINT8_TO_STREAM (pp, fragment_pref); |
| 1047 | |
| 1048 | memset(pp, 0, data_len + 1); |
| 1049 | |
| 1050 | if (p_data != NULL && data_len > 0) |
| 1051 | { |
| 1052 | UINT8_TO_STREAM (pp, data_len); |
| 1053 | ARRAY_TO_STREAM (pp, p_data, data_len); |
| 1054 | } |
| 1055 | |
| 1056 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 1057 | return (TRUE); |
| 1058 | } |
| 1059 | |
| 1060 | BOOLEAN btsnd_hcic_ble_set_extended_scan_rsp_data (UINT8 set_id, UINT8 operation, UINT8 fragment_pref, |
| 1061 | UINT8 data_len, UINT8 *p_scan_rsp) |
| 1062 | { |
| 1063 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 1064 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 1065 | |
| 1066 | p->len = HCIC_PREAMBLE_SIZE + data_len + 4; |
| 1067 | p->offset = 0; |
| 1068 | |
| 1069 | if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_RSP ) |
| 1070 | data_len = HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_RSP; |
| 1071 | |
| 1072 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_EXTENDED_SCAN_RSP_DATA); |
| 1073 | UINT8_TO_STREAM (pp, data_len + 4); |
| 1074 | UINT8_TO_STREAM (pp, set_id); |
| 1075 | UINT8_TO_STREAM (pp, operation); |
| 1076 | UINT8_TO_STREAM (pp, fragment_pref); |
| 1077 | |
| 1078 | memset(pp, 0, data_len + 1); |
| 1079 | |
| 1080 | if (p_scan_rsp != NULL && data_len > 0) |
| 1081 | { |
| 1082 | UINT8_TO_STREAM (pp, data_len); |
| 1083 | ARRAY_TO_STREAM (pp, p_scan_rsp, data_len); |
| 1084 | } |
| 1085 | |
| 1086 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 1087 | return (TRUE); |
| 1088 | } |
| 1089 | |
| 1090 | BOOLEAN btsnd_hcic_ble_set_extended_adv_enable (UINT8 adv_enable, UINT8 num_sets, UINT8* handles, |
| 1091 | UINT16* durations, UINT8* max_adv_events) |
| 1092 | { |
| 1093 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 1094 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 1095 | |
| 1096 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_EXTENDED_ADV_ENABLE + num_sets*4; |
| 1097 | p->offset = 0; |
| 1098 | |
| 1099 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_EXTENDED_ADV_ENABLE); |
| 1100 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_EXTENDED_ADV_ENABLE + 4*num_sets); |
| 1101 | |
| 1102 | UINT8_TO_STREAM (pp, adv_enable); |
| 1103 | UINT8_TO_STREAM (pp, num_sets); |
| 1104 | |
| 1105 | if (num_sets > 0) { |
| 1106 | for (UINT8 count = 0; count < num_sets; count++) { |
| 1107 | UINT8_TO_STREAM(pp, handles[count]); |
| 1108 | UINT16_TO_STREAM (pp, durations[count]); |
| 1109 | UINT8_TO_STREAM(pp, max_adv_events[count]); |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 1114 | return (TRUE); |
| 1115 | } |
| 1116 | |
| 1117 | BOOLEAN btsnd_hcic_ble_read_num_adv_sets (void) |
| 1118 | { |
| 1119 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 1120 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 1121 | |
| 1122 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; |
| 1123 | p->offset = 0; |
| 1124 | |
| 1125 | UINT16_TO_STREAM (pp, HCI_BLE_READ_NUM_ADV_SETS); |
| 1126 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); |
| 1127 | |
| 1128 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 1129 | return (TRUE); |
| 1130 | } |
| 1131 | |
| 1132 | BOOLEAN btsnd_hcic_ble_write_extended_rpa (UINT8 set_id, BD_ADDR rpa) |
| 1133 | { |
| 1134 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 1135 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 1136 | |
| 1137 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_EXTENDED_ADV_RPA; |
| 1138 | p->offset = 0; |
| 1139 | |
| 1140 | UINT16_TO_STREAM (pp, HCI_BLE_WRITE_EXTENDED_ADV_RPA); |
| 1141 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_WRITE_EXTENDED_ADV_RPA); |
| 1142 | UINT8_TO_STREAM (pp, set_id); |
| 1143 | BDADDR_TO_STREAM (pp, rpa); |
| 1144 | |
| 1145 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 1146 | return (TRUE); |
| 1147 | } |
| 1148 | |
| 1149 | BOOLEAN btsnd_hcic_ble_read_extended_max_adv_len (void) |
| 1150 | { |
| 1151 | BT_HDR *p = (BT_HDR *)osi_malloc(HCI_CMD_BUF_SIZE); |
| 1152 | UINT8 *pp = (UINT8 *)(p + 1);; |
| 1153 | |
| 1154 | p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; |
| 1155 | p->offset = 0; |
| 1156 | |
| 1157 | UINT16_TO_STREAM (pp, HCI_BLE_READ_MAX_ADV_LENGTH); |
| 1158 | UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_READ_CMD); |
| 1159 | |
| 1160 | btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); |
| 1161 | return (TRUE); |
| 1162 | } |
| 1163 | |
| 1164 | #endif |