hciblecmds.cc revision 911d1ae03efec2d54c3b1b605589d790d1745488
15738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 25738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 35738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Copyright (C) 1999-2012 Broadcom Corporation 45738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 55738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 65738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * you may not use this file except in compliance with the License. 75738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * You may obtain a copy of the License at: 85738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 95738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 135738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * See the License for the specific language governing permissions and 155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * limitations under the License. 165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/****************************************************************************** 205738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 215738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * This file contains function of the HCIC unit to format and send HCI 225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * commands. 235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project * 245738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project ******************************************************************************/ 255738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 26258c2538e3b62a8cdb403f2730c45d721e5292b4Pavlin Radoslavov#include "bt_common.h" 27911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#include "bt_target.h" 28911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson#include "btu.h" 295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "hcidefs.h" 305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include "hcimsgs.h" 315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <stddef.h> 335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#include <string.h> 345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 35911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_local_used_feat(uint8_t feat_set[8]) { 36911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 37911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 39911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_USED_FEAT_CMD; 40911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 42911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_LOCAL_SPT_FEAT); 43911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, feat_set, HCIC_PARAM_SIZE_SET_USED_FEAT_CMD); 445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 45911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 48911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_random_addr(BD_ADDR random_bda) { 49911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 50911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 52911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD; 53911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 55911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_RANDOM_ADDR); 56911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD); 575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 58911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, random_bda); 595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 60911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 63911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_write_adv_params(uint16_t adv_int_min, uint16_t adv_int_max, 64911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t adv_type, uint8_t addr_type_own, 65911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t addr_type_dir, BD_ADDR direct_bda, 66911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t channel_map, 67911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t adv_filter_policy) { 68911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 69911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 71911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS; 72911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 74911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_ADV_PARAMS); 75911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS); 765738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 77911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, adv_int_min); 78911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, adv_int_max); 79911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, adv_type); 80911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_own); 81911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_dir); 82911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, direct_bda); 83911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, channel_map); 84911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, adv_filter_policy); 855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 86911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 875738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 88911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_read_adv_chnl_tx_power(void) { 89911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 90911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 92911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; 93911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 95911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_READ_ADV_CHNL_TX_POWER); 96911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_CMD); 975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 98911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 101911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_adv_data(uint8_t data_len, uint8_t* p_data) { 102911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 103911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 1045738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 105911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1; 106911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 1075738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 108911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_ADV_DATA); 109911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1); 1105738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 111911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA); 1125738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 113911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson if (p_data != NULL && data_len > 0) { 114911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA) 115911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson data_len = HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA; 1165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 117911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, data_len); 1185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 119911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, p_data, data_len); 120911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson } 121911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 1225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 123911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_scan_rsp_data(uint8_t data_len, uint8_t* p_scan_rsp) { 124911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 125911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 1265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 127911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1; 128911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 1295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 130911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_SCAN_RSP_DATA); 131911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1); 1325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 133911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson memset(pp, 0, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP); 1345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 135911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson if (p_scan_rsp != NULL && data_len > 0) { 136911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson if (data_len > HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP) 137911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson data_len = HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP; 1385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 139911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, data_len); 1405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 141911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, p_scan_rsp, data_len); 142911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson } 1435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 144911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 1455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 147911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_adv_enable(uint8_t adv_enable) { 148911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 149911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 1505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 151911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_ADV_ENABLE; 152911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 1535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 154911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_ADV_ENABLE); 155911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_ADV_ENABLE); 1565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 157911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, adv_enable); 1585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 159911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 1605738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 161911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_scan_params(uint8_t scan_type, uint16_t scan_int, 162911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t scan_win, uint8_t addr_type_own, 163911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t scan_filter_policy) { 164911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 165911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 1665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 167911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM; 168911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 1695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 170911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_SCAN_PARAMS); 171911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM); 1725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 173911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, scan_type); 174911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, scan_int); 175911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, scan_win); 176911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_own); 177911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, scan_filter_policy); 1785738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 179911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 1805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1815738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 182911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_scan_enable(uint8_t scan_enable, uint8_t duplicate) { 183911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 184911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 1855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 186911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE; 187911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 1885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 189911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_WRITE_SCAN_ENABLE); 190911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE); 1915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 192911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, scan_enable); 193911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, duplicate); 1945738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 195911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 1965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 1975738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 1985738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* link layer connection management commands */ 199911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_create_ll_conn(uint16_t scan_int, uint16_t scan_win, 200911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t init_filter_policy, 201911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t addr_type_peer, BD_ADDR bda_peer, 202911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t addr_type_own, uint16_t conn_int_min, 203911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_int_max, uint16_t conn_latency, 204911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_timeout, uint16_t min_ce_len, 205911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t max_ce_len) { 206911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 207911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 2085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 209911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN; 210911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 2115738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 212911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_CREATE_LL_CONN); 213911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_CREATE_LL_CONN); 2145738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 215911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, scan_int); 216911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, scan_win); 217911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, init_filter_policy); 2185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 219911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_peer); 220911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, bda_peer); 221911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_own); 2225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 223911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_int_min); 224911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_int_max); 225911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_latency); 226911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_timeout); 2275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 228911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, min_ce_len); 229911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, max_ce_len); 2305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 231911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 2325738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 234911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_create_conn_cancel(void) { 235911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 236911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 2375738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 238911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL; 239911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 2405738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 241911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_CREATE_CONN_CANCEL); 242911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_CREATE_CONN_CANCEL); 2435738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 244911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 2455738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 247911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_clear_white_list(void) { 248911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 249911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 2505738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 251911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_CLEAR_WHITE_LIST; 252911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 2535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 254911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_WHITE_LIST); 255911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_WHITE_LIST); 2565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 257911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 2585738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 260911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_add_white_list(uint8_t addr_type, BD_ADDR bda) { 261911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 262911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 2635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 264911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_ADD_WHITE_LIST; 265911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 2665738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 267911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_ADD_WHITE_LIST); 268911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ADD_WHITE_LIST); 2695738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 270911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type); 271911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, bda); 2725738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 273911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 2745738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2755738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 276911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_remove_from_white_list(uint8_t addr_type, BD_ADDR bda) { 277911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 278911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 2795738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 280911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_REMOVE_WHITE_LIST; 281911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 2825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 283911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_WHITE_LIST); 284911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_REMOVE_WHITE_LIST); 2855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 286911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type); 287911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, bda); 2885738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 289911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 2905738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 2915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 292911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_upd_ll_conn_params(uint16_t handle, uint16_t conn_int_min, 293911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_int_max, 294911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_latency, 295911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_timeout, 296911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t min_ce_len, 297911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t max_ce_len) { 298911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 299911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 3005738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 301911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS; 302911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 3035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 304911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_UPD_LL_CONN_PARAMS); 305911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_UPD_LL_CONN_PARAMS); 3065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 307911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 3085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 309911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_int_min); 310911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_int_max); 311911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_latency); 312911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_timeout); 313911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, min_ce_len); 314911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, max_ce_len); 3155738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 316911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 3175738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3185738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 319911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_host_chnl_class( 320911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t chnl_map[HCIC_BLE_CHNL_MAP_SIZE]) { 321911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 322911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 3235738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 324911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS; 325911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 3265738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 327911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_SET_HOST_CHNL_CLASS); 328911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_HOST_CHNL_CLASS); 3295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 330911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, chnl_map, HCIC_BLE_CHNL_MAP_SIZE); 3315738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 332911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 3335738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3345738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 335911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_read_chnl_map(uint16_t handle) { 336911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 337911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 3385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 339911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CHNL_MAP; 340911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 3415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 342911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_READ_CHNL_MAP); 343911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_CHNL_MAP); 3445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 345911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 3465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 347911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 3485738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3495738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 350911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_read_remote_feat(uint16_t handle) { 351911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 352911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 3535738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 354911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT; 355911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 3565738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 357911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_READ_REMOTE_FEAT); 358911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_READ_REMOTE_FEAT); 3595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 360911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 3615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 362911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 3635738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3645738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 3655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project/* security management commands */ 366911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_encrypt(uint8_t* key, uint8_t key_len, uint8_t* plain_text, 367911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t pt_len, void* p_cmd_cplt_cback) { 368911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 369911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 3705738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 371911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ENCRYPT; 372911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = sizeof(void*); 3735738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 374911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson *((void**)pp) = 375911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p_cmd_cplt_cback; /* Store command complete callback in buffer */ 376911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson pp += sizeof(void*); /* Skip over callback pointer */ 3775738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 378911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_ENCRYPT); 379911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_ENCRYPT); 3805738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 381911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson memset(pp, 0, HCIC_PARAM_SIZE_BLE_ENCRYPT); 3825738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 383911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson if (key_len > HCIC_BLE_ENCRYT_KEY_SIZE) key_len = HCIC_BLE_ENCRYT_KEY_SIZE; 384911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson if (pt_len > HCIC_BLE_ENCRYT_KEY_SIZE) pt_len = HCIC_BLE_ENCRYT_KEY_SIZE; 3855738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 386911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, key, key_len); 387911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson pp += (HCIC_BLE_ENCRYT_KEY_SIZE - key_len); 388911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, plain_text, pt_len); 3895738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 390911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 3915738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 3925738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 393911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_rand(void* p_cmd_cplt_cback) { 394911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 395911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 3965738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 397911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RAND; 398911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = sizeof(void*); 3995738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 400911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson *((void**)pp) = 401911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p_cmd_cplt_cback; /* Store command complete callback in buffer */ 402911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson pp += sizeof(void*); /* Skip over callback pointer */ 4035738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 404911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_RAND); 405911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_RAND); 4065738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 407911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 4085738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4095738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 410911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_start_enc(uint16_t handle, 411911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t rand[HCIC_BLE_RAND_DI_SIZE], 412911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t ediv, 413911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t ltk[HCIC_BLE_ENCRYT_KEY_SIZE]) { 414911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 415911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 4165738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 417911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_START_ENC; 418911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 4195738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 420911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_START_ENC); 421911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_START_ENC); 4225738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 423911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 424911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, rand, HCIC_BLE_RAND_DI_SIZE); 425911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, ediv); 426911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE); 4275738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 428911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 4295738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4305738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 431911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_ltk_req_reply(uint16_t handle, 432911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t ltk[HCIC_BLE_ENCRYT_KEY_SIZE]) { 433911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 434911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 4355738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 436911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_REPLY; 437911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 4385738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 439911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_LTK_REQ_REPLY); 440911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_LTK_REQ_REPLY); 4415738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 442911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 443911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, ltk, HCIC_BLE_ENCRYT_KEY_SIZE); 4445738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 445911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 4465738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4475738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 448911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_ltk_req_neg_reply(uint16_t handle) { 449911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 450911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 4515738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 452911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY; 453911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 4545738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 455911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_LTK_REQ_NEG_REPLY); 456911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_LTK_REQ_NEG_REPLY); 4575738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 458911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 4595738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 460911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 4615738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project} 4625738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project 463911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_receiver_test(uint8_t rx_freq) { 464911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 465911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 466ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 467911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM1; 468911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 469ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 470911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_RECEIVER_TEST); 471911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_PARAM1); 472ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 473911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, rx_freq); 474ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 475911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 476ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 477ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 478911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_transmitter_test(uint8_t tx_freq, uint8_t test_data_len, 479911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t payload) { 480911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 481911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 482ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 483911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_PARAM3; 484911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 485ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 486911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_TRANSMITTER_TEST); 487911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_PARAM3); 488ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 489911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, tx_freq); 490911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, test_data_len); 491911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, payload); 492ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 493911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 494ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 495ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 496911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_test_end(void) { 497911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 498911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 499ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 500911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; 501911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 502ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 503911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_TEST_END); 504911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_CMD); 505ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 506911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 507ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 508ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 509911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_read_host_supported(void) { 510911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 511911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 512ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 513911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_READ_CMD; 514911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 515ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 516911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_READ_LE_HOST_SUPPORT); 517911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_CMD); 518ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 519911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 520ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta} 521ead3cde4bac0c3e32cd31f149093f004eef8ceebGanesh Ganapathi Batta 522d19e0785e662e640191a075eda07acce61c2aedaMarie Janssen#if (BLE_LLT_INCLUDED == TRUE) 5237fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 524911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_rc_param_req_reply(uint16_t handle, uint16_t conn_int_min, 525911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_int_max, 526911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_latency, 527911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t conn_timeout, 528911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t min_ce_len, 529911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t max_ce_len) { 530911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 531911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 5327fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 533911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY; 534911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 5357fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 536911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_RC_PARAM_REQ_REPLY); 537911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_REPLY); 5387fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 539911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 540911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_int_min); 541911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_int_max); 542911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_latency); 543911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_timeout); 544911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, min_ce_len); 545911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, max_ce_len); 5467fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 547911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 5487fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta} 5497fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 550911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_rc_param_req_neg_reply(uint16_t handle, uint8_t reason) { 551911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 552911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 5537fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 554911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY; 555911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 5567fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 557911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_RC_PARAM_REQ_NEG_REPLY); 558911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_RC_PARAM_REQ_NEG_REPLY); 5597fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 560911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, handle); 561911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, reason); 5627fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 563911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 5647fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta} 5655738f83aeb59361a0a2eda2460113f6dc919427The Android Open Source Project#endif 5667fa4fba6f59f97df00aff07dbe8fb21b114b3c2cGanesh Ganapathi Batta 567911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_add_device_resolving_list( 568911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t addr_type_peer, BD_ADDR bda_peer, 569911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t irk_peer[HCIC_BLE_IRK_SIZE], uint8_t irk_local[HCIC_BLE_IRK_SIZE]) { 570911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 571911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 572444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 573911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST; 574911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 575444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 576911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_ADD_DEV_RESOLVING_LIST); 577911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_ADD_DEV_RESOLVING_LIST); 578911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_peer); 579911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, bda_peer); 580911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, irk_peer, HCIC_BLE_ENCRYT_KEY_SIZE); 581911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson ARRAY_TO_STREAM(pp, irk_local, HCIC_BLE_ENCRYT_KEY_SIZE); 582444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 583911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 584444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji} 585444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 586911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_rm_device_resolving_list(uint8_t addr_type_peer, 587911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR bda_peer) { 588911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 589911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 590444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 591911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST; 592911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 593444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 594911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_RM_DEV_RESOLVING_LIST); 595911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_RM_DEV_RESOLVING_LIST); 596911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_peer); 597911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, bda_peer); 598444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 599911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 600444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji} 601444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 602911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_clear_resolving_list(void) { 603911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 604911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 605444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 606911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST; 607911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 608444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 609911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_RESOLVING_LIST); 610911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_CLEAR_RESOLVING_LIST); 611444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 612911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 613444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji} 614444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 615911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_read_resolvable_addr_peer(uint8_t addr_type_peer, 616911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR bda_peer) { 617911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 618911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 619444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 620911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER; 621911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 622444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 623911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_READ_RESOLVABLE_ADDR_PEER); 624911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_PEER); 625911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_peer); 626911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, bda_peer); 627444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 628911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 629444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji} 630444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 631911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_read_resolvable_addr_local(uint8_t addr_type_peer, 632911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BD_ADDR bda_peer) { 633911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 634911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 635444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 636911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL; 637911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 638444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 639911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL); 640911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_READ_RESOLVABLE_ADDR_LOCAL); 641911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_type_peer); 642911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BDADDR_TO_STREAM(pp, bda_peer); 643444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 644911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 645444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji} 646444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 647911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_addr_resolution_enable(uint8_t addr_resolution_enable) { 648911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 649911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 650444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 651911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE; 652911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 653444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 654911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_SET_ADDR_RESOLUTION_ENABLE); 655911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_ADDR_RESOLUTION_ENABLE); 656911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, addr_resolution_enable); 657444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 658911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 659444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji} 660444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 661911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_rand_priv_addr_timeout(uint16_t rpa_timout) { 662911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 663911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 664444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 665911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT; 666911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 667444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 668911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT); 669911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_RAND_PRIV_ADDR_TIMOUT); 670911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, rpa_timout); 671444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 672911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 673444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji} 674444a8da807abaf5f9e813ce70c56a79160495fb3Satya Calloji 675911d1ae03efec2d54c3b1b605589d790d1745488Myles Watsonvoid btsnd_hcic_ble_set_data_length(uint16_t conn_handle, uint16_t tx_octets, 676911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint16_t tx_time) { 677911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); 678911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson uint8_t* pp = (uint8_t*)(p + 1); 679636d6714a4c08dd99d2147dcce05dc3892e804b4Priti Aghera 680911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH; 681911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson p->offset = 0; 682636d6714a4c08dd99d2147dcce05dc3892e804b4Priti Aghera 683911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, HCI_BLE_SET_DATA_LENGTH); 684911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH); 685636d6714a4c08dd99d2147dcce05dc3892e804b4Priti Aghera 686911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, conn_handle); 687911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, tx_octets); 688911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson UINT16_TO_STREAM(pp, tx_time); 689636d6714a4c08dd99d2147dcce05dc3892e804b4Priti Aghera 690911d1ae03efec2d54c3b1b605589d790d1745488Myles Watson btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); 691636d6714a4c08dd99d2147dcce05dc3892e804b4Priti Aghera} 692