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