• 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 <hardware/bt_common_types.h>
29 #include <memory>
30 #include "bt_target.h"
31 #include "bt_types.h"
32 #include "btm_api.h"
33 #include "btm_ble_api.h"
34 
35 /*****************************************************************************
36  *  Constants and data types
37  ****************************************************************************/
38 
39 /* Status Return Value */
40 #define BTA_SUCCESS 0 /* Successful operation. */
41 #define BTA_FAILURE 1 /* Generic failure. */
42 #define BTA_PENDING 2 /* API cannot be completed right now */
43 #define BTA_BUSY 3
44 #define BTA_NO_RESOURCES 4
45 #define BTA_WRONG_MODE 5
46 
47 typedef uint8_t tBTA_STATUS;
48 
49 /*
50  * Service ID
51  *
52  * NOTES: When you add a new Service ID for BTA AND require to change the value
53  * of BTA_MAX_SERVICE_ID, make sure that the correct security ID of the new
54  * service from Security service definitions (btm_api.h) should be added to
55  * bta_service_id_to_btm_srv_id_lkup_tbl table in bta_dm_act.cc
56  */
57 
58 #define BTA_RES_SERVICE_ID 0         /* Reserved */
59 #define BTA_SPP_SERVICE_ID 1         /* Serial port profile. */
60 #define BTA_DUN_SERVICE_ID 2         /* Dial-up networking profile. */
61 #define BTA_A2DP_SOURCE_SERVICE_ID 3 /* A2DP Source profile. */
62 #define BTA_LAP_SERVICE_ID 4         /* LAN access profile. */
63 #define BTA_HSP_SERVICE_ID 5         /* Headset profile. */
64 #define BTA_HFP_SERVICE_ID 6         /* Hands-free profile. */
65 #define BTA_OPP_SERVICE_ID 7         /* Object push  */
66 #define BTA_FTP_SERVICE_ID 8         /* File transfer */
67 #define BTA_CTP_SERVICE_ID 9         /* Cordless Terminal */
68 #define BTA_ICP_SERVICE_ID 10        /* Intercom Terminal */
69 #define BTA_SYNC_SERVICE_ID 11       /* Synchronization */
70 #define BTA_BPP_SERVICE_ID 12        /* Basic printing profile */
71 #define BTA_BIP_SERVICE_ID 13        /* Basic Imaging profile */
72 #define BTA_PANU_SERVICE_ID 14       /* PAN User */
73 #define BTA_NAP_SERVICE_ID 15        /* PAN Network access point */
74 #define BTA_GN_SERVICE_ID 16         /* PAN Group Ad-hoc networks */
75 #define BTA_SAP_SERVICE_ID 17        /* SIM Access profile */
76 #define BTA_A2DP_SINK_SERVICE_ID 18  /* A2DP Sink */
77 #define BTA_AVRCP_SERVICE_ID 19      /* A/V remote control */
78 #define BTA_HID_SERVICE_ID 20        /* HID */
79 #define BTA_VDP_SERVICE_ID 21        /* Video distribution */
80 #define BTA_PBAP_SERVICE_ID 22       /* PhoneBook Access Server*/
81 #define BTA_HSP_HS_SERVICE_ID 23     /* HFP HS role */
82 #define BTA_HFP_HS_SERVICE_ID 24     /* HSP HS role */
83 #define BTA_MAP_SERVICE_ID 25        /* Message Access Profile */
84 #define BTA_MN_SERVICE_ID 26         /* Message Notification Service */
85 #define BTA_HDP_SERVICE_ID 27        /* Health Device Profile */
86 #define BTA_PCE_SERVICE_ID 28        /* PhoneBook Access Client */
87 #define BTA_SDP_SERVICE_ID 29        /* SDP Search */
88 #define BTA_HIDD_SERVICE_ID 30       /* HID Device */
89 
90 /* BLE profile service ID */
91 #define BTA_BLE_SERVICE_ID 31  /* GATT profile */
92 #define BTA_USER_SERVICE_ID 32 /* User requested UUID */
93 #define BTA_MAX_SERVICE_ID 33
94 
95 /* service IDs (BTM_SEC_SERVICE_FIRST_EMPTY + 1) to (BTM_SEC_MAX_SERVICES - 1)
96  * are used by BTA JV */
97 #define BTA_FIRST_JV_SERVICE_ID (BTM_SEC_SERVICE_FIRST_EMPTY + 1)
98 #define BTA_LAST_JV_SERVICE_ID (BTM_SEC_MAX_SERVICES - 1)
99 
100 typedef uint8_t tBTA_SERVICE_ID;
101 
102 /* Service ID Mask */
103 #define BTA_RES_SERVICE_MASK 0x00000001    /* Reserved */
104 #define BTA_SPP_SERVICE_MASK 0x00000002    /* Serial port profile. */
105 #define BTA_DUN_SERVICE_MASK 0x00000004    /* Dial-up networking profile. */
106 #define BTA_FAX_SERVICE_MASK 0x00000008    /* Fax profile. */
107 #define BTA_LAP_SERVICE_MASK 0x00000010    /* LAN access profile. */
108 #define BTA_HSP_SERVICE_MASK 0x00000020    /* HSP AG role. */
109 #define BTA_HFP_SERVICE_MASK 0x00000040    /* HFP AG role */
110 #define BTA_OPP_SERVICE_MASK 0x00000080    /* Object push  */
111 #define BTA_FTP_SERVICE_MASK 0x00000100    /* File transfer */
112 #define BTA_CTP_SERVICE_MASK 0x00000200    /* Cordless Terminal */
113 #define BTA_ICP_SERVICE_MASK 0x00000400    /* Intercom Terminal */
114 #define BTA_SYNC_SERVICE_MASK 0x00000800   /* Synchronization */
115 #define BTA_BPP_SERVICE_MASK 0x00001000    /* Print server */
116 #define BTA_BIP_SERVICE_MASK 0x00002000    /* Basic Imaging */
117 #define BTA_PANU_SERVICE_MASK 0x00004000   /* PAN User */
118 #define BTA_NAP_SERVICE_MASK 0x00008000    /* PAN Network access point */
119 #define BTA_GN_SERVICE_MASK 0x00010000     /* PAN Group Ad-hoc networks */
120 #define BTA_SAP_SERVICE_MASK 0x00020000    /* PAN Group Ad-hoc networks */
121 #define BTA_A2DP_SERVICE_MASK 0x00040000   /* Advanced audio distribution */
122 #define BTA_AVRCP_SERVICE_MASK 0x00080000  /* A/V remote control */
123 #define BTA_HID_SERVICE_MASK 0x00100000    /* HID */
124 #define BTA_VDP_SERVICE_MASK 0x00200000    /* Video distribution */
125 #define BTA_PBAP_SERVICE_MASK 0x00400000   /* Phone Book Server */
126 #define BTA_HSP_HS_SERVICE_MASK 0x00800000 /* HFP HS role */
127 #define BTA_HFP_HS_SERVICE_MASK 0x01000000 /* HSP HS role */
128 #define BTA_MAS_SERVICE_MASK 0x02000000    /* Message Access Profile */
129 #define BTA_MN_SERVICE_MASK 0x04000000     /* Message Notification Profile */
130 #define BTA_HL_SERVICE_MASK 0x08000000     /* Health Device Profile */
131 #define BTA_PCE_SERVICE_MASK 0x10000000    /* Phone Book Client */
132 #define BTA_HIDD_SERVICE_MASK 0x20000000   /* HID Device */
133 
134 #define BTA_BLE_SERVICE_MASK 0x40000000  /* GATT based service */
135 #define BTA_ALL_SERVICE_MASK 0x7FFFFFFF  /* All services supported by BTA. */
136 #define BTA_USER_SERVICE_MASK 0x80000000 /* Message Notification Profile */
137 
138 typedef uint32_t tBTA_SERVICE_MASK;
139 
140 /* extended service mask, including mask with one or more GATT UUID */
141 typedef struct {
142   tBTA_SERVICE_MASK srvc_mask;
143   uint8_t num_uuid;
144   bluetooth::Uuid* p_uuid;
145 } tBTA_SERVICE_MASK_EXT;
146 
147 /* Security Setting Mask */
148 #define BTA_SEC_NONE BTM_SEC_NONE /* No security. */
149 #define BTA_SEC_AUTHORIZE                                               \
150   (BTM_SEC_IN_AUTHORIZE) /* Authorization required (only needed for out \
151                             going connection )*/
152 #define BTA_SEC_AUTHENTICATE \
153   (BTM_SEC_IN_AUTHENTICATE | \
154    BTM_SEC_OUT_AUTHENTICATE) /* Authentication required. */
155 #define BTA_SEC_ENCRYPT \
156   (BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT) /* Encryption required. */
157 
158 typedef uint16_t tBTA_SEC;
159 
160 /* Ignore for Discoverable, Connectable, Pairable and Connectable Paired only
161  * device modes */
162 #define BTA_DM_IGNORE 0x00FF
163 
164 /* Ignore for Discoverable, Connectable only for LE modes */
165 #define BTA_DM_LE_IGNORE 0xFF00
166 
167 #define BTA_APP_ID_PAN_MULTI 0xFE /* app id for pan multiple connection */
168 #define BTA_ALL_APP_ID 0xFF
169 
170 /* Discoverable Modes */
171 #define BTA_DM_NON_DISC BTM_NON_DISCOVERABLE /* Device is not discoverable. */
172 #define BTA_DM_GENERAL_DISC                         \
173   BTM_GENERAL_DISCOVERABLE /* General discoverable. \
174                               */
175 #define BTA_DM_BLE_NON_DISCOVERABLE \
176   BTM_BLE_NON_DISCOVERABLE /* Device is not LE discoverable */
177 #define BTA_DM_BLE_GENERAL_DISCOVERABLE \
178   BTM_BLE_GENERAL_DISCOVERABLE /* Device is LE General discoverable */
179 #define BTA_DM_BLE_LIMITED_DISCOVERABLE \
180   BTM_BLE_LIMITED_DISCOVERABLE /* Device is LE Limited discoverable */
181 typedef uint16_t
182     tBTA_DM_DISC; /* this discoverability mode is a bit mask among BR mode and
183                      LE mode */
184 
185 /* Connectable Modes */
186 #define BTA_DM_NON_CONN BTM_NON_CONNECTABLE /* Device is not connectable. */
187 #define BTA_DM_CONN BTM_CONNECTABLE         /* Device is connectable. */
188 #define BTA_DM_BLE_NON_CONNECTABLE \
189   BTM_BLE_NON_CONNECTABLE /* Device is LE non-connectable. */
190 #define BTA_DM_BLE_CONNECTABLE \
191   BTM_BLE_CONNECTABLE /* Device is LE connectable. */
192 
193 typedef uint16_t tBTA_DM_CONN;
194 
195 #define BTA_TRANSPORT_UNKNOWN 0
196 #define BTA_TRANSPORT_BR_EDR BT_TRANSPORT_BR_EDR
197 #define BTA_TRANSPORT_LE BT_TRANSPORT_LE
198 typedef tBT_TRANSPORT tBTA_TRANSPORT;
199 
200 /* Pairable Modes */
201 #define BTA_DM_PAIRABLE 1
202 #define BTA_DM_NON_PAIRABLE 0
203 
204 /* Connectable Paired Only Mode */
205 #define BTA_DM_CONN_ALL 0
206 #define BTA_DM_CONN_PAIRED 1
207 
208 /* Inquiry Modes */
209 #define BTA_DM_INQUIRY_NONE BTM_INQUIRY_NONE /*No BR inquiry. */
210 #define BTA_DM_GENERAL_INQUIRY \
211   BTM_GENERAL_INQUIRY /* Perform general inquiry. */
212 #define BTA_DM_LIMITED_INQUIRY \
213   BTM_LIMITED_INQUIRY /* Perform limited inquiry. */
214 
215 #define BTA_BLE_INQUIRY_NONE BTM_BLE_INQUIRY_NONE
216 #define BTA_BLE_GENERAL_INQUIRY \
217   BTM_BLE_GENERAL_INQUIRY /* Perform LE general inquiry. */
218 #define BTA_BLE_LIMITED_INQUIRY \
219   BTM_BLE_LIMITED_INQUIRY /* Perform LE limited inquiry. */
220 typedef uint8_t tBTA_DM_INQ_MODE;
221 
222 /* Inquiry Filter Type */
223 #define BTA_DM_INQ_CLR BTM_CLR_INQUIRY_FILTER /* Clear inquiry filter. */
224 #define BTA_DM_INQ_DEV_CLASS \
225   BTM_FILTER_COND_DEVICE_CLASS /* Filter on device class. */
226 #define BTA_DM_INQ_BD_ADDR \
227   BTM_FILTER_COND_BD_ADDR /* Filter on a specific  BD address. */
228 
229 typedef uint8_t tBTA_DM_INQ_FILT;
230 
231 /* Authorize Response */
232 #define BTA_DM_AUTH_PERM \
233   0 /* Authorized for future connections to the service */
234 #define BTA_DM_AUTH_TEMP 1 /* Authorized for current connection only */
235 #define BTA_DM_NOT_AUTH 2  /* Not authorized for the service */
236 
237 typedef uint8_t tBTA_AUTH_RESP;
238 
239 /* M/S preferred roles */
240 #define BTA_ANY_ROLE 0x00
241 #define BTA_MASTER_ROLE_PREF 0x01
242 #define BTA_MASTER_ROLE_ONLY 0x02
243 #define BTA_SLAVE_ROLE_ONLY \
244   0x03 /* Used for PANU only, skip role switch to master */
245 
246 typedef uint8_t tBTA_PREF_ROLES;
247 
248 enum {
249 
250   BTA_DM_NO_SCATTERNET,      /* Device doesn't support scatternet, it might
251                                 support "role switch during connection" for
252                                 an incoming connection, when it already has
253                                 another connection in master role */
254   BTA_DM_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
255                                 simulateous connection in Master and Slave roles
256                                 for short period of time */
257   BTA_DM_FULL_SCATTERNET /* Device can have simultaneous connection in master
258                             and slave roles */
259 
260 };
261 
262 /* Inquiry filter device class condition */
263 typedef struct {
264   DEV_CLASS dev_class;      /* device class of interest */
265   DEV_CLASS dev_class_mask; /* mask to determine the bits of device class of
266                                interest */
267 } tBTA_DM_COD_COND;
268 
269 /* Inquiry Filter Condition */
270 typedef union {
271   RawAddress bd_addr;              /* BD address of  device to filter. */
272   tBTA_DM_COD_COND dev_class_cond; /* Device class filter condition */
273 } tBTA_DM_INQ_COND;
274 
275 /* Inquiry Parameters */
276 typedef struct {
277   tBTA_DM_INQ_MODE mode; /* Inquiry mode, limited or general. */
278   uint8_t duration;      /* Inquiry duration in 1.28 sec units. */
279   uint8_t max_resps; /* Maximum inquiry responses.  Set to zero for unlimited
280                         responses. */
281   bool report_dup; /* report duplicated inquiry response with higher RSSI value
282                       */
283   tBTA_DM_INQ_FILT filter_type; /* Filter condition type. */
284   tBTA_DM_INQ_COND filter_cond; /* Filter condition data. */
285 } tBTA_DM_INQ;
286 
287 typedef struct {
288   uint8_t bta_dm_eir_min_name_len; /* minimum length of local name when it is
289                                       shortened */
290 #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
291   uint8_t bta_dm_eir_uuid16_len; /* length of 16-bit UUIDs */
292   uint8_t* bta_dm_eir_uuid16;    /* 16-bit UUIDs */
293 #else
294   uint32_t uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
295 #endif
296   int8_t* bta_dm_eir_inq_tx_power;     /* Inquiry TX power         */
297   uint8_t bta_dm_eir_flag_len;         /* length of flags in bytes */
298   uint8_t* bta_dm_eir_flags;           /* flags for EIR */
299   uint8_t bta_dm_eir_manufac_spec_len; /* length of manufacturer specific in
300                                           bytes */
301   uint8_t* bta_dm_eir_manufac_spec;    /* manufacturer specific */
302   uint8_t bta_dm_eir_additional_len;   /* length of additional data in bytes */
303   uint8_t* bta_dm_eir_additional;      /* additional data */
304 } tBTA_DM_EIR_CONF;
305 
306 /* advertising filter policy */
307 typedef tBTM_BLE_AFP tBTA_BLE_AFP;
308 
309 enum {
310   BTA_BLE_BATCH_SCAN_MODE_PASS = 1,
311   BTA_BLE_BATCH_SCAN_MODE_ACTI = 2,
312   BTA_BLE_BATCH_SCAN_MODE_PASS_ACTI = 3
313 };
314 typedef uint8_t tBTA_BLE_BATCH_SCAN_MODE;
315 
316 enum { BTA_BLE_DISCARD_OLD_ITEMS = 0, BTA_BLE_DISCARD_LOWER_RSSI_ITEMS = 1 };
317 typedef uint8_t tBTA_BLE_DISCARD_RULE;
318 
319 enum { BTA_BLE_ADV_SEEN_FIRST_TIME = 0, BTA_BLE_ADV_TRACKING_TIMEOUT = 1 };
320 typedef uint8_t tBTA_BLE_ADV_CHANGE_REASON;
321 
322 /* BLE customer specific feature function type definitions */
323 /* data type used on customer specific feature for RSSI monitoring */
324 #define BTA_BLE_RSSI_ALERT_HI 0
325 #define BTA_BLE_RSSI_ALERT_RANGE 1
326 #define BTA_BLE_RSSI_ALERT_LO 2
327 typedef uint8_t tBTA_DM_BLE_RSSI_ALERT_TYPE;
328 
329 #define BTA_BLE_RSSI_ALERT_NONE BTM_BLE_RSSI_ALERT_NONE     /*    (0) */
330 #define BTA_BLE_RSSI_ALERT_HI_BIT BTM_BLE_RSSI_ALERT_HI_BIT /*    (1) */
331 #define BTA_BLE_RSSI_ALERT_RANGE_BIT \
332   BTM_BLE_RSSI_ALERT_RANGE_BIT                              /*    (1 << 1) */
333 #define BTA_BLE_RSSI_ALERT_LO_BIT BTM_BLE_RSSI_ALERT_LO_BIT /*    (1 << 2) */
334 typedef uint8_t tBTA_DM_BLE_RSSI_ALERT_MASK;
335 
336 typedef void(tBTA_DM_BLE_RSSI_CBACK)(const RawAddress& bd_addr,
337                                      tBTA_DM_BLE_RSSI_ALERT_TYPE alert_type,
338                                      int8_t rssi);
339 
340 typedef int8_t tBTA_DM_RSSI_VALUE;
341 typedef uint8_t tBTA_DM_LINK_QUALITY_VALUE;
342 
343 typedef uint8_t tBTA_SIG_STRENGTH_MASK;
344 
345 /* Security Callback Events */
346 #define BTA_DM_ENABLE_EVT 0    /* Enable Event */
347 #define BTA_DM_DISABLE_EVT 1   /* Disable Event */
348 #define BTA_DM_PIN_REQ_EVT 2   /* PIN request. */
349 #define BTA_DM_AUTH_CMPL_EVT 3 /* Authentication complete indication. */
350 #define BTA_DM_AUTHORIZE_EVT 4 /* Authorization request. */
351 #define BTA_DM_LINK_UP_EVT 5   /* Connection UP event */
352 #define BTA_DM_LINK_DOWN_EVT 6 /* Connection DOWN event */
353 #define BTA_DM_SIG_STRENGTH_EVT                                             \
354   7                             /* Signal strength for bluetooth connection \
355                                    */
356 #define BTA_DM_BUSY_LEVEL_EVT 8 /* System busy level */
357 #define BTA_DM_BOND_CANCEL_CMPL_EVT 9 /* Bond cancel complete indication */
358 #define BTA_DM_SP_CFM_REQ_EVT                     \
359   10 /* Simple Pairing User Confirmation request. \
360         */
361 #define BTA_DM_SP_KEY_NOTIF_EVT 11 /* Simple Pairing Passkey Notification */
362 #define BTA_DM_SP_RMT_OOB_EVT 12   /* Simple Pairing Remote OOB Data request. */
363 #define BTA_DM_SP_KEYPRESS_EVT 13  /* Key press notification event. */
364 #define BTA_DM_ROLE_CHG_EVT 14     /* Role Change event. */
365 #define BTA_DM_BLE_KEY_EVT 15      /* BLE SMP key event for peer device keys */
366 #define BTA_DM_BLE_SEC_REQ_EVT 16  /* BLE SMP security request */
367 #define BTA_DM_BLE_PASSKEY_NOTIF_EVT 17 /* SMP passkey notification event */
368 #define BTA_DM_BLE_PASSKEY_REQ_EVT 18   /* SMP passkey request event */
369 #define BTA_DM_BLE_OOB_REQ_EVT 19       /* SMP OOB request event */
370 #define BTA_DM_BLE_LOCAL_IR_EVT 20      /* BLE local IR event */
371 #define BTA_DM_BLE_LOCAL_ER_EVT 21      /* BLE local ER event */
372 #define BTA_DM_BLE_NC_REQ_EVT 22 /* SMP Numeric Comparison request event */
373 #define BTA_DM_SP_RMT_OOB_EXT_EVT \
374   23 /* Simple Pairing Remote OOB Extended Data request. */
375 #define BTA_DM_BLE_AUTH_CMPL_EVT 24 /* BLE Auth complete */
376 #define BTA_DM_DEV_UNPAIRED_EVT 25
377 #define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */
378 #define BTA_DM_LE_FEATURES_READ                                             \
379   27                             /* Cotroller specific LE features are read \
380                                     */
381 #define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
382 #define BTA_DM_BLE_SC_OOB_REQ_EVT 29 /* SMP SC OOB request event */
383 #define BTA_DM_BLE_CONSENT_REQ_EVT 30 /* SMP consent request event */
384 typedef uint8_t tBTA_DM_SEC_EVT;
385 
386 /* Structure associated with BTA_DM_ENABLE_EVT */
387 typedef struct { tBTA_STATUS status; } tBTA_DM_ENABLE;
388 
389 /* Structure associated with BTA_DM_PIN_REQ_EVT */
390 typedef struct {
391   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
392    * order */
393   RawAddress bd_addr;  /* BD address peer device. */
394   DEV_CLASS dev_class; /* Class of Device */
395   BD_NAME bd_name;     /* Name of peer device. */
396   bool min_16_digit;   /* true if the pin returned must be at least 16 digits */
397 } tBTA_DM_PIN_REQ;
398 
399 /* BLE related definition */
400 
401 #define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10)
402 
403 /* Converts SMP error codes defined in smp_api.h to SMP auth fail reasons below.
404  */
405 #define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x))
406 
407 #define BTA_DM_AUTH_SMP_PASSKEY_FAIL \
408   (BTA_DM_AUTH_FAIL_BASE + SMP_PASSKEY_ENTRY_FAIL)
409 #define BTA_DM_AUTH_SMP_OOB_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_OOB_FAIL)
410 #define BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL \
411   (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_AUTH_FAIL)
412 #define BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL \
413   (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_VALUE_ERR)
414 #define BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT \
415   (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_NOT_SUPPORT)
416 #define BTA_DM_AUTH_SMP_ENC_KEY_SIZE (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_KEY_SIZE)
417 #define BTA_DM_AUTH_SMP_INVALID_CMD (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_CMD)
418 #define BTA_DM_AUTH_SMP_UNKNOWN_ERR \
419   (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_FAIL_UNKNOWN)
420 #define BTA_DM_AUTH_SMP_REPEATED_ATTEMPT \
421   (BTA_DM_AUTH_FAIL_BASE + SMP_REPEATED_ATTEMPTS)
422 #define BTA_DM_AUTH_SMP_INVALID_PARAMETERS \
423   (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_PARAMETERS)
424 #define BTA_DM_AUTH_SMP_INTERNAL_ERR \
425   (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_INTERNAL_ERR)
426 #define BTA_DM_AUTH_SMP_UNKNOWN_IO (BTA_DM_AUTH_FAIL_BASE + SMP_UNKNOWN_IO_CAP)
427 #define BTA_DM_AUTH_SMP_INIT_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_INIT_FAIL)
428 #define BTA_DM_AUTH_SMP_CONFIRM_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_FAIL)
429 #define BTA_DM_AUTH_SMP_BUSY (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY)
430 #define BTA_DM_AUTH_SMP_ENC_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL)
431 #define BTA_DM_AUTH_SMP_RSP_TIMEOUT (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT)
432 #define BTA_DM_AUTH_SMP_CONN_TOUT (BTA_DM_AUTH_FAIL_BASE + SMP_CONN_TOUT)
433 
434 /* connection parameter boundary value and dummy value */
435 #define BTA_DM_BLE_SCAN_INT_MIN BTM_BLE_SCAN_INT_MIN
436 #define BTA_DM_BLE_SCAN_INT_MAX BTM_BLE_SCAN_INT_MAX
437 #define BTA_DM_BLE_SCAN_WIN_MIN BTM_BLE_SCAN_WIN_MIN
438 #define BTA_DM_BLE_SCAN_WIN_MAX BTM_BLE_SCAN_WIN_MAX
439 #define BTA_DM_BLE_CONN_INT_MIN BTM_BLE_CONN_INT_MIN
440 #define BTA_DM_BLE_CONN_INT_MAX BTM_BLE_CONN_INT_MAX
441 #define BTA_DM_BLE_CONN_LATENCY_MAX BTM_BLE_CONN_LATENCY_MAX
442 #define BTA_DM_BLE_CONN_SUP_TOUT_MIN BTM_BLE_CONN_SUP_TOUT_MIN
443 #define BTA_DM_BLE_CONN_SUP_TOUT_MAX BTM_BLE_CONN_SUP_TOUT_MAX
444 #define BTA_DM_BLE_CONN_PARAM_UNDEF                                          \
445   BTM_BLE_CONN_PARAM_UNDEF /* use this value when a specific value not to be \
446                               overwritten */
447 
448 #define BTA_LE_KEY_PENC \
449   BTM_LE_KEY_PENC /* encryption information of peer device */
450 #define BTA_LE_KEY_PID BTM_LE_KEY_PID     /* identity key of the peer device */
451 #define BTA_LE_KEY_PCSRK BTM_LE_KEY_PCSRK /* peer SRK */
452 #define BTA_LE_KEY_LENC \
453   BTM_LE_KEY_LENC                     /* master role security information:div */
454 #define BTA_LE_KEY_LID BTM_LE_KEY_LID /* master device ID key */
455 #define BTA_LE_KEY_LCSRK \
456   BTM_LE_KEY_LCSRK                /* local CSRK has been deliver to peer */
457 typedef uint8_t tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
458 
459 typedef tBTM_LE_PENC_KEYS tBTA_LE_PENC_KEYS;
460 typedef tBTM_LE_PCSRK_KEYS tBTA_LE_PCSRK_KEYS;
461 typedef tBTM_LE_LENC_KEYS tBTA_LE_LENC_KEYS;
462 typedef tBTM_LE_LCSRK_KEYS tBTA_LE_LCSRK_KEYS;
463 typedef tBTM_LE_PID_KEYS tBTA_LE_PID_KEYS;
464 
465 typedef union {
466   tBTA_LE_PENC_KEYS penc_key;  /* received peer encryption key */
467   tBTA_LE_PCSRK_KEYS psrk_key; /* received peer device SRK */
468   tBTA_LE_PID_KEYS pid_key;    /* peer device ID key */
469   tBTA_LE_LENC_KEYS
470       lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
471   tBTA_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
472   tBTA_LE_PID_KEYS lid_key; /* local device ID key for the particular remote */
473 } tBTA_LE_KEY_VALUE;
474 
475 #define BTA_BLE_LOCAL_KEY_TYPE_ID 1
476 #define BTA_BLE_LOCAL_KEY_TYPE_ER 2
477 typedef uint8_t tBTA_DM_BLE_LOCAL_KEY_MASK;
478 
479 typedef struct {
480   Octet16 ir;
481   Octet16 irk;
482   Octet16 dhk;
483 } tBTA_BLE_LOCAL_ID_KEYS;
484 
485 #define BTA_DM_SEC_GRANTED BTA_SUCCESS
486 #define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
487 #define BTA_DM_SEC_REP_ATTEMPTS BTA_DM_AUTH_SMP_REPEATED_ATTEMPT
488 typedef uint8_t tBTA_DM_BLE_SEC_GRANT;
489 
490 /* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
491 typedef struct {
492   RawAddress bd_addr; /* peer address */
493   BD_NAME bd_name; /* peer device name */
494 } tBTA_DM_BLE_SEC_REQ;
495 
496 typedef struct {
497   RawAddress bd_addr; /* peer address */
498   tBTM_LE_KEY_TYPE key_type;
499   tBTM_LE_KEY_VALUE* p_key_value;
500 } tBTA_DM_BLE_KEY;
501 
502 /* Structure associated with BTA_DM_AUTH_CMPL_EVT */
503 typedef struct {
504   RawAddress bd_addr;  /* BD address peer device. */
505   BD_NAME bd_name;     /* Name of peer device. */
506   bool key_present;    /* Valid link key value in key element */
507   LinkKey key;         /* Link key associated with peer device. */
508   uint8_t key_type;    /* The type of Link Key */
509   bool success;        /* true of authentication succeeded, false if failed. */
510   uint8_t fail_reason; /* The HCI reason/error code for when success=false */
511   tBLE_ADDR_TYPE addr_type; /* Peer device address type */
512   tBT_DEVICE_TYPE dev_type;
513 } tBTA_DM_AUTH_CMPL;
514 
515 /* Structure associated with BTA_DM_AUTHORIZE_EVT */
516 typedef struct {
517   RawAddress bd_addr;      /* BD address peer device. */
518   BD_NAME bd_name;         /* Name of peer device. */
519   tBTA_SERVICE_ID service; /* Service ID to authorize. */
520   DEV_CLASS dev_class;
521 } tBTA_DM_AUTHORIZE;
522 
523 /* Structure associated with BTA_DM_LINK_UP_EVT */
524 typedef struct {
525   RawAddress bd_addr; /* BD address peer device. */
526   tBTA_TRANSPORT link_type;
527 } tBTA_DM_LINK_UP;
528 
529 /* Structure associated with BTA_DM_LINK_DOWN_EVT */
530 typedef struct {
531   RawAddress bd_addr; /* BD address peer device. */
532   uint8_t status;  /* connection open/closed */
533   bool is_removed; /* true if device is removed when link is down */
534   tBTA_TRANSPORT link_type;
535 } tBTA_DM_LINK_DOWN;
536 
537 /* Structure associated with BTA_DM_ROLE_CHG_EVT */
538 typedef struct {
539   RawAddress bd_addr; /* BD address peer device. */
540   uint8_t new_role; /* the new connection role */
541 } tBTA_DM_ROLE_CHG;
542 
543 /* Structure associated with BTA_DM_BUSY_LEVEL_EVT */
544 typedef struct {
545   uint8_t level;       /* when paging or inquiring, level is 10.
546                           Otherwise, the number of ACL links */
547   uint8_t level_flags; /* indicates individual flags */
548 } tBTA_DM_BUSY_LEVEL;
549 
550 #define BTA_IO_CAP_OUT BTM_IO_CAP_OUT       /* 0 DisplayOnly */
551 #define BTA_IO_CAP_IO BTM_IO_CAP_IO         /* 1 DisplayYesNo */
552 #define BTA_IO_CAP_IN BTM_IO_CAP_IN         /* 2 KeyboardOnly */
553 #define BTA_IO_CAP_NONE BTM_IO_CAP_NONE     /* 3 NoInputNoOutput */
554 #define BTA_IO_CAP_KBDISP BTM_IO_CAP_KBDISP /* 4 Keyboard display */
555 typedef tBTM_IO_CAP tBTA_IO_CAP;
556 
557 #define BTA_AUTH_SP_NO                                      \
558   BTM_AUTH_SP_NO /* 0 MITM Protection Not Required - Single \
559                    Profile/non-bonding                      \
560                    Numeric comparison with automatic accept allowed */
561 #define BTA_AUTH_SP_YES                                                       \
562   BTM_AUTH_SP_YES /* 1 MITM Protection Required - Single Profile/non-bonding  \
563                     Use IO Capabilities to determine authentication procedure \
564                     */
565 #define BTA_AUTH_AP_NO                                                      \
566   BTM_AUTH_AP_NO /* 2 MITM Protection Not Required - All Profiles/dedicated \
567                    bonding                                                  \
568                    Numeric comparison with automatic accept allowed */
569 #define BTA_AUTH_AP_YES                                                       \
570   BTM_AUTH_AP_YES /* 3 MITM Protection Required - All Profiles/dedicated      \
571                     bonding                                                   \
572                     Use IO Capabilities to determine authentication procedure \
573                     */
574 #define BTA_AUTH_SPGB_NO                                                       \
575   BTM_AUTH_SPGB_NO /* 4 MITM Protection Not Required - Single Profiles/general \
576                      bonding                                                   \
577                      Numeric comparison with automatic accept allowed */
578 #define BTA_AUTH_SPGB_YES                                                   \
579   BTM_AUTH_SPGB_YES /* 5 MITM Protection Required - Single Profiles/general \
580                       bonding                                               \
581                       Use IO Capabilities to determine authentication       \
582                       procedure */
583 typedef tBTM_AUTH_REQ tBTA_AUTH_REQ;
584 
585 #define BTA_AUTH_DD_BOND \
586   BTM_AUTH_DD_BOND /* 2 this bit is set for dedicated bonding */
587 #define BTA_AUTH_GEN_BOND \
588   BTM_AUTH_SPGB_NO /* 4 this bit is set for general bonding */
589 #define BTA_AUTH_BONDS \
590   BTM_AUTH_BONDS /* 6 the general/dedicated bonding bits  */
591 
592 #define BTA_LE_AUTH_NO_BOND BTM_LE_AUTH_REQ_NO_BOND /* 0*/
593 #define BTA_LE_AUTH_BOND BTM_LE_AUTH_REQ_BOND       /* 1 << 0 */
594 #define BTA_LE_AUTH_REQ_MITM BTM_LE_AUTH_REQ_MITM   /* 1 << 2 */
595 
596 #define BTA_LE_AUTH_REQ_SC_ONLY BTM_LE_AUTH_REQ_SC_ONLY           /* 1 << 3 */
597 #define BTA_LE_AUTH_REQ_SC_BOND BTM_LE_AUTH_REQ_SC_BOND           /* 1001 */
598 #define BTA_LE_AUTH_REQ_SC_MITM BTM_LE_AUTH_REQ_SC_MITM           /* 1100 */
599 #define BTA_LE_AUTH_REQ_SC_MITM_BOND BTM_LE_AUTH_REQ_SC_MITM_BOND /* 1101 */
600 typedef tBTM_LE_AUTH_REQ
601     tBTA_LE_AUTH_REQ; /* combination of the above bit pattern */
602 
603 #define BTA_OOB_NONE BTM_OOB_NONE
604 #define BTA_OOB_PRESENT BTM_OOB_PRESENT
605 #define BTA_OOB_UNKNOWN BTM_OOB_UNKNOWN
606 
607 typedef tBTM_OOB_DATA tBTA_OOB_DATA;
608 
609 /* Structure associated with BTA_DM_SP_CFM_REQ_EVT */
610 typedef struct {
611   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
612    * order */
613   RawAddress bd_addr;  /* peer address */
614   DEV_CLASS dev_class; /* peer CoD */
615   BD_NAME bd_name;     /* peer device name */
616   uint32_t num_val; /* the numeric value for comparison. If just_works, do not
617                        show this number to UI */
618   bool just_works;  /* true, if "Just Works" association model */
619   tBTA_AUTH_REQ loc_auth_req; /* Authentication required for local device */
620   tBTA_AUTH_REQ rmt_auth_req; /* Authentication required for peer device */
621   tBTA_IO_CAP loc_io_caps;    /* IO Capabilities of local device */
622   tBTA_AUTH_REQ rmt_io_caps;  /* IO Capabilities of remote device */
623 } tBTA_DM_SP_CFM_REQ;
624 
625 enum {
626   BTA_SP_KEY_STARTED, /* passkey entry started */
627   BTA_SP_KEY_ENTERED, /* passkey digit entered */
628   BTA_SP_KEY_ERASED,  /* passkey digit erased */
629   BTA_SP_KEY_CLEARED, /* passkey cleared */
630   BTA_SP_KEY_COMPLT   /* passkey entry completed */
631 };
632 typedef uint8_t tBTA_SP_KEY_TYPE;
633 
634 /* Structure associated with BTA_DM_SP_KEYPRESS_EVT */
635 typedef struct {
636   RawAddress bd_addr; /* peer address */
637   tBTA_SP_KEY_TYPE notif_type;
638 } tBTA_DM_SP_KEY_PRESS;
639 
640 /* Structure associated with BTA_DM_SP_KEY_NOTIF_EVT */
641 typedef struct {
642   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
643    * order */
644   RawAddress bd_addr;  /* peer address */
645   DEV_CLASS dev_class; /* peer CoD */
646   BD_NAME bd_name;     /* peer device name */
647   uint32_t passkey; /* the numeric value for comparison. If just_works, do not
648                        show this number to UI */
649 } tBTA_DM_SP_KEY_NOTIF;
650 
651 /* Structure associated with BTA_DM_SP_RMT_OOB_EVT */
652 typedef struct {
653   /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in
654    * order */
655   RawAddress bd_addr;  /* peer address */
656   DEV_CLASS dev_class; /* peer CoD */
657   BD_NAME bd_name;     /* peer device name */
658 } tBTA_DM_SP_RMT_OOB;
659 
660 /* Structure associated with BTA_DM_BOND_CANCEL_CMPL_EVT */
661 typedef struct {
662   tBTA_STATUS result; /* true of bond cancel succeeded, false if failed. */
663 } tBTA_DM_BOND_CANCEL_CMPL;
664 
665 /* Union of all security callback structures */
666 typedef union {
667   tBTA_DM_ENABLE enable;          /* BTA enabled */
668   tBTA_DM_PIN_REQ pin_req;        /* PIN request. */
669   tBTA_DM_AUTH_CMPL auth_cmpl;    /* Authentication complete indication. */
670   tBTA_DM_AUTHORIZE authorize;    /* Authorization request. */
671   tBTA_DM_LINK_UP link_up;        /* ACL connection down event */
672   tBTA_DM_LINK_DOWN link_down;    /* ACL connection down event */
673   tBTA_DM_BUSY_LEVEL busy_level;  /* System busy level */
674   tBTA_DM_SP_CFM_REQ cfm_req;     /* user confirm request */
675   tBTA_DM_SP_KEY_NOTIF key_notif; /* passkey notification */
676   tBTA_DM_SP_RMT_OOB rmt_oob;     /* remote oob */
677   tBTA_DM_BOND_CANCEL_CMPL
678       bond_cancel_cmpl;               /* Bond Cancel Complete indication */
679   tBTA_DM_SP_KEY_PRESS key_press;     /* key press notification event */
680   tBTA_DM_ROLE_CHG role_chg;          /* role change event */
681   tBTA_DM_BLE_SEC_REQ ble_req;        /* BLE SMP related request */
682   tBTA_DM_BLE_KEY ble_key;            /* BLE SMP keys used when pairing */
683   tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
684   Octet16 ble_er;                     /* ER event data */
685 } tBTA_DM_SEC;
686 
687 /* Security callback */
688 typedef void(tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data);
689 
690 #define BTA_DM_BLE_PF_LIST_LOGIC_OR 1
691 #define BTA_DM_BLE_PF_FILT_LOGIC_OR 0
692 
693 /* Search callback events */
694 #define BTA_DM_INQ_RES_EVT 0  /* Inquiry result for a peer device. */
695 #define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
696 #define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */
697 #define BTA_DM_DISC_BLE_RES_EVT \
698   3 /* Discovery result for BLE GATT based servoce on a peer device. */
699 #define BTA_DM_DISC_CMPL_EVT 4          /* Discovery complete. */
700 #define BTA_DM_DI_DISC_CMPL_EVT 5       /* Discovery complete. */
701 #define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
702 
703 typedef uint8_t tBTA_DM_SEARCH_EVT;
704 
705 #define BTA_DM_INQ_RES_IGNORE_RSSI \
706   BTM_INQ_RES_IGNORE_RSSI /* 0x7f RSSI value not supplied (ignore it) */
707 
708 /* Structure associated with BTA_DM_INQ_RES_EVT */
709 typedef struct {
710   RawAddress bd_addr;          /* BD address peer device. */
711   DEV_CLASS dev_class;         /* Device class of peer device. */
712   bool remt_name_not_required; /* Application sets this flag if it already knows
713                                   the name of the device */
714   /* If the device name is known to application BTA skips the remote name
715    * request */
716   bool is_limited; /* true, if the limited inquiry bit is set in the CoD */
717   int8_t rssi;     /* The rssi value */
718   uint8_t* p_eir;  /* received EIR */
719   uint16_t eir_len; /* received EIR length */
720   uint8_t inq_result_type;
721   uint8_t ble_addr_type;
722   uint16_t ble_evt_type;
723   uint8_t ble_primary_phy;
724   uint8_t ble_secondary_phy;
725   uint8_t ble_advertising_sid;
726   int8_t ble_tx_power;
727   uint16_t ble_periodic_adv_int;
728   tBT_DEVICE_TYPE device_type;
729   uint8_t flag;
730 } tBTA_DM_INQ_RES;
731 
732 /* Structure associated with BTA_DM_INQ_CMPL_EVT */
733 typedef struct {
734   uint8_t num_resps; /* Number of inquiry responses. */
735 } tBTA_DM_INQ_CMPL;
736 
737 /* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
738 typedef struct {
739   RawAddress bd_addr; /* BD address peer device. */
740   uint8_t num_record; /* Number of DI record */
741   tBTA_STATUS result;
742 } tBTA_DM_DI_DISC_CMPL;
743 
744 /* Structure associated with BTA_DM_DISC_RES_EVT */
745 typedef struct {
746   RawAddress bd_addr;          /* BD address peer device. */
747   BD_NAME bd_name;             /* Name of peer device. */
748   tBTA_SERVICE_MASK services;  /* Services found on peer device. */
749   uint8_t* p_raw_data;         /* Raw data for discovery DB */
750   uint32_t raw_data_size;      /* size of raw data */
751   tBT_DEVICE_TYPE device_type; /* device type in case it is BLE device */
752   uint32_t num_uuids;
753   bluetooth::Uuid* p_uuid_list;
754   tBTA_STATUS result;
755 } tBTA_DM_DISC_RES;
756 
757 /* Structure associated with tBTA_DM_DISC_BLE_RES */
758 typedef struct {
759   RawAddress bd_addr; /* BD address peer device. */
760   BD_NAME bd_name;  /* Name of peer device. */
761   bluetooth::Uuid service; /* GATT based Services UUID found on peer device. */
762 } tBTA_DM_DISC_BLE_RES;
763 
764 /* Union of all search callback structures */
765 typedef union {
766   tBTA_DM_INQ_RES inq_res;   /* Inquiry result for a peer device. */
767   tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
768   tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
769   tBTA_DM_DISC_BLE_RES
770       disc_ble_res;             /* discovery result for GATT based service */
771   tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
772 
773 } tBTA_DM_SEARCH;
774 
775 /* Search callback */
776 typedef void(tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event,
777                                    tBTA_DM_SEARCH* p_data);
778 
779 /* Execute call back */
780 typedef void(tBTA_DM_EXEC_CBACK)(void* p_param);
781 
782 /* Encryption callback*/
783 typedef void(tBTA_DM_ENCRYPT_CBACK)(const RawAddress& bd_addr,
784                                     tBTA_TRANSPORT transport,
785                                     tBTA_STATUS result);
786 
787 #define BTA_DM_BLE_SEC_NONE BTM_BLE_SEC_NONE
788 #define BTA_DM_BLE_SEC_ENCRYPT BTM_BLE_SEC_ENCRYPT
789 #define BTA_DM_BLE_SEC_NO_MITM BTM_BLE_SEC_ENCRYPT_NO_MITM
790 #define BTA_DM_BLE_SEC_MITM BTM_BLE_SEC_ENCRYPT_MITM
791 typedef tBTM_BLE_SEC_ACT tBTA_DM_BLE_SEC_ACT;
792 
793 typedef tBTM_BLE_TX_TIME_MS tBTA_DM_BLE_TX_TIME_MS;
794 typedef tBTM_BLE_RX_TIME_MS tBTA_DM_BLE_RX_TIME_MS;
795 typedef tBTM_BLE_IDLE_TIME_MS tBTA_DM_BLE_IDLE_TIME_MS;
796 typedef tBTM_BLE_ENERGY_USED tBTA_DM_BLE_ENERGY_USED;
797 
798 #define BTA_DM_CONTRL_UNKNOWN 0 /* Unknown state */
799 #define BTA_DM_CONTRL_ACTIVE 1  /* ACL link on, SCO link ongoing, sniff mode */
800 #define BTA_DM_CONTRL_SCAN                   \
801   2 /* Scan state - paging/inquiry/trying to \
802        connect*/
803 #define BTA_DM_CONTRL_IDLE                           \
804   3 /* Idle state - page scan, LE advt, inquiry scan \
805        */
806 
807 typedef uint8_t tBTA_DM_CONTRL_STATE;
808 
809 typedef uint8_t tBTA_DM_BLE_ADV_STATE;
810 typedef uint8_t tBTA_DM_BLE_ADV_INFO_PRESENT;
811 typedef uint8_t tBTA_DM_BLE_RSSI_VALUE;
812 typedef uint16_t tBTA_DM_BLE_ADV_INFO_TIMESTAMP;
813 
814 typedef void(tBTA_BLE_ENERGY_INFO_CBACK)(tBTA_DM_BLE_TX_TIME_MS tx_time,
815                                          tBTA_DM_BLE_RX_TIME_MS rx_time,
816                                          tBTA_DM_BLE_IDLE_TIME_MS idle_time,
817                                          tBTA_DM_BLE_ENERGY_USED energy_used,
818                                          tBTA_DM_CONTRL_STATE ctrl_state,
819                                          tBTA_STATUS status);
820 
821 /* Maximum service name length */
822 #define BTA_SERVICE_NAME_LEN 35
823 #define BTA_SERVICE_DESP_LEN BTA_SERVICE_NAME_LEN
824 #define BTA_PROVIDER_NAME_LEN BTA_SERVICE_NAME_LEN
825 
826 /* link policy masks  */
827 #define BTA_DM_LP_SWITCH HCI_ENABLE_MASTER_SLAVE_SWITCH
828 #define BTA_DM_LP_HOLD HCI_ENABLE_HOLD_MODE
829 #define BTA_DM_LP_SNIFF HCI_ENABLE_SNIFF_MODE
830 #define BTA_DM_LP_PARK HCI_ENABLE_PARK_MODE
831 typedef uint16_t tBTA_DM_LP_MASK;
832 
833 /* power mode actions  */
834 #define BTA_DM_PM_NO_ACTION 0x00 /* no change to the current pm setting */
835 #define BTA_DM_PM_PARK 0x10      /* prefers park mode */
836 #define BTA_DM_PM_SNIFF 0x20     /* prefers sniff mode */
837 #define BTA_DM_PM_SNIFF1 0x21    /* prefers sniff1 mode */
838 #define BTA_DM_PM_SNIFF2 0x22    /* prefers sniff2 mode */
839 #define BTA_DM_PM_SNIFF3 0x23    /* prefers sniff3 mode */
840 #define BTA_DM_PM_SNIFF4 0x24    /* prefers sniff4 mode */
841 #define BTA_DM_PM_SNIFF5 0x25    /* prefers sniff5 mode */
842 #define BTA_DM_PM_SNIFF6 0x26    /* prefers sniff6 mode */
843 #define BTA_DM_PM_SNIFF7 0x27    /* prefers sniff7 mode */
844 #define BTA_DM_PM_SNIFF_USER0 \
845   0x28 /* prefers user-defined sniff0 mode (testtool only) */
846 #define BTA_DM_PM_SNIFF_USER1 \
847   0x29 /* prefers user-defined sniff1 mode (testtool only) */
848 #define BTA_DM_PM_ACTIVE 0x40  /* prefers active mode */
849 #define BTA_DM_PM_RETRY 0x80   /* retry power mode based on current settings */
850 #define BTA_DM_PM_SUSPEND 0x04 /* prefers suspend mode */
851 #define BTA_DM_PM_NO_PREF                                                   \
852   0x01 /* service has no prefernce on power mode setting. eg. connection to \
853           service got closed */
854 
855 typedef uint8_t tBTA_DM_PM_ACTION;
856 
857 /* index to bta_dm_ssr_spec */
858 #define BTA_DM_PM_SSR0 0
859 #define BTA_DM_PM_SSR1                      \
860   1 /* BTA_DM_PM_SSR1 will be dedicated for \
861     HH SSR setting entry, no other profile can use it */
862 #define BTA_DM_PM_SSR2 2
863 #define BTA_DM_PM_SSR3 3
864 #define BTA_DM_PM_SSR4 4
865 #define BTA_DM_PM_SSR5 5
866 #define BTA_DM_PM_SSR6 6
867 
868 #define BTA_DM_PM_NUM_EVTS 9
869 
870 #ifndef BTA_DM_PM_PARK_IDX
871 #define BTA_DM_PM_PARK_IDX \
872   6 /* the actual index to bta_dm_pm_md[] for PARK mode */
873 #endif
874 
875 #ifndef BTA_DM_PM_SNIFF_A2DP_IDX
876 #define BTA_DM_PM_SNIFF_A2DP_IDX BTA_DM_PM_SNIFF
877 #endif
878 
879 #ifndef BTA_DM_PM_SNIFF_HD_IDLE_IDX
880 #define BTA_DM_PM_SNIFF_HD_IDLE_IDX BTA_DM_PM_SNIFF2
881 #endif
882 
883 #ifndef BTA_DM_PM_SNIFF_SCO_OPEN_IDX
884 #define BTA_DM_PM_SNIFF_SCO_OPEN_IDX BTA_DM_PM_SNIFF3
885 #endif
886 
887 #ifndef BTA_DM_PM_SNIFF_HD_ACTIVE_IDX
888 #define BTA_DM_PM_SNIFF_HD_ACTIVE_IDX BTA_DM_PM_SNIFF4
889 #endif
890 
891 #ifndef BTA_DM_PM_SNIFF_HH_OPEN_IDX
892 #define BTA_DM_PM_SNIFF_HH_OPEN_IDX BTA_DM_PM_SNIFF2
893 #endif
894 
895 #ifndef BTA_DM_PM_SNIFF_HH_ACTIVE_IDX
896 #define BTA_DM_PM_SNIFF_HH_ACTIVE_IDX BTA_DM_PM_SNIFF2
897 #endif
898 
899 #ifndef BTA_DM_PM_SNIFF_HH_IDLE_IDX
900 #define BTA_DM_PM_SNIFF_HH_IDLE_IDX BTA_DM_PM_SNIFF2
901 #endif
902 
903 #ifndef BTA_DM_PM_HH_OPEN_DELAY
904 #define BTA_DM_PM_HH_OPEN_DELAY 30000
905 #endif
906 
907 #ifndef BTA_DM_PM_HH_ACTIVE_DELAY
908 #define BTA_DM_PM_HH_ACTIVE_DELAY 30000
909 #endif
910 
911 #ifndef BTA_DM_PM_HH_IDLE_DELAY
912 #define BTA_DM_PM_HH_IDLE_DELAY 30000
913 #endif
914 
915 /* The Sniff Parameters defined below must be ordered from highest
916  * latency (biggest interval) to lowest latency.  If there is a conflict
917  * among the connected services the setting with the lowest latency will
918  * be selected.  If a device should override a sniff parameter then it
919  * must insure that order is maintained.
920  */
921 #ifndef BTA_DM_PM_SNIFF_MAX
922 #define BTA_DM_PM_SNIFF_MAX 800
923 #define BTA_DM_PM_SNIFF_MIN 400
924 #define BTA_DM_PM_SNIFF_ATTEMPT 4
925 #define BTA_DM_PM_SNIFF_TIMEOUT 1
926 #endif
927 
928 #ifndef BTA_DM_PM_SNIFF1_MAX
929 #define BTA_DM_PM_SNIFF1_MAX 400
930 #define BTA_DM_PM_SNIFF1_MIN 200
931 #define BTA_DM_PM_SNIFF1_ATTEMPT 4
932 #define BTA_DM_PM_SNIFF1_TIMEOUT 1
933 #endif
934 
935 #ifndef BTA_DM_PM_SNIFF2_MAX
936 #define BTA_DM_PM_SNIFF2_MAX 54
937 #define BTA_DM_PM_SNIFF2_MIN 30
938 #define BTA_DM_PM_SNIFF2_ATTEMPT 4
939 #define BTA_DM_PM_SNIFF2_TIMEOUT 1
940 #endif
941 
942 #ifndef BTA_DM_PM_SNIFF3_MAX
943 #define BTA_DM_PM_SNIFF3_MAX 150
944 #define BTA_DM_PM_SNIFF3_MIN 50
945 #define BTA_DM_PM_SNIFF3_ATTEMPT 4
946 #define BTA_DM_PM_SNIFF3_TIMEOUT 1
947 #endif
948 
949 #ifndef BTA_DM_PM_SNIFF4_MAX
950 #define BTA_DM_PM_SNIFF4_MAX 18
951 #define BTA_DM_PM_SNIFF4_MIN 10
952 #define BTA_DM_PM_SNIFF4_ATTEMPT 4
953 #define BTA_DM_PM_SNIFF4_TIMEOUT 1
954 #endif
955 
956 #ifndef BTA_DM_PM_SNIFF5_MAX
957 #define BTA_DM_PM_SNIFF5_MAX 36
958 #define BTA_DM_PM_SNIFF5_MIN 30
959 #define BTA_DM_PM_SNIFF5_ATTEMPT 2
960 #define BTA_DM_PM_SNIFF5_TIMEOUT 0
961 #endif
962 
963 #ifndef BTA_DM_PM_SNIFF6_MAX
964 #define BTA_DM_PM_SNIFF6_MAX 18
965 #define BTA_DM_PM_SNIFF6_MIN 14
966 #define BTA_DM_PM_SNIFF6_ATTEMPT 1
967 #define BTA_DM_PM_SNIFF6_TIMEOUT 0
968 #endif
969 
970 #ifndef BTA_DM_PM_PARK_MAX
971 #define BTA_DM_PM_PARK_MAX 800
972 #define BTA_DM_PM_PARK_MIN 400
973 #define BTA_DM_PM_PARK_ATTEMPT 0
974 #define BTA_DM_PM_PARK_TIMEOUT 0
975 #endif
976 
977 /* Switch callback events */
978 #define BTA_DM_SWITCH_CMPL_EVT 0 /* Completion of the Switch API */
979 
980 typedef uint8_t tBTA_DM_SWITCH_EVT;
981 typedef void(tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event,
982                                    tBTA_STATUS status);
983 
984 /* Audio routing out configuration */
985 #define BTA_DM_ROUTE_NONE 0x00      /* No Audio output */
986 #define BTA_DM_ROUTE_DAC 0x01       /* routing over analog output */
987 #define BTA_DM_ROUTE_I2S 0x02       /* routing over digital (I2S) output */
988 #define BTA_DM_ROUTE_BT_MONO 0x04   /* routing over SCO */
989 #define BTA_DM_ROUTE_BT_STEREO 0x08 /* routing over BT Stereo */
990 #define BTA_DM_ROUTE_HOST 0x10      /* routing over Host */
991 #define BTA_DM_ROUTE_FMTX 0x20      /* routing over FMTX */
992 #define BTA_DM_ROUTE_FMRX 0x40      /* routing over FMRX */
993 #define BTA_DM_ROUTE_BTSNK 0x80     /* routing over BT SNK */
994 
995 typedef uint8_t tBTA_DM_ROUTE_PATH;
996 
997 /* Device Identification (DI) data structure
998 */
999 /* Used to set the DI record */
1000 typedef tSDP_DI_RECORD tBTA_DI_RECORD;
1001 /* Used to get the DI record */
1002 typedef tSDP_DI_GET_RECORD tBTA_DI_GET_RECORD;
1003 /* SDP discovery database */
1004 typedef tSDP_DISCOVERY_DB tBTA_DISCOVERY_DB;
1005 
1006 #ifndef BTA_DI_NUM_MAX
1007 #define BTA_DI_NUM_MAX 3
1008 #endif
1009 
1010 /* Device features mask definitions */
1011 #define BTA_FEATURE_BYTES_PER_PAGE BTM_FEATURE_BYTES_PER_PAGE
1012 #define BTA_EXT_FEATURES_PAGE_MAX BTM_EXT_FEATURES_PAGE_MAX
1013 /* ACL type
1014 */
1015 #define BTA_DM_LINK_TYPE_BR_EDR 0x01
1016 #define BTA_DM_LINK_TYPE_LE 0x02
1017 #define BTA_DM_LINK_TYPE_ALL 0xFF
1018 typedef uint8_t tBTA_DM_LINK_TYPE;
1019 
1020 #define IMMEDIATE_DELY_MODE 0x00
1021 #define ONFOUND_DELY_MODE 0x01
1022 #define BATCH_DELY_MODE 0x02
1023 #define ALLOW_ALL_FILTER 0x00
1024 #define LOWEST_RSSI_VALUE 129
1025 
1026 /*****************************************************************************
1027  *  External Function Declarations
1028  ****************************************************************************/
1029 
1030 /*******************************************************************************
1031  *
1032  * Function         BTA_EnableBluetooth
1033  *
1034  * Description      This function initializes BTA and prepares BTA and the
1035  *                  Bluetooth protocol stack for use.  This function is
1036  *                  typically called at startup or when Bluetooth services
1037  *                  are required by the phone.  This function must be called
1038  *                  before calling any other API function.
1039  *
1040  *
1041  * Returns          BTA_SUCCESS if successful.
1042  *                  BTA_FAIL if internal failure.
1043  *
1044  ******************************************************************************/
1045 extern tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK* p_cback);
1046 
1047 /*******************************************************************************
1048  *
1049  * Function         BTA_DisableBluetooth
1050  *
1051  * Description      This function disables BTA and the Bluetooth protocol
1052  *                  stack.  It is called when BTA is no longer being used
1053  *                  by any application in the system.
1054  *
1055  *
1056  * Returns          void
1057  *
1058  ******************************************************************************/
1059 extern tBTA_STATUS BTA_DisableBluetooth(void);
1060 
1061 /*******************************************************************************
1062  *
1063  * Function         BTA_EnableTestMode
1064  *
1065  * Description      Enables bluetooth device under test mode
1066  *
1067  *
1068  * Returns          tBTA_STATUS
1069  *
1070  ******************************************************************************/
1071 extern void BTA_EnableTestMode(void);
1072 
1073 /*******************************************************************************
1074  *
1075  * Function         BTA_DisableTestMode
1076  *
1077  * Description      Disable bluetooth device under test mode
1078  *
1079  *
1080  * Returns          None
1081  *
1082  ******************************************************************************/
1083 extern void BTA_DisableTestMode(void);
1084 
1085 /*******************************************************************************
1086  *
1087  * Function         BTA_DmSetDeviceName
1088  *
1089  * Description      This function sets the Bluetooth name of the local device.
1090  *
1091  *
1092  * Returns          void
1093  *
1094  ******************************************************************************/
1095 extern void BTA_DmSetDeviceName(char* p_name);
1096 
1097 /*******************************************************************************
1098  *
1099  * Function         BTA_DmSetVisibility
1100  *
1101  * Description      This function sets the Bluetooth connectable,discoverable,
1102  *                  pairable and conn paired only modesmodes of the local
1103  *                  device.
1104  *                  This controls whether other Bluetooth devices can find and
1105  *                  connect to the local device.
1106  *
1107  *
1108  * Returns          void
1109  *
1110  ******************************************************************************/
1111 extern void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode,
1112                                 uint8_t pairable_mode, uint8_t conn_filter);
1113 
1114 /*******************************************************************************
1115  *
1116  * Function         BTA_DmSearch
1117  *
1118  * Description      This function searches for peer Bluetooth devices.  It
1119  *                  first performs an inquiry; for each device found from the
1120  *                  inquiry it gets the remote name of the device.  If
1121  *                  parameter services is nonzero, service discovery will be
1122  *                  performed on each device for the services specified.
1123  *
1124  *
1125  * Returns          void
1126  *
1127  ******************************************************************************/
1128 extern void BTA_DmSearch(tBTA_DM_INQ* p_dm_inq, tBTA_SERVICE_MASK services,
1129                          tBTA_DM_SEARCH_CBACK* p_cback);
1130 
1131 /*******************************************************************************
1132  *
1133  * Function         BTA_DmSearchCancel
1134  *
1135  * Description      This function cancels a search that has been initiated
1136  *                  by calling BTA_DmSearch().
1137  *
1138  *
1139  * Returns          void
1140  *
1141  ******************************************************************************/
1142 extern void BTA_DmSearchCancel(void);
1143 
1144 /*******************************************************************************
1145  *
1146  * Function         BTA_DmDiscover
1147  *
1148  * Description      This function performs service discovery for the services
1149  *                  of a particular peer device.
1150  *
1151  *
1152  * Returns          void
1153  *
1154  ******************************************************************************/
1155 extern void BTA_DmDiscover(const RawAddress& bd_addr,
1156                            tBTA_SERVICE_MASK services,
1157                            tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search);
1158 
1159 /*******************************************************************************
1160  *
1161  * Function         BTA_DmDiscoverUUID
1162  *
1163  * Description      This function performs service discovery for the services
1164  *                  of a particular peer device.
1165  *
1166  *
1167  * Returns          void
1168  *
1169  ******************************************************************************/
1170 extern void BTA_DmDiscoverUUID(const RawAddress& bd_addr,
1171                                const bluetooth::Uuid& uuid,
1172                                tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search);
1173 
1174 /*******************************************************************************
1175  *
1176  * Function         BTA_DmGetCachedRemoteName
1177  *
1178  * Description      Retieve cached remote name if available
1179  *
1180  * Returns          BTA_SUCCESS if cached name was retrieved
1181  *                  BTA_FAILURE if cached name is not available
1182  *
1183  ******************************************************************************/
1184 tBTA_STATUS BTA_DmGetCachedRemoteName(const RawAddress& remote_device,
1185                                       uint8_t** pp_cached_name);
1186 
1187 /*******************************************************************************
1188  *
1189  * Function         BTA_DmBond
1190  *
1191  * Description      This function initiates a bonding procedure with a peer
1192  *                  device by designated transport.  The bonding procedure
1193  *                  enables authentication and optionally encryption on the
1194  *                  Bluetooth link.
1195  *
1196  *
1197  * Returns          void
1198  *
1199  ******************************************************************************/
1200 extern void BTA_DmBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
1201                        tBTA_TRANSPORT transport);
1202 
1203 /*******************************************************************************
1204  *
1205  * Function         BTA_DmBondCancel
1206  *
1207  * Description      This function cancels a bonding procedure with a peer
1208  *                  device.
1209  *
1210  *
1211  * Returns          void
1212  *
1213  ******************************************************************************/
1214 extern void BTA_DmBondCancel(const RawAddress& bd_addr);
1215 
1216 /*******************************************************************************
1217  *
1218  * Function         BTA_DmPinReply
1219  *
1220  * Description      This function provides a PIN when one is requested by DM
1221  *                  during a bonding procedure.  The application should call
1222  *                  this function after the security callback is called with
1223  *                  a BTA_DM_PIN_REQ_EVT.
1224  *
1225  *
1226  * Returns          void
1227  *
1228  ******************************************************************************/
1229 extern void BTA_DmPinReply(const RawAddress& bd_addr, bool accept,
1230                            uint8_t pin_len, uint8_t* p_pin);
1231 
1232 /*******************************************************************************
1233  *
1234  * Function         BTA_DmLocalOob
1235  *
1236  * Description      This function retrieves the OOB data from local controller.
1237  *                  The result is reported by bta_dm_co_loc_oob().
1238  *
1239  * Returns          void
1240  *
1241  ******************************************************************************/
1242 extern void BTA_DmLocalOob(void);
1243 
1244 /*******************************************************************************
1245  *
1246  * Function         BTA_DmConfirm
1247  *
1248  * Description      This function accepts or rejects the numerical value of the
1249  *                  Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
1250  *
1251  * Returns          void
1252  *
1253  ******************************************************************************/
1254 extern void BTA_DmConfirm(const RawAddress& bd_addr, bool accept);
1255 
1256 /*******************************************************************************
1257  *
1258  * Function         BTA_DmAddDevice
1259  *
1260  * Description      This function adds a device to the security database list
1261  *                  of peer devices. This function would typically be called
1262  *                  at system startup to initialize the security database with
1263  *                  known peer devices.  This is a direct execution function
1264  *                  that may lock task scheduling on some platforms.
1265  *
1266  * Returns          void
1267  *
1268  ******************************************************************************/
1269 extern void BTA_DmAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
1270                             const LinkKey& link_key,
1271                             tBTA_SERVICE_MASK trusted_mask, bool is_trusted,
1272                             uint8_t key_type, tBTA_IO_CAP io_cap,
1273                             uint8_t pin_length);
1274 
1275 /*******************************************************************************
1276  *
1277  * Function         BTA_DmRemoveDevice
1278  *
1279  * Description      This function removes a device from the security database.
1280  *                  This is a direct execution function that may lock task
1281  *                  scheduling on some platforms.
1282  *
1283  *
1284  * Returns          BTA_SUCCESS if successful.
1285  *                  BTA_FAIL if operation failed.
1286  *
1287  ******************************************************************************/
1288 extern tBTA_STATUS BTA_DmRemoveDevice(const RawAddress& bd_addr);
1289 
1290 /*******************************************************************************
1291  *
1292  * Function         BTA_GetEirService
1293  *
1294  * Description      This function is called to get BTA service mask from EIR.
1295  *
1296  * Parameters       p_eir - pointer of EIR significant part
1297  *                  eir_len - EIR length
1298  *                  p_services - return the BTA service mask
1299  *
1300  * Returns          None
1301  *
1302  ******************************************************************************/
1303 extern void BTA_GetEirService(uint8_t* p_eir, size_t eir_len,
1304                               tBTA_SERVICE_MASK* p_services);
1305 
1306 /*******************************************************************************
1307  *
1308  * Function         BTA_DmGetConnectionState
1309  *
1310  * Description      Returns whether the remote device is currently connected.
1311  *
1312  * Returns          0 if the device is NOT connected.
1313  *
1314  ******************************************************************************/
1315 extern uint16_t BTA_DmGetConnectionState(const RawAddress& bd_addr);
1316 
1317 /*******************************************************************************
1318  *
1319  * Function         BTA_DmSetLocalDiRecord
1320  *
1321  * Description      This function adds a DI record to the local SDP database.
1322  *
1323  * Returns          BTA_SUCCESS if record set sucessfully, otherwise error code.
1324  *
1325  ******************************************************************************/
1326 extern tBTA_STATUS BTA_DmSetLocalDiRecord(tBTA_DI_RECORD* p_device_info,
1327                                           uint32_t* p_handle);
1328 
1329 /*******************************************************************************
1330  *
1331  *
1332  * Function         BTA_DmCloseACL
1333  *
1334  * Description      This function force to close an ACL connection and remove
1335  the
1336  *                  device from the security database list of known devices.
1337  *
1338  * Parameters:      bd_addr       - Address of the peer device
1339  *                  remove_dev    - remove device or not after link down
1340  *                  transport     - which transport to close
1341 
1342  *
1343  * Returns          void.
1344  *
1345  ******************************************************************************/
1346 extern void BTA_DmCloseACL(const RawAddress& bd_addr, bool remove_dev,
1347                            tBTA_TRANSPORT transport);
1348 
1349 /* BLE related API functions */
1350 /*******************************************************************************
1351  *
1352  * Function         BTA_DmBleSecurityGrant
1353  *
1354  * Description      Grant security request access.
1355  *
1356  * Parameters:      bd_addr          - BD address of the peer
1357  *                  res              - security grant status.
1358  *
1359  * Returns          void
1360  *
1361  ******************************************************************************/
1362 extern void BTA_DmBleSecurityGrant(const RawAddress& bd_addr,
1363                                    tBTA_DM_BLE_SEC_GRANT res);
1364 
1365 /*******************************************************************************
1366  *
1367  * Function         BTA_DmBlePasskeyReply
1368  *
1369  * Description      Send BLE SMP passkey reply.
1370  *
1371  * Parameters:      bd_addr          - BD address of the peer
1372  *                  accept           - passkey entry sucessful or declined.
1373  *                  passkey          - passkey value, must be a 6 digit number,
1374  *                                     can be lead by 0.
1375  *
1376  * Returns          void
1377  *
1378  ******************************************************************************/
1379 extern void BTA_DmBlePasskeyReply(const RawAddress& bd_addr, bool accept,
1380                                   uint32_t passkey);
1381 
1382 /*******************************************************************************
1383  *
1384  * Function         BTA_DmBleConfirmReply
1385  *
1386  * Description      Send BLE SMP SC user confirmation reply.
1387  *
1388  * Parameters:      bd_addr          - BD address of the peer
1389  *                  accept           - numbers to compare are the same or
1390  *                                     different.
1391  *
1392  * Returns          void
1393  *
1394  ******************************************************************************/
1395 extern void BTA_DmBleConfirmReply(const RawAddress& bd_addr, bool accept);
1396 
1397 /*******************************************************************************
1398  *
1399  * Function         BTA_DmAddBleDevice
1400  *
1401  * Description      Add a BLE device.  This function will be normally called
1402  *                  during host startup to restore all required information
1403  *                  for a LE device stored in the NVRAM.
1404  *
1405  * Parameters:      bd_addr          - BD address of the peer
1406  *                  dev_type         - Remote device's device type.
1407  *                  addr_type        - LE device address type.
1408  *
1409  * Returns          void
1410  *
1411  ******************************************************************************/
1412 extern void BTA_DmAddBleDevice(const RawAddress& bd_addr,
1413                                tBLE_ADDR_TYPE addr_type,
1414                                tBT_DEVICE_TYPE dev_type);
1415 
1416 /*******************************************************************************
1417  *
1418  * Function         BTA_DmAddBleKey
1419  *
1420  * Description      Add/modify LE device information.  This function will be
1421  *                  normally called during host startup to restore all required
1422  *                  information stored in the NVRAM.
1423  *
1424  * Parameters:      bd_addr          - BD address of the peer
1425  *                  p_le_key         - LE key values.
1426  *                  key_type         - LE SMP key type.
1427  *
1428  * Returns          void
1429  *
1430  ******************************************************************************/
1431 extern void BTA_DmAddBleKey(const RawAddress& bd_addr,
1432                             tBTA_LE_KEY_VALUE* p_le_key,
1433                             tBTA_LE_KEY_TYPE key_type);
1434 
1435 /*******************************************************************************
1436  *
1437  * Function         BTA_DmSetBlePrefConnParams
1438  *
1439  * Description      This function is called to set the preferred connection
1440  *                  parameters when default connection parameter is not desired.
1441  *
1442  * Parameters:      bd_addr          - BD address of the peripheral
1443  *                  min_conn_int     - minimum preferred connection interval
1444  *                  max_conn_int     - maximum preferred connection interval
1445  *                  slave_latency    - preferred slave latency
1446  *                  supervision_tout - preferred supervision timeout
1447  *
1448  *
1449  * Returns          void
1450  *
1451  ******************************************************************************/
1452 extern void BTA_DmSetBlePrefConnParams(const RawAddress& bd_addr,
1453                                        uint16_t min_conn_int,
1454                                        uint16_t max_conn_int,
1455                                        uint16_t slave_latency,
1456                                        uint16_t supervision_tout);
1457 
1458 /*******************************************************************************
1459  *
1460  * Function         BTA_DmSetBleConnScanParams
1461  *
1462  * Description      This function is called to set scan parameters used in
1463  *                  BLE connection request
1464  *
1465  * Parameters:      scan_interval    - scan interval
1466  *                  scan_window      - scan window
1467  *
1468  * Returns          void
1469  *
1470  ******************************************************************************/
1471 extern void BTA_DmSetBleConnScanParams(uint32_t scan_interval,
1472                                        uint32_t scan_window);
1473 
1474 /*******************************************************************************
1475  *
1476  * Function         BTA_DmSearchExt
1477  *
1478  * Description      This function searches for peer Bluetooth devices. It
1479  *                  performs an inquiry and gets the remote name for devices.
1480  *                  Service discovery is done if services is non zero
1481  *
1482  * Parameters       p_dm_inq: inquiry conditions
1483  *                  services: if service is not empty, service discovery will be
1484  *                            done.
1485  *                            for all GATT based service condition, put
1486  *                            num_uuid, and p_uuid is the pointer to the list of
1487  *                            UUID values.
1488  *                  p_cback: callback functino when search is completed.
1489  *
1490  *
1491  *
1492  * Returns          void
1493  *
1494  ******************************************************************************/
1495 extern void BTA_DmSearchExt(tBTA_DM_INQ* p_dm_inq,
1496                             tBTA_SERVICE_MASK_EXT* p_services,
1497                             tBTA_DM_SEARCH_CBACK* p_cback);
1498 
1499 /*******************************************************************************
1500  *
1501  * Function         BTA_DmDiscoverExt
1502  *
1503  * Description      This function does service discovery for services of a
1504  *                  peer device. When services.num_uuid is 0, it indicates all
1505  *                  GATT based services are to be searched; other wise a list of
1506  *                  UUID of interested services should be provided through
1507  *                  services.p_uuid.
1508  *
1509  *
1510  *
1511  * Returns          void
1512  *
1513  ******************************************************************************/
1514 extern void BTA_DmDiscoverExt(const RawAddress& bd_addr,
1515                               tBTA_SERVICE_MASK_EXT* p_services,
1516                               tBTA_DM_SEARCH_CBACK* p_cback, bool sdp_search);
1517 
1518 /*******************************************************************************
1519  *
1520  * Function         BTA_DmDiscoverByTransport
1521  *
1522  * Description      This function does service discovery on particular transport
1523  *                  for services of a
1524  *                  peer device. When services.num_uuid is 0, it indicates all
1525  *                  GATT based services are to be searched; other wise a list of
1526  *                  UUID of interested services should be provided through
1527  *                  p_services->p_uuid.
1528  *
1529  *
1530  *
1531  * Returns          void
1532  *
1533  ******************************************************************************/
1534 extern void BTA_DmDiscoverByTransport(const RawAddress& bd_addr,
1535                                       tBTA_SERVICE_MASK_EXT* p_services,
1536                                       tBTA_DM_SEARCH_CBACK* p_cback,
1537                                       bool sdp_search,
1538                                       tBTA_TRANSPORT transport);
1539 
1540 /*******************************************************************************
1541  *
1542  * Function         BTA_DmSetEncryption
1543  *
1544  * Description      This function is called to ensure that connection is
1545  *                  encrypted.  Should be called only on an open connection.
1546  *                  Typically only needed for connections that first want to
1547  *                  bring up unencrypted links, then later encrypt them.
1548  *
1549  * Parameters:      bd_addr       - Address of the peer device
1550  *                  transport     - transport of the link to be encruypted
1551  *                  p_callback    - Pointer to callback function to indicat the
1552  *                                  link encryption status
1553  *                  sec_act       - This is the security action to indicate
1554  *                                  what kind of BLE security level is required
1555  *                                  for the BLE link if BLE is supported
1556  *                                  Note: This parameter is ignored for
1557  *                                        BR/EDR or if BLE is not supported.
1558  *
1559  * Returns          void
1560  *
1561  *
1562  ******************************************************************************/
1563 extern void BTA_DmSetEncryption(const RawAddress& bd_addr,
1564                                 tBTA_TRANSPORT transport,
1565                                 tBTA_DM_ENCRYPT_CBACK* p_callback,
1566                                 tBTA_DM_BLE_SEC_ACT sec_act);
1567 
1568 /*******************************************************************************
1569  *
1570  * Function         BTA_DmBleObserve
1571  *
1572  * Description      This procedure keep the device listening for advertising
1573  *                  events from a broadcast device.
1574  *
1575  * Parameters       start: start or stop observe.
1576  *                  duration : Duration of the scan. Continuous scan if 0 is
1577  *                             passed
1578  *                  p_results_cb: Callback to be called with scan results
1579  *
1580  * Returns          void
1581  *
1582  ******************************************************************************/
1583 extern void BTA_DmBleObserve(bool start, uint8_t duration,
1584                              tBTA_DM_SEARCH_CBACK* p_results_cb);
1585 
1586 /*******************************************************************************
1587  *
1588  * Function         BTA_DmBleConfigLocalPrivacy
1589  *
1590  * Description      Enable/disable privacy on the local device
1591  *
1592  * Parameters:      privacy_enable   - enable/disabe privacy on remote device.
1593  *
1594  * Returns          void
1595  *
1596  ******************************************************************************/
1597 extern void BTA_DmBleConfigLocalPrivacy(bool privacy_enable);
1598 
1599 /*******************************************************************************
1600  *
1601  * Function         BTA_DmBleEnableRemotePrivacy
1602  *
1603  * Description      Enable/disable privacy on a remote device
1604  *
1605  * Parameters:      bd_addr          - BD address of the peer
1606  *                  privacy_enable   - enable/disabe privacy on remote device.
1607  *
1608  * Returns          void
1609  *
1610  ******************************************************************************/
1611 extern void BTA_DmBleEnableRemotePrivacy(const RawAddress& bd_addr,
1612                                          bool privacy_enable);
1613 
1614 /*******************************************************************************
1615  *
1616  * Function         BTA_DmBleUpdateConnectionParams
1617  *
1618  * Description      Update connection parameters, can only be used when
1619  *                  connection is up.
1620  *
1621  * Parameters:      bd_addr   - BD address of the peer
1622  *                  min_int   - minimum connection interval, [0x0004 ~ 0x4000]
1623  *                  max_int   - maximum connection interval, [0x0004 ~ 0x4000]
1624  *                  latency   - slave latency [0 ~ 500]
1625  *                  timeout   - supervision timeout [0x000a ~ 0xc80]
1626  *
1627  * Returns          void
1628  *
1629  ******************************************************************************/
1630 extern void BTA_DmBleUpdateConnectionParams(const RawAddress& bd_addr,
1631                                             uint16_t min_int, uint16_t max_int,
1632                                             uint16_t latency, uint16_t timeout,
1633                                             uint16_t min_ce_len,
1634                                             uint16_t max_ce_len);
1635 
1636 /*******************************************************************************
1637  *
1638  * Function         BTA_DmBleSetDataLength
1639  *
1640  * Description      This function is to set maximum LE data packet size
1641  *
1642  * Returns          void
1643  *
1644  ******************************************************************************/
1645 extern void BTA_DmBleSetDataLength(const RawAddress& remote_device,
1646                                    uint16_t tx_data_length);
1647 
1648 /*******************************************************************************
1649  *
1650  * Function         BTA_DmBleGetEnergyInfo
1651  *
1652  * Description      This function is called to obtain the energy info
1653  *
1654  * Parameters       p_cmpl_cback - Command complete callback
1655  *
1656  * Returns          void
1657  *
1658  ******************************************************************************/
1659 extern void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK* p_cmpl_cback);
1660 
1661 /*******************************************************************************
1662  *
1663  * Function         BTA_BrcmInit
1664  *
1665  * Description      This function initializes Broadcom specific VS handler in
1666  *                  BTA
1667  *
1668  * Returns          void
1669  *
1670  ******************************************************************************/
1671 extern void BTA_VendorInit(void);
1672 
1673 /*******************************************************************************
1674  *
1675  * Function         BTA_BrcmCleanup
1676  *
1677  * Description      This function frees up Broadcom specific VS specific dynamic
1678  *                  memory
1679  *
1680  * Returns          void
1681  *
1682  ******************************************************************************/
1683 extern void BTA_VendorCleanup(void);
1684 
1685 #endif /* BTA_API_H */
1686