The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Jakub Pawlowski | 5b790fe | 2017-09-18 09:00:20 -0700 | [diff] [blame] | 3 | * Copyright 2003-2014 Broadcom Corporation |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 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 is the API implementation file for the BTA device manager. |
| 22 | * |
| 23 | ******************************************************************************/ |
Jakub Pawlowski | 7098432 | 2016-12-16 10:43:49 -0800 | [diff] [blame] | 24 | #include <base/bind_helpers.h> |
Myles Watson | f355ef5 | 2016-11-09 13:04:33 -0800 | [diff] [blame] | 25 | #include <string.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 26 | |
Pavlin Radoslavov | 258c253 | 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 "bta_api.h" |
Jakub Pawlowski | 5b12a83 | 2016-08-11 03:30:47 -0700 | [diff] [blame] | 29 | #include "bta_closure_api.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 30 | #include "bta_dm_int.h" |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 31 | #include "bta_sys.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 32 | #include "bta_sys_int.h" |
| 33 | #include "btm_api.h" |
| 34 | #include "btm_int.h" |
Myles Watson | d7ffd64 | 2016-10-27 10:27:36 -0700 | [diff] [blame] | 35 | #include "osi/include/osi.h" |
Mike J. Chen | 5cd8bff | 2014-01-31 18:16:59 -0800 | [diff] [blame] | 36 | #include "utl.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 37 | |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 38 | using bluetooth::Uuid; |
| 39 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 40 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 41 | * Constants |
| 42 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 43 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 44 | static const tBTA_SYS_REG bta_dm_search_reg = {bta_dm_search_sm_execute, |
| 45 | bta_dm_search_sm_disable}; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 46 | |
| 47 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 48 | * |
| 49 | * Function BTA_EnableBluetooth |
| 50 | * |
| 51 | * Description Enables bluetooth service. This function must be |
| 52 | * called before any other functions in the BTA API are called. |
| 53 | * |
| 54 | * |
| 55 | * Returns tBTA_STATUS |
| 56 | * |
| 57 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 58 | tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK* p_cback) { |
| 59 | /* Bluetooth disabling is in progress */ |
| 60 | if (bta_dm_cb.disabling) return BTA_FAILURE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 61 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 62 | bta_sys_register(BTA_ID_DM_SEARCH, &bta_dm_search_reg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 63 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 64 | /* if UUID list is not provided as static data */ |
| 65 | bta_sys_eir_register(bta_dm_eir_update_uuid); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 66 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 67 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_enable, p_cback)); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 68 | return BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 72 | * |
| 73 | * Function BTA_DisableBluetooth |
| 74 | * |
| 75 | * Description Disables bluetooth service. This function is called when |
| 76 | * the application no longer needs bluetooth service |
| 77 | * |
| 78 | * Returns void |
| 79 | * |
| 80 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 81 | tBTA_STATUS BTA_DisableBluetooth(void) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 82 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_disable)); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 83 | return BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 84 | } |
| 85 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 86 | /** Enables bluetooth device under test mode */ |
| 87 | void BTA_EnableTestMode(void) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 88 | do_in_bta_thread(FROM_HERE, |
| 89 | base::Bind(base::IgnoreResult(BTM_EnableTestMode))); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 90 | } |
| 91 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 92 | /** Disable bluetooth device under test mode */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 93 | void BTA_DisableTestMode(void) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 94 | do_in_bta_thread(FROM_HERE, base::Bind(BTM_DeviceReset, nullptr)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 95 | } |
| 96 | |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 97 | /** This function sets the Bluetooth name of local device */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 98 | void BTA_DmSetDeviceName(char* p_name) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 99 | std::vector<uint8_t> name(BD_NAME_LEN); |
| 100 | strlcpy((char*)name.data(), p_name, BD_NAME_LEN); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 101 | |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 102 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_set_dev_name, name)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 103 | } |
| 104 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 105 | /** This function sets the Bluetooth connectable, discoverable, pairable and |
| 106 | * conn paired only modes of local device |
| 107 | */ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 108 | void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 109 | uint8_t pairable_mode, uint8_t conn_paired_only) { |
| 110 | do_in_bta_thread(FROM_HERE, |
| 111 | base::Bind(bta_dm_set_visibility, disc_mode, conn_mode, |
| 112 | pairable_mode, conn_paired_only)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 116 | * |
| 117 | * Function BTA_DmSearch |
| 118 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 119 | * Description This function searches for peer Bluetooth devices. It |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 120 | * performs an inquiry and gets the remote name for devices. |
| 121 | * Service discovery is done if services is non zero |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 122 | * |
| 123 | * |
| 124 | * Returns void |
| 125 | * |
| 126 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 127 | void BTA_DmSearch(tBTA_DM_INQ* p_dm_inq, tBTA_SERVICE_MASK services, |
| 128 | tBTA_DM_SEARCH_CBACK* p_cback) { |
| 129 | tBTA_DM_API_SEARCH* p_msg = |
| 130 | (tBTA_DM_API_SEARCH*)osi_calloc(sizeof(tBTA_DM_API_SEARCH)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 131 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 132 | p_msg->hdr.event = BTA_DM_API_SEARCH_EVT; |
| 133 | memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ)); |
| 134 | p_msg->services = services; |
| 135 | p_msg->p_cback = p_cback; |
| 136 | p_msg->rs_res = BTA_DM_RS_NONE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 137 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 138 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 139 | } |
| 140 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 141 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 142 | * |
| 143 | * Function BTA_DmSearchCancel |
| 144 | * |
| 145 | * Description This function cancels a search initiated by BTA_DmSearch |
| 146 | * |
| 147 | * |
| 148 | * Returns void |
| 149 | * |
| 150 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 151 | void BTA_DmSearchCancel(void) { |
| 152 | BT_HDR* p_msg = (BT_HDR*)osi_malloc(sizeof(BT_HDR)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 153 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 154 | p_msg->event = BTA_DM_API_SEARCH_CANCEL_EVT; |
| 155 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 159 | * |
| 160 | * Function BTA_DmDiscover |
| 161 | * |
| 162 | * Description This function does service discovery for services of a |
| 163 | * peer device |
| 164 | * |
| 165 | * |
| 166 | * Returns void |
| 167 | * |
| 168 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 169 | void BTA_DmDiscover(const RawAddress& bd_addr, tBTA_SERVICE_MASK services, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 170 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search) { |
| 171 | tBTA_DM_API_DISCOVER* p_msg = |
| 172 | (tBTA_DM_API_DISCOVER*)osi_calloc(sizeof(tBTA_DM_API_DISCOVER)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 173 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 174 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 175 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 176 | p_msg->services = services; |
| 177 | p_msg->p_cback = p_cback; |
| 178 | p_msg->sdp_search = sdp_search; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 179 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 180 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 184 | * |
| 185 | * Function BTA_DmDiscoverUUID |
| 186 | * |
| 187 | * Description This function does service discovery for services of a |
| 188 | * peer device |
| 189 | * |
| 190 | * |
| 191 | * Returns void |
| 192 | * |
| 193 | ******************************************************************************/ |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 194 | void BTA_DmDiscoverUUID(const RawAddress& bd_addr, const Uuid& uuid, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 195 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search) { |
| 196 | tBTA_DM_API_DISCOVER* p_msg = |
| 197 | (tBTA_DM_API_DISCOVER*)osi_malloc(sizeof(tBTA_DM_API_DISCOVER)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 198 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 199 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 200 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 201 | p_msg->services = BTA_USER_SERVICE_MASK; // Not exposed at API level |
| 202 | p_msg->p_cback = p_cback; |
| 203 | p_msg->sdp_search = sdp_search; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 204 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 205 | p_msg->num_uuid = 0; |
| 206 | p_msg->p_uuid = NULL; |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 207 | p_msg->uuid = uuid; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 208 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 209 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 210 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 211 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 212 | /** This function initiates a bonding procedure with a peer device */ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 213 | void BTA_DmBond(const RawAddress& bd_addr) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 214 | do_in_bta_thread(FROM_HERE, |
| 215 | base::Bind(bta_dm_bond, bd_addr, BTA_TRANSPORT_UNKNOWN)); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 218 | /** This function initiates a bonding procedure with a peer device */ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 219 | void BTA_DmBondByTransport(const RawAddress& bd_addr, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 220 | tBTA_TRANSPORT transport) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 221 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_bond, bd_addr, transport)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 222 | } |
| 223 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 224 | /** This function cancels the bonding procedure with a peer device |
| 225 | */ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 226 | void BTA_DmBondCancel(const RawAddress& bd_addr) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 227 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_bond_cancel, bd_addr)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 231 | * |
| 232 | * Function BTA_DmPinReply |
| 233 | * |
| 234 | * Description This function provides a pincode for a remote device when |
| 235 | * one is requested by DM through BTA_DM_PIN_REQ_EVT |
| 236 | * |
| 237 | * |
| 238 | * Returns void |
| 239 | * |
| 240 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 241 | void BTA_DmPinReply(const RawAddress& bd_addr, bool accept, uint8_t pin_len, |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 242 | uint8_t* p_pin) { |
| 243 | std::unique_ptr<tBTA_DM_API_PIN_REPLY> msg = |
| 244 | std::make_unique<tBTA_DM_API_PIN_REPLY>(); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 245 | |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 246 | msg->bd_addr = bd_addr; |
| 247 | msg->accept = accept; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 248 | if (accept) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 249 | msg->pin_len = pin_len; |
| 250 | memcpy(msg->p_pin, p_pin, pin_len); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 251 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 252 | |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 253 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_pin_reply, base::Passed(&msg))); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 254 | } |
| 255 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 256 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 257 | * |
| 258 | * Function BTA_DmLocalOob |
| 259 | * |
| 260 | * Description This function retrieves the OOB data from local controller. |
| 261 | * The result is reported by: |
| 262 | * - bta_dm_co_loc_oob_ext() if device supports secure |
| 263 | * connections (SC) |
| 264 | * - bta_dm_co_loc_oob() if device doesn't support SC |
| 265 | * |
| 266 | * Returns void |
| 267 | * |
| 268 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 269 | void BTA_DmLocalOob(void) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 270 | do_in_bta_thread(FROM_HERE, base::Bind(BTM_ReadLocalOobData)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 271 | } |
Jakub Pawlowski | 175da70 | 2015-11-12 15:00:58 -0800 | [diff] [blame] | 272 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 273 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 274 | * |
| 275 | * Function BTA_DmConfirm |
| 276 | * |
| 277 | * Description This function accepts or rejects the numerical value of the |
| 278 | * Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT |
| 279 | * |
| 280 | * Returns void |
| 281 | * |
| 282 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 283 | void BTA_DmConfirm(const RawAddress& bd_addr, bool accept) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 284 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_confirm, bd_addr, accept)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 288 | * |
| 289 | * Function BTA_DmAddDevice |
| 290 | * |
| 291 | * Description This function adds a device to the security database list of |
| 292 | * peer device |
| 293 | * |
| 294 | * |
| 295 | * Returns void |
| 296 | * |
| 297 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 298 | void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 299 | LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask, |
| 300 | bool is_trusted, uint8_t key_type, tBTA_IO_CAP io_cap, |
| 301 | uint8_t pin_length) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 302 | std::unique_ptr<tBTA_DM_API_ADD_DEVICE> msg = |
| 303 | std::make_unique<tBTA_DM_API_ADD_DEVICE>(); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 304 | |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 305 | msg->bd_addr = bd_addr; |
| 306 | msg->tm = trusted_mask; |
| 307 | msg->is_trusted = is_trusted; |
| 308 | msg->io_cap = io_cap; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 309 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 310 | if (link_key) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 311 | msg->link_key_known = true; |
| 312 | msg->key_type = key_type; |
| 313 | memcpy(msg->link_key, link_key, LINK_KEY_LEN); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 314 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 315 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 316 | /* Load device class if specified */ |
| 317 | if (dev_class) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 318 | msg->dc_known = true; |
| 319 | memcpy(msg->dc, dev_class, DEV_CLASS_LEN); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 320 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 321 | |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 322 | memset(msg->bd_name, 0, BD_NAME_LEN + 1); |
| 323 | memset(msg->features, 0, sizeof(msg->features)); |
| 324 | msg->pin_length = pin_length; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 325 | |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 326 | do_in_bta_thread(FROM_HERE, |
| 327 | base::Bind(bta_dm_add_device, base::Passed(&msg))); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 328 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 329 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 330 | /** This function removes a device fromthe security database list of peer |
| 331 | * device. It manages unpairing even while connected */ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 332 | tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 333 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_remove_device, bd_addr)); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 334 | return BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 338 | * |
| 339 | * Function BTA_GetEirService |
| 340 | * |
| 341 | * Description This function is called to get BTA service mask from EIR. |
| 342 | * |
| 343 | * Parameters p_eir - pointer of EIR significant part |
| 344 | * p_services - return the BTA service mask |
| 345 | * |
| 346 | * Returns None |
| 347 | * |
| 348 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 349 | extern const uint16_t bta_service_id_to_uuid_lkup_tbl[]; |
Jakub Pawlowski | 0595ca0 | 2017-02-07 12:15:06 -0800 | [diff] [blame] | 350 | void BTA_GetEirService(uint8_t* p_eir, size_t eir_len, |
| 351 | tBTA_SERVICE_MASK* p_services) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 352 | uint8_t xx, yy; |
| 353 | uint8_t num_uuid, max_num_uuid = 32; |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 354 | uint8_t uuid_list[32 * Uuid::kNumBytes16]; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 355 | uint16_t* p_uuid16 = (uint16_t*)uuid_list; |
| 356 | tBTA_SERVICE_MASK mask; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 357 | |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 358 | BTM_GetEirUuidList(p_eir, eir_len, Uuid::kNumBytes16, &num_uuid, uuid_list, |
Jakub Pawlowski | 0595ca0 | 2017-02-07 12:15:06 -0800 | [diff] [blame] | 359 | max_num_uuid); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 360 | for (xx = 0; xx < num_uuid; xx++) { |
| 361 | mask = 1; |
| 362 | for (yy = 0; yy < BTA_MAX_SERVICE_ID; yy++) { |
| 363 | if (*(p_uuid16 + xx) == bta_service_id_to_uuid_lkup_tbl[yy]) { |
| 364 | *p_services |= mask; |
| 365 | break; |
| 366 | } |
| 367 | mask <<= 1; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 368 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 369 | |
| 370 | /* for HSP v1.2 only device */ |
| 371 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HEADSET_HS) |
| 372 | *p_services |= BTA_HSP_SERVICE_MASK; |
| 373 | |
| 374 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SOURCE) |
| 375 | *p_services |= BTA_HL_SERVICE_MASK; |
| 376 | |
| 377 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SINK) |
| 378 | *p_services |= BTA_HL_SERVICE_MASK; |
| 379 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 383 | * |
| 384 | * Function BTA_DmGetConnectionState |
| 385 | * |
| 386 | * Description Returns whether the remote device is currently connected. |
| 387 | * |
| 388 | * Returns 0 if the device is NOT connected. |
| 389 | * |
| 390 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 391 | uint16_t BTA_DmGetConnectionState(const RawAddress& bd_addr) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 392 | tBTA_DM_PEER_DEVICE* p_dev = bta_dm_find_peer_device(bd_addr); |
| 393 | return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED); |
Andre Eisenbach | 5c0b052 | 2014-06-18 12:20:37 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Andre Eisenbach | 5c0b052 | 2014-06-18 12:20:37 -0700 | [diff] [blame] | 396 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 397 | * Device Identification (DI) Server Functions |
| 398 | ******************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 399 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 400 | * |
| 401 | * Function BTA_DmSetLocalDiRecord |
| 402 | * |
| 403 | * Description This function adds a DI record to the local SDP database. |
| 404 | * |
| 405 | * Returns BTA_SUCCESS if record set sucessfully, otherwise error code. |
| 406 | * |
| 407 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 408 | tBTA_STATUS BTA_DmSetLocalDiRecord(tBTA_DI_RECORD* p_device_info, |
| 409 | uint32_t* p_handle) { |
| 410 | tBTA_STATUS status = BTA_FAILURE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 411 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 412 | if (bta_dm_di_cb.di_num < BTA_DI_NUM_MAX) { |
| 413 | if (SDP_SetLocalDiRecord((tSDP_DI_RECORD*)p_device_info, p_handle) == |
| 414 | SDP_SUCCESS) { |
| 415 | if (!p_device_info->primary_record) { |
| 416 | bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = *p_handle; |
| 417 | bta_dm_di_cb.di_num++; |
| 418 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 419 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 420 | bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION); |
| 421 | status = BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 422 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 423 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 424 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 425 | return status; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 429 | * |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 430 | * Function BTA_DmAddBleKey |
| 431 | * |
| 432 | * Description Add/modify LE device information. This function will be |
| 433 | * normally called during host startup to restore all required |
| 434 | * information stored in the NVRAM. |
| 435 | * |
| 436 | * Parameters: bd_addr - BD address of the peer |
| 437 | * p_le_key - LE key values. |
| 438 | * key_type - LE SMP key type. |
| 439 | * |
| 440 | * Returns BTA_SUCCESS if successful |
| 441 | * BTA_FAIL if operation failed. |
| 442 | * |
| 443 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 444 | void BTA_DmAddBleKey(const RawAddress& bd_addr, tBTA_LE_KEY_VALUE* p_le_key, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 445 | tBTA_LE_KEY_TYPE key_type) { |
Jakub Pawlowski | 0d48680 | 2018-01-23 12:46:07 -0800 | [diff] [blame] | 446 | do_in_bta_thread(FROM_HERE, |
| 447 | base::Bind(bta_dm_add_blekey, bd_addr, *p_le_key, key_type)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 451 | * |
| 452 | * Function BTA_DmAddBleDevice |
| 453 | * |
| 454 | * Description Add a BLE device. This function will be normally called |
| 455 | * during host startup to restore all required information |
| 456 | * for a LE device stored in the NVRAM. |
| 457 | * |
| 458 | * Parameters: bd_addr - BD address of the peer |
| 459 | * dev_type - Remote device's device type. |
| 460 | * addr_type - LE device address type. |
| 461 | * |
| 462 | * Returns void |
| 463 | * |
| 464 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 465 | void BTA_DmAddBleDevice(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 466 | tBT_DEVICE_TYPE dev_type) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 467 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_add_ble_device, bd_addr, |
| 468 | addr_type, dev_type)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 469 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 470 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 471 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 472 | * |
| 473 | * Function BTA_DmBlePasskeyReply |
| 474 | * |
| 475 | * Description Send BLE SMP passkey reply. |
| 476 | * |
| 477 | * Parameters: bd_addr - BD address of the peer |
| 478 | * accept - passkey entry sucessful or declined. |
| 479 | * passkey - passkey value, must be a 6 digit number, |
| 480 | * can be lead by 0. |
| 481 | * |
| 482 | * Returns void |
| 483 | * |
| 484 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 485 | void BTA_DmBlePasskeyReply(const RawAddress& bd_addr, bool accept, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 486 | uint32_t passkey) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 487 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_ble_passkey_reply, bd_addr, |
| 488 | accept, accept ? passkey : 0)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 489 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 490 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 491 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 492 | * |
| 493 | * Function BTA_DmBleConfirmReply |
| 494 | * |
| 495 | * Description Send BLE SMP SC user confirmation reply. |
| 496 | * |
| 497 | * Parameters: bd_addr - BD address of the peer |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 498 | * accept - numbers to compare are the same or |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 499 | * different. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 500 | * |
| 501 | * Returns void |
| 502 | * |
| 503 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 504 | void BTA_DmBleConfirmReply(const RawAddress& bd_addr, bool accept) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 505 | do_in_bta_thread(FROM_HERE, |
| 506 | base::Bind(bta_dm_ble_confirm_reply, bd_addr, accept)); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 510 | * |
| 511 | * Function BTA_DmBleSecurityGrant |
| 512 | * |
| 513 | * Description Grant security request access. |
| 514 | * |
| 515 | * Parameters: bd_addr - BD address of the peer |
| 516 | * res - security grant status. |
| 517 | * |
| 518 | * Returns void |
| 519 | * |
| 520 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 521 | void BTA_DmBleSecurityGrant(const RawAddress& bd_addr, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 522 | tBTA_DM_BLE_SEC_GRANT res) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 523 | do_in_bta_thread(FROM_HERE, base::Bind(BTM_SecurityGrant, bd_addr, res)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 524 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 525 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 526 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 527 | * |
| 528 | * Function BTA_DmSetBlePrefConnParams |
| 529 | * |
| 530 | * Description This function is called to set the preferred connection |
| 531 | * parameters when default connection parameter is not desired. |
| 532 | * |
| 533 | * Parameters: bd_addr - BD address of the peripheral |
| 534 | * scan_interval - scan interval |
| 535 | * scan_window - scan window |
| 536 | * min_conn_int - minimum preferred connection interval |
| 537 | * max_conn_int - maximum preferred connection interval |
| 538 | * slave_latency - preferred slave latency |
| 539 | * supervision_tout - preferred supervision timeout |
| 540 | * |
| 541 | * |
| 542 | * Returns void |
| 543 | * |
| 544 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 545 | void BTA_DmSetBlePrefConnParams(const RawAddress& bd_addr, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 546 | uint16_t min_conn_int, uint16_t max_conn_int, |
| 547 | uint16_t slave_latency, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 548 | uint16_t supervision_tout) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 549 | do_in_bta_thread(FROM_HERE, |
| 550 | base::Bind(bta_dm_ble_set_conn_params, bd_addr, min_conn_int, |
| 551 | max_conn_int, slave_latency, supervision_tout)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 555 | * |
| 556 | * Function BTA_DmSetBleConnScanParams |
| 557 | * |
| 558 | * Description This function is called to set scan parameters used in |
| 559 | * BLE connection request |
| 560 | * |
| 561 | * Parameters: scan_interval - scan interval |
| 562 | * scan_window - scan window |
| 563 | * |
| 564 | * Returns void |
| 565 | * |
| 566 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 567 | void BTA_DmSetBleConnScanParams(uint32_t scan_interval, uint32_t scan_window) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 568 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_ble_set_conn_scan_params, |
| 569 | scan_interval, scan_window)); |
Satya Calloji | 5725fc6 | 2015-03-31 13:24:32 -0700 | [diff] [blame] | 570 | } |
| 571 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 572 | /** Set BLE connectable mode to auto connect */ |
Jakub Pawlowski | 83211b0 | 2016-12-07 11:25:15 -0800 | [diff] [blame] | 573 | void BTA_DmBleStartAutoConn() { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 574 | do_in_bta_thread(FROM_HERE, base::Bind(BTM_BleStartAutoConn)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 575 | } |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 576 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 577 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 578 | * |
| 579 | * Function bta_dm_discover_send_msg |
| 580 | * |
| 581 | * Description This function send discover message to BTA task. |
| 582 | * |
| 583 | * Returns void |
| 584 | * |
| 585 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 586 | static void bta_dm_discover_send_msg(const RawAddress& bd_addr, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 587 | tBTA_SERVICE_MASK_EXT* p_services, |
| 588 | tBTA_DM_SEARCH_CBACK* p_cback, |
| 589 | bool sdp_search, |
| 590 | tBTA_TRANSPORT transport) { |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 591 | const size_t len = |
| 592 | p_services |
| 593 | ? (sizeof(tBTA_DM_API_DISCOVER) + sizeof(Uuid) * p_services->num_uuid) |
| 594 | : sizeof(tBTA_DM_API_DISCOVER); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 595 | tBTA_DM_API_DISCOVER* p_msg = (tBTA_DM_API_DISCOVER*)osi_calloc(len); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 596 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 597 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 598 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 599 | p_msg->p_cback = p_cback; |
| 600 | p_msg->sdp_search = sdp_search; |
| 601 | p_msg->transport = transport; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 602 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 603 | if (p_services != NULL) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 604 | p_msg->services = p_services->srvc_mask; |
| 605 | p_msg->num_uuid = p_services->num_uuid; |
| 606 | if (p_services->num_uuid != 0) { |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 607 | p_msg->p_uuid = (Uuid*)(p_msg + 1); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 608 | memcpy(p_msg->p_uuid, p_services->p_uuid, |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 609 | sizeof(Uuid) * p_services->num_uuid); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 610 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 611 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 612 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 613 | bta_sys_sendmsg(p_msg); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 614 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 615 | |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 616 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 617 | * |
| 618 | * Function BTA_DmDiscoverByTransport |
| 619 | * |
| 620 | * Description This function does service discovery on particular transport |
| 621 | * for services of a |
| 622 | * peer device. When services.num_uuid is 0, it indicates all |
| 623 | * GATT based services are to be searched; otherwise a list of |
| 624 | * UUID of interested services should be provided through |
| 625 | * p_services->p_uuid. |
| 626 | * |
| 627 | * |
| 628 | * |
| 629 | * Returns void |
| 630 | * |
| 631 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 632 | void BTA_DmDiscoverByTransport(const RawAddress& bd_addr, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 633 | tBTA_SERVICE_MASK_EXT* p_services, |
| 634 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search, |
| 635 | tBTA_TRANSPORT transport) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 636 | bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, transport); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 637 | } |
| 638 | |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 639 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 640 | * |
| 641 | * Function BTA_DmDiscoverExt |
| 642 | * |
| 643 | * Description This function does service discovery for services of a |
| 644 | * peer device. When services.num_uuid is 0, it indicates all |
| 645 | * GATT based services are to be searched; other wise a list of |
| 646 | * UUID of interested services should be provided through |
| 647 | * p_services->p_uuid. |
| 648 | * |
| 649 | * |
| 650 | * |
| 651 | * Returns void |
| 652 | * |
| 653 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 654 | void BTA_DmDiscoverExt(const RawAddress& bd_addr, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 655 | tBTA_SERVICE_MASK_EXT* p_services, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 656 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 657 | bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, |
| 658 | BTA_TRANSPORT_UNKNOWN); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 662 | * |
| 663 | * Function BTA_DmSearchExt |
| 664 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 665 | * Description This function searches for peer Bluetooth devices. It |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 666 | * performs an inquiry and gets the remote name for devices. |
| 667 | * Service discovery is done if services is non zero |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 668 | * |
| 669 | * Parameters p_dm_inq: inquiry conditions |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 670 | * p_services: if service is not empty, service discovery will |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 671 | * be done. For all GATT based service conditions, |
| 672 | * put num_uuid, and p_uuid is the pointer to the |
| 673 | * list of UUID values. |
| 674 | * p_cback: callback function when search is completed. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 675 | * |
| 676 | * |
| 677 | * |
| 678 | * Returns void |
| 679 | * |
| 680 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 681 | void BTA_DmSearchExt(tBTA_DM_INQ* p_dm_inq, tBTA_SERVICE_MASK_EXT* p_services, |
| 682 | tBTA_DM_SEARCH_CBACK* p_cback) { |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 683 | const size_t len = |
| 684 | p_services |
| 685 | ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(Uuid) * p_services->num_uuid) |
| 686 | : sizeof(tBTA_DM_API_SEARCH); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 687 | tBTA_DM_API_SEARCH* p_msg = (tBTA_DM_API_SEARCH*)osi_calloc(len); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 688 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 689 | p_msg->hdr.event = BTA_DM_API_SEARCH_EVT; |
| 690 | memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ)); |
| 691 | p_msg->p_cback = p_cback; |
| 692 | p_msg->rs_res = BTA_DM_RS_NONE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 693 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 694 | if (p_services != NULL) { |
| 695 | p_msg->services = p_services->srvc_mask; |
| 696 | p_msg->num_uuid = p_services->num_uuid; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 697 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 698 | if (p_services->num_uuid != 0) { |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 699 | p_msg->p_uuid = (Uuid*)(p_msg + 1); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 700 | memcpy(p_msg->p_uuid, p_services->p_uuid, |
Jakub Pawlowski | 819e2ec | 2017-07-10 09:56:09 -0700 | [diff] [blame] | 701 | sizeof(Uuid) * p_services->num_uuid); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 702 | } else { |
| 703 | p_msg->p_uuid = NULL; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 704 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 705 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 706 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 707 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 708 | } |
Myles Watson | 9979121 | 2016-11-18 08:42:23 -0800 | [diff] [blame] | 709 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 710 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 711 | * |
| 712 | * Function BTA_DmBleUpdateConnectionParam |
| 713 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 714 | * Description Update connection parameters, can only be used when |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 715 | * connection is up. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 716 | * |
| 717 | * Parameters: bd_addr - BD address of the peer |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 718 | * min_int - minimum connection interval, |
| 719 | * [0x0004 ~ 0x4000] |
| 720 | * max_int - maximum connection interval, |
| 721 | * [0x0004 ~ 0x4000] |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 722 | * latency - slave latency [0 ~ 500] |
| 723 | * timeout - supervision timeout [0x000a ~ 0xc80] |
| 724 | * |
| 725 | * Returns void |
| 726 | * |
| 727 | ******************************************************************************/ |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 728 | void BTA_DmBleUpdateConnectionParams(const RawAddress& bd_addr, |
| 729 | uint16_t min_int, uint16_t max_int, |
Stanley Tng | a0b984e | 2018-03-19 12:48:04 -0700 | [diff] [blame^] | 730 | uint16_t latency, uint16_t timeout, |
| 731 | uint16_t min_ce_len, uint16_t max_ce_len) { |
| 732 | do_in_bta_thread( |
| 733 | FROM_HERE, base::Bind(bta_dm_ble_update_conn_params, bd_addr, min_int, |
| 734 | max_int, latency, timeout, min_ce_len, max_ce_len)); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 735 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 736 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 737 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 738 | * |
| 739 | * Function BTA_DmBleConfigLocalPrivacy |
| 740 | * |
| 741 | * Description Enable/disable privacy on the local device |
| 742 | * |
| 743 | * Parameters: privacy_enable - enable/disabe privacy on remote device. |
| 744 | * |
| 745 | * Returns void |
| 746 | * |
| 747 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 748 | void BTA_DmBleConfigLocalPrivacy(bool privacy_enable) { |
Myles Watson | 84baa7f | 2016-11-14 12:05:37 -0800 | [diff] [blame] | 749 | #if (BLE_PRIVACY_SPT == TRUE) |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 750 | do_in_bta_thread(FROM_HERE, |
| 751 | base::Bind(bta_dm_ble_config_local_privacy, privacy_enable)); |
Wei Wang | ed534e3 | 2014-05-20 06:30:13 +0000 | [diff] [blame] | 752 | #else |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 753 | UNUSED(privacy_enable); |
Wei Wang | ed534e3 | 2014-05-20 06:30:13 +0000 | [diff] [blame] | 754 | #endif |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 755 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 756 | |
| 757 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 758 | * |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 759 | * Function BTA_DmBleGetEnergyInfo |
| 760 | * |
| 761 | * Description This function is called to obtain the energy info |
| 762 | * |
| 763 | * Parameters p_cmpl_cback - Command complete callback |
| 764 | * |
| 765 | * Returns void |
| 766 | * |
| 767 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 768 | void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK* p_cmpl_cback) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 769 | do_in_bta_thread(FROM_HERE, |
| 770 | base::Bind(bta_dm_ble_get_energy_info, p_cmpl_cback)); |
Satya Calloji | e5ba884 | 2014-07-03 17:18:02 -0700 | [diff] [blame] | 771 | } |
| 772 | |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 773 | /** This function is to set maximum LE data packet size */ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 774 | void BTA_DmBleSetDataLength(const RawAddress& remote_device, |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame] | 775 | uint16_t tx_data_length) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 776 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_ble_set_data_length, |
| 777 | remote_device, tx_data_length)); |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 778 | } |
| 779 | |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 780 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 781 | * |
| 782 | * Function BTA_DmSetEncryption |
| 783 | * |
| 784 | * Description This function is called to ensure that connection is |
| 785 | * encrypted. Should be called only on an open connection. |
| 786 | * Typically only needed for connections that first want to |
| 787 | * bring up unencrypted links, then later encrypt them. |
| 788 | * |
| 789 | * Parameters: bd_addr - Address of the peer device |
| 790 | * transport - transport of the link to be encruypted |
| 791 | * p_callback - Pointer to callback function to indicat the |
| 792 | * link encryption status |
| 793 | * sec_act - This is the security action to indicate |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 794 | * what kind of BLE security level is required |
| 795 | * for the BLE link if BLE is supported. |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 796 | * Note: This parameter is ignored for the |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 797 | * BR/EDR or if BLE is not supported. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 798 | * |
| 799 | * Returns void |
| 800 | * |
| 801 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 802 | void BTA_DmSetEncryption(const RawAddress& bd_addr, tBTA_TRANSPORT transport, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 803 | tBTA_DM_ENCRYPT_CBACK* p_callback, |
| 804 | tBTA_DM_BLE_SEC_ACT sec_act) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 805 | APPL_TRACE_API("%s", __func__); |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 806 | do_in_bta_thread(FROM_HERE, base::Bind(bta_dm_set_encryption, bd_addr, |
| 807 | transport, p_callback, sec_act)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 808 | } |
| 809 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 810 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 811 | * |
| 812 | * Function BTA_DmCloseACL |
| 813 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 814 | * Description This function force to close an ACL connection and remove |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 815 | * the device from the security database list of known devices. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 816 | * |
| 817 | * Parameters: bd_addr - Address of the peer device |
| 818 | * remove_dev - remove device or not after link down |
| 819 | * |
| 820 | * Returns void |
| 821 | * |
| 822 | ******************************************************************************/ |
Jakub Pawlowski | a484a88 | 2017-06-24 17:30:18 -0700 | [diff] [blame] | 823 | void BTA_DmCloseACL(const RawAddress& bd_addr, bool remove_dev, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 824 | tBTA_TRANSPORT transport) { |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 825 | do_in_bta_thread( |
| 826 | FROM_HERE, base::Bind(bta_dm_close_acl, bd_addr, remove_dev, transport)); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 830 | * |
| 831 | * Function BTA_DmBleObserve |
| 832 | * |
| 833 | * Description This procedure keep the device listening for advertising |
| 834 | * events from a broadcast device. |
| 835 | * |
| 836 | * Parameters start: start or stop observe. |
| 837 | * |
| 838 | * Returns void |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 839 | |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 840 | * |
| 841 | * Returns void. |
| 842 | * |
| 843 | ******************************************************************************/ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 844 | extern void BTA_DmBleObserve(bool start, uint8_t duration, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 845 | tBTA_DM_SEARCH_CBACK* p_results_cb) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 846 | APPL_TRACE_API("%s:start = %d ", __func__, start); |
Jakub Pawlowski | 154be11 | 2018-01-22 10:22:43 -0800 | [diff] [blame] | 847 | do_in_bta_thread( |
| 848 | FROM_HERE, base::Bind(bta_dm_ble_observe, start, duration, p_results_cb)); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 849 | } |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 850 | |
| 851 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 852 | * |
| 853 | * Function BTA_VendorInit |
| 854 | * |
| 855 | * Description This function initializes vendor specific |
| 856 | * |
| 857 | * Returns void |
| 858 | * |
| 859 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 860 | void BTA_VendorInit(void) { APPL_TRACE_API("BTA_VendorInit"); } |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 861 | |
| 862 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 863 | * |
| 864 | * Function BTA_VendorCleanup |
| 865 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 866 | * Description This function frees up Broadcom specific VS specific dynamic |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 867 | * memory |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 868 | * |
| 869 | * Returns void |
| 870 | * |
| 871 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 872 | void BTA_VendorCleanup(void) { |
| 873 | tBTM_BLE_VSC_CB cmn_ble_vsc_cb; |
| 874 | BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 875 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 876 | if (cmn_ble_vsc_cb.max_filter > 0) { |
| 877 | btm_ble_adv_filter_cleanup(); |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 878 | #if (BLE_PRIVACY_SPT == TRUE) |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 879 | btm_ble_resolving_list_cleanup(); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 880 | #endif |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 881 | } |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 882 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 883 | if (cmn_ble_vsc_cb.tot_scan_results_strg > 0) btm_ble_batchscan_cleanup(); |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 884 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 885 | if (cmn_ble_vsc_cb.adv_inst_max > 0) btm_ble_multi_adv_cleanup(); |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 886 | } |