• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2003-2012 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 "data_types.h"
29 #include "bt_target.h"
30 #include "bt_types.h"
31 #include "btm_api.h"
32 #include "uipc_msg.h"
33 
34 #if BLE_INCLUDED == TRUE
35 #include "btm_ble_api.h"
36 #endif
37 
38 /*****************************************************************************
39 **  Constants and data types
40 *****************************************************************************/
41 
42 /* Status Return Value */
43 #define BTA_SUCCESS             0           /* Successful operation. */
44 #define BTA_FAILURE             1           /* Generic failure. */
45 #define BTA_PENDING             2           /* API cannot be completed right now */
46 #define BTA_BUSY                3
47 #define BTA_NO_RESOURCES        4
48 #define BTA_WRONG_MODE          5
49 
50 typedef UINT8 tBTA_STATUS;
51 
52 /*
53  * Service ID
54  *
55  * NOTES: When you add a new Service ID for BTA AND require to change the value of BTA_MAX_SERVICE_ID,
56  *        make sure that the correct security ID of the new service from Security service definitions (btm_api.h)
57  *        should be added to bta_service_id_to_btm_srv_id_lkup_tbl table in bta_dm_act.c.
58  */
59 
60 #define BTA_RES_SERVICE_ID      0           /* Reserved */
61 #define BTA_SPP_SERVICE_ID      1           /* Serial port profile. */
62 #define BTA_DUN_SERVICE_ID      2           /* Dial-up networking profile. */
63 #define BTA_A2DP_SOURCE_SERVICE_ID      3   /* A2DP Source profile. */
64 #define BTA_LAP_SERVICE_ID      4           /* LAN access profile. */
65 #define BTA_HSP_SERVICE_ID      5           /* Headset profile. */
66 #define BTA_HFP_SERVICE_ID      6           /* Hands-free profile. */
67 #define BTA_OPP_SERVICE_ID      7           /* Object push  */
68 #define BTA_FTP_SERVICE_ID      8           /* File transfer */
69 #define BTA_CTP_SERVICE_ID      9           /* Cordless Terminal */
70 #define BTA_ICP_SERVICE_ID      10          /* Intercom Terminal */
71 #define BTA_SYNC_SERVICE_ID     11          /* Synchronization */
72 #define BTA_BPP_SERVICE_ID      12          /* Basic printing profile */
73 #define BTA_BIP_SERVICE_ID      13          /* Basic Imaging profile */
74 #define BTA_PANU_SERVICE_ID     14          /* PAN User */
75 #define BTA_NAP_SERVICE_ID      15          /* PAN Network access point */
76 #define BTA_GN_SERVICE_ID       16          /* PAN Group Ad-hoc networks */
77 #define BTA_SAP_SERVICE_ID      17          /* SIM Access profile */
78 #define BTA_A2DP_SERVICE_ID     18          /* A2DP Sink */
79 #define BTA_AVRCP_SERVICE_ID    19          /* A/V remote control */
80 #define BTA_HID_SERVICE_ID      20          /* HID */
81 #define BTA_VDP_SERVICE_ID      21          /* Video distribution */
82 #define BTA_PBAP_SERVICE_ID     22          /* PhoneBook Access Server*/
83 #define BTA_HSP_HS_SERVICE_ID   23          /* HFP HS role */
84 #define BTA_HFP_HS_SERVICE_ID   24          /* HSP HS role */
85 #define BTA_MAP_SERVICE_ID      25          /* Message Access Profile */
86 #define BTA_MN_SERVICE_ID       26          /* Message Notification Service */
87 #define BTA_HDP_SERVICE_ID      27          /* Health Device Profile */
88 #define BTA_PCE_SERVICE_ID      28          /* PhoneBook Access Client*/
89 
90 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
91 /* BLE profile service ID */
92 #define BTA_BLE_SERVICE_ID      29          /* GATT profile */
93 
94 // btla-specific ++
95 #define BTA_USER_SERVICE_ID     30          /* User requested UUID */
96 
97 #define BTA_MAX_SERVICE_ID      31
98 // btla-specific --
99 #else
100 #define BTA_USER_SERVICE_ID     29          /* User requested UUID */
101 #define BTA_MAX_SERVICE_ID      30
102 #endif
103 /* service IDs (BTM_SEC_SERVICE_FIRST_EMPTY + 1) to (BTM_SEC_MAX_SERVICES - 1)
104  * are used by BTA JV */
105 #define BTA_FIRST_JV_SERVICE_ID     (BTM_SEC_SERVICE_FIRST_EMPTY + 1)
106 #define BTA_LAST_JV_SERVICE_ID      (BTM_SEC_MAX_SERVICES - 1)
107 
108 typedef UINT8 tBTA_SERVICE_ID;
109 
110 /* Service ID Mask */
111 #define BTA_RES_SERVICE_MASK        0x00000001  /* Reserved */
112 #define BTA_SPP_SERVICE_MASK        0x00000002  /* Serial port profile. */
113 #define BTA_DUN_SERVICE_MASK        0x00000004  /* Dial-up networking profile. */
114 #define BTA_FAX_SERVICE_MASK        0x00000008  /* Fax profile. */
115 #define BTA_LAP_SERVICE_MASK        0x00000010  /* LAN access profile. */
116 #define BTA_HSP_SERVICE_MASK        0x00000020  /* HSP AG role. */
117 #define BTA_HFP_SERVICE_MASK        0x00000040  /* HFP AG role */
118 #define BTA_OPP_SERVICE_MASK        0x00000080  /* Object push  */
119 #define BTA_FTP_SERVICE_MASK        0x00000100  /* File transfer */
120 #define BTA_CTP_SERVICE_MASK        0x00000200  /* Cordless Terminal */
121 #define BTA_ICP_SERVICE_MASK        0x00000400  /* Intercom Terminal */
122 #define BTA_SYNC_SERVICE_MASK       0x00000800  /* Synchronization */
123 #define BTA_BPP_SERVICE_MASK        0x00001000  /* Print server */
124 #define BTA_BIP_SERVICE_MASK        0x00002000  /* Basic Imaging */
125 #define BTA_PANU_SERVICE_MASK       0x00004000  /* PAN User */
126 #define BTA_NAP_SERVICE_MASK        0x00008000  /* PAN Network access point */
127 #define BTA_GN_SERVICE_MASK         0x00010000  /* PAN Group Ad-hoc networks */
128 #define BTA_SAP_SERVICE_MASK        0x00020000  /* PAN Group Ad-hoc networks */
129 #define BTA_A2DP_SERVICE_MASK       0x00040000  /* Advanced audio distribution */
130 #define BTA_AVRCP_SERVICE_MASK      0x00080000  /* A/V remote control */
131 #define BTA_HID_SERVICE_MASK        0x00100000  /* HID */
132 #define BTA_VDP_SERVICE_MASK        0x00200000  /* Video distribution */
133 #define BTA_PBAP_SERVICE_MASK       0x00400000  /* Phone Book Server */
134 #define BTA_HSP_HS_SERVICE_MASK     0x00800000  /* HFP HS role */
135 #define BTA_HFP_HS_SERVICE_MASK     0x01000000  /* HSP HS role */
136 #define BTA_MAS_SERVICE_MASK        0x02000000  /* Message Access Profile */
137 #define BTA_MN_SERVICE_MASK         0x04000000  /* Message Notification Profile */
138 #define BTA_HL_SERVICE_MASK         0x08000000  /* Health Device Profile */
139 #define BTA_PCE_SERVICE_MASK        0x10000000  /* Phone Book Client */
140 
141 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
142 #define BTA_BLE_SERVICE_MASK        0x20000000  /* GATT based service */
143 // btla-specific ++
144 #define BTA_USER_SERVICE_MASK       0x40000000  /* Message Notification Profile */
145 // btla-specific --
146 #else
147 // btla-specific ++
148 #define BTA_USER_SERVICE_MASK       0x20000000  /* Message Notification Profile */
149 // btla-specific --
150 #endif
151 
152 #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
153 #define BTA_ALL_SERVICE_MASK        0x3FFFFFFF  /* All services supported by BTA. */
154 #else
155 #define BTA_ALL_SERVICE_MASK        0x1FFFFFFF  /* All services supported by BTA. */
156 #endif
157 
158 typedef UINT32 tBTA_SERVICE_MASK;
159 
160 /* extended service mask, including mask with one or more GATT UUID */
161 typedef struct
162 {
163     tBTA_SERVICE_MASK   srvc_mask;
164     UINT8               num_uuid;
165     tBT_UUID            *p_uuid;
166 }tBTA_SERVICE_MASK_EXT;
167 
168 /* Security Setting Mask */
169 #define BTA_SEC_NONE            BTM_SEC_NONE                                         /* No security. */
170 #define BTA_SEC_AUTHORIZE       (BTM_SEC_IN_AUTHORIZE )                              /* Authorization required (only needed for out going connection )*/
171 #define BTA_SEC_AUTHENTICATE    (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_OUT_AUTHENTICATE) /* Authentication required. */
172 #define BTA_SEC_ENCRYPT         (BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT)           /* Encryption required. */
173 
174 typedef UINT8 tBTA_SEC;
175 
176 /* Ignore for Discoverable, Connectable, Pairable and Connectable Paired only device modes */
177 
178 #define BTA_DM_IGNORE           0xFF
179 
180 
181 /* Discoverable Modes */
182 #define BTA_DM_NON_DISC         BTM_NON_DISCOVERABLE        /* Device is not discoverable. */
183 #define BTA_DM_GENERAL_DISC     BTM_GENERAL_DISCOVERABLE    /* General discoverable. */
184 #define BTA_DM_LIMITED_DISC     BTM_LIMITED_DISCOVERABLE    /* Limited discoverable. */
185 #if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
186 #define BTA_DM_BLE_NON_DISCOVERABLE        BTM_BLE_NON_DISCOVERABLE        /* Device is not LE discoverable */
187 #define BTA_DM_BLE_GENERAL_DISCOVERABLE    BTM_BLE_GENERAL_DISCOVERABLE    /* Device is LE General discoverable */
188 #define BTA_DM_BLE_LIMITED_DISCOVERABLE    BTM_BLE_LIMITED_DISCOVERABLE    /* Device is LE Limited discoverable */
189 #endif
190 typedef UINT16 tBTA_DM_DISC;        /* this discoverability mode is a bit mask among BR mode and LE mode */
191 
192 /* Connectable Modes */
193 #define BTA_DM_NON_CONN         BTM_NON_CONNECTABLE         /* Device is not connectable. */
194 #define BTA_DM_CONN             BTM_CONNECTABLE             /* Device is connectable. */
195 #if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
196 #define BTA_DM_BLE_NON_CONNECTABLE      BTM_BLE_NON_CONNECTABLE     /* Device is LE non-connectable. */
197 #define BTA_DM_BLE_CONNECTABLE          BTM_BLE_CONNECTABLE         /* Device is LE connectable. */
198 #endif
199 
200 // btla-specific ++
201 typedef UINT16 tBTA_DM_CONN;
202 // btla-specific --
203 
204 /* Pairable Modes */
205 #define BTA_DM_PAIRABLE         1
206 #define BTA_DM_NON_PAIRABLE     0
207 
208 /* Connectable Paired Only Mode */
209 #define BTA_DM_CONN_ALL         0
210 #define BTA_DM_CONN_PAIRED      1
211 
212 /* Inquiry Modes */
213 #define BTA_DM_INQUIRY_NONE		BTM_INQUIRY_NONE            /*No BR inquiry. */
214 #define BTA_DM_GENERAL_INQUIRY  BTM_GENERAL_INQUIRY         /* Perform general inquiry. */
215 #define BTA_DM_LIMITED_INQUIRY  BTM_LIMITED_INQUIRY         /* Perform limited inquiry. */
216 
217 #if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
218 #define BTA_BLE_INQUIRY_NONE    BTM_BLE_INQUIRY_NONE
219 #define BTA_BLE_GENERAL_INQUIRY BTM_BLE_GENERAL_INQUIRY      /* Perform LE general inquiry. */
220 #define BTA_BLE_LIMITED_INQUIRY BTM_BLE_LIMITED_INQUIRY      /* Perform LE limited inquiry. */
221 #endif
222 typedef UINT8 tBTA_DM_INQ_MODE;
223 
224 /* Inquiry Filter Type */
225 #define BTA_DM_INQ_CLR          BTM_CLR_INQUIRY_FILTER          /* Clear inquiry filter. */
226 #define BTA_DM_INQ_DEV_CLASS    BTM_FILTER_COND_DEVICE_CLASS    /* Filter on device class. */
227 #define BTA_DM_INQ_BD_ADDR      BTM_FILTER_COND_BD_ADDR         /* Filter on a specific  BD address. */
228 
229 typedef UINT8 tBTA_DM_INQ_FILT;
230 
231 /* Authorize Response */
232 #define BTA_DM_AUTH_PERM        0      /* Authorized for future connections to the service */
233 #define BTA_DM_AUTH_TEMP        1      /* Authorized for current connection only */
234 #define BTA_DM_NOT_AUTH         2      /* Not authorized for the service */
235 
236 typedef UINT8 tBTA_AUTH_RESP;
237 
238 /* M/S preferred roles */
239 #define BTA_ANY_ROLE          0x00
240 #define BTA_MASTER_ROLE_PREF  0x01
241 #define BTA_MASTER_ROLE_ONLY  0x02
242 
243 typedef UINT8 tBTA_PREF_ROLES;
244 
245 enum
246 {
247 
248     BTA_DM_NO_SCATTERNET,        /* Device doesn't support scatternet, it might
249                                     support "role switch during connection" for
250                                     an incoming connection, when it already has
251                                     another connection in master role */
252     BTA_DM_PARTIAL_SCATTERNET,   /* Device supports partial scatternet. It can have
253                                     simulateous connection in Master and Slave roles
254                                     for short period of time */
255     BTA_DM_FULL_SCATTERNET       /* Device can have simultaneous connection in master
256                                     and slave roles */
257 
258 };
259 
260 
261 /* Inquiry filter device class condition */
262 typedef struct
263 {
264     DEV_CLASS       dev_class;        /* device class of interest */
265     DEV_CLASS       dev_class_mask;   /* mask to determine the bits of device class of interest */
266 } tBTA_DM_COD_COND;
267 
268 
269 /* Inquiry Filter Condition */
270 typedef union
271 {
272     BD_ADDR              bd_addr;            /* BD address of  device to filter. */
273     tBTA_DM_COD_COND     dev_class_cond;     /* Device class filter condition */
274 } tBTA_DM_INQ_COND;
275 
276 /* Inquiry Parameters */
277 typedef struct
278 {
279     tBTA_DM_INQ_MODE    mode;           /* Inquiry mode, limited or general. */
280     UINT8               duration;       /* Inquiry duration in 1.28 sec units. */
281     UINT8               max_resps;      /* Maximum inquiry responses.  Set to zero for unlimited responses. */
282     BOOLEAN             report_dup;     /* report duplicated inquiry response with higher RSSI value */
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 {
289     UINT8   bta_dm_eir_min_name_len;        /* minimum length of local name when it is shortened */
290 #if (BTA_EIR_CANNED_UUID_LIST == TRUE)
291     UINT8   bta_dm_eir_uuid16_len;          /* length of 16-bit UUIDs */
292     UINT8  *bta_dm_eir_uuid16;              /* 16-bit UUIDs */
293 #else
294     UINT32  uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
295 #endif
296     INT8   *bta_dm_eir_inq_tx_power;        /* Inquiry TX power         */
297     UINT8   bta_dm_eir_flag_len;            /* length of flags in bytes */
298     UINT8  *bta_dm_eir_flags;               /* flags for EIR */
299     UINT8   bta_dm_eir_manufac_spec_len;    /* length of manufacturer specific in bytes */
300     UINT8  *bta_dm_eir_manufac_spec;        /* manufacturer specific */
301     UINT8   bta_dm_eir_additional_len;      /* length of additional data in bytes */
302     UINT8  *bta_dm_eir_additional;          /* additional data */
303 } tBTA_DM_EIR_CONF;
304 
305 #if BLE_INCLUDED == TRUE
306 /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
307 #define BTA_BLE_LIMIT_DISC_FLAG     BTM_BLE_LIMIT_DISC_FLAG
308 #define BTA_BLE_GEN_DISC_FLAG       BTM_BLE_GEN_DISC_FLAG
309 #define BTA_BLE_BREDR_NOT_SPT       BTM_BLE_BREDR_NOT_SPT
310 #define BTA_BLE_NON_LIMIT_DISC_FLAG BTM_BLE_NON_LIMIT_DISC_FLAG
311 #define BTA_BLE_ADV_FLAG_MASK       BTM_BLE_ADV_FLAG_MASK
312 #define BTA_BLE_LIMIT_DISC_MASK     BTM_BLE_LIMIT_DISC_MASK
313 
314 /* ADV data bit mask */
315 #define BTA_BLE_AD_BIT_DEV_NAME        BTM_BLE_AD_BIT_DEV_NAME
316 #define BTA_BLE_AD_BIT_FLAGS           BTM_BLE_AD_BIT_FLAGS
317 #define BTA_BLE_AD_BIT_MANU            BTM_BLE_AD_BIT_MANU
318 #define BTA_BLE_AD_BIT_TX_PWR          BTM_BLE_AD_BIT_TX_PWR
319 #define BTA_BLE_AD_BIT_INT_RANGE       BTM_BLE_AD_BIT_INT_RANGE
320 #define BTA_BLE_AD_BIT_SERVICE         BTM_BLE_AD_BIT_SERVICE
321 #define BTA_BLE_AD_BIT_APPEARANCE      BTM_BLE_AD_BIT_APPEARANCE
322 #define BTA_BLE_AD_BIT_PROPRIETARY     BTM_BLE_AD_BIT_PROPRIETARY
323 #define BTA_DM_BLE_AD_BIT_SERVICE_SOL     BTM_BLE_AD_BIT_SERVICE_SOL
324 #define BTA_DM_BLE_AD_BIT_SERVICE_DATA    BTM_BLE_AD_BIT_SERVICE_DATA
325 #define BTA_DM_BLE_AD_BIT_SIGN_DATA       BTM_BLE_AD_BIT_SIGN_DATA
326 #define BTA_DM_BLE_AD_BIT_SERVICE_128SOL  BTM_BLE_AD_BIT_SERVICE_128SOL
327 #define BTA_DM_BLE_AD_BIT_PUBLIC_ADDR     BTM_BLE_AD_BIT_PUBLIC_ADDR
328 #define BTA_DM_BLE_AD_BIT_RANDOM_ADDR     BTM_BLE_AD_BIT_RANDOM_ADDR
329 
330 typedef  UINT16  tBTA_BLE_AD_MASK;
331 
332 /* slave preferred connection interval range */
333 typedef struct
334 {
335     UINT16  low;
336     UINT16  hi;
337 
338 }tBTA_BLE_INT_RANGE;
339 
340 /* Service tag supported in the device */
341 typedef struct
342 {
343     UINT8       num_service;
344     BOOLEAN     list_cmpl;
345     UINT16      *p_uuid;
346 }tBTA_BLE_SERVICE;
347 
348 
349 typedef struct
350 {
351     UINT8       len;
352     UINT8      *p_val;
353 }tBTA_BLE_MANU;
354 
355 typedef struct
356 {
357     UINT8       adv_type;
358     UINT8       len;
359     UINT8       *p_val;     /* number of len byte */
360 }tBTA_BLE_PROP_ELEM;
361 
362 /* vendor proprietary adv type */
363 typedef struct
364 {
365     UINT8                   num_elem;
366     tBTA_BLE_PROP_ELEM      *p_elem;
367 }tBTA_BLE_PROPRIETARY;
368 
369 typedef struct
370 {
371     tBTA_BLE_MANU			manu;			/* manufactuer data */
372     tBTA_BLE_INT_RANGE		int_range;      /* slave prefered conn interval range */
373     tBTA_BLE_SERVICE		services;       /* services */
374 	UINT16					appearance;		/* appearance data */
375     UINT8					flag;
376     tBTA_BLE_PROPRIETARY    *p_proprietary;
377 
378 }tBTA_BLE_ADV_DATA;
379 
380 /* These are the fields returned in each device adv packet.  It
381 ** is returned in the results callback if registered.
382 */
383 typedef struct
384 {
385     UINT8               conn_mode;
386     tBTA_BLE_AD_MASK    ad_mask;        /* mask of the valid adv data field */
387     UINT8               flag;
388     UINT8               tx_power_level;
389     UINT8               remote_name_len;
390     UINT8               *p_remote_name;
391     tBTA_BLE_SERVICE    service;
392 } tBTA_BLE_INQ_DATA;
393 #endif
394 
395 /* BLE customer specific feature function type definitions */
396 /* data type used on customer specific feature for RSSI monitoring */
397 #define BTA_BLE_RSSI_ALERT_HI        0
398 #define BTA_BLE_RSSI_ALERT_RANGE     1
399 #define BTA_BLE_RSSI_ALERT_LO        2
400 typedef UINT8 tBTA_DM_BLE_RSSI_ALERT_TYPE;
401 
402 #define BTA_BLE_RSSI_ALERT_NONE		    BTM_BLE_RSSI_ALERT_NONE		/*	(0) */
403 #define BTA_BLE_RSSI_ALERT_HI_BIT		BTM_BLE_RSSI_ALERT_HI_BIT		/*	(1) */
404 #define BTA_BLE_RSSI_ALERT_RANGE_BIT	BTM_BLE_RSSI_ALERT_RANGE_BIT	/*	(1 << 1) */
405 #define BTA_BLE_RSSI_ALERT_LO_BIT		BTM_BLE_RSSI_ALERT_LO_BIT		/*	(1 << 2) */
406 typedef UINT8     tBTA_DM_BLE_RSSI_ALERT_MASK;
407 
408 
409 typedef void (tBTA_DM_BLE_RSSI_CBACK) (BD_ADDR bd_addr, tBTA_DM_BLE_RSSI_ALERT_TYPE alert_type, INT8 rssi);
410 
411 /* max number of filter spot for different filter type */
412 #define BTA_DM_BLE_MAX_UUID_FILTER     BTM_BLE_MAX_UUID_FILTER    /* 8 */
413 #define BTA_DM_BLE_MAX_ADDR_FILTER     BTM_BLE_MAX_ADDR_FILTER    /* 8 */
414 #define BTA_DM_BLE_PF_STR_COND_MAX     BTM_BLE_PF_STR_COND_MAX    /* 4    apply to manu data , or local name */
415 #define BTA_DM_BLE_PF_STR_LEN_MAX      BTM_BLE_PF_STR_LEN_MAX  /* match for first 20 bytes */
416 
417 #define BTA_DM_BLE_PF_LOGIC_OR              0
418 #define BTA_DM_BLE_PF_LOGIC_AND             1
419 typedef UINT8 tBTA_DM_BLE_PF_LOGIC_TYPE;
420 
421 enum
422 {
423     BTA_DM_BLE_SCAN_COND_ADD,
424     BTA_DM_BLE_SCAN_COND_DELETE,
425     BTA_DM_BLE_SCAN_COND_CLEAR = 2
426 };
427 typedef UINT8 tBTA_DM_BLE_SCAN_COND_OP;
428 
429 /* filter selection bit index  */
430 #define BTA_DM_BLE_PF_ADDR_FILTER          BTM_BLE_PF_ADDR_FILTER
431 #define BTA_DM_BLE_PF_SRVC_UUID            BTM_BLE_PF_SRVC_UUID
432 #define BTA_DM_BLE_PF_SRVC_SOL_UUID        BTM_BLE_PF_SRVC_SOL_UUID
433 #define BTA_DM_BLE_PF_LOCAL_NAME           BTM_BLE_PF_LOCAL_NAME
434 #define BTA_DM_BLE_PF_MANU_DATA            BTM_BLE_PF_MANU_DATA
435 #define BTA_DM_BLE_PF_SRVC_DATA            BTM_BLE_PF_SRVC_DATA
436 #define BTA_DM_BLE_PF_TYPE_MAX             BTM_BLE_PF_TYPE_MAX
437 #define BTA_DM_BLE_PF_TYPE_ALL             BTM_BLE_PF_TYPE_ALL
438 typedef UINT8   tBTA_DM_BLE_PF_COND_TYPE;
439 
440 typedef struct
441 {
442     tBLE_BD_ADDR                *p_target_addr;     /* target address, if NULL, generic UUID filter */
443     tBT_UUID                    uuid;           /* UUID condition */
444     tBTA_DM_BLE_PF_LOGIC_TYPE   cond_logic;    /* AND/OR */
445 }tBTA_DM_BLE_PF_UUID_COND;
446 
447 typedef struct
448 {
449     UINT8                   data_len;       /* <= 20 bytes */
450     UINT8                   *p_data;
451 }tBTA_DM_BLE_PF_LOCAL_NAME_COND;
452 
453 typedef struct
454 {
455     UINT16                  company_id;     /* company ID */
456     UINT8                   data_len;       /* <= 20 bytes */
457     UINT8                   *p_pattern;
458 }tBTA_DM_BLE_PF_MANU_COND;
459 
460 typedef union
461 {
462     tBLE_BD_ADDR                            target_addr;
463     tBTA_DM_BLE_PF_LOCAL_NAME_COND             local_name; /* lcoal name filtering */
464     tBTA_DM_BLE_PF_MANU_COND                   manu_data;  /* manufactuer data filtering */
465     tBTA_DM_BLE_PF_UUID_COND                   srvc_uuid;  /* service UUID filtering */
466     tBTA_DM_BLE_PF_UUID_COND                   solicitate_uuid;   /* solicitated service UUID filtering */
467 }tBTA_DM_BLE_PF_COND_PARAM;
468 
469 
470 typedef INT8 tBTA_DM_RSSI_VALUE;
471 typedef UINT8 tBTA_DM_LINK_QUALITY_VALUE;
472 
473 
474 /* signal strength mask */
475 #define BTA_SIG_STRENGTH_RSSI_MASK          1
476 #define BTA_SIG_STRENGTH_LINK_QUALITY_MASK  2
477 
478 typedef UINT8 tBTA_SIG_STRENGTH_MASK;
479 
480 
481 /* Security Callback Events */
482 #define BTA_DM_ENABLE_EVT               0       /* Enable Event */
483 #define BTA_DM_DISABLE_EVT              1       /* Disable Event */
484 #define BTA_DM_PIN_REQ_EVT              2       /* PIN request. */
485 #define BTA_DM_AUTH_CMPL_EVT            3       /* Authentication complete indication. */
486 #define BTA_DM_AUTHORIZE_EVT            4       /* Authorization request. */
487 #define BTA_DM_LINK_UP_EVT              5       /* Connection UP event */
488 #define BTA_DM_LINK_DOWN_EVT            6       /* Connection DOWN event */
489 #define BTA_DM_SIG_STRENGTH_EVT         7       /* Signal strength for bluetooth connection */
490 #define BTA_DM_BUSY_LEVEL_EVT           8       /* System busy level */
491 #define BTA_DM_BOND_CANCEL_CMPL_EVT     9       /* Bond cancel complete indication */
492 #define BTA_DM_SP_CFM_REQ_EVT           10      /* Simple Pairing User Confirmation request. */
493 #define BTA_DM_SP_KEY_NOTIF_EVT         11      /* Simple Pairing Passkey Notification */
494 #define BTA_DM_SP_RMT_OOB_EVT           12      /* Simple Pairing Remote OOB Data request. */
495 #define BTA_DM_SP_KEYPRESS_EVT          13      /* Key press notification event. */
496 #define BTA_DM_ROLE_CHG_EVT             14      /* Role Change event. */
497 #define BTA_DM_BLE_KEY_EVT              15      /* BLE SMP key event for peer device keys */
498 #define BTA_DM_BLE_SEC_REQ_EVT          16      /* BLE SMP security request */
499 #define BTA_DM_BLE_PASSKEY_NOTIF_EVT    17      /* SMP passkey notification event */
500 #define BTA_DM_BLE_PASSKEY_REQ_EVT      18      /* SMP passkey request event */
501 #define BTA_DM_BLE_OOB_REQ_EVT          19      /* SMP OOB request event */
502 #define BTA_DM_BLE_LOCAL_IR_EVT         20      /* BLE local IR event */
503 #define BTA_DM_BLE_LOCAL_ER_EVT         21      /* BLE local ER event */
504 // btla-specific ++
505 #define BTA_DM_BLE_AUTH_CMPL_EVT        22      /* BLE Auth complete */
506 // btla-specific --
507 #define BTA_DM_DEV_UNPAIRED_EVT         23
508 #define BTA_DM_HW_ERROR_EVT             24      /* BT Chip H/W error */
509 typedef UINT8 tBTA_DM_SEC_EVT;
510 
511 /* Structure associated with BTA_DM_ENABLE_EVT */
512 typedef struct
513 {
514     BD_ADDR         bd_addr;            /* BD address of local device. */
515     tBTA_STATUS    status;
516 } tBTA_DM_ENABLE;
517 
518 /* Structure associated with BTA_DM_PIN_REQ_EVT */
519 typedef struct
520 {
521     BD_ADDR         bd_addr;            /* BD address peer device. */
522     DEV_CLASS       dev_class;          /* Class of Device */
523     BD_NAME         bd_name;            /* Name of peer device. */
524 } tBTA_DM_PIN_REQ;
525 
526 /* BLE related definition */
527 
528 #define BTA_DM_AUTH_FAIL_BASE                   (HCI_ERR_MAX_ERR + 10)
529 #define BTA_DM_AUTH_CONVERT_SMP_CODE(x)        (BTA_DM_AUTH_FAIL_BASE + (x))
530 #define BTA_DM_AUTH_SMP_PASSKEY_FAIL             BTA_DM_AUTH_CONVERT_SMP_CODE (SMP_PASSKEY_ENTRY_FAIL)
531 #define BTA_DM_AUTH_SMP_OOB_FAIL                (BTA_DM_AUTH_FAIL_BASE + SMP_OOB_FAIL)
532 #define BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL          (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_AUTH_FAIL)
533 #define BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL      (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_VALUE_ERR)
534 #define BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT        (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_NOT_SUPPORT)
535 #define BTA_DM_AUTH_SMP_ENC_KEY_SIZE            (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_KEY_SIZE)
536 #define BTA_DM_AUTH_SMP_INVALID_CMD             (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_CMD)
537 #define BTA_DM_AUTH_SMP_UNKNOWN_ERR             (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_FAIL_UNKNOWN)
538 #define BTA_DM_AUTH_SMP_REPEATED_ATTEMPT        (BTA_DM_AUTH_FAIL_BASE + SMP_REPEATED_ATTEMPTS)
539 #define BTA_DM_AUTH_SMP_INTERNAL_ERR            (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_INTERNAL_ERR)
540 #define BTA_DM_AUTH_SMP_UNKNOWN_IO              (BTA_DM_AUTH_FAIL_BASE + SMP_UNKNOWN_IO_CAP)
541 #define BTA_DM_AUTH_SMP_INIT_FAIL               (BTA_DM_AUTH_FAIL_BASE + SMP_INIT_FAIL)
542 #define BTA_DM_AUTH_SMP_CONFIRM_FAIL            (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_FAIL)
543 #define BTA_DM_AUTH_SMP_BUSY                    (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY)
544 #define BTA_DM_AUTH_SMP_ENC_FAIL                (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL)
545 #define BTA_DM_AUTH_SMP_RSP_TIMEOUT             (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT)
546 
547 /* connection parameter boundary value and dummy value */
548 #define BTA_DM_BLE_SCAN_INT_MIN          BTM_BLE_SCAN_INT_MIN
549 #define BTA_DM_BLE_SCAN_INT_MAX          BTM_BLE_SCAN_INT_MAX
550 #define BTA_DM_BLE_SCAN_WIN_MIN          BTM_BLE_SCAN_WIN_MIN
551 #define BTA_DM_BLE_SCAN_WIN_MAX          BTM_BLE_SCAN_WIN_MAX
552 #define BTA_DM_BLE_CONN_INT_MIN          BTM_BLE_CONN_INT_MIN
553 #define BTA_DM_BLE_CONN_INT_MAX          BTM_BLE_CONN_INT_MAX
554 #define BTA_DM_BLE_CONN_LATENCY_MAX      BTM_BLE_CONN_LATENCY_MAX
555 #define BTA_DM_BLE_CONN_SUP_TOUT_MIN     BTM_BLE_CONN_SUP_TOUT_MIN
556 #define BTA_DM_BLE_CONN_SUP_TOUT_MAX     BTM_BLE_CONN_SUP_TOUT_MAX
557 #define BTA_DM_BLE_CONN_PARAM_UNDEF      BTM_BLE_CONN_PARAM_UNDEF  /* use this value when a specific value not to be overwritten */
558 
559 
560 #define BTA_LE_KEY_PENC      BTM_LE_KEY_PENC  /* encryption information of peer device */
561 #define BTA_LE_KEY_PID       BTM_LE_KEY_PID   /* identity key of the peer device */
562 #define BTA_LE_KEY_PCSRK     BTM_LE_KEY_PCSRK   /* peer SRK */
563 #define BTA_LE_KEY_LENC      BTM_LE_KEY_LENC        /* master role security information:div */
564 #define BTA_LE_KEY_LID       BTM_LE_KEY_LID         /* master device ID key */
565 #define BTA_LE_KEY_LCSRK     BTM_LE_KEY_LCSRK        /* local CSRK has been deliver to peer */
566 typedef UINT8 tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
567 
568 
569 typedef tBTM_LE_PENC_KEYS  tBTA_LE_PENC_KEYS ;
570 typedef tBTM_LE_PCSRK_KEYS tBTA_LE_PCSRK_KEYS;
571 typedef tBTM_LE_LENC_KEYS  tBTA_LE_LENC_KEYS  ;
572 typedef tBTM_LE_LCSRK_KEYS tBTA_LE_LCSRK_KEYS ;
573 typedef tBTM_LE_PID_KEYS   tBTA_LE_PID_KEYS ;
574 
575 typedef union
576 {
577     tBTA_LE_PENC_KEYS   penc_key;       /* received peer encryption key */
578     tBTA_LE_PCSRK_KEYS  psrk_key;       /* received peer device SRK */
579     tBTA_LE_PID_KEYS    pid_key;        /* peer device ID key */
580     tBTA_LE_LENC_KEYS   lenc_key;       /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
581     tBTA_LE_LCSRK_KEYS  lcsrk_key;      /* local device CSRK = d1(ER,DIV,1)*/
582 }tBTA_LE_KEY_VALUE;
583 
584 #define BTA_BLE_LOCAL_KEY_TYPE_ID         1
585 #define BTA_BLE_LOCAL_KEY_TYPE_ER         2
586 typedef UINT8 tBTA_DM_BLE_LOCAL_KEY_MASK;
587 
588 typedef struct
589 {
590     BT_OCTET16       ir;
591     BT_OCTET16       irk;
592     BT_OCTET16       dhk;
593 }tBTA_BLE_LOCAL_ID_KEYS;
594 
595 #define BTA_DM_SEC_GRANTED              BTA_SUCCESS
596 #define BTA_DM_SEC_PAIR_NOT_SPT         BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
597 #define BTA_DM_SEC_REP_ATTEMPTS         BTA_DM_AUTH_SMP_REPEATED_ATTEMPT
598 typedef UINT8 tBTA_DM_BLE_SEC_GRANT;
599 
600 
601 #define BTA_DM_BLE_ONN_NONE             BTM_BLE_CONN_NONE
602 #define BTA_DM_BLE_CONN_AUTO            BTM_BLE_CONN_AUTO
603 #define BTA_DM_BLE_CONN_SELECTIVE       BTM_BLE_CONN_SELECTIVE
604 typedef UINT8 tBTA_DM_BLE_CONN_TYPE;
605 
606 typedef BOOLEAN (tBTA_DM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
607 
608 /* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
609 typedef struct
610 {
611     BD_ADDR         bd_addr;        /* peer address */
612     BD_NAME         bd_name;        /* peer device name */
613 } tBTA_DM_BLE_SEC_REQ;
614 
615 typedef struct
616 {
617     BD_ADDR                 bd_addr;        /* peer address */
618     tBTM_LE_KEY_TYPE        key_type;
619     tBTM_LE_KEY_VALUE       key_value;
620 }tBTA_DM_BLE_KEY;
621 
622 /* Structure associated with BTA_DM_AUTH_CMPL_EVT */
623 typedef struct
624 {
625     BD_ADDR         bd_addr;            /* BD address peer device. */
626     BD_NAME         bd_name;            /* Name of peer device. */
627     BOOLEAN         key_present;        /* Valid link key value in key element */
628     LINK_KEY        key;                /* Link key associated with peer device. */
629     UINT8           key_type;           /* The type of Link Key */
630     BOOLEAN         success;            /* TRUE of authentication succeeded, FALSE if failed. */
631 #if BLE_INCLUDED == TRUE
632     BOOLEAN         privacy_enabled;    /* used for BLE device only */
633 #endif
634     UINT8           fail_reason;        /* The HCI reason/error code for when success=FALSE */
635 
636 } tBTA_DM_AUTH_CMPL;
637 
638 
639 /* Structure associated with BTA_DM_AUTHORIZE_EVT */
640 typedef struct
641 {
642     BD_ADDR         bd_addr;            /* BD address peer device. */
643     BD_NAME         bd_name;            /* Name of peer device. */
644     tBTA_SERVICE_ID service;            /* Service ID to authorize. */
645 // btla-specific ++
646     DEV_CLASS      dev_class;
647 // btla-specific --
648 } tBTA_DM_AUTHORIZE;
649 
650 /* Structure associated with BTA_DM_LINK_UP_EVT */
651 typedef struct
652 {
653     BD_ADDR         bd_addr;            /* BD address peer device. */
654 } tBTA_DM_LINK_UP;
655 
656 /* Structure associated with BTA_DM_LINK_DOWN_EVT */
657 typedef struct
658 {
659     BD_ADDR         bd_addr;            /* BD address peer device. */
660     UINT8           status;             /* connection open/closed */
661     BOOLEAN         is_removed;         /* TRUE if device is removed when link is down */
662 } tBTA_DM_LINK_DOWN;
663 
664 /* Structure associated with BTA_DM_ROLE_CHG_EVT */
665 typedef struct
666 {
667     BD_ADDR         bd_addr;            /* BD address peer device. */
668     UINT8           new_role;           /* the new connection role */
669 } tBTA_DM_ROLE_CHG;
670 
671 /* Structure associated with BTA_DM_SIG_STRENGTH_EVT */
672 typedef struct
673 {
674     BD_ADDR         bd_addr;            /* BD address peer device. */
675     tBTA_SIG_STRENGTH_MASK mask;        /* mask for the values that are valid */
676     tBTA_DM_RSSI_VALUE  rssi_value;
677     tBTA_DM_LINK_QUALITY_VALUE link_quality_value;
678 
679 } tBTA_DM_SIG_STRENGTH;
680 
681 /* Structure associated with BTA_DM_BUSY_LEVEL_EVT */
682 typedef struct
683 {
684     UINT8           level;     /* when paging or inquiring, level is 10.
685                                     Otherwise, the number of ACL links */
686     UINT8           level_flags; /* indicates individual flags */
687 } tBTA_DM_BUSY_LEVEL;
688 
689 #define BTA_IO_CAP_OUT      BTM_IO_CAP_OUT      /* DisplayOnly */
690 #define BTA_IO_CAP_IO       BTM_IO_CAP_IO       /* DisplayYesNo */
691 #define BTA_IO_CAP_IN       BTM_IO_CAP_IN       /* KeyboardOnly */
692 #define BTA_IO_CAP_NONE     BTM_IO_CAP_NONE     /* NoInputNoOutput */
693 typedef tBTM_IO_CAP     tBTA_IO_CAP;
694 
695 #define BTA_AUTH_SP_NO    BTM_AUTH_SP_NO      /* 0 MITM Protection Not Required - Single Profile/non-bonding
696                                                 Numeric comparison with automatic accept allowed */
697 #define BTA_AUTH_SP_YES   BTM_AUTH_SP_YES     /* 1 MITM Protection Required - Single Profile/non-bonding
698                                                 Use IO Capabilities to determine authentication procedure */
699 #define BTA_AUTH_AP_NO    BTM_AUTH_AP_NO      /* 2 MITM Protection Not Required - All Profiles/dedicated bonding
700                                                 Numeric comparison with automatic accept allowed */
701 #define BTA_AUTH_AP_YES   BTM_AUTH_AP_YES     /* 3 MITM Protection Required - All Profiles/dedicated bonding
702                                                 Use IO Capabilities to determine authentication procedure */
703 #define BTA_AUTH_SPGB_NO  BTM_AUTH_SPGB_NO    /* 4 MITM Protection Not Required - Single Profiles/general bonding
704                                                 Numeric comparison with automatic accept allowed */
705 #define BTA_AUTH_SPGB_YES BTM_AUTH_SPGB_YES   /* 5 MITM Protection Required - Single Profiles/general bonding
706                                                 Use IO Capabilities to determine authentication procedure */
707 typedef tBTM_AUTH_REQ   tBTA_AUTH_REQ;
708 
709 #define BTA_AUTH_DD_BOND    BTM_AUTH_DD_BOND  /* 2 this bit is set for dedicated bonding */
710 #define BTA_AUTH_GEN_BOND   BTM_AUTH_SPGB_NO  /* 4 this bit is set for general bonding */
711 #define BTA_AUTH_BONDS      BTM_AUTH_BONDS    /* 6 the general/dedicated bonding bits  */
712 
713 #define BTA_LE_AUTH_NO_BOND    BTM_LE_AUTH_REQ_NO_BOND  /* 0*/
714 #define BTA_LE_AUTH_BOND       BTM_LE_AUTH_REQ_BOND     /* 1 << 0 */
715 #define BTA_LE_AUTH_REQ_MITM   BTM_LE_AUTH_REQ_MITM    /* 1 << 2 */
716 typedef tBTM_LE_AUTH_REQ       tBTA_LE_AUTH_REQ;       /* combination of the above bit pattern */
717 
718 #define BTA_OOB_NONE        BTM_OOB_NONE
719 #define BTA_OOB_PRESENT     BTM_OOB_PRESENT
720 #if BTM_OOB_INCLUDED == TRUE
721 #define BTA_OOB_UNKNOWN     BTM_OOB_UNKNOWN
722 #endif
723 typedef tBTM_OOB_DATA   tBTA_OOB_DATA;
724 
725 /* Structure associated with BTA_DM_SP_CFM_REQ_EVT */
726 typedef struct
727 {
728     /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */
729     BD_ADDR         bd_addr;        /* peer address */
730     DEV_CLASS       dev_class;      /* peer CoD */
731     BD_NAME         bd_name;        /* peer device name */
732     UINT32          num_val;        /* the numeric value for comparison. If just_works, do not show this number to UI */
733     BOOLEAN         just_works;     /* TRUE, if "Just Works" association model */
734     tBTA_AUTH_REQ   loc_auth_req;   /* Authentication required for local device */
735     tBTA_AUTH_REQ   rmt_auth_req;   /* Authentication required for peer device */
736     tBTA_IO_CAP     loc_io_caps;    /* IO Capabilities of local device */
737     tBTA_AUTH_REQ   rmt_io_caps;    /* IO Capabilities of remote device */
738 } tBTA_DM_SP_CFM_REQ;
739 
740 enum
741 {
742     BTA_SP_KEY_STARTED,         /* passkey entry started */
743     BTA_SP_KEY_ENTERED,         /* passkey digit entered */
744     BTA_SP_KEY_ERASED,          /* passkey digit erased */
745     BTA_SP_KEY_CLEARED,         /* passkey cleared */
746     BTA_SP_KEY_COMPLT           /* passkey entry completed */
747 };
748 typedef UINT8   tBTA_SP_KEY_TYPE;
749 
750 /* Structure associated with BTA_DM_SP_KEYPRESS_EVT */
751 typedef struct
752 {
753     BD_ADDR             bd_addr;        /* peer address */
754     tBTA_SP_KEY_TYPE   notif_type;
755 }tBTA_DM_SP_KEY_PRESS;
756 
757 /* Structure associated with BTA_DM_SP_KEY_NOTIF_EVT */
758 typedef struct
759 {
760     /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */
761     BD_ADDR         bd_addr;        /* peer address */
762     DEV_CLASS       dev_class;      /* peer CoD */
763     BD_NAME         bd_name;        /* peer device name */
764     UINT32          passkey;        /* the numeric value for comparison. If just_works, do not show this number to UI */
765 } tBTA_DM_SP_KEY_NOTIF;
766 
767 /* Structure associated with BTA_DM_SP_RMT_OOB_EVT */
768 typedef struct
769 {
770     /* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */
771     BD_ADDR         bd_addr;        /* peer address */
772     DEV_CLASS       dev_class;      /* peer CoD */
773     BD_NAME         bd_name;        /* peer device name */
774 } tBTA_DM_SP_RMT_OOB;
775 
776 /* Structure associated with BTA_DM_BOND_CANCEL_CMPL_EVT */
777 typedef struct
778 {
779     tBTA_STATUS     result;    /* TRUE of bond cancel succeeded, FALSE if failed. */
780 } tBTA_DM_BOND_CANCEL_CMPL;
781 
782 /* Union of all security callback structures */
783 typedef union
784 {
785     tBTA_DM_ENABLE      enable;         /* BTA enabled */
786     tBTA_DM_PIN_REQ     pin_req;        /* PIN request. */
787     tBTA_DM_AUTH_CMPL   auth_cmpl;      /* Authentication complete indication. */
788     tBTA_DM_AUTHORIZE   authorize;      /* Authorization request. */
789     tBTA_DM_LINK_UP     link_up;       /* ACL connection down event */
790     tBTA_DM_LINK_DOWN   link_down;       /* ACL connection down event */
791     tBTA_DM_SIG_STRENGTH sig_strength;  /* rssi and link quality value */
792     tBTA_DM_BUSY_LEVEL  busy_level;     /* System busy level */
793     tBTA_DM_SP_CFM_REQ  cfm_req;        /* user confirm request */
794     tBTA_DM_SP_KEY_NOTIF key_notif;     /* passkey notification */
795     tBTA_DM_SP_RMT_OOB  rmt_oob;        /* remote oob */
796     tBTA_DM_BOND_CANCEL_CMPL bond_cancel_cmpl; /* Bond Cancel Complete indication */
797     tBTA_DM_SP_KEY_PRESS   key_press;   /* key press notification event */
798     tBTA_DM_ROLE_CHG     role_chg;       /* role change event */
799     tBTA_DM_BLE_SEC_REQ  ble_req;        /* BLE SMP related request */
800     tBTA_DM_BLE_KEY      ble_key;        /* BLE SMP keys used when pairing */
801     tBTA_BLE_LOCAL_ID_KEYS  ble_id_keys;  /* IR event */
802     BT_OCTET16              ble_er;       /* ER event data */
803 } tBTA_DM_SEC;
804 
805 /* Security callback */
806 typedef void (tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data);
807 
808 /* Vendor Specific Command Callback */
809 typedef tBTM_VSC_CMPL_CB        tBTA_VENDOR_CMPL_CBACK;
810 
811 /* Search callback events */
812 #define BTA_DM_INQ_RES_EVT              0       /* Inquiry result for a peer device. */
813 #define BTA_DM_INQ_CMPL_EVT             1       /* Inquiry complete. */
814 #define BTA_DM_DISC_RES_EVT             2       /* Discovery result for a peer device. */
815 #define BTA_DM_DISC_BLE_RES_EVT         3       /* Discovery result for BLE GATT based servoce on a peer device. */
816 #define BTA_DM_DISC_CMPL_EVT            4       /* Discovery complete. */
817 #define BTA_DM_DI_DISC_CMPL_EVT         5       /* Discovery complete. */
818 #define BTA_DM_SEARCH_CANCEL_CMPL_EVT   6       /* Search cancelled */
819 
820 typedef UINT8 tBTA_DM_SEARCH_EVT;
821 
822 #define BTA_DM_INQ_RES_IGNORE_RSSI      BTM_INQ_RES_IGNORE_RSSI /* 0x7f RSSI value not supplied (ignore it) */
823 
824 /* Structure associated with BTA_DM_INQ_RES_EVT */
825 typedef struct
826 {
827     BD_ADDR         bd_addr;                /* BD address peer device. */
828     DEV_CLASS       dev_class;              /* Device class of peer device. */
829     BOOLEAN         remt_name_not_required; /* Application sets this flag if it already knows the name of the device */
830                                             /* If the device name is known to application BTA skips the remote name request */
831     BOOLEAN         is_limited;             /* TRUE, if the limited inquiry bit is set in the CoD */
832     INT8            rssi;                   /* The rssi value */
833     UINT8           *p_eir;                 /* received EIR */
834 #if (BLE_INCLUDED == TRUE)
835     UINT8               inq_result_type;
836     UINT8               ble_addr_type;
837     tBTM_BLE_EVT_TYPE   ble_evt_type;
838     tBT_DEVICE_TYPE     device_type;
839 #endif
840 
841 } tBTA_DM_INQ_RES;
842 
843 /* Structure associated with BTA_DM_INQ_CMPL_EVT */
844 typedef struct
845 {
846     UINT8           num_resps;          /* Number of inquiry responses. */
847 } tBTA_DM_INQ_CMPL;
848 
849 /* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
850 typedef struct
851 {
852     BD_ADDR             bd_addr;        /* BD address peer device. */
853     UINT8               num_record;     /* Number of DI record */
854     tBTA_STATUS         result;
855 } tBTA_DM_DI_DISC_CMPL;
856 
857 /* Structure associated with BTA_DM_DISC_RES_EVT */
858 typedef struct
859 {
860     BD_ADDR             bd_addr;        /* BD address peer device. */
861     BD_NAME             bd_name;        /* Name of peer device. */
862     tBTA_SERVICE_MASK   services;       /* Services found on peer device. */
863 // btla-specific ++
864     UINT8           *   p_raw_data;     /* Raw data for discovery DB */
865     UINT32              raw_data_size;  /* size of raw data */
866     tBT_DEVICE_TYPE     device_type;    /* device type in case it is BLE device */
867     UINT32              num_uuids;
868     UINT8               *p_uuid_list;
869 // btla-specific --
870     tBTA_STATUS         result;
871 } tBTA_DM_DISC_RES;
872 
873 /* Structure associated with tBTA_DM_DISC_BLE_RES */
874 typedef struct
875 {
876     BD_ADDR             bd_addr;        /* BD address peer device. */
877     BD_NAME             bd_name;        /* Name of peer device. */
878     tBT_UUID            service;        /* GATT based Services UUID found on peer device. */
879 } tBTA_DM_DISC_BLE_RES;
880 
881 
882 /* Union of all search callback structures */
883 typedef union
884 {
885     tBTA_DM_INQ_RES     inq_res;        /* Inquiry result for a peer device. */
886     tBTA_DM_INQ_CMPL    inq_cmpl;       /* Inquiry complete. */
887     tBTA_DM_DISC_RES    disc_res;       /* Discovery result for a peer device. */
888     tBTA_DM_DISC_BLE_RES    disc_ble_res;   /* discovery result for GATT based service */
889     tBTA_DM_DI_DISC_CMPL    di_disc;        /* DI discovery result for a peer device */
890 
891 } tBTA_DM_SEARCH;
892 
893 /* Search callback */
894 typedef void (tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data);
895 
896 /* Execute call back */
897 typedef void (tBTA_DM_EXEC_CBACK) (void * p_param);
898 
899 /* Encryption callback*/
900 typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_STATUS result);
901 
902 #if BLE_INCLUDED == TRUE
903 #define BTA_DM_BLE_SEC_NONE         BTM_BLE_SEC_NONE
904 #define BTA_DM_BLE_SEC_ENCRYPT      BTM_BLE_SEC_ENCRYPT
905 #define BTA_DM_BLE_SEC_NO_MITM      BTM_BLE_SEC_ENCRYPT_NO_MITM
906 #define BTA_DM_BLE_SEC_MITM         BTM_BLE_SEC_ENCRYPT_MITM
907 typedef tBTM_BLE_SEC_ACT            tBTA_DM_BLE_SEC_ACT;
908 #else
909 typedef UINT8                       tBTA_DM_BLE_SEC_ACT;
910 #endif
911 
912 /* Maximum service name length */
913 #define BTA_SERVICE_NAME_LEN    35
914 #define BTA_SERVICE_DESP_LEN    BTA_SERVICE_NAME_LEN
915 #define BTA_PROVIDER_NAME_LEN   BTA_SERVICE_NAME_LEN
916 
917 
918 /* link policy masks  */
919 #define BTA_DM_LP_SWITCH        HCI_ENABLE_MASTER_SLAVE_SWITCH
920 #define BTA_DM_LP_HOLD          HCI_ENABLE_HOLD_MODE
921 #define BTA_DM_LP_SNIFF         HCI_ENABLE_SNIFF_MODE
922 #define BTA_DM_LP_PARK          HCI_ENABLE_PARK_MODE
923 typedef UINT16 tBTA_DM_LP_MASK;
924 
925 /* power mode actions  */
926 #define BTA_DM_PM_NO_ACTION    0x00       /* no change to the current pm setting */
927 #define BTA_DM_PM_PARK         0x10       /* prefers park mode */
928 #define BTA_DM_PM_SNIFF        0x20       /* prefers sniff mode */
929 #define BTA_DM_PM_SNIFF1       0x21       /* prefers sniff1 mode */
930 #define BTA_DM_PM_SNIFF2       0x22       /* prefers sniff2 mode */
931 #define BTA_DM_PM_SNIFF3       0x23       /* prefers sniff3 mode */
932 #define BTA_DM_PM_SNIFF4       0x24       /* prefers sniff4 mode */
933 #define BTA_DM_PM_SNIFF5       0x25       /* prefers sniff5 mode */
934 #define BTA_DM_PM_SNIFF6       0x26       /* prefers sniff6 mode */
935 #define BTA_DM_PM_SNIFF7       0x27       /* prefers sniff7 mode */
936 #define BTA_DM_PM_SNIFF_USER0  0x28       /* prefers user-defined sniff0 mode (testtool only) */
937 #define BTA_DM_PM_SNIFF_USER1  0x29       /* prefers user-defined sniff1 mode (testtool only) */
938 #define BTA_DM_PM_ACTIVE       0x40       /* prefers active mode */
939 #define BTA_DM_PM_RETRY        0x80       /* retry power mode based on current settings */
940 #define BTA_DM_PM_NO_PREF      0x01       /* service has no prefernce on power mode setting. eg. connection to service got closed */
941 
942 typedef UINT8 tBTA_DM_PM_ACTTION;
943 
944 /* index to bta_dm_ssr_spec */
945 #define BTA_DM_PM_SSR0          0
946 #define BTA_DM_PM_SSR1          1       /* BTA_DM_PM_SSR1 will be dedicated for
947                                         HH SSR setting entry, no other profile can use it */
948 #define BTA_DM_PM_SSR2          2
949 #define BTA_DM_PM_SSR3          3
950 #define BTA_DM_PM_SSR4          4
951 #define BTA_DM_PM_SSR5          5
952 #define BTA_DM_PM_SSR6          6
953 
954 #define BTA_DM_PM_NUM_EVTS      9
955 
956 #ifndef BTA_DM_PM_PARK_IDX
957 #define BTA_DM_PM_PARK_IDX      5 /* the actual index to bta_dm_pm_md[] for PARK mode */
958 #endif
959 
960 #define BTA_DM_SW_BB_TO_MM      BTM_SW_BB_TO_MM
961 #define BTA_DM_SW_MM_TO_BB      BTM_SW_MM_TO_BB
962 #define BTA_DM_SW_BB_TO_BTC     BTM_SW_BB_TO_BTC
963 #define BTA_DM_SW_BTC_TO_BB     BTM_SW_BTC_TO_BB
964 
965 typedef tBTM_SW_DIR tBTA_DM_SW_DIR;
966 
967 /* Switch callback events */
968 #define BTA_DM_SWITCH_CMPL_EVT      0       /* Completion of the Switch API */
969 
970 typedef UINT8 tBTA_DM_SWITCH_EVT;
971 typedef void (tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event, tBTA_STATUS status);
972 
973 /* Audio routing out configuration */
974 #define BTA_DM_ROUTE_NONE       0x00    /* No Audio output */
975 #define BTA_DM_ROUTE_DAC        0x01    /* routing over analog output */
976 #define BTA_DM_ROUTE_I2S        0x02    /* routing over digital (I2S) output */
977 #define BTA_DM_ROUTE_BT_MONO    0x04    /* routing over SCO */
978 #define BTA_DM_ROUTE_BT_STEREO  0x08    /* routing over BT Stereo */
979 #define BTA_DM_ROUTE_HOST       0x10    /* routing over Host */
980 #define BTA_DM_ROUTE_FMTX       0x20    /* routing over FMTX */
981 #define BTA_DM_ROUTE_FMRX       0x40    /* routing over FMRX */
982 #define BTA_DM_ROUTE_BTSNK      0x80    /* routing over BT SNK */
983 
984 typedef UINT8 tBTA_DM_ROUTE_PATH;
985 
986 
987 /* Device Identification (DI) data structure
988 */
989 /* Used to set the DI record */
990 typedef tSDP_DI_RECORD          tBTA_DI_RECORD;
991 /* Used to get the DI record */
992 typedef tSDP_DI_GET_RECORD      tBTA_DI_GET_RECORD;
993 /* SDP discovery database */
994 typedef tSDP_DISCOVERY_DB       tBTA_DISCOVERY_DB;
995 
996 #ifndef         BTA_DI_NUM_MAX
997 #define         BTA_DI_NUM_MAX       3
998 #endif
999 
1000 /* Device features mask definitions */
1001 #define BTA_FEATURE_BYTES_PER_PAGE  BTM_FEATURE_BYTES_PER_PAGE
1002 #define BTA_EXT_FEATURES_PAGE_MAX   BTM_EXT_FEATURES_PAGE_MAX
1003 
1004 /*****************************************************************************
1005 **  External Function Declarations
1006 *****************************************************************************/
1007 #ifdef __cplusplus
1008 extern "C"
1009 {
1010 #endif
1011 
1012 /*******************************************************************************
1013 **
1014 ** Function         BTA_EnableBluetooth
1015 **
1016 ** Description      This function initializes BTA and prepares BTA and the
1017 **                  Bluetooth protocol stack for use.  This function is
1018 **                  typically called at startup or when Bluetooth services
1019 **                  are required by the phone.  This function must be called
1020 **                  before calling any other API function.
1021 **
1022 **
1023 ** Returns          BTA_SUCCESS if successful.
1024 **                  BTA_FAIL if internal failure.
1025 **
1026 *******************************************************************************/
1027 BTA_API extern tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback);
1028 
1029 /*******************************************************************************
1030 **
1031 ** Function         BTA_DisableBluetooth
1032 **
1033 ** Description      This function disables BTA and the Bluetooth protocol
1034 **                  stack.  It is called when BTA is no longer being used
1035 **                  by any application in the system.
1036 **
1037 **
1038 ** Returns          void
1039 **
1040 *******************************************************************************/
1041 BTA_API extern tBTA_STATUS BTA_DisableBluetooth(void);
1042 
1043 /*******************************************************************************
1044 **
1045 ** Function         BTA_EnableTestMode
1046 **
1047 ** Description      Enables bluetooth device under test mode
1048 **
1049 **
1050 ** Returns          tBTA_STATUS
1051 **
1052 *******************************************************************************/
1053 BTA_API extern tBTA_STATUS BTA_EnableTestMode(void);
1054 
1055 /*******************************************************************************
1056 **
1057 ** Function         BTA_DisableTestMode
1058 **
1059 ** Description      Disable bluetooth device under test mode
1060 **
1061 **
1062 ** Returns          None
1063 **
1064 *******************************************************************************/
1065 BTA_API extern void BTA_DisableTestMode(void);
1066 
1067 /*******************************************************************************
1068 **
1069 ** Function         BTA_DmIsDeviceUp
1070 **
1071 ** Description      This function tests whether the Bluetooth module is up
1072 **                  and ready.  This is a direct execution function that
1073 **                  may lock task scheduling on some platforms.
1074 **
1075 **
1076 ** Returns          TRUE if the module is ready.
1077 **                  FALSE if the module is not ready.
1078 **
1079 *******************************************************************************/
1080 BTA_API extern BOOLEAN BTA_DmIsDeviceUp(void);
1081 
1082 /*******************************************************************************
1083 **
1084 ** Function         BTA_DmSetDeviceName
1085 **
1086 ** Description      This function sets the Bluetooth name of the local device.
1087 **
1088 **
1089 ** Returns          void
1090 **
1091 *******************************************************************************/
1092 BTA_API extern void BTA_DmSetDeviceName(char *p_name);
1093 
1094 /*******************************************************************************
1095 **
1096 ** Function         BTA_DmSetVisibility
1097 **
1098 ** Description      This function sets the Bluetooth connectable,discoverable,
1099 **                  pairable and conn paired only modesmodes of the local device.
1100 **                  This controls whether other Bluetooth devices can find and connect to
1101 **                  the local device.
1102 **
1103 **
1104 ** Returns          void
1105 **
1106 *******************************************************************************/
1107 BTA_API extern void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 pairable_mode, UINT8 conn_filter);
1108 
1109 /*******************************************************************************
1110 **
1111 ** Function         BTA_DmSetScanParam
1112 **
1113 ** Description      This function sets the parameters for page scan and
1114 **                  inquiry scan.
1115 **
1116 **
1117 ** Returns          void
1118 **
1119 *******************************************************************************/
1120 BTA_API extern void BTA_DmSetScanParam (UINT16 page_scan_interval, UINT16 page_scan_window,
1121                                   UINT16 inquiry_scan_interval, UINT16 inquiry_scan_window);
1122 
1123 /*******************************************************************************
1124 **
1125 ** Function         BTA_DmSetAfhChannels
1126 **
1127 ** Description      This function sets the AFH first and
1128 **                  last disable channel, so channels within
1129 **                  that range are disabled.
1130 **                  In order to use this API, BTM_BYPASS_AMP_AUTO_AFH must be set
1131 **                  to be TRUE
1132 **
1133 ** Returns          void
1134 **
1135 *******************************************************************************/
1136 BTA_API extern void BTA_DmSetAfhChannels(UINT8 first, UINT8 last);
1137 
1138 
1139 /*******************************************************************************
1140 **
1141 ** Function         BTA_DmVendorSpecificCommand
1142 **
1143 ** Description      This function sends the vendor specific command
1144 **                  to the controller
1145 **
1146 **
1147 ** Returns          tBTA_STATUS
1148 **
1149 *******************************************************************************/
1150 BTA_API extern tBTA_STATUS BTA_DmVendorSpecificCommand (UINT16 opcode, UINT8 param_len,UINT8 *p_param_buf, tBTA_VENDOR_CMPL_CBACK *p_cback);
1151 
1152 
1153 /*******************************************************************************
1154 **
1155 ** Function         BTA_DmSearch
1156 **
1157 ** Description      This function searches for peer Bluetooth devices.  It
1158 **                  first performs an inquiry; for each device found from the
1159 **                  inquiry it gets the remote name of the device.  If
1160 **                  parameter services is nonzero, service discovery will be
1161 **                  performed on each device for the services specified.
1162 **
1163 **
1164 ** Returns          void
1165 **
1166 *******************************************************************************/
1167 BTA_API extern void BTA_DmSearch(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK services,
1168                                  tBTA_DM_SEARCH_CBACK *p_cback);
1169 
1170 /*******************************************************************************
1171 **
1172 ** Function         BTA_DmSearchCancel
1173 **
1174 ** Description      This function cancels a search that has been initiated
1175 **                  by calling BTA_DmSearch().
1176 **
1177 **
1178 ** Returns          void
1179 **
1180 *******************************************************************************/
1181 BTA_API extern void BTA_DmSearchCancel(void);
1182 
1183 /*******************************************************************************
1184 **
1185 ** Function         BTA_DmDiscover
1186 **
1187 ** Description      This function performs service discovery for the services
1188 **                  of a particular peer device.
1189 **
1190 **
1191 ** Returns          void
1192 **
1193 *******************************************************************************/
1194 BTA_API extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
1195                                    tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
1196 
1197 // btla-specific ++
1198 /*******************************************************************************
1199 **
1200 ** Function         BTA_DmDiscoverUUID
1201 **
1202 ** Description      This function performs service discovery for the services
1203 **                  of a particular peer device.
1204 **
1205 **
1206 ** Returns          void
1207 **
1208 *******************************************************************************/
1209 BTA_API extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
1210                     tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
1211 
1212 /*******************************************************************************
1213 **
1214 ** Function         BTA_DmGetCachedRemoteName
1215 **
1216 ** Description      Retieve cached remote name if available
1217 **
1218 ** Returns          BTA_SUCCESS if cached name was retrieved
1219 **                  BTA_FAILURE if cached name is not available
1220 **
1221 *******************************************************************************/
1222 tBTA_STATUS BTA_DmGetCachedRemoteName(BD_ADDR remote_device, UINT8 **pp_cached_name);
1223 // btla-specific --
1224 
1225 /*******************************************************************************
1226 **
1227 ** Function         BTA_DmIsMaster
1228 **
1229 ** Description      This function checks if the local device is the master of
1230 **                  the link to the given device
1231 **
1232 ** Returns          TRUE if master.
1233 **                  FALSE if not.
1234 **
1235 *******************************************************************************/
1236 BTA_API extern BOOLEAN BTA_DmIsMaster(BD_ADDR bd_addr);
1237 
1238 /*******************************************************************************
1239 **
1240 ** Function         BTA_DmBond
1241 **
1242 ** Description      This function initiates a bonding procedure with a peer
1243 **                  device.  The bonding procedure enables authentication
1244 **                  and optionally encryption on the Bluetooth link.
1245 **
1246 **
1247 ** Returns          void
1248 **
1249 *******************************************************************************/
1250 BTA_API extern void BTA_DmBond(BD_ADDR bd_addr);
1251 
1252 /*******************************************************************************
1253 **
1254 ** Function         BTA_DmBondCancel
1255 **
1256 ** Description      This function cancels a bonding procedure with a peer
1257 **                  device.
1258 **
1259 **
1260 ** Returns          void
1261 **
1262 *******************************************************************************/
1263 BTA_API extern void BTA_DmBondCancel(BD_ADDR bd_addr);
1264 
1265 /*******************************************************************************
1266 **
1267 ** Function         BTA_DmPinReply
1268 **
1269 ** Description      This function provides a PIN when one is requested by DM
1270 **                  during a bonding procedure.  The application should call
1271 **                  this function after the security callback is called with
1272 **                  a BTA_DM_PIN_REQ_EVT.
1273 **
1274 **
1275 ** Returns          void
1276 **
1277 *******************************************************************************/
1278 BTA_API extern void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len,
1279                                    UINT8 *p_pin);
1280 
1281 /*******************************************************************************
1282 **
1283 ** Function         BTA_DmLinkPolicy
1284 **
1285 ** Description      This function sets/clears the link policy mask to the given
1286 **                  bd_addr.
1287 **                  If clearing the sniff or park mode mask, the link is put
1288 **                  in active mode.
1289 **
1290 ** Returns          void
1291 **
1292 *******************************************************************************/
1293 BTA_API extern void BTA_DmLinkPolicy(BD_ADDR bd_addr, tBTA_DM_LP_MASK policy_mask,
1294                                      BOOLEAN set);
1295 
1296 #if (BTM_OOB_INCLUDED == TRUE)
1297 /*******************************************************************************
1298 **
1299 ** Function         BTA_DmLocalOob
1300 **
1301 ** Description      This function retrieves the OOB data from local controller.
1302 **                  The result is reported by bta_dm_co_loc_oob().
1303 **
1304 ** Returns          void
1305 **
1306 *******************************************************************************/
1307 BTA_API extern void BTA_DmLocalOob(void);
1308 #endif /* BTM_OOB_INCLUDED */
1309 
1310 /*******************************************************************************
1311 **
1312 ** Function         BTA_DmConfirm
1313 **
1314 ** Description      This function accepts or rejects the numerical value of the
1315 **                  Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
1316 **
1317 ** Returns          void
1318 **
1319 *******************************************************************************/
1320 BTA_API extern void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept);
1321 
1322 /*******************************************************************************
1323 **
1324 ** Function         BTA_DmPasskeyCancel
1325 **
1326 ** Description      This function is called to cancel the simple pairing process
1327 **                  reported by BTA_DM_SP_KEY_NOTIF_EVT
1328 **
1329 ** Returns          void
1330 **
1331 *******************************************************************************/
1332 BTA_API extern void BTA_DmPasskeyCancel(BD_ADDR bd_addr);
1333 
1334 /*******************************************************************************
1335 **
1336 ** Function         BTA_DmAddDevice
1337 **
1338 ** Description      This function adds a device to the security database list
1339 **                  of peer devices. This function would typically be called
1340 **                  at system startup to initialize the security database with
1341 **                  known peer devices.  This is a direct execution function
1342 **                  that may lock task scheduling on some platforms.
1343 **
1344 ** Returns          void
1345 **
1346 *******************************************************************************/
1347 BTA_API extern void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class,
1348                                     LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
1349                                     BOOLEAN is_trusted, UINT8 key_type,
1350                                     tBTA_IO_CAP io_cap);
1351 
1352 /*******************************************************************************
1353 **
1354 ** Function         BTA_DmAddDevWithName
1355 **
1356 ** Description      This function is newer version of  BTA_DmAddDevice()
1357 **                  which added bd_name and features as input parameters.
1358 **
1359 **
1360 ** Returns          void
1361 **
1362 ** Note:            features points to the remote device features array.
1363 **                  The array size is
1364 **                  BTA_FEATURE_BYTES_PER_PAGE * (BTA_EXT_FEATURES_PAGE_MAX + 1)
1365 **
1366 *******************************************************************************/
1367 BTA_API extern void BTA_DmAddDevWithName (BD_ADDR bd_addr, DEV_CLASS dev_class,
1368                                       BD_NAME bd_name, UINT8 *features,
1369                                       LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
1370                                       BOOLEAN is_trusted, UINT8 key_type, tBTA_IO_CAP io_cap);
1371 
1372 /*******************************************************************************
1373 **
1374 ** Function         BTA_DmRemoveDevice
1375 **
1376 ** Description      This function removes a device from the security database.
1377 **                  This is a direct execution function that may lock task
1378 **                  scheduling on some platforms.
1379 **
1380 **
1381 ** Returns          BTA_SUCCESS if successful.
1382 **                  BTA_FAIL if operation failed.
1383 **
1384 *******************************************************************************/
1385 BTA_API extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr);
1386 
1387 /*******************************************************************************
1388 **
1389 ** Function         BTA_DmAuthorizeReply
1390 **
1391 ** Description      This function provides an authorization reply when
1392 **                  authorization is requested by BTA.  The application calls
1393 **                  this function after the security callback is called with
1394 **                  a BTA_DM_AUTHORIZE_EVT.
1395 **
1396 **
1397 ** Returns          void
1398 **
1399 *******************************************************************************/
1400 BTA_API extern void BTA_DmAuthorizeReply(BD_ADDR bd_addr, tBTA_SERVICE_ID service,
1401                                          tBTA_AUTH_RESP response);
1402 
1403 /*******************************************************************************
1404 **
1405 ** Function         BTA_DmSignalStrength
1406 **
1407 ** Description      This function initiates RSSI and channnel quality
1408 **                  measurments. BTA_DM_SIG_STRENGTH_EVT is sent to
1409 **                  application with the values of RSSI and channel
1410 **                  quality
1411 **
1412 **
1413 ** Returns          void
1414 **
1415 *******************************************************************************/
1416 BTA_API extern void BTA_DmSignalStrength(tBTA_SIG_STRENGTH_MASK mask, UINT16 period, BOOLEAN start);
1417 
1418 /*******************************************************************************
1419 **
1420 ** Function         BTA_DmWriteInqTxPower
1421 **
1422 ** Description      This command is used to write the inquiry transmit power level
1423 **                  used to transmit the inquiry (ID) data packets.
1424 **
1425 ** Parameters       tx_power - tx inquiry power to use, valid value is -70 ~ 20
1426 
1427 ** Returns          void
1428 **
1429 *******************************************************************************/
1430 BTA_API extern void BTA_DmWriteInqTxPower(INT8 tx_power);
1431 
1432 /*******************************************************************************
1433 **
1434 ** Function         BTA_DmEirAddUUID
1435 **
1436 ** Description      This function is called to add UUID into EIR.
1437 **
1438 ** Parameters       tBT_UUID - UUID
1439 **
1440 ** Returns          None
1441 **
1442 *******************************************************************************/
1443 BTA_API extern void BTA_DmEirAddUUID (tBT_UUID *p_uuid);
1444 
1445 /*******************************************************************************
1446 **
1447 ** Function         BTA_DmEirRemoveUUID
1448 **
1449 ** Description      This function is called to remove UUID from EIR.
1450 **
1451 ** Parameters       tBT_UUID - UUID
1452 **
1453 ** Returns          None
1454 **
1455 *******************************************************************************/
1456 BTA_API extern void BTA_DmEirRemoveUUID (tBT_UUID *p_uuid);
1457 
1458 /*******************************************************************************
1459 **
1460 ** Function         BTA_DmSetEIRConfig
1461 **
1462 ** Description      This function is called to override the BTA default EIR parameters.
1463 **                  This funciton is only valid in a system where BTU & App task
1464 **                  are in the same memory space.
1465 **
1466 ** Parameters       Pointer to User defined EIR config
1467 **
1468 ** Returns          None
1469 **
1470 *******************************************************************************/
1471 BTA_API extern void BTA_DmSetEIRConfig (tBTA_DM_EIR_CONF *p_eir_cfg);
1472 
1473 /*******************************************************************************
1474 **
1475 ** Function         BTA_CheckEirData
1476 **
1477 ** Description      This function is called to get EIR data from significant part.
1478 **
1479 ** Parameters       p_eir - pointer of EIR significant part
1480 **                  type   - finding EIR data type
1481 **                  p_length - return the length of EIR data
1482 **
1483 ** Returns          pointer of EIR data
1484 **
1485 *******************************************************************************/
1486 BTA_API extern UINT8 *BTA_CheckEirData( UINT8 *p_eir, UINT8 tag, UINT8 *p_length );
1487 
1488 /*******************************************************************************
1489 **
1490 ** Function         BTA_GetEirService
1491 **
1492 ** Description      This function is called to get BTA service mask from EIR.
1493 **
1494 ** Parameters       p_eir - pointer of EIR significant part
1495 **                  p_services - return the BTA service mask
1496 **
1497 ** Returns          None
1498 **
1499 *******************************************************************************/
1500 BTA_API extern void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services );
1501 
1502 /*******************************************************************************
1503 **
1504 ** Function         BTA_DmUseSsr
1505 **
1506 ** Description      This function is called to check if the connected peer device
1507 **                  supports SSR or not.
1508 **
1509 ** Returns          TRUE, if SSR is supported
1510 **
1511 *******************************************************************************/
1512 BTA_API extern BOOLEAN BTA_DmUseSsr( BD_ADDR bd_addr );
1513 
1514 
1515 /*******************************************************************************
1516 **
1517 ** Function         BTA_DmSetLocalDiRecord
1518 **
1519 ** Description      This function adds a DI record to the local SDP database.
1520 **
1521 ** Returns          BTA_SUCCESS if record set sucessfully, otherwise error code.
1522 **
1523 *******************************************************************************/
1524 BTA_API extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
1525 	                          UINT32 *p_handle );
1526 
1527 /*******************************************************************************
1528 **
1529 ** Function         BTA_DmGetLocalDiRecord
1530 **
1531 ** Description      Get a specified DI record to the local SDP database. If no
1532 **                  record handle is provided, the primary DI record will be
1533 **                  returned.
1534 **
1535 ** Returns          BTA_SUCCESS if record set sucessfully, otherwise error code.
1536 **
1537 *******************************************************************************/
1538 BTA_API extern tBTA_STATUS BTA_DmGetLocalDiRecord( tBTA_DI_GET_RECORD *p_device_info,
1539 	                          UINT32 *p_handle );
1540 
1541 /*******************************************************************************
1542 **
1543 ** Function         BTA_DmDiDiscover
1544 **
1545 ** Description      This function queries a remote device for DI information.
1546 **
1547 ** Returns          None.
1548 **
1549 *******************************************************************************/
1550 BTA_API extern void BTA_DmDiDiscover( BD_ADDR remote_device, tBTA_DISCOVERY_DB *p_db,
1551                        UINT32 len, tBTA_DM_SEARCH_CBACK *p_cback );
1552 
1553 /*******************************************************************************
1554 **
1555 ** Function         BTA_DmGetDiRecord
1556 **
1557 ** Description      This function retrieves a remote device's DI record from
1558 **                  the specified database.
1559 **
1560 ** Returns          None.
1561 **
1562 *******************************************************************************/
1563 BTA_API extern tBTA_STATUS BTA_DmGetDiRecord( UINT8 get_record_index, tBTA_DI_GET_RECORD *p_device_info,
1564                         tBTA_DISCOVERY_DB *p_db );
1565 
1566 /*******************************************************************************
1567 **
1568 **
1569 ** Function         BTA_DmCloseACL
1570 **
1571 ** Description      This function force to close an ACL connection and remove the
1572 **                  device from the security database list of known devices.
1573 **
1574 ** Parameters:      bd_addr       - Address of the peer device
1575 **                  remove_dev    - remove device or not after link down
1576 **
1577 ** Returns          void.
1578 **
1579 *******************************************************************************/
1580 BTA_API extern void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev);
1581 
1582 /*******************************************************************************
1583 **
1584 ** Function         BTA_SysFeatures
1585 **
1586 ** Description      This function is called to set system features.
1587 **
1588 ** Returns          void
1589 **
1590 *******************************************************************************/
1591 BTA_API extern void BTA_SysFeatures (UINT16 sys_features);
1592 
1593 /*******************************************************************************
1594 **
1595 ** Function         bta_dmexecutecallback
1596 **
1597 ** Description      This function will request BTA to execute a call back in the context of BTU task
1598 **                  This API was named in lower case because it is only intended
1599 **                  for the internal customers(like BTIF).
1600 **
1601 ** Returns          void
1602 **
1603 *******************************************************************************/
1604 BTA_API extern void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param);
1605 
1606 #if (BTM_SCO_HCI_INCLUDED == TRUE)
1607 /*******************************************************************************
1608 **
1609 ** Function         BTA_DmPcmInitSamples
1610 **
1611 ** Description      initialize the down sample converter.
1612 **
1613 **                  src_sps: original samples per second (source audio data)
1614 **                            (ex. 44100, 48000)
1615 **                  bits: number of bits per pcm sample (16)
1616 **                  n_channels: number of channels (i.e. mono(1), stereo(2)...)
1617 **
1618 ** Returns          none
1619 **
1620 *******************************************************************************/
1621 BTA_API extern void BTA_DmPcmInitSamples (UINT32 src_sps, UINT32 bits, UINT32 n_channels);
1622 
1623 /**************************************************************************************
1624 ** Function         BTA_DmPcmResample
1625 **
1626 ** Description      Down sampling utility to convert higher sampling rate into 8K/16bits
1627 **                  PCM samples.
1628 **
1629 ** Parameters       p_src: pointer to the buffer where the original sampling PCM
1630 **                              are stored.
1631 **                  in_bytes:  Length of the input PCM sample buffer in byte.
1632 **                  p_dst:      pointer to the buffer which is to be used to store
1633 **                              the converted PCM samples.
1634 **
1635 **
1636 ** Returns          INT32: number of samples converted.
1637 **
1638 **************************************************************************************/
1639 BTA_API extern INT32 BTA_DmPcmResample (void *p_src, UINT32 in_bytes, void *p_dst);
1640 #endif
1641 
1642 #if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
1643 /* BLE related API functions */
1644 /*******************************************************************************
1645 **
1646 ** Function         BTA_DmBleSecurityGrant
1647 **
1648 ** Description      Grant security request access.
1649 **
1650 ** Parameters:      bd_addr          - BD address of the peer
1651 **                  res              - security grant status.
1652 **
1653 ** Returns          void
1654 **
1655 *******************************************************************************/
1656 BTA_API extern void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res);
1657 
1658 
1659 
1660 /*******************************************************************************
1661 **
1662 ** Function         BTA_DmBleSetBgConnType
1663 **
1664 ** Description      This function is called to set BLE connectable mode for a
1665 **                  peripheral device.
1666 **
1667 ** Parameters       bg_conn_type: it can be auto connection, or selective connection.
1668 **                  p_select_cback: callback function when selective connection procedure
1669 **                              is being used.
1670 **
1671 ** Returns          void
1672 **
1673 *******************************************************************************/
1674 BTA_API extern void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_CBACK *p_select_cback);
1675 
1676 /*******************************************************************************
1677 **
1678 ** Function         BTA_DmBlePasskeyReply
1679 **
1680 ** Description      Send BLE SMP passkey reply.
1681 **
1682 ** Parameters:      bd_addr          - BD address of the peer
1683 **                  accept           - passkey entry sucessful or declined.
1684 **                  passkey          - passkey value, must be a 6 digit number,
1685 **                                     can be lead by 0.
1686 **
1687 ** Returns          void
1688 **
1689 *******************************************************************************/
1690 BTA_API extern void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey);
1691 
1692 /*******************************************************************************
1693 **
1694 ** Function         BTA_DmAddBleDevice
1695 **
1696 ** Description      Add a BLE device.  This function will be normally called
1697 **                  during host startup to restore all required information
1698 **                  for a LE device stored in the NVRAM.
1699 **
1700 ** Parameters:      bd_addr          - BD address of the peer
1701 **                  dev_type         - Remote device's device type.
1702 **                  addr_type        - LE device address type.
1703 **
1704 ** Returns          void
1705 **
1706 *******************************************************************************/
1707 BTA_API extern void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type,
1708                                        tBT_DEVICE_TYPE dev_type);
1709 
1710 
1711 /*******************************************************************************
1712 **
1713 ** Function         BTA_DmAddBleKey
1714 **
1715 ** Description      Add/modify LE device information.  This function will be
1716 **                  normally called during host startup to restore all required
1717 **                  information stored in the NVRAM.
1718 **
1719 ** Parameters:      bd_addr          - BD address of the peer
1720 **                  p_le_key         - LE key values.
1721 **                  key_type         - LE SMP key type.
1722 **
1723 ** Returns          void
1724 **
1725 *******************************************************************************/
1726 BTA_API extern void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key,
1727                                      tBTA_LE_KEY_TYPE key_type);
1728 
1729 /*******************************************************************************
1730 **
1731 ** Function         BTA_DmSetBlePrefConnParams
1732 **
1733 ** Description      This function is called to set the preferred connection
1734 **                  parameters when default connection parameter is not desired.
1735 **
1736 ** Parameters:      bd_addr          - BD address of the peripheral
1737 **                  min_conn_int     - minimum preferred connection interval
1738 **                  max_conn_int     - maximum preferred connection interval
1739 **                  slave_latency    - preferred slave latency
1740 **                  supervision_tout - preferred supervision timeout
1741 **
1742 **
1743 ** Returns          void
1744 **
1745 *******************************************************************************/
1746 BTA_API extern void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
1747                                UINT16 min_conn_int, UINT16 max_conn_int,
1748                                UINT16 slave_latency, UINT16 supervision_tout );
1749 
1750 /*******************************************************************************
1751 **
1752 ** Function         BTA_DmSetBleConnScanParams
1753 **
1754 ** Description      This function is called to set scan parameters used in
1755 **                  BLE connection request
1756 **
1757 ** Parameters:      bd_addr          - BD address of the peripheral
1758 **                  scan_interval    - scan interval
1759 **                  scan_window      - scan window
1760 **
1761 ** Returns          void
1762 **
1763 *******************************************************************************/
1764 BTA_API extern void BTA_DmSetBleConnScanParams(UINT16 scan_interval,
1765                                                UINT16 scan_window );
1766 
1767 /*******************************************************************************
1768 **
1769 ** Function         BTA_DmSearchExt
1770 **
1771 ** Description      This function searches for peer Bluetooth devices. It performs
1772 **                  an inquiry and gets the remote name for devices. Service
1773 **                  discovery is done if services is non zero
1774 **
1775 ** Parameters       p_dm_inq: inquiry conditions
1776 **                  services: if service is not empty, service discovery will be done.
1777 **                            for all GATT based service condition, put num_uuid, and
1778 **                            p_uuid is the pointer to the list of UUID values.
1779 **                  p_cback: callback functino when search is completed.
1780 **
1781 **
1782 **
1783 ** Returns          void
1784 **
1785 *******************************************************************************/
1786 BTA_API extern void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services,
1787                                     tBTA_DM_SEARCH_CBACK *p_cback);
1788 
1789 /*******************************************************************************
1790 **
1791 ** Function         BTA_DmDiscoverExt
1792 **
1793 ** Description      This function does service discovery for services of a
1794 **                  peer device. When services.num_uuid is 0, it indicates all
1795 **                  GATT based services are to be searched; other wise a list of
1796 **                  UUID of interested services should be provided through
1797 **                  services.p_uuid.
1798 **
1799 **
1800 **
1801 ** Returns          void
1802 **
1803 *******************************************************************************/
1804 BTA_API extern void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1805                                     tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
1806 
1807 
1808 /*******************************************************************************
1809 **
1810 ** Function         BTA_DmSetEncryption
1811 **
1812 ** Description      This function is called to ensure that connection is
1813 **                  encrypted.  Should be called only on an open connection.
1814 **                  Typically only needed for connections that first want to
1815 **                  bring up unencrypted links, then later encrypt them.
1816 **
1817 ** Parameters:      bd_addr       - Address of the peer device
1818 **                  p_callback    - Pointer to callback function to indicat the
1819 **                                  link encryption status
1820 **                  sec_act       - This is the security action to indicate
1821 **                                  what knid of BLE security level is required for
1822 **                                  the BLE link if the BLE is supported
1823 **                                  Note: This parameter is ignored for the BR/EDR link
1824 **                                        or the BLE is not supported
1825 **
1826 ** Returns          void
1827 **
1828 **
1829 *******************************************************************************/
1830 BTA_API extern void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_DM_ENCRYPT_CBACK *p_callback,
1831                             tBTA_DM_BLE_SEC_ACT sec_act);
1832 
1833 
1834 /*******************************************************************************
1835 **
1836 ** Function         BTA_DmBleObserve
1837 **
1838 ** Description      This procedure keep the device listening for advertising
1839 **                  events from a broadcast device.
1840 **
1841 ** Parameters       start: start or stop observe.
1842 **                  duration : Duration of the scan. Continuous scan if 0 is passed
1843 **                  p_results_cb: Callback to be called with scan results
1844 **
1845 ** Returns          void
1846 **
1847 *******************************************************************************/
1848 BTA_API extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
1849                                            tBTA_DM_SEARCH_CBACK *p_results_cb);
1850 
1851 
1852 #endif
1853 
1854 // btla-specific ++
1855 /*******************************************************************************
1856 **
1857 ** Function         BTA_DmSetAfhChannelAssessment
1858 **
1859 ** Description      This function is called to set the channel assessment mode on or off
1860 **
1861 ** Returns          status
1862 **
1863 *******************************************************************************/
1864 BTA_API extern void BTA_DmSetAfhChannelAssessment (BOOLEAN enable_or_disable);
1865 
1866 #if BLE_INCLUDE == TRUE
1867 // btla-specific --
1868 /*******************************************************************************
1869 **
1870 ** Function         BTA_DmBleConfigLocalPrivacy
1871 **
1872 ** Description      Enable/disable privacy on the local device
1873 **
1874 ** Parameters:      privacy_enable   - enable/disabe privacy on remote device.
1875 **
1876 ** Returns          void
1877 **
1878 *******************************************************************************/
1879 BTA_API extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable);
1880 
1881 /*******************************************************************************
1882 **
1883 ** Function         BTA_DmBleEnableRemotePrivacy
1884 **
1885 ** Description      Enable/disable privacy on a remote device
1886 **
1887 ** Parameters:      bd_addr          - BD address of the peer
1888 **                  privacy_enable   - enable/disabe privacy on remote device.
1889 **
1890 ** Returns          void
1891 **
1892 *******************************************************************************/
1893 BTA_API extern void BTA_DmBleEnableRemotePrivacy(BD_ADDR bd_addr, BOOLEAN privacy_enable);
1894 
1895 
1896 /*******************************************************************************
1897 **
1898 ** Function         BTA_DmBleSetAdvConfig
1899 **
1900 ** Description      This function is called to override the BTA default ADV parameters.
1901 **
1902 ** Parameters       Pointer to User defined ADV data structure
1903 **
1904 ** Returns          None
1905 **
1906 *******************************************************************************/
1907 BTA_API extern void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask,
1908                                            tBTA_BLE_ADV_DATA *p_adv_cfg);
1909 #endif
1910 
1911 #ifdef __cplusplus
1912 }
1913 #endif
1914 
1915 #endif /* BTA_API_H */
1916 
1917