• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2003-2014 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the public interface file for BTA, Broadcom's Bluetooth
22  *  application layer for mobile phones.
23  *
24  ******************************************************************************/
25 #ifndef BTA_API_H
26 #define BTA_API_H
27 
28 #include <cstdint>
29 #include <vector>
30 
31 #include "bt_target.h"  // Must be first to define build configuration
32 
33 #include "osi/include/log.h"
34 #include "stack/include/bt_types.h"
35 #include "stack/include/btm_api_types.h"
36 #include "stack/include/btm_ble_api_types.h"
37 #include "stack/include/hci_error_code.h"
38 #include "stack/include/sdp_api.h"
39 #include "types/ble_address_with_type.h"
40 #include "types/bluetooth/uuid.h"
41 #include "types/bt_transport.h"
42 #include "types/raw_address.h"
43 
44 /*****************************************************************************
45  *  Constants and data types
46  ****************************************************************************/
47 
48 /* Status Return Value */
49 typedef enum : uint8_t {
50   BTA_SUCCESS = 0, /* Successful operation. */
51   BTA_FAILURE = 1, /* Generic failure. */
52   BTA_PENDING = 2, /* API cannot be completed right now */
53   BTA_BUSY = 3,
54   BTA_NO_RESOURCES = 4,
55   BTA_WRONG_MODE = 5,
56 } tBTA_STATUS;
57 
58 /*
59  * Service ID
60  */
61 
62 #define BTA_A2DP_SOURCE_SERVICE_ID 3 /* A2DP Source profile. */
63 #define BTA_HSP_SERVICE_ID 5         /* Headset profile. */
64 #define BTA_HFP_SERVICE_ID 6         /* Hands-free profile. */
65 #define BTA_BIP_SERVICE_ID 13        /* Basic Imaging profile */
66 #define BTA_A2DP_SINK_SERVICE_ID 18  /* A2DP Sink */
67 #define BTA_HID_SERVICE_ID 20        /* HID */
68 #define BTA_HFP_HS_SERVICE_ID 24     /* HSP HS role */
69 #define BTA_SDP_SERVICE_ID 29        /* SDP Search */
70 #define BTA_HIDD_SERVICE_ID 30       /* HID Device */
71 
72 /* BLE profile service ID */
73 #define BTA_BLE_SERVICE_ID 31  /* GATT profile */
74 #define BTA_USER_SERVICE_ID 32 /* User requested UUID */
75 #define BTA_MAX_SERVICE_ID 33
76 
77 /* service IDs (BTM_SEC_SERVICE_FIRST_EMPTY + 1) to (BTM_SEC_MAX_SERVICES - 1)
78  * are used by BTA JV */
79 #define BTA_FIRST_JV_SERVICE_ID (BTM_SEC_SERVICE_FIRST_EMPTY + 1)
80 #define BTA_LAST_JV_SERVICE_ID (BTM_SEC_MAX_SERVICES - 1)
81 
82 typedef uint8_t tBTA_SERVICE_ID;
83 
84 /* Service ID Mask */
85 #define BTA_RES_SERVICE_MASK 0x00000001    /* Reserved */
86 #define BTA_HSP_SERVICE_MASK 0x00000020    /* HSP AG role. */
87 #define BTA_HFP_SERVICE_MASK 0x00000040    /* HFP AG role */
88 #define BTA_HL_SERVICE_MASK 0x08000000     /* Health Device Profile */
89 
90 #define BTA_BLE_SERVICE_MASK 0x40000000  /* GATT based service */
91 #define BTA_ALL_SERVICE_MASK 0x7FFFFFFF  /* All services supported by BTA. */
92 #define BTA_USER_SERVICE_MASK 0x80000000 /* Message Notification Profile */
93 
94 typedef uint32_t tBTA_SERVICE_MASK;
95 
96 /* Security Setting Mask */
97 #define BTA_SEC_AUTHENTICATE \
98   (BTM_SEC_IN_AUTHENTICATE | \
99    BTM_SEC_OUT_AUTHENTICATE) /* Authentication required. */
100 #define BTA_SEC_ENCRYPT \
101   (BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT) /* Encryption required. */
102 
103 typedef uint16_t tBTA_SEC;
104 
105 #define BTA_APP_ID_PAN_MULTI 0xFE /* app id for pan multiple connection */
106 #define BTA_ALL_APP_ID 0xFF
107 
108 /* Discoverable Modes */
109 #define BTA_DM_NON_DISC BTM_NON_DISCOVERABLE /* Device is not discoverable. */
110 #define BTA_DM_GENERAL_DISC                         \
111   BTM_GENERAL_DISCOVERABLE /* General discoverable. \
112                               */
113 typedef uint16_t
114     tBTA_DM_DISC; /* this discoverability mode is a bit mask among BR mode and
115                      LE mode */
116 
117 /* Connectable Modes */
118 #define BTA_DM_NON_CONN BTM_NON_CONNECTABLE /* Device is not connectable. */
119 #define BTA_DM_CONN BTM_CONNECTABLE         /* Device is connectable. */
120 
121 typedef uint16_t tBTA_DM_CONN;
122 
123 /* Central/peripheral preferred roles */
124 typedef enum : uint8_t {
125   BTA_ANY_ROLE = 0x00,
126   BTA_CENTRAL_ROLE_PREF = 0x01,
127   BTA_CENTRAL_ROLE_ONLY = 0x02,
128   /* Used for PANU only, skip role switch to central */
129   BTA_PERIPHERAL_ROLE_ONLY = 0x03,
130 } tBTA_PREF_ROLES;
131 
toBTA_PREF_ROLES(uint8_t role)132 inline tBTA_PREF_ROLES toBTA_PREF_ROLES(uint8_t role) {
133   ASSERT_LOG(role <= BTA_PERIPHERAL_ROLE_ONLY,
134              "Passing illegal preferred role:0x%02x [0x%02x<=>0x%02x]", role,
135              BTA_ANY_ROLE, BTA_PERIPHERAL_ROLE_ONLY);
136   return static_cast<tBTA_PREF_ROLES>(role);
137 }
138 
139 #define CASE_RETURN_TEXT(code) \
140   case code:                   \
141     return #code
142 
preferred_role_text(const tBTA_PREF_ROLES & role)143 inline std::string preferred_role_text(const tBTA_PREF_ROLES& role) {
144   switch (role) {
145     CASE_RETURN_TEXT(BTA_ANY_ROLE);
146     CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_PREF);
147     CASE_RETURN_TEXT(BTA_CENTRAL_ROLE_ONLY);
148     CASE_RETURN_TEXT(BTA_PERIPHERAL_ROLE_ONLY);
149     default:
150       return std::string("UNKNOWN:%hhu", role);
151   }
152 }
153 #undef CASE_RETURN_TEXT
154 
155 enum {
156 
157   BTA_DM_NO_SCATTERNET,      /* Device doesn't support scatternet, it might
158                                 support "role switch during connection" for
159                                 an incoming connection, when it already has
160                                 another connection in central role */
161   BTA_DM_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
162                                 simultaneous connection in Central and
163                                 Peripheral roles for short period of time */
164   BTA_DM_FULL_SCATTERNET /* Device can have simultaneous connection in central
165                             and peripheral roles */
166 
167 };
168 
169 typedef struct {
170   uint8_t bta_dm_eir_min_name_len; /* minimum length of local name when it is
171                                       shortened */
172 #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
173   uint8_t bta_dm_eir_uuid16_len; /* length of 16-bit UUIDs */
174   uint8_t* bta_dm_eir_uuid16;    /* 16-bit UUIDs */
175 #else
176   uint32_t uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
177 #endif
178   int8_t* bta_dm_eir_inq_tx_power;     /* Inquiry TX power         */
179   uint8_t bta_dm_eir_flag_len;         /* length of flags in bytes */
180   uint8_t* bta_dm_eir_flags;           /* flags for EIR */
181   uint8_t bta_dm_eir_manufac_spec_len; /* length of manufacturer specific in
182                                           bytes */
183   uint8_t* bta_dm_eir_manufac_spec;    /* manufacturer specific */
184   uint8_t bta_dm_eir_additional_len;   /* length of additional data in bytes */
185   uint8_t* bta_dm_eir_additional;      /* additional data */
186 } tBTA_DM_EIR_CONF;
187 
188 typedef uint8_t tBTA_DM_BLE_RSSI_ALERT_TYPE;
189 
190 /* Security Callback Events */
191 #define BTA_DM_PIN_REQ_EVT 2   /* PIN request. */
192 #define BTA_DM_AUTH_CMPL_EVT 3 /* Authentication complete indication. */
193 #define BTA_DM_AUTHORIZE_EVT 4 /* Authorization request. */
194 #define BTA_DM_LINK_UP_EVT 5   /* Connection UP event */
195 #define BTA_DM_LINK_DOWN_EVT 6 /* Connection DOWN event */
196 #define BTA_DM_BOND_CANCEL_CMPL_EVT 9 /* Bond cancel complete indication */
197 #define BTA_DM_SP_CFM_REQ_EVT                     \
198   10 /* Simple Pairing User Confirmation request. \
199         */
200 #define BTA_DM_SP_KEY_NOTIF_EVT 11 /* Simple Pairing Passkey Notification */
201 #define BTA_DM_BLE_KEY_EVT 15      /* BLE SMP key event for peer device keys */
202 #define BTA_DM_BLE_SEC_REQ_EVT 16  /* BLE SMP security request */
203 #define BTA_DM_BLE_PASSKEY_NOTIF_EVT 17 /* SMP passkey notification event */
204 #define BTA_DM_BLE_PASSKEY_REQ_EVT 18   /* SMP passkey request event */
205 #define BTA_DM_BLE_OOB_REQ_EVT 19       /* SMP OOB request event */
206 #define BTA_DM_BLE_LOCAL_IR_EVT 20      /* BLE local IR event */
207 #define BTA_DM_BLE_LOCAL_ER_EVT 21      /* BLE local ER event */
208 #define BTA_DM_BLE_NC_REQ_EVT 22 /* SMP Numeric Comparison request event */
209 #define BTA_DM_SP_RMT_OOB_EXT_EVT \
210   23 /* Simple Pairing Remote OOB Extended Data request. */
211 #define BTA_DM_BLE_AUTH_CMPL_EVT 24 /* BLE Auth complete */
212 #define BTA_DM_DEV_UNPAIRED_EVT 25
213 #define BTA_DM_LE_FEATURES_READ                                             \
214   27                             /* Cotroller specific LE features are read \
215                                     */
216 #define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
217 #define BTA_DM_BLE_SC_OOB_REQ_EVT 29 /* SMP SC OOB request event */
218 #define BTA_DM_BLE_CONSENT_REQ_EVT 30 /* SMP consent request event */
219 #define BTA_DM_BLE_SC_CR_LOC_OOB_EVT \
220   31 /* SMP SC Create Local OOB request event */
221 typedef uint8_t tBTA_DM_SEC_EVT;
222 
223 /* Structure associated with BTA_DM_PIN_REQ_EVT */
224 typedef struct {
225   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
226    * order */
227   RawAddress bd_addr;  /* BD address peer device. */
228   DEV_CLASS dev_class; /* Class of Device */
229   BD_NAME bd_name;     /* Name of peer device. */
230   bool min_16_digit;   /* true if the pin returned must be at least 16 digits */
231 } tBTA_DM_PIN_REQ;
232 
233 /* BLE related definition */
234 
235 #define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10)
236 
237 /* Converts SMP error codes defined in smp_api.h to SMP auth fail reasons below.
238  */
239 #define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x))
240 
241 #define BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL \
242   (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_AUTH_FAIL)
243 #define BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL \
244   (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_VALUE_ERR)
245 #define BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT \
246   (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_NOT_SUPPORT)
247 #define BTA_DM_AUTH_SMP_UNKNOWN_ERR \
248   (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_FAIL_UNKNOWN)
249 #define BTA_DM_AUTH_SMP_CONN_TOUT (BTA_DM_AUTH_FAIL_BASE + SMP_CONN_TOUT)
250 
251 typedef uint8_t tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
252 
253 typedef union {
254   tBTM_LE_PENC_KEYS penc_key;  /* received peer encryption key */
255   tBTM_LE_PCSRK_KEYS psrk_key; /* received peer device SRK */
256   tBTM_LE_PID_KEYS pid_key;    /* peer device ID key */
257   tBTM_LE_LENC_KEYS
258       lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
259   tBTM_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
260   tBTM_LE_PID_KEYS lid_key; /* local device ID key for the particular remote */
261 } tBTA_LE_KEY_VALUE;
262 
263 #define BTA_BLE_LOCAL_KEY_TYPE_ID 1
264 #define BTA_BLE_LOCAL_KEY_TYPE_ER 2
265 typedef uint8_t tBTA_DM_BLE_LOCAL_KEY_MASK;
266 
267 typedef struct {
268   Octet16 ir;
269   Octet16 irk;
270   Octet16 dhk;
271 } tBTA_BLE_LOCAL_ID_KEYS;
272 
273 #define BTA_DM_SEC_GRANTED BTA_SUCCESS
274 #define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
275 typedef uint8_t tBTA_DM_BLE_SEC_GRANT;
276 
277 /* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
278 typedef struct {
279   RawAddress bd_addr; /* peer address */
280   BD_NAME bd_name; /* peer device name */
281 } tBTA_DM_BLE_SEC_REQ;
282 
283 typedef struct {
284   RawAddress bd_addr; /* peer address */
285   tBTM_LE_KEY_TYPE key_type;
286   tBTM_LE_KEY_VALUE* p_key_value;
287 } tBTA_DM_BLE_KEY;
288 
289 /* Structure associated with BTA_DM_AUTH_CMPL_EVT */
290 typedef struct {
291   RawAddress bd_addr;  /* BD address peer device. */
292   BD_NAME bd_name;     /* Name of peer device. */
293   bool key_present;    /* Valid link key value in key element */
294   LinkKey key;         /* Link key associated with peer device. */
295   uint8_t key_type;    /* The type of Link Key */
296   bool success;        /* true of authentication succeeded, false if failed. */
297   tHCI_REASON
298       fail_reason; /* The HCI reason/error code for when success=false */
299   tBLE_ADDR_TYPE addr_type; /* Peer device address type */
300   tBT_DEVICE_TYPE dev_type;
301 } tBTA_DM_AUTH_CMPL;
302 
303 /* Structure associated with BTA_DM_LINK_UP_EVT */
304 typedef struct {
305   RawAddress bd_addr; /* BD address peer device. */
306 } tBTA_DM_LINK_UP;
307 
308 /* Structure associated with BTA_DM_LINK_DOWN_EVT */
309 typedef struct {
310   RawAddress bd_addr; /* BD address peer device. */
311 } tBTA_DM_LINK_DOWN;
312 
313 #define BTA_AUTH_SP_YES                                                       \
314   BTM_AUTH_SP_YES /* 1 MITM Protection Required - Single Profile/non-bonding  \
315                     Use IO Capabilities to determine authentication procedure \
316                     */
317 
318 #define BTA_AUTH_DD_BOND \
319   BTM_AUTH_DD_BOND /* 2 this bit is set for dedicated bonding */
320 #define BTA_AUTH_GEN_BOND \
321   BTM_AUTH_SPGB_NO /* 4 this bit is set for general bonding */
322 #define BTA_AUTH_BONDS \
323   BTM_AUTH_BONDS /* 6 the general/dedicated bonding bits  */
324 
325 #define BTA_LE_AUTH_REQ_SC_MITM_BOND BTM_LE_AUTH_REQ_SC_MITM_BOND /* 1101 */
326 
327 /* Structure associated with BTA_DM_SP_CFM_REQ_EVT */
328 typedef struct {
329   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
330    * order */
331   RawAddress bd_addr;  /* peer address */
332   DEV_CLASS dev_class; /* peer CoD */
333   BD_NAME bd_name;     /* peer device name */
334   uint32_t num_val; /* the numeric value for comparison. If just_works, do not
335                        show this number to UI */
336   bool just_works;  /* true, if "Just Works" association model */
337   tBTM_AUTH_REQ loc_auth_req; /* Authentication required for local device */
338   tBTM_AUTH_REQ rmt_auth_req; /* Authentication required for peer device */
339   tBTM_IO_CAP loc_io_caps;    /* IO Capabilities of local device */
340   tBTM_AUTH_REQ rmt_io_caps;  /* IO Capabilities of remote device */
341 } tBTA_DM_SP_CFM_REQ;
342 
343 /* Structure associated with BTA_DM_SP_KEY_NOTIF_EVT */
344 typedef struct {
345   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
346    * order */
347   RawAddress bd_addr;  /* peer address */
348   DEV_CLASS dev_class; /* peer CoD */
349   BD_NAME bd_name;     /* peer device name */
350   uint32_t passkey; /* the numeric value for comparison. If just_works, do not
351                        show this number to UI */
352 } tBTA_DM_SP_KEY_NOTIF;
353 
354 /* Structure associated with BTA_DM_SP_RMT_OOB_EVT */
355 typedef struct {
356   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
357    * order */
358   RawAddress bd_addr;  /* peer address */
359   DEV_CLASS dev_class; /* peer CoD */
360   BD_NAME bd_name;     /* peer device name */
361 } tBTA_DM_SP_RMT_OOB;
362 
363 /* Structure associated with BTA_DM_BOND_CANCEL_CMPL_EVT */
364 typedef struct {
365   tBTA_STATUS result; /* true of bond cancel succeeded, false if failed. */
366 } tBTA_DM_BOND_CANCEL_CMPL;
367 
368 typedef struct {
369   Octet16 local_oob_c; /* Local OOB Data Confirmation/Commitment */
370   Octet16 local_oob_r; /* Local OOB Data Randomizer */
371 } tBTA_DM_LOC_OOB_DATA;
372 
373 /* Union of all security callback structures */
374 typedef union {
375   tBTA_DM_PIN_REQ pin_req;        /* PIN request. */
376   tBTA_DM_AUTH_CMPL auth_cmpl;    /* Authentication complete indication. */
377   tBTA_DM_LINK_UP link_up;        /* ACL connection down event */
378   tBTA_DM_LINK_DOWN link_down;    /* ACL connection down event */
379   tBTA_DM_SP_CFM_REQ cfm_req;     /* user confirm request */
380   tBTA_DM_SP_KEY_NOTIF key_notif; /* passkey notification */
381   tBTA_DM_SP_RMT_OOB rmt_oob;     /* remote oob */
382   tBTA_DM_BOND_CANCEL_CMPL
383       bond_cancel_cmpl;               /* Bond Cancel Complete indication */
384   tBTA_DM_BLE_SEC_REQ ble_req;        /* BLE SMP related request */
385   tBTA_DM_BLE_KEY ble_key;            /* BLE SMP keys used when pairing */
386   tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
387   Octet16 ble_er;                     /* ER event data */
388   tBTA_DM_LOC_OOB_DATA local_oob_data; /* Local OOB data generated by us */
389 } tBTA_DM_SEC;
390 
391 /* Security callback */
392 typedef void(tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data);
393 
394 #define BTA_DM_BLE_PF_LIST_LOGIC_OR 1
395 #define BTA_DM_BLE_PF_FILT_LOGIC_OR 0
396 
397 /* Search callback events */
398 #define BTA_DM_INQ_RES_EVT 0  /* Inquiry result for a peer device. */
399 #define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
400 #define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */
401 #define BTA_DM_DISC_BLE_RES_EVT \
402   3 /* Discovery result for BLE GATT based servoce on a peer device. */
403 #define BTA_DM_DISC_CMPL_EVT 4          /* Discovery complete. */
404 #define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
405 
406 typedef uint8_t tBTA_DM_SEARCH_EVT;
407 
408 /* Structure associated with BTA_DM_INQ_RES_EVT */
409 typedef struct {
410   RawAddress bd_addr;          /* BD address peer device. */
411   DEV_CLASS dev_class;         /* Device class of peer device. */
412   bool remt_name_not_required; /* Application sets this flag if it already knows
413                                   the name of the device */
414   /* If the device name is known to application BTA skips the remote name
415    * request */
416   bool is_limited; /* true, if the limited inquiry bit is set in the CoD */
417   int8_t rssi;     /* The rssi value */
418   uint8_t* p_eir;  /* received EIR */
419   uint16_t eir_len; /* received EIR length */
420   uint8_t inq_result_type;
421   tBLE_ADDR_TYPE ble_addr_type;
422   uint16_t ble_evt_type;
423   uint8_t ble_primary_phy;
424   uint8_t ble_secondary_phy;
425   uint8_t ble_advertising_sid;
426   int8_t ble_tx_power;
427   uint16_t ble_periodic_adv_int;
428   tBT_DEVICE_TYPE device_type;
429   uint8_t flag;
430 } tBTA_DM_INQ_RES;
431 
432 /* Structure associated with BTA_DM_INQ_CMPL_EVT */
433 typedef struct {
434   uint8_t num_resps; /* Number of inquiry responses. */
435 } tBTA_DM_INQ_CMPL;
436 
437 /* Structure associated with BTA_DM_DISC_RES_EVT */
438 typedef struct {
439   RawAddress bd_addr;          /* BD address peer device. */
440   BD_NAME bd_name;             /* Name of peer device. */
441   tBTA_SERVICE_MASK services;  /* Services found on peer device. */
442   tBT_DEVICE_TYPE device_type; /* device type in case it is BLE device */
443   uint32_t num_uuids;
444   bluetooth::Uuid* p_uuid_list;
445   tBTA_STATUS result;
446 } tBTA_DM_DISC_RES;
447 
448 /* Structure associated with tBTA_DM_DISC_BLE_RES */
449 typedef struct {
450   RawAddress bd_addr; /* BD address peer device. */
451   BD_NAME bd_name;  /* Name of peer device. */
452   std::vector<bluetooth::Uuid>*
453       services; /* GATT based Services UUID found on peer device. */
454 } tBTA_DM_DISC_BLE_RES;
455 
456 /* Union of all search callback structures */
457 typedef union {
458   tBTA_DM_INQ_RES inq_res;   /* Inquiry result for a peer device. */
459   tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
460   tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
461   tBTA_DM_DISC_BLE_RES
462       disc_ble_res;             /* discovery result for GATT based service */
463 } tBTA_DM_SEARCH;
464 
465 /* Search callback */
466 typedef void(tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event,
467                                    tBTA_DM_SEARCH* p_data);
468 
469 /* Execute call back */
470 typedef void(tBTA_DM_EXEC_CBACK)(void* p_param);
471 
472 /* Encryption callback*/
473 typedef void(tBTA_DM_ENCRYPT_CBACK)(const RawAddress& bd_addr,
474                                     tBT_TRANSPORT transport,
475                                     tBTA_STATUS result);
476 
477 #define BTA_DM_CONTRL_UNKNOWN 0 /* Unknown state */
478 
479 typedef uint8_t tBTA_DM_CONTRL_STATE;
480 
481 typedef void(tBTA_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time,
482                                          tBTM_BLE_RX_TIME_MS rx_time,
483                                          tBTM_BLE_IDLE_TIME_MS idle_time,
484                                          tBTM_BLE_ENERGY_USED energy_used,
485                                          tBTA_DM_CONTRL_STATE ctrl_state,
486                                          tBTA_STATUS status);
487 
488 /* Maximum service name length */
489 #define BTA_SERVICE_NAME_LEN 35
490 
491 typedef enum : uint8_t {
492   /* power mode actions  */
493   BTA_DM_PM_NO_ACTION = 0x00, /* no change to the current pm setting */
494   BTA_DM_PM_PARK = 0x10,      /* prefers park mode */
495   BTA_DM_PM_SNIFF = 0x20,     /* prefers sniff mode */
496   BTA_DM_PM_SNIFF1 = 0x21,    /* prefers sniff1 mode */
497   BTA_DM_PM_SNIFF2 = 0x22,    /* prefers sniff2 mode */
498   BTA_DM_PM_SNIFF3 = 0x23,    /* prefers sniff3 mode */
499   BTA_DM_PM_SNIFF4 = 0x24,    /* prefers sniff4 mode */
500   BTA_DM_PM_SNIFF5 = 0x25,    /* prefers sniff5 mode */
501   BTA_DM_PM_SNIFF6 = 0x26,    /* prefers sniff6 mode */
502   BTA_DM_PM_SNIFF7 = 0x27,    /* prefers sniff7 mode */
503   BTA_DM_PM_SNIFF_USER0 =
504       0x28, /* prefers user-defined sniff0 mode (testtool only) */
505   BTA_DM_PM_SNIFF_USER1 =
506       0x29, /* prefers user-defined sniff1 mode (testtool only) */
507   BTA_DM_PM_ACTIVE = 0x40,  /* prefers active mode */
508   BTA_DM_PM_RETRY = 0x80,   /* retry power mode based on current settings */
509   BTA_DM_PM_SUSPEND = 0x04, /* prefers suspend mode */
510   BTA_DM_PM_NO_PREF = 0x01, /* service has no preference on power mode setting.
511                                eg. connection to \ service got closed */
512   BTA_DM_PM_SNIFF_MASK = 0x0f,  // Masks the sniff submode
513 } tBTA_DM_PM_ACTION_BITMASK;
514 typedef uint8_t tBTA_DM_PM_ACTION;
515 
516 /* index to bta_dm_ssr_spec */
517 enum {
518   BTA_DM_PM_SSR0 = 0,
519   /* BTA_DM_PM_SSR1 will be dedicated for \
520      HH SSR setting entry, no other profile can use it */
521   BTA_DM_PM_SSR1 = 1,
522   BTA_DM_PM_SSR2 = 2,
523   BTA_DM_PM_SSR3 = 3,
524   BTA_DM_PM_SSR4 = 4,
525 };
526 
527 #define BTA_DM_PM_NUM_EVTS 9
528 
529 #ifndef BTA_DM_PM_PARK_IDX
530 #define BTA_DM_PM_PARK_IDX \
531   6 /* the actual index to bta_dm_pm_md[] for PARK mode */
532 #endif
533 
534 #ifndef BTA_DM_PM_SNIFF_A2DP_IDX
535 #define BTA_DM_PM_SNIFF_A2DP_IDX BTA_DM_PM_SNIFF
536 #endif
537 
538 #ifndef BTA_DM_PM_SNIFF_HD_IDLE_IDX
539 #define BTA_DM_PM_SNIFF_HD_IDLE_IDX BTA_DM_PM_SNIFF2
540 #endif
541 
542 #ifndef BTA_DM_PM_SNIFF_SCO_OPEN_IDX
543 #define BTA_DM_PM_SNIFF_SCO_OPEN_IDX BTA_DM_PM_SNIFF3
544 #endif
545 
546 #ifndef BTA_DM_PM_SNIFF_HD_ACTIVE_IDX
547 #define BTA_DM_PM_SNIFF_HD_ACTIVE_IDX BTA_DM_PM_SNIFF4
548 #endif
549 
550 #ifndef BTA_DM_PM_SNIFF_HH_OPEN_IDX
551 #define BTA_DM_PM_SNIFF_HH_OPEN_IDX BTA_DM_PM_SNIFF2
552 #endif
553 
554 #ifndef BTA_DM_PM_SNIFF_HH_ACTIVE_IDX
555 #define BTA_DM_PM_SNIFF_HH_ACTIVE_IDX BTA_DM_PM_SNIFF2
556 #endif
557 
558 #ifndef BTA_DM_PM_SNIFF_HH_IDLE_IDX
559 #define BTA_DM_PM_SNIFF_HH_IDLE_IDX BTA_DM_PM_SNIFF2
560 #endif
561 
562 #ifndef BTA_DM_PM_HH_OPEN_DELAY
563 #define BTA_DM_PM_HH_OPEN_DELAY 30000
564 #endif
565 
566 #ifndef BTA_DM_PM_HH_ACTIVE_DELAY
567 #define BTA_DM_PM_HH_ACTIVE_DELAY 30000
568 #endif
569 
570 #ifndef BTA_DM_PM_HH_IDLE_DELAY
571 #define BTA_DM_PM_HH_IDLE_DELAY 30000
572 #endif
573 
574 /* The Sniff Parameters defined below must be ordered from highest
575  * latency (biggest interval) to lowest latency.  If there is a conflict
576  * among the connected services the setting with the lowest latency will
577  * be selected.  If a device should override a sniff parameter then it
578  * must insure that order is maintained.
579  */
580 #ifndef BTA_DM_PM_SNIFF_MAX
581 #define BTA_DM_PM_SNIFF_MAX 800
582 #define BTA_DM_PM_SNIFF_MIN 400
583 #define BTA_DM_PM_SNIFF_ATTEMPT 4
584 #define BTA_DM_PM_SNIFF_TIMEOUT 1
585 #endif
586 
587 #ifndef BTA_DM_PM_SNIFF1_MAX
588 #define BTA_DM_PM_SNIFF1_MAX 400
589 #define BTA_DM_PM_SNIFF1_MIN 200
590 #define BTA_DM_PM_SNIFF1_ATTEMPT 4
591 #define BTA_DM_PM_SNIFF1_TIMEOUT 1
592 #endif
593 
594 #ifndef BTA_DM_PM_SNIFF2_MAX
595 #define BTA_DM_PM_SNIFF2_MAX 54
596 #define BTA_DM_PM_SNIFF2_MIN 30
597 #define BTA_DM_PM_SNIFF2_ATTEMPT 4
598 #define BTA_DM_PM_SNIFF2_TIMEOUT 1
599 #endif
600 
601 #ifndef BTA_DM_PM_SNIFF3_MAX
602 #define BTA_DM_PM_SNIFF3_MAX 150
603 #define BTA_DM_PM_SNIFF3_MIN 50
604 #define BTA_DM_PM_SNIFF3_ATTEMPT 4
605 #define BTA_DM_PM_SNIFF3_TIMEOUT 1
606 #endif
607 
608 #ifndef BTA_DM_PM_SNIFF4_MAX
609 #define BTA_DM_PM_SNIFF4_MAX 18
610 #define BTA_DM_PM_SNIFF4_MIN 10
611 #define BTA_DM_PM_SNIFF4_ATTEMPT 4
612 #define BTA_DM_PM_SNIFF4_TIMEOUT 1
613 #endif
614 
615 #ifndef BTA_DM_PM_SNIFF5_MAX
616 #define BTA_DM_PM_SNIFF5_MAX 36
617 #define BTA_DM_PM_SNIFF5_MIN 30
618 #define BTA_DM_PM_SNIFF5_ATTEMPT 2
619 #define BTA_DM_PM_SNIFF5_TIMEOUT 0
620 #endif
621 
622 #ifndef BTA_DM_PM_SNIFF6_MAX
623 #define BTA_DM_PM_SNIFF6_MAX 18
624 #define BTA_DM_PM_SNIFF6_MIN 14
625 #define BTA_DM_PM_SNIFF6_ATTEMPT 1
626 #define BTA_DM_PM_SNIFF6_TIMEOUT 0
627 #endif
628 
629 #ifndef BTA_DM_PM_PARK_MAX
630 #define BTA_DM_PM_PARK_MAX 800
631 #define BTA_DM_PM_PARK_MIN 400
632 #define BTA_DM_PM_PARK_ATTEMPT 0
633 #define BTA_DM_PM_PARK_TIMEOUT 0
634 #endif
635 
636 /* Device Identification (DI) data structure
637 */
638 
639 #ifndef BTA_DI_NUM_MAX
640 #define BTA_DI_NUM_MAX 3
641 #endif
642 
643 #define IMMEDIATE_DELY_MODE 0x00
644 #define ALLOW_ALL_FILTER 0x00
645 #define LOWEST_RSSI_VALUE 129
646 
647 /*****************************************************************************
648  *  External Function Declarations
649  ****************************************************************************/
650 
651 void BTA_dm_init();
652 
653 /*******************************************************************************
654  *
655  * Function         BTA_EnableTestMode
656  *
657  * Description      Enables bluetooth device under test mode
658  *
659  *
660  * Returns          tBTA_STATUS
661  *
662  ******************************************************************************/
663 extern void BTA_EnableTestMode(void);
664 
665 /*******************************************************************************
666  *
667  * Function         BTA_DmSetDeviceName
668  *
669  * Description      This function sets the Bluetooth name of the local device.
670  *
671  *
672  * Returns          void
673  *
674  ******************************************************************************/
675 extern void BTA_DmSetDeviceName(char* p_name);
676 
677 /*******************************************************************************
678  *
679  * Function         BTA_DmSetVisibility
680  *
681  * Description      This function sets the Bluetooth connectable,discoverable,
682  *                  pairable and conn paired only modesmodes of the local
683  *                  device.
684  *                  This controls whether other Bluetooth devices can find and
685  *                  connect to the local device.
686  *
687  *
688  * Returns          void
689  *
690  ******************************************************************************/
691 extern bool BTA_DmSetVisibility(bt_scan_mode_t mode);
692 
693 /*******************************************************************************
694  *
695  * Function         BTA_DmSearch
696  *
697  * Description      This function searches for peer Bluetooth devices.  It
698  *                  first performs an inquiry; for each device found from the
699  *                  inquiry it gets the remote name of the device.  If
700  *                  parameter services is nonzero, service discovery will be
701  *                  performed on each device for the services specified. If the
702  *                  parameter is_bonding_or_sdp is true, the request will be
703  *                  queued until bonding or sdp completes
704  *
705  *
706  * Returns          void
707  *
708  ******************************************************************************/
709 extern void BTA_DmSearch(tBTA_DM_SEARCH_CBACK* p_cback, bool is_bonding_or_sdp);
710 
711 /*******************************************************************************
712  *
713  * Function         BTA_DmSearchCancel
714  *
715  * Description      This function cancels a search that has been initiated
716  *                  by calling BTA_DmSearch().
717  *
718  *
719  * Returns          void
720  *
721  ******************************************************************************/
722 extern void BTA_DmSearchCancel(void);
723 
724 /*******************************************************************************
725  *
726  * Function         BTA_DmDiscover
727  *
728  * Description      This function performs service discovery for the services
729  *                  of a particular peer device.
730  *
731  *
732  * Returns          void
733  *
734  ******************************************************************************/
735 extern void BTA_DmDiscover(const RawAddress& bd_addr,
736                            tBTA_DM_SEARCH_CBACK* p_cback,
737                            tBT_TRANSPORT transport, bool is_bonding_or_sdp);
738 
739 /*******************************************************************************
740  *
741  * Function         BTA_DmGetCachedRemoteName
742  *
743  * Description      Retieve cached remote name if available
744  *
745  * Returns          BTA_SUCCESS if cached name was retrieved
746  *                  BTA_FAILURE if cached name is not available
747  *
748  ******************************************************************************/
749 tBTA_STATUS BTA_DmGetCachedRemoteName(const RawAddress& remote_device,
750                                       uint8_t** pp_cached_name);
751 
752 /*******************************************************************************
753  *
754  * Function         BTA_DmBond
755  *
756  * Description      This function initiates a bonding procedure with a peer
757  *                  device by designated transport.  The bonding procedure
758  *                  enables authentication and optionally encryption on the
759  *                  Bluetooth link.
760  *
761  *
762  * Returns          void
763  *
764  ******************************************************************************/
765 extern void BTA_DmBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
766                        tBT_TRANSPORT transport, int device_type);
767 
768 /*******************************************************************************
769  *
770  * Function         BTA_DmBondCancel
771  *
772  * Description      This function cancels a bonding procedure with a peer
773  *                  device.
774  *
775  *
776  * Returns          void
777  *
778  ******************************************************************************/
779 extern void BTA_DmBondCancel(const RawAddress& bd_addr);
780 
781 /*******************************************************************************
782  *
783  * Function         BTA_DmPinReply
784  *
785  * Description      This function provides a PIN when one is requested by DM
786  *                  during a bonding procedure.  The application should call
787  *                  this function after the security callback is called with
788  *                  a BTA_DM_PIN_REQ_EVT.
789  *
790  *
791  * Returns          void
792  *
793  ******************************************************************************/
794 extern void BTA_DmPinReply(const RawAddress& bd_addr, bool accept,
795                            uint8_t pin_len, uint8_t* p_pin);
796 
797 /*******************************************************************************
798  *
799  * Function         BTA_DmLocalOob
800  *
801  * Description      This function retrieves the OOB data from local controller.
802  *                  The result is reported by bta_dm_co_loc_oob().
803  *
804  * Returns          void
805  *
806  ******************************************************************************/
807 extern void BTA_DmLocalOob(void);
808 
809 /*******************************************************************************
810  *
811  * Function         BTA_DmConfirm
812  *
813  * Description      This function accepts or rejects the numerical value of the
814  *                  Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
815  *
816  * Returns          void
817  *
818  ******************************************************************************/
819 extern void BTA_DmConfirm(const RawAddress& bd_addr, bool accept);
820 
821 /*******************************************************************************
822  *
823  * Function         BTA_DmAddDevice
824  *
825  * Description      This function adds a device to the security database list
826  *                  of peer devices. This function would typically be called
827  *                  at system startup to initialize the security database with
828  *                  known peer devices.  This is a direct execution function
829  *                  that may lock task scheduling on some platforms.
830  *
831  * Returns          void
832  *
833  ******************************************************************************/
834 extern void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
835                             const LinkKey& link_key, uint8_t key_type,
836                             uint8_t pin_length);
837 
838 /*******************************************************************************
839  *
840  * Function         BTA_DmRemoveDevice
841  *
842  * Description      This function removes a device from the security database.
843  *                  This is a direct execution function that may lock task
844  *                  scheduling on some platforms.
845  *
846  *
847  * Returns          BTA_SUCCESS if successful.
848  *                  BTA_FAIL if operation failed.
849  *
850  ******************************************************************************/
851 extern tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr);
852 
853 /*******************************************************************************
854  *
855  * Function         BTA_GetEirService
856  *
857  * Description      This function is called to get BTA service mask from EIR.
858  *
859  * Parameters       p_eir - pointer of EIR significant part
860  *                  eir_len - EIR length
861  *                  p_services - return the BTA service mask
862  *
863  * Returns          None
864  *
865  ******************************************************************************/
866 extern void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
867                               tBTA_SERVICE_MASK* p_services);
868 
869 /*******************************************************************************
870  *
871  * Function         BTA_AddEirUuid
872  *
873  * Description      Request to add a new service class UUID to the local
874  *                  device's EIR data.
875  *
876  * Parameters       uuid16 - The service class UUID you wish to add
877  *
878  * Returns          void
879  *
880  ******************************************************************************/
881 extern void BTA_AddEirUuid(uint16_t uuid16);
882 
883 /*******************************************************************************
884  *
885  * Function         BTA_RemoveEirUuid
886  *
887  * Description      Request to remove a service class UID from the local
888  *                  device's EIR data.
889  *
890  * Parameters       uuid16 - The service class UUID you wish to remove
891  *
892  * Returns          void
893  *
894  ******************************************************************************/
895 extern void BTA_RemoveEirUuid(uint16_t uuid16);
896 
897 /*******************************************************************************
898  *
899  * Function         BTA_DmGetConnectionState
900  *
901  * Description      Returns whether the remote device is currently connected.
902  *
903  * Returns          true if the device is NOT connected, false otherwise.
904  *
905  ******************************************************************************/
906 extern bool BTA_DmGetConnectionState(const RawAddress& bd_addr);
907 
908 /*******************************************************************************
909  *
910  * Function         BTA_DmSetLocalDiRecord
911  *
912  * Description      This function adds a DI record to the local SDP database.
913  *
914  * Returns          BTA_SUCCESS if record set sucessfully, otherwise error code.
915  *
916  ******************************************************************************/
917 extern tBTA_STATUS BTA_DmSetLocalDiRecord(tSDP_DI_RECORD* p_device_info,
918                                           uint32_t* p_handle);
919 
920 /*******************************************************************************
921  *
922  *
923  * Function         BTA_DmCloseACL
924  *
925  * Description      This function force to close an ACL connection and remove
926  the
927  *                  device from the security database list of known devices.
928  *
929  * Parameters:      bd_addr       - Address of the peer device
930  *                  remove_dev    - remove device or not after link down
931  *                  transport     - which transport to close
932 
933  *
934  * Returns          void.
935  *
936  ******************************************************************************/
937 extern void BTA_DmCloseACL(const RawAddress& bd_addr, bool remove_dev,
938                            tBT_TRANSPORT transport);
939 
940 /* BLE related API functions */
941 /*******************************************************************************
942  *
943  * Function         BTA_DmBleSecurityGrant
944  *
945  * Description      Grant security request access.
946  *
947  * Parameters:      bd_addr          - BD address of the peer
948  *                  res              - security grant status.
949  *
950  * Returns          void
951  *
952  ******************************************************************************/
953 extern void BTA_DmBleSecurityGrant(const RawAddress& bd_addr,
954                                    tBTA_DM_BLE_SEC_GRANT res);
955 
956 /*******************************************************************************
957  *
958  * Function         BTA_DmBlePasskeyReply
959  *
960  * Description      Send BLE SMP passkey reply.
961  *
962  * Parameters:      bd_addr          - BD address of the peer
963  *                  accept           - passkey entry sucessful or declined.
964  *                  passkey          - passkey value, must be a 6 digit number,
965  *                                     can be lead by 0.
966  *
967  * Returns          void
968  *
969  ******************************************************************************/
970 extern void BTA_DmBlePasskeyReply(const RawAddress& bd_addr, bool accept,
971                                   uint32_t passkey);
972 
973 /*******************************************************************************
974  *
975  * Function         BTA_DmBleConfirmReply
976  *
977  * Description      Send BLE SMP SC user confirmation reply.
978  *
979  * Parameters:      bd_addr          - BD address of the peer
980  *                  accept           - numbers to compare are the same or
981  *                                     different.
982  *
983  * Returns          void
984  *
985  ******************************************************************************/
986 extern void BTA_DmBleConfirmReply(const RawAddress& bd_addr, bool accept);
987 
988 /*******************************************************************************
989  *
990  * Function         BTA_DmAddBleDevice
991  *
992  * Description      Add a BLE device.  This function will be normally called
993  *                  during host startup to restore all required information
994  *                  for a LE device stored in the NVRAM.
995  *
996  * Parameters:      bd_addr          - BD address of the peer
997  *                  dev_type         - Remote device's device type.
998  *                  addr_type        - LE device address type.
999  *
1000  * Returns          void
1001  *
1002  ******************************************************************************/
1003 extern void BTA_DmAddBleDevice(const RawAddress& bd_addr,
1004                                tBLE_ADDR_TYPE addr_type,
1005                                tBT_DEVICE_TYPE dev_type);
1006 
1007 /*******************************************************************************
1008  *
1009  * Function         BTA_DmAddBleKey
1010  *
1011  * Description      Add/modify LE device information.  This function will be
1012  *                  normally called during host startup to restore all required
1013  *                  information stored in the NVRAM.
1014  *
1015  * Parameters:      bd_addr          - BD address of the peer
1016  *                  p_le_key         - LE key values.
1017  *                  key_type         - LE SMP key type.
1018  *
1019  * Returns          void
1020  *
1021  ******************************************************************************/
1022 extern void BTA_DmAddBleKey(const RawAddress& bd_addr,
1023                             tBTA_LE_KEY_VALUE* p_le_key,
1024                             tBTM_LE_KEY_TYPE key_type);
1025 
1026 /*******************************************************************************
1027  *
1028  * Function         BTA_DmSetBlePrefConnParams
1029  *
1030  * Description      This function is called to set the preferred connection
1031  *                  parameters when default connection parameter is not desired.
1032  *
1033  * Parameters:      bd_addr          - BD address of the peripheral
1034  *                  min_conn_int     - minimum preferred connection interval
1035  *                  max_conn_int     - maximum preferred connection interval
1036  *                  peripheral_latency    - preferred peripheral latency
1037  *                  supervision_tout - preferred supervision timeout
1038  *
1039  *
1040  * Returns          void
1041  *
1042  ******************************************************************************/
1043 extern void BTA_DmSetBlePrefConnParams(const RawAddress& bd_addr,
1044                                        uint16_t min_conn_int,
1045                                        uint16_t max_conn_int,
1046                                        uint16_t peripheral_latency,
1047                                        uint16_t supervision_tout);
1048 
1049 /*******************************************************************************
1050  *
1051  * Function         BTA_DmSetEncryption
1052  *
1053  * Description      This function is called to ensure that connection is
1054  *                  encrypted.  Should be called only on an open connection.
1055  *                  Typically only needed for connections that first want to
1056  *                  bring up unencrypted links, then later encrypt them.
1057  *
1058  * Parameters:      bd_addr       - Address of the peer device
1059  *                  transport     - transport of the link to be encruypted
1060  *                  p_callback    - Pointer to callback function to indicat the
1061  *                                  link encryption status
1062  *                  sec_act       - This is the security action to indicate
1063  *                                  what kind of BLE security level is required
1064  *                                  for the BLE link if BLE is supported
1065  *                                  Note: This parameter is ignored for
1066  *                                        BR/EDR or if BLE is not supported.
1067  *
1068  * Returns          void
1069  *
1070  *
1071  ******************************************************************************/
1072 extern void BTA_DmSetEncryption(const RawAddress& bd_addr,
1073                                 tBT_TRANSPORT transport,
1074                                 tBTA_DM_ENCRYPT_CBACK* p_callback,
1075                                 tBTM_BLE_SEC_ACT sec_act);
1076 
1077 /*******************************************************************************
1078  *
1079  * Function         BTA_DmBleObserve
1080  *
1081  * Description      This procedure keep the device listening for advertising
1082  *                  events from a broadcast device.
1083  *
1084  * Parameters       start: start or stop observe.
1085  *                  duration : Duration of the scan. Continuous scan if 0 is
1086  *                             passed
1087  *                  p_results_cb: Callback to be called with scan results
1088  *
1089  * Returns          void
1090  *
1091  ******************************************************************************/
1092 extern void BTA_DmBleObserve(bool start, uint8_t duration,
1093                              tBTA_DM_SEARCH_CBACK* p_results_cb);
1094 
1095 /*******************************************************************************
1096  *
1097  * Function         BTA_DmBleConfigLocalPrivacy
1098  *
1099  * Description      Enable/disable privacy on the local device
1100  *
1101  * Parameters:      privacy_enable   - enable/disabe privacy on remote device.
1102  *
1103  * Returns          void
1104  *
1105  ******************************************************************************/
1106 extern void BTA_DmBleConfigLocalPrivacy(bool privacy_enable);
1107 
1108 /*******************************************************************************
1109  *
1110  * Function         BTA_DmBleEnableRemotePrivacy
1111  *
1112  * Description      Enable/disable privacy on a remote device
1113  *
1114  * Parameters:      bd_addr          - BD address of the peer
1115  *                  privacy_enable   - enable/disabe privacy on remote device.
1116  *
1117  * Returns          void
1118  *
1119  ******************************************************************************/
1120 extern void BTA_DmBleEnableRemotePrivacy(const RawAddress& bd_addr,
1121                                          bool privacy_enable);
1122 
1123 /*******************************************************************************
1124  *
1125  * Function         BTA_DmBleUpdateConnectionParams
1126  *
1127  * Description      Update connection parameters, can only be used when
1128  *                  connection is up.
1129  *
1130  * Parameters:      bd_addr   - BD address of the peer
1131  *                  min_int   - minimum connection interval, [0x0004 ~ 0x4000]
1132  *                  max_int   - maximum connection interval, [0x0004 ~ 0x4000]
1133  *                  latency   - peripheral latency [0 ~ 500]
1134  *                  timeout   - supervision timeout [0x000a ~ 0xc80]
1135  *
1136  * Returns          void
1137  *
1138  ******************************************************************************/
1139 extern void BTA_DmBleUpdateConnectionParams(const RawAddress& bd_addr,
1140                                             uint16_t min_int, uint16_t max_int,
1141                                             uint16_t latency, uint16_t timeout,
1142                                             uint16_t min_ce_len,
1143                                             uint16_t max_ce_len);
1144 
1145 /*******************************************************************************
1146  *
1147  * Function         BTA_DmBleSetDataLength
1148  *
1149  * Description      This function is to set maximum LE data packet size
1150  *
1151  * Returns          void
1152  *
1153  ******************************************************************************/
1154 extern void BTA_DmBleRequestMaxTxDataLength(const RawAddress& remote_device);
1155 
1156 /*******************************************************************************
1157  *
1158  * Function         BTA_DmBleGetEnergyInfo
1159  *
1160  * Description      This function is called to obtain the energy info
1161  *
1162  * Parameters       p_cmpl_cback - Command complete callback
1163  *
1164  * Returns          void
1165  *
1166  ******************************************************************************/
1167 extern void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK* p_cmpl_cback);
1168 
1169 /*******************************************************************************
1170  *
1171  * Function         BTA_BrcmInit
1172  *
1173  * Description      This function initializes Broadcom specific VS handler in
1174  *                  BTA
1175  *
1176  * Returns          void
1177  *
1178  ******************************************************************************/
1179 extern void BTA_VendorInit(void);
1180 
1181 #endif /* BTA_API_H */
1182