The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Satya Calloji | c4e2596 | 2014-05-10 23:46:24 -0700 | [diff] [blame] | 3 | * Copyright (C) 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 | |
| 38 | /***************************************************************************** |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 39 | * Constants |
| 40 | ****************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 41 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 42 | static const tBTA_SYS_REG bta_dm_reg = {bta_dm_sm_execute, bta_dm_sm_disable}; |
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, &bta_dm_reg); |
| 63 | 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] | 64 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 65 | /* if UUID list is not provided as static data */ |
| 66 | bta_sys_eir_register(bta_dm_eir_update_uuid); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 67 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 68 | tBTA_DM_API_ENABLE* p_msg = |
| 69 | (tBTA_DM_API_ENABLE*)osi_malloc(sizeof(tBTA_DM_API_ENABLE)); |
| 70 | p_msg->hdr.event = BTA_DM_API_ENABLE_EVT; |
| 71 | p_msg->p_sec_cback = p_cback; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 72 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 73 | bta_sys_sendmsg(p_msg); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 74 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 75 | return BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 79 | * |
| 80 | * Function BTA_DisableBluetooth |
| 81 | * |
| 82 | * Description Disables bluetooth service. This function is called when |
| 83 | * the application no longer needs bluetooth service |
| 84 | * |
| 85 | * Returns void |
| 86 | * |
| 87 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 88 | tBTA_STATUS BTA_DisableBluetooth(void) { |
| 89 | 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] | 90 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 91 | p_msg->event = BTA_DM_API_DISABLE_EVT; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 92 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 93 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 94 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 95 | return BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 99 | * |
| 100 | * Function BTA_EnableTestMode |
| 101 | * |
| 102 | * Description Enables bluetooth device under test mode |
| 103 | * |
| 104 | * |
| 105 | * Returns tBTA_STATUS |
| 106 | * |
| 107 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 108 | tBTA_STATUS BTA_EnableTestMode(void) { |
| 109 | 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] | 110 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 111 | APPL_TRACE_API("%s", __func__); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 112 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 113 | p_msg->event = BTA_DM_API_ENABLE_TEST_MODE_EVT; |
| 114 | bta_sys_sendmsg(p_msg); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 115 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 116 | return BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 120 | * |
| 121 | * Function BTA_DisableTestMode |
| 122 | * |
| 123 | * Description Disable bluetooth device under test mode |
| 124 | * |
| 125 | * |
| 126 | * Returns None |
| 127 | * |
| 128 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 129 | void BTA_DisableTestMode(void) { |
| 130 | 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] | 131 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 132 | APPL_TRACE_API("%s", __func__); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 133 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 134 | p_msg->event = BTA_DM_API_DISABLE_TEST_MODE_EVT; |
| 135 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 139 | * |
| 140 | * Function BTA_DmSetDeviceName |
| 141 | * |
| 142 | * Description This function sets the Bluetooth name of local device |
| 143 | * |
| 144 | * |
| 145 | * Returns void |
| 146 | * |
| 147 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 148 | void BTA_DmSetDeviceName(char* p_name) { |
| 149 | tBTA_DM_API_SET_NAME* p_msg = |
| 150 | (tBTA_DM_API_SET_NAME*)osi_malloc(sizeof(tBTA_DM_API_SET_NAME)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 151 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 152 | p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT; |
| 153 | strlcpy((char*)p_msg->name, p_name, BD_NAME_LEN); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 154 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 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_DmSetVisibility |
| 161 | * |
| 162 | * Description This function sets the Bluetooth connectable, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 163 | * discoverable, pairable and conn paired only modes of local |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 164 | * device |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 165 | * |
| 166 | * |
| 167 | * Returns void |
| 168 | * |
| 169 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 170 | void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, |
| 171 | uint8_t pairable_mode, uint8_t conn_filter) { |
| 172 | tBTA_DM_API_SET_VISIBILITY* p_msg = |
| 173 | (tBTA_DM_API_SET_VISIBILITY*)osi_malloc(sizeof(tBTA_DM_MSG)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 174 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 175 | p_msg->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT; |
| 176 | p_msg->disc_mode = disc_mode; |
| 177 | p_msg->conn_mode = conn_mode; |
| 178 | p_msg->pair_mode = pairable_mode; |
| 179 | p_msg->conn_paired_only = conn_filter; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 180 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 181 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 185 | * |
| 186 | * Function BTA_DmSearch |
| 187 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 188 | * Description This function searches for peer Bluetooth devices. It |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 189 | * performs an inquiry and gets the remote name for devices. |
| 190 | * Service discovery is done if services is non zero |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 191 | * |
| 192 | * |
| 193 | * Returns void |
| 194 | * |
| 195 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 196 | void BTA_DmSearch(tBTA_DM_INQ* p_dm_inq, tBTA_SERVICE_MASK services, |
| 197 | tBTA_DM_SEARCH_CBACK* p_cback) { |
| 198 | tBTA_DM_API_SEARCH* p_msg = |
| 199 | (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] | 200 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 201 | p_msg->hdr.event = BTA_DM_API_SEARCH_EVT; |
| 202 | memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ)); |
| 203 | p_msg->services = services; |
| 204 | p_msg->p_cback = p_cback; |
| 205 | p_msg->rs_res = BTA_DM_RS_NONE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 206 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 207 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 208 | } |
| 209 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 210 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 211 | * |
| 212 | * Function BTA_DmSearchCancel |
| 213 | * |
| 214 | * Description This function cancels a search initiated by BTA_DmSearch |
| 215 | * |
| 216 | * |
| 217 | * Returns void |
| 218 | * |
| 219 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 220 | void BTA_DmSearchCancel(void) { |
| 221 | 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] | 222 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 223 | p_msg->event = BTA_DM_API_SEARCH_CANCEL_EVT; |
| 224 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 228 | * |
| 229 | * Function BTA_DmDiscover |
| 230 | * |
| 231 | * Description This function does service discovery for services of a |
| 232 | * peer device |
| 233 | * |
| 234 | * |
| 235 | * Returns void |
| 236 | * |
| 237 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 238 | void BTA_DmDiscover(const bt_bdaddr_t& bd_addr, tBTA_SERVICE_MASK services, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 239 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search) { |
| 240 | tBTA_DM_API_DISCOVER* p_msg = |
| 241 | (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] | 242 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 243 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 244 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 245 | p_msg->services = services; |
| 246 | p_msg->p_cback = p_cback; |
| 247 | p_msg->sdp_search = sdp_search; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 248 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 249 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 253 | * |
| 254 | * Function BTA_DmDiscoverUUID |
| 255 | * |
| 256 | * Description This function does service discovery for services of a |
| 257 | * peer device |
| 258 | * |
| 259 | * |
| 260 | * Returns void |
| 261 | * |
| 262 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 263 | void BTA_DmDiscoverUUID(const bt_bdaddr_t& bd_addr, tSDP_UUID* uuid, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 264 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search) { |
| 265 | tBTA_DM_API_DISCOVER* p_msg = |
| 266 | (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] | 267 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 268 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 269 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 270 | p_msg->services = BTA_USER_SERVICE_MASK; // Not exposed at API level |
| 271 | p_msg->p_cback = p_cback; |
| 272 | p_msg->sdp_search = sdp_search; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 273 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 274 | p_msg->num_uuid = 0; |
| 275 | p_msg->p_uuid = NULL; |
Myles Watson | 9979121 | 2016-11-18 08:42:23 -0800 | [diff] [blame] | 276 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 277 | memcpy(&p_msg->uuid, uuid, sizeof(tSDP_UUID)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 278 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 279 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 280 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 281 | |
| 282 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 283 | * |
| 284 | * Function BTA_DmBond |
| 285 | * |
| 286 | * Description This function initiates a bonding procedure with a peer |
| 287 | * device |
| 288 | * |
| 289 | * |
| 290 | * Returns void |
| 291 | * |
| 292 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 293 | void BTA_DmBond(const bt_bdaddr_t& bd_addr) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 294 | tBTA_DM_API_BOND* p_msg = |
| 295 | (tBTA_DM_API_BOND*)osi_malloc(sizeof(tBTA_DM_API_BOND)); |
VenkatRaghavan VijayaRaghavan | 76356ae | 2015-04-21 11:32:29 -0700 | [diff] [blame] | 296 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 297 | p_msg->hdr.event = BTA_DM_API_BOND_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 298 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 299 | p_msg->transport = BTA_TRANSPORT_UNKNOWN; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 300 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 301 | bta_sys_sendmsg(p_msg); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 305 | * |
| 306 | * Function BTA_DmBondByTransports |
| 307 | * |
| 308 | * Description This function initiates a bonding procedure with a peer |
| 309 | * device |
| 310 | * |
| 311 | * |
| 312 | * Returns void |
| 313 | * |
| 314 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 315 | void BTA_DmBondByTransport(const bt_bdaddr_t& bd_addr, |
| 316 | tBTA_TRANSPORT transport) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 317 | tBTA_DM_API_BOND* p_msg = |
| 318 | (tBTA_DM_API_BOND*)osi_malloc(sizeof(tBTA_DM_API_BOND)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 319 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 320 | p_msg->hdr.event = BTA_DM_API_BOND_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 321 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 322 | p_msg->transport = transport; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 323 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 324 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 328 | * |
| 329 | * Function BTA_DmBondCancel |
| 330 | * |
| 331 | * Description This function cancels the bonding procedure with a peer |
| 332 | * device |
| 333 | * |
| 334 | * |
| 335 | * Returns void |
| 336 | * |
| 337 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 338 | void BTA_DmBondCancel(const bt_bdaddr_t& bd_addr) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 339 | tBTA_DM_API_BOND_CANCEL* p_msg = |
| 340 | (tBTA_DM_API_BOND_CANCEL*)osi_malloc(sizeof(tBTA_DM_API_BOND_CANCEL)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 341 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 342 | p_msg->hdr.event = BTA_DM_API_BOND_CANCEL_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 343 | p_msg->bd_addr = bd_addr; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 344 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 345 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 349 | * |
| 350 | * Function BTA_DmPinReply |
| 351 | * |
| 352 | * Description This function provides a pincode for a remote device when |
| 353 | * one is requested by DM through BTA_DM_PIN_REQ_EVT |
| 354 | * |
| 355 | * |
| 356 | * Returns void |
| 357 | * |
| 358 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 359 | void BTA_DmPinReply(const bt_bdaddr_t& bd_addr, bool accept, uint8_t pin_len, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 360 | uint8_t* p_pin) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 361 | |
| 362 | { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 363 | tBTA_DM_API_PIN_REPLY* p_msg = |
| 364 | (tBTA_DM_API_PIN_REPLY*)osi_malloc(sizeof(tBTA_DM_API_PIN_REPLY)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 365 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 366 | p_msg->hdr.event = BTA_DM_API_PIN_REPLY_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 367 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 368 | p_msg->accept = accept; |
| 369 | if (accept) { |
| 370 | p_msg->pin_len = pin_len; |
| 371 | memcpy(p_msg->p_pin, p_pin, pin_len); |
| 372 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 373 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 374 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 375 | } |
| 376 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 377 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 378 | * |
| 379 | * Function BTA_DmLocalOob |
| 380 | * |
| 381 | * Description This function retrieves the OOB data from local controller. |
| 382 | * The result is reported by: |
| 383 | * - bta_dm_co_loc_oob_ext() if device supports secure |
| 384 | * connections (SC) |
| 385 | * - bta_dm_co_loc_oob() if device doesn't support SC |
| 386 | * |
| 387 | * Returns void |
| 388 | * |
| 389 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 390 | void BTA_DmLocalOob(void) { |
| 391 | tBTA_DM_API_LOC_OOB* p_msg = |
| 392 | (tBTA_DM_API_LOC_OOB*)osi_malloc(sizeof(tBTA_DM_API_LOC_OOB)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 393 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 394 | p_msg->hdr.event = BTA_DM_API_LOC_OOB_EVT; |
| 395 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 396 | } |
Jakub Pawlowski | 175da70 | 2015-11-12 15:00:58 -0800 | [diff] [blame] | 397 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 398 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 399 | * |
| 400 | * Function BTA_DmConfirm |
| 401 | * |
| 402 | * Description This function accepts or rejects the numerical value of the |
| 403 | * Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT |
| 404 | * |
| 405 | * Returns void |
| 406 | * |
| 407 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 408 | void BTA_DmConfirm(const bt_bdaddr_t& bd_addr, bool accept) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 409 | tBTA_DM_API_CONFIRM* p_msg = |
| 410 | (tBTA_DM_API_CONFIRM*)osi_malloc(sizeof(tBTA_DM_API_CONFIRM)); |
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 | p_msg->hdr.event = BTA_DM_API_CONFIRM_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 413 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 414 | p_msg->accept = accept; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 415 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 416 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 420 | * |
| 421 | * Function BTA_DmAddDevice |
| 422 | * |
| 423 | * Description This function adds a device to the security database list of |
| 424 | * peer device |
| 425 | * |
| 426 | * |
| 427 | * Returns void |
| 428 | * |
| 429 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 430 | void BTA_DmAddDevice(const bt_bdaddr_t& bd_addr, DEV_CLASS dev_class, |
| 431 | LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask, |
| 432 | bool is_trusted, uint8_t key_type, tBTA_IO_CAP io_cap, |
| 433 | uint8_t pin_length) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 434 | tBTA_DM_API_ADD_DEVICE* p_msg = |
| 435 | (tBTA_DM_API_ADD_DEVICE*)osi_calloc(sizeof(tBTA_DM_API_ADD_DEVICE)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 436 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 437 | p_msg->hdr.event = BTA_DM_API_ADD_DEVICE_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 438 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 439 | p_msg->tm = trusted_mask; |
| 440 | p_msg->is_trusted = is_trusted; |
| 441 | p_msg->io_cap = io_cap; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 442 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 443 | if (link_key) { |
| 444 | p_msg->link_key_known = true; |
| 445 | p_msg->key_type = key_type; |
| 446 | memcpy(p_msg->link_key, link_key, LINK_KEY_LEN); |
| 447 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 448 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 449 | /* Load device class if specified */ |
| 450 | if (dev_class) { |
| 451 | p_msg->dc_known = true; |
| 452 | memcpy(p_msg->dc, dev_class, DEV_CLASS_LEN); |
| 453 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 454 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 455 | memset(p_msg->bd_name, 0, BD_NAME_LEN + 1); |
| 456 | memset(p_msg->features, 0, sizeof(p_msg->features)); |
| 457 | p_msg->pin_length = pin_length; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 458 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 459 | bta_sys_sendmsg(p_msg); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 460 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 461 | |
| 462 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 463 | * |
| 464 | * Function BTA_DmRemoveDevice |
| 465 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 466 | * Description This function removes a device fromthe security database |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 467 | * list of peer device. It manages unpairing even while |
| 468 | * connected. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 469 | * |
| 470 | * |
| 471 | * Returns void |
| 472 | * |
| 473 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 474 | tBTA_STATUS BTA_DmRemoveDevice(const bt_bdaddr_t& bd_addr) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 475 | tBTA_DM_API_REMOVE_DEVICE* p_msg = |
| 476 | (tBTA_DM_API_REMOVE_DEVICE*)osi_calloc(sizeof(tBTA_DM_API_REMOVE_DEVICE)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 477 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 478 | p_msg->hdr.event = BTA_DM_API_REMOVE_DEVICE_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 479 | p_msg->bd_addr = bd_addr; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 480 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 481 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 482 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 483 | return BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 487 | * |
| 488 | * Function BTA_GetEirService |
| 489 | * |
| 490 | * Description This function is called to get BTA service mask from EIR. |
| 491 | * |
| 492 | * Parameters p_eir - pointer of EIR significant part |
| 493 | * p_services - return the BTA service mask |
| 494 | * |
| 495 | * Returns None |
| 496 | * |
| 497 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 498 | extern const uint16_t bta_service_id_to_uuid_lkup_tbl[]; |
Jakub Pawlowski | 0595ca0 | 2017-02-07 12:15:06 -0800 | [diff] [blame] | 499 | void BTA_GetEirService(uint8_t* p_eir, size_t eir_len, |
| 500 | tBTA_SERVICE_MASK* p_services) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 501 | uint8_t xx, yy; |
| 502 | uint8_t num_uuid, max_num_uuid = 32; |
| 503 | uint8_t uuid_list[32 * LEN_UUID_16]; |
| 504 | uint16_t* p_uuid16 = (uint16_t*)uuid_list; |
| 505 | tBTA_SERVICE_MASK mask; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 506 | |
Jakub Pawlowski | 0595ca0 | 2017-02-07 12:15:06 -0800 | [diff] [blame] | 507 | BTM_GetEirUuidList(p_eir, eir_len, LEN_UUID_16, &num_uuid, uuid_list, |
| 508 | max_num_uuid); |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 509 | for (xx = 0; xx < num_uuid; xx++) { |
| 510 | mask = 1; |
| 511 | for (yy = 0; yy < BTA_MAX_SERVICE_ID; yy++) { |
| 512 | if (*(p_uuid16 + xx) == bta_service_id_to_uuid_lkup_tbl[yy]) { |
| 513 | *p_services |= mask; |
| 514 | break; |
| 515 | } |
| 516 | mask <<= 1; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 517 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 518 | |
| 519 | /* for HSP v1.2 only device */ |
| 520 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HEADSET_HS) |
| 521 | *p_services |= BTA_HSP_SERVICE_MASK; |
| 522 | |
| 523 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SOURCE) |
| 524 | *p_services |= BTA_HL_SERVICE_MASK; |
| 525 | |
| 526 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SINK) |
| 527 | *p_services |= BTA_HL_SERVICE_MASK; |
| 528 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 532 | * |
| 533 | * Function BTA_DmGetConnectionState |
| 534 | * |
| 535 | * Description Returns whether the remote device is currently connected. |
| 536 | * |
| 537 | * Returns 0 if the device is NOT connected. |
| 538 | * |
| 539 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 540 | uint16_t BTA_DmGetConnectionState(const bt_bdaddr_t& bd_addr) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 541 | tBTA_DM_PEER_DEVICE* p_dev = bta_dm_find_peer_device(bd_addr); |
| 542 | return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED); |
Andre Eisenbach | 5c0b052 | 2014-06-18 12:20:37 -0700 | [diff] [blame] | 543 | } |
| 544 | |
Andre Eisenbach | 5c0b052 | 2014-06-18 12:20:37 -0700 | [diff] [blame] | 545 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 546 | * Device Identification (DI) Server Functions |
| 547 | ******************************************************************************/ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 548 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 549 | * |
| 550 | * Function BTA_DmSetLocalDiRecord |
| 551 | * |
| 552 | * Description This function adds a DI record to the local SDP database. |
| 553 | * |
| 554 | * Returns BTA_SUCCESS if record set sucessfully, otherwise error code. |
| 555 | * |
| 556 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 557 | tBTA_STATUS BTA_DmSetLocalDiRecord(tBTA_DI_RECORD* p_device_info, |
| 558 | uint32_t* p_handle) { |
| 559 | tBTA_STATUS status = BTA_FAILURE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 560 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 561 | if (bta_dm_di_cb.di_num < BTA_DI_NUM_MAX) { |
| 562 | if (SDP_SetLocalDiRecord((tSDP_DI_RECORD*)p_device_info, p_handle) == |
| 563 | SDP_SUCCESS) { |
| 564 | if (!p_device_info->primary_record) { |
| 565 | bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = *p_handle; |
| 566 | bta_dm_di_cb.di_num++; |
| 567 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 568 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 569 | bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION); |
| 570 | status = BTA_SUCCESS; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 571 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 572 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 573 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 574 | return status; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 578 | * |
| 579 | * Function bta_dmexecutecallback |
| 580 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 581 | * Description This function will request BTA to execute a call back in the |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 582 | * context of BTU task. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 583 | * This API was named in lower case because it is only intended |
| 584 | * for the internal customers(like BTIF). |
| 585 | * |
| 586 | * Returns void |
| 587 | * |
| 588 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 589 | void bta_dmexecutecallback(tBTA_DM_EXEC_CBACK* p_callback, void* p_param) { |
| 590 | tBTA_DM_API_EXECUTE_CBACK* p_msg = |
| 591 | (tBTA_DM_API_EXECUTE_CBACK*)osi_malloc(sizeof(tBTA_DM_MSG)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 592 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 593 | p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT; |
| 594 | p_msg->p_param = p_param; |
| 595 | p_msg->p_exec_cback = p_callback; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 596 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 597 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 601 | * |
| 602 | * Function BTA_DmAddBleKey |
| 603 | * |
| 604 | * Description Add/modify LE device information. This function will be |
| 605 | * normally called during host startup to restore all required |
| 606 | * information stored in the NVRAM. |
| 607 | * |
| 608 | * Parameters: bd_addr - BD address of the peer |
| 609 | * p_le_key - LE key values. |
| 610 | * key_type - LE SMP key type. |
| 611 | * |
| 612 | * Returns BTA_SUCCESS if successful |
| 613 | * BTA_FAIL if operation failed. |
| 614 | * |
| 615 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 616 | void BTA_DmAddBleKey(const bt_bdaddr_t& bd_addr, tBTA_LE_KEY_VALUE* p_le_key, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 617 | tBTA_LE_KEY_TYPE key_type) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 618 | tBTA_DM_API_ADD_BLEKEY* p_msg = |
| 619 | (tBTA_DM_API_ADD_BLEKEY*)osi_calloc(sizeof(tBTA_DM_API_ADD_BLEKEY)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 620 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 621 | p_msg->hdr.event = BTA_DM_API_ADD_BLEKEY_EVT; |
| 622 | p_msg->key_type = key_type; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 623 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 624 | memcpy(&p_msg->blekey, p_le_key, sizeof(tBTA_LE_KEY_VALUE)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 625 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 626 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 630 | * |
| 631 | * Function BTA_DmAddBleDevice |
| 632 | * |
| 633 | * Description Add a BLE device. This function will be normally called |
| 634 | * during host startup to restore all required information |
| 635 | * for a LE device stored in the NVRAM. |
| 636 | * |
| 637 | * Parameters: bd_addr - BD address of the peer |
| 638 | * dev_type - Remote device's device type. |
| 639 | * addr_type - LE device address type. |
| 640 | * |
| 641 | * Returns void |
| 642 | * |
| 643 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 644 | void BTA_DmAddBleDevice(const bt_bdaddr_t& bd_addr, tBLE_ADDR_TYPE addr_type, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 645 | tBT_DEVICE_TYPE dev_type) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 646 | tBTA_DM_API_ADD_BLE_DEVICE* p_msg = (tBTA_DM_API_ADD_BLE_DEVICE*)osi_calloc( |
| 647 | sizeof(tBTA_DM_API_ADD_BLE_DEVICE)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 648 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 649 | p_msg->hdr.event = BTA_DM_API_ADD_BLEDEVICE_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 650 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 651 | p_msg->addr_type = addr_type; |
| 652 | p_msg->dev_type = dev_type; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 653 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 654 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 655 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 656 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 657 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 658 | * |
| 659 | * Function BTA_DmBlePasskeyReply |
| 660 | * |
| 661 | * Description Send BLE SMP passkey reply. |
| 662 | * |
| 663 | * Parameters: bd_addr - BD address of the peer |
| 664 | * accept - passkey entry sucessful or declined. |
| 665 | * passkey - passkey value, must be a 6 digit number, |
| 666 | * can be lead by 0. |
| 667 | * |
| 668 | * Returns void |
| 669 | * |
| 670 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 671 | void BTA_DmBlePasskeyReply(const bt_bdaddr_t& bd_addr, bool accept, |
| 672 | uint32_t passkey) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 673 | tBTA_DM_API_PASSKEY_REPLY* p_msg = |
| 674 | (tBTA_DM_API_PASSKEY_REPLY*)osi_calloc(sizeof(tBTA_DM_API_PASSKEY_REPLY)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 675 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 676 | p_msg->hdr.event = BTA_DM_API_BLE_PASSKEY_REPLY_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 677 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 678 | p_msg->accept = accept; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 679 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 680 | if (accept) p_msg->passkey = passkey; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 681 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 682 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 683 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 684 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 685 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 686 | * |
| 687 | * Function BTA_DmBleConfirmReply |
| 688 | * |
| 689 | * Description Send BLE SMP SC user confirmation reply. |
| 690 | * |
| 691 | * Parameters: bd_addr - BD address of the peer |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 692 | * accept - numbers to compare are the same or |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 693 | * different. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 694 | * |
| 695 | * Returns void |
| 696 | * |
| 697 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 698 | void BTA_DmBleConfirmReply(const bt_bdaddr_t& bd_addr, bool accept) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 699 | tBTA_DM_API_CONFIRM* p_msg = |
| 700 | (tBTA_DM_API_CONFIRM*)osi_calloc(sizeof(tBTA_DM_API_CONFIRM)); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 701 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 702 | p_msg->hdr.event = BTA_DM_API_BLE_CONFIRM_REPLY_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 703 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 704 | p_msg->accept = accept; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 705 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 706 | bta_sys_sendmsg(p_msg); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 710 | * |
| 711 | * Function BTA_DmBleSecurityGrant |
| 712 | * |
| 713 | * Description Grant security request access. |
| 714 | * |
| 715 | * Parameters: bd_addr - BD address of the peer |
| 716 | * res - security grant status. |
| 717 | * |
| 718 | * Returns void |
| 719 | * |
| 720 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 721 | void BTA_DmBleSecurityGrant(const bt_bdaddr_t& bd_addr, |
| 722 | tBTA_DM_BLE_SEC_GRANT res) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 723 | tBTA_DM_API_BLE_SEC_GRANT* p_msg = |
| 724 | (tBTA_DM_API_BLE_SEC_GRANT*)osi_calloc(sizeof(tBTA_DM_API_BLE_SEC_GRANT)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 725 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 726 | p_msg->hdr.event = BTA_DM_API_BLE_SEC_GRANT_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 727 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 728 | p_msg->res = res; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 729 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 730 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 731 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 732 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 733 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 734 | * |
| 735 | * Function BTA_DmSetBlePrefConnParams |
| 736 | * |
| 737 | * Description This function is called to set the preferred connection |
| 738 | * parameters when default connection parameter is not desired. |
| 739 | * |
| 740 | * Parameters: bd_addr - BD address of the peripheral |
| 741 | * scan_interval - scan interval |
| 742 | * scan_window - scan window |
| 743 | * min_conn_int - minimum preferred connection interval |
| 744 | * max_conn_int - maximum preferred connection interval |
| 745 | * slave_latency - preferred slave latency |
| 746 | * supervision_tout - preferred supervision timeout |
| 747 | * |
| 748 | * |
| 749 | * Returns void |
| 750 | * |
| 751 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 752 | void BTA_DmSetBlePrefConnParams(const bt_bdaddr_t& bd_addr, |
| 753 | uint16_t min_conn_int, uint16_t max_conn_int, |
| 754 | uint16_t slave_latency, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 755 | uint16_t supervision_tout) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 756 | tBTA_DM_API_BLE_CONN_PARAMS* p_msg = (tBTA_DM_API_BLE_CONN_PARAMS*)osi_calloc( |
| 757 | sizeof(tBTA_DM_API_BLE_CONN_PARAMS)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 758 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 759 | p_msg->hdr.event = BTA_DM_API_BLE_CONN_PARAM_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 760 | p_msg->peer_bda = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 761 | p_msg->conn_int_max = max_conn_int; |
| 762 | p_msg->conn_int_min = min_conn_int; |
| 763 | p_msg->slave_latency = slave_latency; |
| 764 | p_msg->supervision_tout = supervision_tout; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 765 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 766 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 770 | * |
| 771 | * Function BTA_DmSetBleConnScanParams |
| 772 | * |
| 773 | * Description This function is called to set scan parameters used in |
| 774 | * BLE connection request |
| 775 | * |
| 776 | * Parameters: scan_interval - scan interval |
| 777 | * scan_window - scan window |
| 778 | * |
| 779 | * Returns void |
| 780 | * |
| 781 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 782 | void BTA_DmSetBleConnScanParams(uint32_t scan_interval, uint32_t scan_window) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 783 | tBTA_DM_API_BLE_SCAN_PARAMS* p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS*)osi_calloc( |
| 784 | sizeof(tBTA_DM_API_BLE_SCAN_PARAMS)); |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 785 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 786 | p_msg->hdr.event = BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT; |
| 787 | p_msg->scan_int = scan_interval; |
| 788 | p_msg->scan_window = scan_window; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 789 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 790 | bta_sys_sendmsg(p_msg); |
Satya Calloji | 5725fc6 | 2015-03-31 13:24:32 -0700 | [diff] [blame] | 791 | } |
| 792 | |
Jakub Pawlowski | 83211b0 | 2016-12-07 11:25:15 -0800 | [diff] [blame] | 793 | /** |
| 794 | * Set BLE connectable mode to auto connect |
| 795 | */ |
| 796 | void BTA_DmBleStartAutoConn() { |
| 797 | tBTA_DM_API_SET_NAME* p_msg = |
| 798 | (tBTA_DM_API_SET_NAME*)osi_calloc(sizeof(tBTA_DM_API_SET_NAME)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 799 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 800 | p_msg->hdr.event = BTA_DM_API_BLE_SET_BG_CONN_TYPE; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 801 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 802 | } |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 803 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 804 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 805 | * |
| 806 | * Function bta_dm_discover_send_msg |
| 807 | * |
| 808 | * Description This function send discover message to BTA task. |
| 809 | * |
| 810 | * Returns void |
| 811 | * |
| 812 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 813 | static void bta_dm_discover_send_msg(const bt_bdaddr_t& bd_addr, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 814 | tBTA_SERVICE_MASK_EXT* p_services, |
| 815 | tBTA_DM_SEARCH_CBACK* p_cback, |
| 816 | bool sdp_search, |
| 817 | tBTA_TRANSPORT transport) { |
| 818 | const size_t len = p_services ? (sizeof(tBTA_DM_API_DISCOVER) + |
| 819 | sizeof(tBT_UUID) * p_services->num_uuid) |
| 820 | : sizeof(tBTA_DM_API_DISCOVER); |
| 821 | 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] | 822 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 823 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 824 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 825 | p_msg->p_cback = p_cback; |
| 826 | p_msg->sdp_search = sdp_search; |
| 827 | p_msg->transport = transport; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 828 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 829 | if (p_services != NULL) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 830 | p_msg->services = p_services->srvc_mask; |
| 831 | p_msg->num_uuid = p_services->num_uuid; |
| 832 | if (p_services->num_uuid != 0) { |
| 833 | p_msg->p_uuid = (tBT_UUID*)(p_msg + 1); |
| 834 | memcpy(p_msg->p_uuid, p_services->p_uuid, |
| 835 | sizeof(tBT_UUID) * p_services->num_uuid); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 836 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 837 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 838 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 839 | bta_sys_sendmsg(p_msg); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 840 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 841 | |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 842 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 843 | * |
| 844 | * Function BTA_DmDiscoverByTransport |
| 845 | * |
| 846 | * Description This function does service discovery on particular transport |
| 847 | * for services of a |
| 848 | * peer device. When services.num_uuid is 0, it indicates all |
| 849 | * GATT based services are to be searched; otherwise a list of |
| 850 | * UUID of interested services should be provided through |
| 851 | * p_services->p_uuid. |
| 852 | * |
| 853 | * |
| 854 | * |
| 855 | * Returns void |
| 856 | * |
| 857 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 858 | void BTA_DmDiscoverByTransport(const bt_bdaddr_t& bd_addr, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 859 | tBTA_SERVICE_MASK_EXT* p_services, |
| 860 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search, |
| 861 | tBTA_TRANSPORT transport) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 862 | 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] | 863 | } |
| 864 | |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 865 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 866 | * |
| 867 | * Function BTA_DmDiscoverExt |
| 868 | * |
| 869 | * Description This function does service discovery for services of a |
| 870 | * peer device. When services.num_uuid is 0, it indicates all |
| 871 | * GATT based services are to be searched; other wise a list of |
| 872 | * UUID of interested services should be provided through |
| 873 | * p_services->p_uuid. |
| 874 | * |
| 875 | * |
| 876 | * |
| 877 | * Returns void |
| 878 | * |
| 879 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 880 | void BTA_DmDiscoverExt(const bt_bdaddr_t& bd_addr, |
| 881 | tBTA_SERVICE_MASK_EXT* p_services, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 882 | tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 883 | bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, |
| 884 | BTA_TRANSPORT_UNKNOWN); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 888 | * |
| 889 | * Function BTA_DmSearchExt |
| 890 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 891 | * Description This function searches for peer Bluetooth devices. It |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 892 | * performs an inquiry and gets the remote name for devices. |
| 893 | * Service discovery is done if services is non zero |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 894 | * |
| 895 | * Parameters p_dm_inq: inquiry conditions |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 896 | * p_services: if service is not empty, service discovery will |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 897 | * be done. For all GATT based service conditions, |
| 898 | * put num_uuid, and p_uuid is the pointer to the |
| 899 | * list of UUID values. |
| 900 | * p_cback: callback function when search is completed. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 901 | * |
| 902 | * |
| 903 | * |
| 904 | * Returns void |
| 905 | * |
| 906 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 907 | void BTA_DmSearchExt(tBTA_DM_INQ* p_dm_inq, tBTA_SERVICE_MASK_EXT* p_services, |
| 908 | tBTA_DM_SEARCH_CBACK* p_cback) { |
| 909 | const size_t len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + |
| 910 | sizeof(tBT_UUID) * p_services->num_uuid) |
| 911 | : sizeof(tBTA_DM_API_SEARCH); |
| 912 | 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] | 913 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 914 | p_msg->hdr.event = BTA_DM_API_SEARCH_EVT; |
| 915 | memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ)); |
| 916 | p_msg->p_cback = p_cback; |
| 917 | p_msg->rs_res = BTA_DM_RS_NONE; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 918 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 919 | if (p_services != NULL) { |
| 920 | p_msg->services = p_services->srvc_mask; |
| 921 | p_msg->num_uuid = p_services->num_uuid; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 922 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 923 | if (p_services->num_uuid != 0) { |
| 924 | p_msg->p_uuid = (tBT_UUID*)(p_msg + 1); |
| 925 | memcpy(p_msg->p_uuid, p_services->p_uuid, |
| 926 | sizeof(tBT_UUID) * p_services->num_uuid); |
| 927 | } else { |
| 928 | p_msg->p_uuid = NULL; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 929 | } |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 930 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 931 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 932 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 933 | } |
Myles Watson | 9979121 | 2016-11-18 08:42:23 -0800 | [diff] [blame] | 934 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 935 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 936 | * |
| 937 | * Function BTA_DmBleUpdateConnectionParam |
| 938 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 939 | * Description Update connection parameters, can only be used when |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 940 | * connection is up. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 941 | * |
| 942 | * Parameters: bd_addr - BD address of the peer |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 943 | * min_int - minimum connection interval, |
| 944 | * [0x0004 ~ 0x4000] |
| 945 | * max_int - maximum connection interval, |
| 946 | * [0x0004 ~ 0x4000] |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 947 | * latency - slave latency [0 ~ 500] |
| 948 | * timeout - supervision timeout [0x000a ~ 0xc80] |
| 949 | * |
| 950 | * Returns void |
| 951 | * |
| 952 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 953 | void BTA_DmBleUpdateConnectionParam(const bt_bdaddr_t& bd_addr, |
| 954 | uint16_t min_int, uint16_t max_int, |
| 955 | uint16_t latency, uint16_t timeout) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 956 | tBTA_DM_API_UPDATE_CONN_PARAM* p_msg = |
| 957 | (tBTA_DM_API_UPDATE_CONN_PARAM*)osi_calloc( |
| 958 | sizeof(tBTA_DM_API_UPDATE_CONN_PARAM)); |
VenkatRaghavan VijayaRaghavan | 76356ae | 2015-04-21 11:32:29 -0700 | [diff] [blame] | 959 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 960 | p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 961 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 962 | p_msg->min_int = min_int; |
| 963 | p_msg->max_int = max_int; |
| 964 | p_msg->latency = latency; |
| 965 | p_msg->timeout = timeout; |
VenkatRaghavan VijayaRaghavan | 76356ae | 2015-04-21 11:32:29 -0700 | [diff] [blame] | 966 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 967 | bta_sys_sendmsg(p_msg); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 968 | } |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 969 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 970 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 971 | * |
| 972 | * Function BTA_DmBleConfigLocalPrivacy |
| 973 | * |
| 974 | * Description Enable/disable privacy on the local device |
| 975 | * |
| 976 | * Parameters: privacy_enable - enable/disabe privacy on remote device. |
| 977 | * |
| 978 | * Returns void |
| 979 | * |
| 980 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 981 | void BTA_DmBleConfigLocalPrivacy(bool privacy_enable) { |
Myles Watson | 84baa7f | 2016-11-14 12:05:37 -0800 | [diff] [blame] | 982 | #if (BLE_PRIVACY_SPT == TRUE) |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 983 | tBTA_DM_API_LOCAL_PRIVACY* p_msg = (tBTA_DM_API_LOCAL_PRIVACY*)osi_calloc( |
| 984 | sizeof(tBTA_DM_API_ENABLE_PRIVACY)); |
Wei Wang | ed534e3 | 2014-05-20 06:30:13 +0000 | [diff] [blame] | 985 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 986 | p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT; |
| 987 | p_msg->privacy_enable = privacy_enable; |
Wei Wang | ed534e3 | 2014-05-20 06:30:13 +0000 | [diff] [blame] | 988 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 989 | bta_sys_sendmsg(p_msg); |
Wei Wang | ed534e3 | 2014-05-20 06:30:13 +0000 | [diff] [blame] | 990 | #else |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 991 | UNUSED(privacy_enable); |
Wei Wang | ed534e3 | 2014-05-20 06:30:13 +0000 | [diff] [blame] | 992 | #endif |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 993 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 994 | |
| 995 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 996 | * |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 997 | * Function BTA_DmBleGetEnergyInfo |
| 998 | * |
| 999 | * Description This function is called to obtain the energy info |
| 1000 | * |
| 1001 | * Parameters p_cmpl_cback - Command complete callback |
| 1002 | * |
| 1003 | * Returns void |
| 1004 | * |
| 1005 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1006 | void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK* p_cmpl_cback) { |
| 1007 | const size_t len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR); |
| 1008 | tBTA_DM_API_ENERGY_INFO* p_msg = (tBTA_DM_API_ENERGY_INFO*)osi_calloc(len); |
Satya Calloji | e5ba884 | 2014-07-03 17:18:02 -0700 | [diff] [blame] | 1009 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1010 | APPL_TRACE_API("%s", __func__); |
Satya Calloji | e5ba884 | 2014-07-03 17:18:02 -0700 | [diff] [blame] | 1011 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1012 | p_msg->hdr.event = BTA_DM_API_BLE_ENERGY_INFO_EVT; |
| 1013 | p_msg->p_energy_info_cback = p_cmpl_cback; |
Pavlin Radoslavov | 717a4a9 | 2016-02-06 08:36:06 -0800 | [diff] [blame] | 1014 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1015 | bta_sys_sendmsg(p_msg); |
Satya Calloji | e5ba884 | 2014-07-03 17:18:02 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
| 1018 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1019 | * |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1020 | * Function BTA_DmBleUpdateConnectionParams |
| 1021 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1022 | * Description Update connection parameters, can only be used when |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 1023 | * connection is up. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1024 | * |
| 1025 | * Parameters: bd_addr - BD address of the peer |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 1026 | * min_int - minimum connection interval, |
| 1027 | * [0x0004 ~ 0x4000] |
| 1028 | * max_int - maximum connection interval, |
| 1029 | * [0x0004 ~ 0x4000] |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1030 | * latency - slave latency [0 ~ 500] |
| 1031 | * timeout - supervision timeout [0x000a ~ 0xc80] |
| 1032 | * |
| 1033 | * Returns void |
| 1034 | * |
| 1035 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1036 | void BTA_DmBleUpdateConnectionParams(const bt_bdaddr_t& bd_addr, |
| 1037 | uint16_t min_int, uint16_t max_int, |
| 1038 | uint16_t latency, uint16_t timeout) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1039 | tBTA_DM_API_UPDATE_CONN_PARAM* p_msg = |
| 1040 | (tBTA_DM_API_UPDATE_CONN_PARAM*)osi_calloc( |
| 1041 | sizeof(tBTA_DM_API_UPDATE_CONN_PARAM)); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 1042 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1043 | p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1044 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1045 | p_msg->min_int = min_int; |
| 1046 | p_msg->max_int = max_int; |
| 1047 | p_msg->latency = latency; |
| 1048 | p_msg->timeout = timeout; |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 1049 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1050 | bta_sys_sendmsg(p_msg); |
Wei Wang | ea85048 | 2014-05-20 04:52:26 +0000 | [diff] [blame] | 1051 | } |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 1052 | |
| 1053 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1054 | * |
| 1055 | * Function BTA_DmBleSetDataLength |
| 1056 | * |
| 1057 | * Description This function is to set maximum LE data packet size |
| 1058 | * |
| 1059 | * Returns void |
| 1060 | * |
| 1061 | * |
| 1062 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1063 | void BTA_DmBleSetDataLength(const bt_bdaddr_t& remote_device, |
| 1064 | uint16_t tx_data_length) { |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1065 | tBTA_DM_API_BLE_SET_DATA_LENGTH* p_msg = |
| 1066 | (tBTA_DM_API_BLE_SET_DATA_LENGTH*)osi_malloc( |
| 1067 | sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)); |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 1068 | |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1069 | p_msg->remote_bda = remote_device; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1070 | p_msg->hdr.event = BTA_DM_API_SET_DATA_LENGTH_EVT; |
| 1071 | p_msg->tx_data_length = tx_data_length; |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 1072 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1073 | bta_sys_sendmsg(p_msg); |
Priti Aghera | 636d671 | 2014-12-18 13:55:48 -0800 | [diff] [blame] | 1074 | } |
| 1075 | |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame] | 1076 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1077 | * |
| 1078 | * Function BTA_DmSetEncryption |
| 1079 | * |
| 1080 | * Description This function is called to ensure that connection is |
| 1081 | * encrypted. Should be called only on an open connection. |
| 1082 | * Typically only needed for connections that first want to |
| 1083 | * bring up unencrypted links, then later encrypt them. |
| 1084 | * |
| 1085 | * Parameters: bd_addr - Address of the peer device |
| 1086 | * transport - transport of the link to be encruypted |
| 1087 | * p_callback - Pointer to callback function to indicat the |
| 1088 | * link encryption status |
| 1089 | * sec_act - This is the security action to indicate |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 1090 | * what kind of BLE security level is required |
| 1091 | * for the BLE link if BLE is supported. |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1092 | * Note: This parameter is ignored for the |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 1093 | * BR/EDR or if BLE is not supported. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1094 | * |
| 1095 | * Returns void |
| 1096 | * |
| 1097 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1098 | void BTA_DmSetEncryption(const bt_bdaddr_t& bd_addr, tBTA_TRANSPORT transport, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1099 | tBTA_DM_ENCRYPT_CBACK* p_callback, |
| 1100 | tBTA_DM_BLE_SEC_ACT sec_act) { |
| 1101 | tBTA_DM_API_SET_ENCRYPTION* p_msg = (tBTA_DM_API_SET_ENCRYPTION*)osi_calloc( |
| 1102 | sizeof(tBTA_DM_API_SET_ENCRYPTION)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1103 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1104 | APPL_TRACE_API("%s", __func__); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1105 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1106 | p_msg->hdr.event = BTA_DM_API_SET_ENCRYPTION_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1107 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1108 | p_msg->transport = transport; |
| 1109 | p_msg->p_callback = p_callback; |
| 1110 | p_msg->sec_act = sec_act; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1111 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1112 | bta_sys_sendmsg(p_msg); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1113 | } |
| 1114 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1115 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1116 | * |
| 1117 | * Function BTA_DmCloseACL |
| 1118 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1119 | * Description This function force to close an ACL connection and remove |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 1120 | * the device from the security database list of known devices. |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1121 | * |
| 1122 | * Parameters: bd_addr - Address of the peer device |
| 1123 | * remove_dev - remove device or not after link down |
| 1124 | * |
| 1125 | * Returns void |
| 1126 | * |
| 1127 | ******************************************************************************/ |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1128 | void BTA_DmCloseACL(const bt_bdaddr_t& bd_addr, bool remove_dev, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1129 | tBTA_TRANSPORT transport) { |
| 1130 | tBTA_DM_API_REMOVE_ACL* p_msg = |
| 1131 | (tBTA_DM_API_REMOVE_ACL*)osi_calloc(sizeof(tBTA_DM_API_REMOVE_ACL)); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1132 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1133 | APPL_TRACE_API("%s", __func__); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1134 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1135 | p_msg->hdr.event = BTA_DM_API_REMOVE_ACL_EVT; |
Jakub Pawlowski | c2276b0 | 2017-06-09 16:00:25 -0700 | [diff] [blame^] | 1136 | p_msg->bd_addr = bd_addr; |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1137 | p_msg->remove_dev = remove_dev; |
| 1138 | p_msg->transport = transport; |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1139 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1140 | bta_sys_sendmsg(p_msg); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1141 | } |
| 1142 | |
| 1143 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1144 | * |
| 1145 | * Function BTA_DmBleObserve |
| 1146 | * |
| 1147 | * Description This procedure keep the device listening for advertising |
| 1148 | * events from a broadcast device. |
| 1149 | * |
| 1150 | * Parameters start: start or stop observe. |
| 1151 | * |
| 1152 | * Returns void |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1153 | |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1154 | * |
| 1155 | * Returns void. |
| 1156 | * |
| 1157 | ******************************************************************************/ |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 1158 | extern void BTA_DmBleObserve(bool start, uint8_t duration, |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1159 | tBTA_DM_SEARCH_CBACK* p_results_cb) { |
| 1160 | tBTA_DM_API_BLE_OBSERVE* p_msg = |
| 1161 | (tBTA_DM_API_BLE_OBSERVE*)osi_calloc(sizeof(tBTA_DM_API_BLE_OBSERVE)); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1162 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1163 | APPL_TRACE_API("%s:start = %d ", __func__, start); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1164 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1165 | p_msg->hdr.event = BTA_DM_API_BLE_OBSERVE_EVT; |
| 1166 | p_msg->start = start; |
| 1167 | p_msg->duration = duration; |
| 1168 | p_msg->p_cback = p_results_cb; |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1169 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1170 | bta_sys_sendmsg(p_msg); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1171 | } |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 1172 | |
| 1173 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1174 | * |
| 1175 | * Function BTA_VendorInit |
| 1176 | * |
| 1177 | * Description This function initializes vendor specific |
| 1178 | * |
| 1179 | * Returns void |
| 1180 | * |
| 1181 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1182 | void BTA_VendorInit(void) { APPL_TRACE_API("BTA_VendorInit"); } |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 1183 | |
| 1184 | /******************************************************************************* |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1185 | * |
| 1186 | * Function BTA_VendorCleanup |
| 1187 | * |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1188 | * Description This function frees up Broadcom specific VS specific dynamic |
Myles Watson | 1baaae3 | 2016-11-09 14:25:23 -0800 | [diff] [blame] | 1189 | * memory |
Myles Watson | 8af480e | 2016-11-09 10:40:23 -0800 | [diff] [blame] | 1190 | * |
| 1191 | * Returns void |
| 1192 | * |
| 1193 | ******************************************************************************/ |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1194 | void BTA_VendorCleanup(void) { |
| 1195 | tBTM_BLE_VSC_CB cmn_ble_vsc_cb; |
| 1196 | BTM_BleGetVendorCapabilities(&cmn_ble_vsc_cb); |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 1197 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1198 | if (cmn_ble_vsc_cb.max_filter > 0) { |
| 1199 | btm_ble_adv_filter_cleanup(); |
Marie Janssen | e9e58ce | 2016-06-17 14:12:17 -0700 | [diff] [blame] | 1200 | #if (BLE_PRIVACY_SPT == TRUE) |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1201 | btm_ble_resolving_list_cleanup(); |
Satya Calloji | 444a8da | 2015-03-06 10:38:22 -0800 | [diff] [blame] | 1202 | #endif |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1203 | } |
Prerepa Viswanadham | 16fe082 | 2014-08-07 11:38:06 -0700 | [diff] [blame] | 1204 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1205 | 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] | 1206 | |
Myles Watson | cd1fd07 | 2016-11-09 13:17:43 -0800 | [diff] [blame] | 1207 | 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] | 1208 | } |