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
50typedef 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
108typedef 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
158typedef UINT32 tBTA_SERVICE_MASK;
159
160/* extended service mask, including mask with one or more GATT UUID */
161typedef 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
174typedef 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
186// btla-specific ++
187typedef UINT16 tBTA_DM_DISC;
188// btla-specific --
189
190/* Connectable Modes */
191#define BTA_DM_NON_CONN         BTM_NON_CONNECTABLE         /* Device is not connectable. */
192#define BTA_DM_CONN             BTM_CONNECTABLE             /* Device is connectable. */
193
194// btla-specific ++
195typedef UINT16 tBTA_DM_CONN;
196// btla-specific --
197
198/* Pairable Modes */
199#define BTA_DM_PAIRABLE         1
200#define BTA_DM_NON_PAIRABLE     0
201
202/* Connectable Paired Only Mode */
203#define BTA_DM_CONN_ALL         0
204#define BTA_DM_CONN_PAIRED      1
205
206/* Inquiry Modes */
207#define BTA_DM_GENERAL_INQUIRY  BTM_GENERAL_INQUIRY         /* Perform general inquiry. */
208#define BTA_DM_LIMITED_INQUIRY  BTM_LIMITED_INQUIRY         /* Perform limited inquiry. */
209
210#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
211#define BTA_BLE_INQUIRY_NONE    BTM_BLE_INQUIRY_NONE
212#define BTA_BLE_GENERAL_INQUIRY BTM_BLE_GENERAL_INQUIRY      /* Perform LE general inquiry. */
213#define BTA_BLE_LIMITED_INQUIRY BTM_BLE_LIMITED_INQUIRY      /* Perform LE limited inquiry. */
214#endif
215typedef UINT8 tBTA_DM_INQ_MODE;
216
217/* Inquiry Filter Type */
218#define BTA_DM_INQ_CLR          BTM_CLR_INQUIRY_FILTER          /* Clear inquiry filter. */
219#define BTA_DM_INQ_DEV_CLASS    BTM_FILTER_COND_DEVICE_CLASS    /* Filter on device class. */
220#define BTA_DM_INQ_BD_ADDR      BTM_FILTER_COND_BD_ADDR         /* Filter on a specific  BD address. */
221
222typedef UINT8 tBTA_DM_INQ_FILT;
223
224/* Authorize Response */
225#define BTA_DM_AUTH_PERM        0      /* Authorized for future connections to the service */
226#define BTA_DM_AUTH_TEMP        1      /* Authorized for current connection only */
227#define BTA_DM_NOT_AUTH         2      /* Not authorized for the service */
228
229typedef UINT8 tBTA_AUTH_RESP;
230
231/* M/S preferred roles */
232#define BTA_ANY_ROLE          0x00
233#define BTA_MASTER_ROLE_PREF  0x01
234#define BTA_MASTER_ROLE_ONLY  0x02
235
236typedef UINT8 tBTA_PREF_ROLES;
237
238enum
239{
240
241    BTA_DM_NO_SCATTERNET,        /* Device doesn't support scatternet, it might
242                                    support "role switch during connection" for
243                                    an incoming connection, when it already has
244                                    another connection in master role */
245    BTA_DM_PARTIAL_SCATTERNET,   /* Device supports partial scatternet. It can have
246                                    simulateous connection in Master and Slave roles
247                                    for short period of time */
248    BTA_DM_FULL_SCATTERNET       /* Device can have simultaneous connection in master
249                                    and slave roles */
250
251};
252
253
254/* Inquiry filter device class condition */
255typedef struct
256{
257    DEV_CLASS       dev_class;        /* device class of interest */
258    DEV_CLASS       dev_class_mask;   /* mask to determine the bits of device class of interest */
259} tBTA_DM_COD_COND;
260
261
262/* Inquiry Filter Condition */
263typedef union
264{
265    BD_ADDR              bd_addr;            /* BD address of  device to filter. */
266    tBTA_DM_COD_COND     dev_class_cond;     /* Device class filter condition */
267} tBTA_DM_INQ_COND;
268
269/* Inquiry Parameters */
270typedef struct
271{
272    tBTA_DM_INQ_MODE    mode;           /* Inquiry mode, limited or general. */
273    UINT8               duration;       /* Inquiry duration in 1.28 sec units. */
274    UINT8               max_resps;      /* Maximum inquiry responses.  Set to zero for unlimited responses. */
275    BOOLEAN             report_dup;     /* report duplicated inquiry response with higher RSSI value */
276    tBTA_DM_INQ_FILT    filter_type;    /* Filter condition type. */
277    tBTA_DM_INQ_COND    filter_cond;    /* Filter condition data. */
278} tBTA_DM_INQ;
279
280typedef struct
281{
282    UINT8   bta_dm_eir_min_name_len;        /* minimum length of local name when it is shortened */
283#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
284    UINT8   bta_dm_eir_uuid16_len;          /* length of 16-bit UUIDs */
285    UINT8  *bta_dm_eir_uuid16;              /* 16-bit UUIDs */
286#else
287    UINT32  uuid_mask[BTM_EIR_SERVICE_ARRAY_SIZE]; /* mask of UUID list in EIR */
288#endif
289    INT8   *bta_dm_eir_inq_tx_power;        /* Inquiry TX power         */
290    UINT8   bta_dm_eir_flag_len;            /* length of flags in bytes */
291    UINT8  *bta_dm_eir_flags;               /* flags for EIR */
292    UINT8   bta_dm_eir_manufac_spec_len;    /* length of manufacturer specific in bytes */
293    UINT8  *bta_dm_eir_manufac_spec;        /* manufacturer specific */
294} tBTA_DM_EIR_CONF;
295
296#if BLE_INCLUDED == TRUE
297/* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */
298#define BTA_BLE_LIMIT_DISC_FLAG     BTM_BLE_LIMIT_DISC_FLAG
299#define BTA_BLE_GEN_DISC_FLAG       BTM_BLE_GEN_DISC_FLAG
300#define BTA_BLE_BREDR_NOT_SPT       BTM_BLE_BREDR_NOT_SPT
301#define BTA_BLE_NON_LIMIT_DISC_FLAG BTM_BLE_NON_LIMIT_DISC_FLAG
302#define BTA_BLE_ADV_FLAG_MASK       BTM_BLE_ADV_FLAG_MASK
303#define BTA_BLE_LIMIT_DISC_MASK     BTM_BLE_LIMIT_DISC_MASK
304
305#define BTA_BLE_AD_BIT_DEV_NAME     BTM_BLE_AD_BIT_DEV_NAME
306#define BTA_BLE_AD_BIT_FLAGS        BTM_BLE_AD_BIT_FLAGS
307#define BTA_BLE_AD_BIT_MANU         BTM_BLE_AD_BIT_MANU
308#define BTA_BLE_AD_BIT_TX_PWR       BTM_BLE_AD_BIT_TX_PWR
309#define BTA_BLE_AD_BIT_ATTR         BTM_BLE_AD_BIT_ATTR
310#define BTA_BLE_AD_BIT_INT_RANGE    BTM_BLE_AD_BIT_INT_RANGE
311#define BTA_BLE_AD_BIT_SERVICE      BTM_BLE_AD_BIT_SERVICE
312#define BTA_BLE_AD_BIT_SERVICE_SOL  BTM_BLE_AD_BIT_SERVICE_SOL
313#define BTA_BLE_AD_BIT_SERVICE_DATA BTM_BLE_AD_BIT_SERVICE_DATA
314#define BTA_BLE_AD_BIT_SIGN_DATA    BTM_BLE_AD_BIT_SIGN_DATA
315typedef  UINT16  tBTA_BLE_AD_MASK;
316
317/* slave preferred connection interval range */
318typedef struct
319{
320    UINT16  low;
321    UINT16  hi;
322
323}tBTA_BLE_INT_RANGE;
324
325/* Service tag supported in the device */
326typedef struct
327{
328    UINT8       num_service;
329    BOOLEAN     list_cmpl;
330    UINT16      *p_uuid;
331}tBTA_BLE_SERVICE;
332
333/* attribute data */
334typedef struct
335{
336    UINT16       uuid;
337    UINT16       data_len;
338    UINT8       *p_data;
339}tBTA_BLE_ATTR;
340
341#define BTA_BLE_NUM_AD_ATTR_MAX         BTM_BLE_NUM_AD_ATTR_MAX
342
343/* attribute list contained in adv data */
344typedef struct
345{
346    UINT8               num_attr;
347    tBTA_BLE_ATTR       attr_list[BTA_BLE_NUM_AD_ATTR_MAX];
348}tBTA_BLE_ATTR_DATA;
349
350typedef struct
351{
352    UINT8       len;
353    UINT8      *p_val;
354}tBTA_BLE_MANU;
355
356typedef struct
357{
358    tBTA_BLE_MANU       manu;        /* manufactuer data */
359    tBTA_BLE_INT_RANGE  int_range;      /* slave prefered conn interval range */
360    tBTA_BLE_SERVICE    services;       /* services */
361    tBTA_BLE_ATTR_DATA  attr;           /* attribute data */
362    UINT8               flag;
363}tBTA_BLE_ADV_DATA;
364
365/* These are the fields returned in each device adv packet.  It
366** is returned in the results callback if registered.
367*/
368typedef struct
369{
370    UINT8               conn_mode;
371    tBTA_BLE_AD_MASK    ad_mask;        /* mask of the valid adv data field */
372    UINT8               flag;
373    UINT8               tx_power_level;
374    UINT8               remote_name_len;
375    UINT8               *p_remote_name;
376    tBTA_BLE_ATTR_DATA  attr_data;
377    tBTA_BLE_SERVICE    service;
378} tBTA_BLE_INQ_DATA;
379#endif
380
381typedef INT8 tBTA_DM_RSSI_VALUE;
382typedef UINT8 tBTA_DM_LINK_QUALITY_VALUE;
383
384
385/* signal strength mask */
386#define BTA_SIG_STRENGTH_RSSI_MASK          1
387#define BTA_SIG_STRENGTH_LINK_QUALITY_MASK  2
388
389typedef UINT8 tBTA_SIG_STRENGTH_MASK;
390
391
392/* Security Callback Events */
393#define BTA_DM_ENABLE_EVT               0       /* Enable Event */
394#define BTA_DM_DISABLE_EVT              1       /* Disable Event */
395#define BTA_DM_PIN_REQ_EVT              2       /* PIN request. */
396#define BTA_DM_AUTH_CMPL_EVT            3       /* Authentication complete indication. */
397#define BTA_DM_AUTHORIZE_EVT            4       /* Authorization request. */
398#define BTA_DM_LINK_UP_EVT              5       /* Connection UP event */
399#define BTA_DM_LINK_DOWN_EVT            6       /* Connection DOWN event */
400#define BTA_DM_SIG_STRENGTH_EVT         7       /* Signal strength for bluetooth connection */
401#define BTA_DM_BUSY_LEVEL_EVT           8       /* System busy level */
402#define BTA_DM_BOND_CANCEL_CMPL_EVT     9       /* Bond cancel complete indication */
403#define BTA_DM_SP_CFM_REQ_EVT           10      /* Simple Pairing User Confirmation request. */
404#define BTA_DM_SP_KEY_NOTIF_EVT         11      /* Simple Pairing Passkey Notification */
405#define BTA_DM_SP_RMT_OOB_EVT           12      /* Simple Pairing Remote OOB Data request. */
406#define BTA_DM_SP_KEYPRESS_EVT          13      /* Key press notification event. */
407#define BTA_DM_ROLE_CHG_EVT             14      /* Role Change event. */
408#define BTA_DM_BLE_KEY_EVT              15      /* BLE SMP key event for peer device keys */
409#define BTA_DM_BLE_SEC_REQ_EVT          16      /* BLE SMP security request */
410#define BTA_DM_BLE_PASSKEY_NOTIF_EVT    17      /* SMP passkey notification event */
411#define BTA_DM_BLE_PASSKEY_REQ_EVT      18      /* SMP passkey request event */
412#define BTA_DM_BLE_OOB_REQ_EVT          19      /* SMP OOB request event */
413#define BTA_DM_BLE_LOCAL_IR_EVT         20      /* BLE local IR event */
414#define BTA_DM_BLE_LOCAL_ER_EVT         21      /* BLE local ER event */
415// btla-specific ++
416#define BTA_DM_BLE_AUTH_CMPL_EVT        22      /* BLE Auth complete */
417// btla-specific --
418#define BTA_DM_DEV_UNPAIRED_EVT         23
419#define BTA_DM_HW_ERROR_EVT             24      /* BT Chip H/W error */
420typedef UINT8 tBTA_DM_SEC_EVT;
421
422/* Structure associated with BTA_DM_ENABLE_EVT */
423typedef struct
424{
425    BD_ADDR         bd_addr;            /* BD address of local device. */
426    tBTA_STATUS    status;
427} tBTA_DM_ENABLE;
428
429/* Structure associated with BTA_DM_PIN_REQ_EVT */
430typedef struct
431{
432    BD_ADDR         bd_addr;            /* BD address peer device. */
433    BD_NAME         bd_name;            /* Name of peer device. */
434    DEV_CLASS       dev_class;          /* Class of Device */
435} tBTA_DM_PIN_REQ;
436
437/* BLE related definition */
438
439#define BTA_DM_AUTH_FAIL_BASE                   (HCI_ERR_MAX_ERR + 10)
440#define BTA_DM_AUTH_CONVERT_SMP_CODE(x)        (BTA_DM_AUTH_FAIL_BASE + (x))
441#define BTA_DM_AUTH_SMP_PASSKEY_FAIL             BTA_DM_AUTH_CONVERT_SMP_CODE (SMP_PASSKEY_ENTRY_FAIL)
442#define BTA_DM_AUTH_SMP_OOB_FAIL                (BTA_DM_AUTH_FAIL_BASE + SMP_OOB_FAIL)
443#define BTA_DM_AUTH_SMP_PAIR_AUTH_FAIL          (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_AUTH_FAIL)
444#define BTA_DM_AUTH_SMP_CONFIRM_VALUE_FAIL      (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_VALUE_ERR)
445#define BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT        (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_NOT_SUPPORT)
446#define BTA_DM_AUTH_SMP_ENC_KEY_SIZE            (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_KEY_SIZE)
447#define BTA_DM_AUTH_SMP_INVALID_CMD             (BTA_DM_AUTH_FAIL_BASE + SMP_INVALID_CMD)
448#define BTA_DM_AUTH_SMP_UNKNOWN_ERR             (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_FAIL_UNKNOWN)
449#define BTA_DM_AUTH_SMP_REPEATED_ATTEMPT        (BTA_DM_AUTH_FAIL_BASE + SMP_REPEATED_ATTEMPTS)
450#define BTA_DM_AUTH_SMP_INTERNAL_ERR            (BTA_DM_AUTH_FAIL_BASE + SMP_PAIR_INTERNAL_ERR)
451#define BTA_DM_AUTH_SMP_UNKNOWN_IO              (BTA_DM_AUTH_FAIL_BASE + SMP_UNKNOWN_IO_CAP)
452#define BTA_DM_AUTH_SMP_INIT_FAIL               (BTA_DM_AUTH_FAIL_BASE + SMP_INIT_FAIL)
453#define BTA_DM_AUTH_SMP_CONFIRM_FAIL            (BTA_DM_AUTH_FAIL_BASE + SMP_CONFIRM_FAIL)
454#define BTA_DM_AUTH_SMP_BUSY                    (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY)
455#define BTA_DM_AUTH_SMP_ENC_FAIL                (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL)
456#define BTA_DM_AUTH_SMP_RSP_TIMEOUT             (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT)
457
458/* connection parameter boundary value and dummy value */
459#define BTA_DM_BLE_SCAN_INT_MIN          BTM_BLE_SCAN_INT_MIN
460#define BTA_DM_BLE_SCAN_INT_MAX          BTM_BLE_SCAN_INT_MAX
461#define BTA_DM_BLE_SCAN_WIN_MIN          BTM_BLE_SCAN_WIN_MIN
462#define BTA_DM_BLE_SCAN_WIN_MAX          BTM_BLE_SCAN_WIN_MAX
463#define BTA_DM_BLE_CONN_INT_MIN          BTM_BLE_CONN_INT_MIN
464#define BTA_DM_BLE_CONN_INT_MAX          BTM_BLE_CONN_INT_MAX
465#define BTA_DM_BLE_CONN_LATENCY_MAX      BTM_BLE_CONN_LATENCY_MAX
466#define BTA_DM_BLE_CONN_SUP_TOUT_MIN     BTM_BLE_CONN_SUP_TOUT_MIN
467#define BTA_DM_BLE_CONN_SUP_TOUT_MAX     BTM_BLE_CONN_SUP_TOUT_MAX
468#define BTA_DM_BLE_CONN_PARAM_UNDEF      BTM_BLE_CONN_PARAM_UNDEF  /* use this value when a specific value not to be overwritten */
469
470
471#define BTA_LE_KEY_PENC      BTM_LE_KEY_PENC  /* encryption information of peer device */
472#define BTA_LE_KEY_PID       BTM_LE_KEY_PID   /* identity key of the peer device */
473#define BTA_LE_KEY_PCSRK     BTM_LE_KEY_PCSRK   /* peer SRK */
474#define BTA_LE_KEY_LENC      BTM_LE_KEY_LENC        /* master role security information:div */
475#define BTA_LE_KEY_LID       BTM_LE_KEY_LID         /* master device ID key */
476#define BTA_LE_KEY_LCSRK     BTM_LE_KEY_LCSRK        /* local CSRK has been deliver to peer */
477typedef UINT8 tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
478
479
480typedef tBTM_LE_PENC_KEYS  tBTA_LE_PENC_KEYS ;
481typedef tBTM_LE_PCSRK_KEYS tBTA_LE_PCSRK_KEYS;
482typedef tBTM_LE_LENC_KEYS  tBTA_LE_LENC_KEYS  ;
483typedef tBTM_LE_LCSRK_KEYS tBTA_LE_LCSRK_KEYS ;
484
485typedef union
486{
487    tBTA_LE_PENC_KEYS   penc_key;       /* received peer encryption key */
488    tBTA_LE_PCSRK_KEYS  psrk_key;       /* received peer device SRK */
489    BT_OCTET16          pid_key;        /* peer device ID key */
490    tBTA_LE_LENC_KEYS   lenc_key;       /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
491    tBTA_LE_LCSRK_KEYS  lcsrk_key;      /* local device CSRK = d1(ER,DIV,1)*/
492}tBTA_LE_KEY_VALUE;
493
494#define BTA_BLE_LOCAL_KEY_TYPE_ID         1
495#define BTA_BLE_LOCAL_KEY_TYPE_ER         2
496typedef UINT8 tBTA_DM_BLE_LOCAL_KEY_MASK;
497
498typedef struct
499{
500    BT_OCTET16       ir;
501    BT_OCTET16       irk;
502    BT_OCTET16       dhk;
503}tBTA_BLE_LOCAL_ID_KEYS;
504
505#define BTA_DM_SEC_GRANTED              BTA_SUCCESS
506#define BTA_DM_SEC_PAIR_NOT_SPT         BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
507#define BTA_DM_SEC_REP_ATTEMPTS         BTA_DM_AUTH_SMP_REPEATED_ATTEMPT
508typedef UINT8 tBTA_DM_BLE_SEC_GRANT;
509
510
511#define BTA_DM_BLE_ONN_NONE             BTM_BLE_CONN_NONE
512#define BTA_DM_BLE_CONN_AUTO            BTM_BLE_CONN_AUTO
513#define BTA_DM_BLE_CONN_SELECTIVE       BTM_BLE_CONN_SELECTIVE
514typedef UINT8 tBTA_DM_BLE_CONN_TYPE;
515
516typedef BOOLEAN (tBTA_DM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
517
518/* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
519typedef struct
520{
521    BD_ADDR         bd_addr;        /* peer address */
522    BD_NAME         bd_name;        /* peer device name */
523} tBTA_DM_BLE_SEC_REQ;
524
525typedef struct
526{
527    BD_ADDR                 bd_addr;        /* peer address */
528    tBTM_LE_KEY_TYPE        key_type;
529    tBTM_LE_KEY_VALUE       key_value;
530}tBTA_DM_BLE_KEY;
531
532/* Structure associated with BTA_DM_AUTH_CMPL_EVT */
533typedef struct
534{
535    BD_ADDR         bd_addr;            /* BD address peer device. */
536    BD_NAME         bd_name;            /* Name of peer device. */
537    BOOLEAN         key_present;        /* Valid link key value in key element */
538    LINK_KEY        key;                /* Link key associated with peer device. */
539    UINT8           key_type;           /* The type of Link Key */
540    BOOLEAN         success;            /* TRUE of authentication succeeded, FALSE if failed. */
541    UINT8           fail_reason;        /* The HCI reason/error code for when success=FALSE */
542
543} tBTA_DM_AUTH_CMPL;
544
545
546/* Structure associated with BTA_DM_AUTHORIZE_EVT */
547typedef struct
548{
549    BD_ADDR         bd_addr;            /* BD address peer device. */
550    BD_NAME         bd_name;            /* Name of peer device. */
551    tBTA_SERVICE_ID service;            /* Service ID to authorize. */
552// btla-specific ++
553    DEV_CLASS      dev_class;
554// btla-specific --
555} tBTA_DM_AUTHORIZE;
556
557/* Structure associated with BTA_DM_LINK_UP_EVT */
558typedef struct
559{
560    BD_ADDR         bd_addr;            /* BD address peer device. */
561} tBTA_DM_LINK_UP;
562
563/* Structure associated with BTA_DM_LINK_DOWN_EVT */
564typedef struct
565{
566    BD_ADDR         bd_addr;            /* BD address peer device. */
567    UINT8           status;             /* connection open/closed */
568} tBTA_DM_LINK_DOWN;
569
570/* Structure associated with BTA_DM_ROLE_CHG_EVT */
571typedef struct
572{
573    BD_ADDR         bd_addr;            /* BD address peer device. */
574    UINT8           new_role;           /* the new connection role */
575} tBTA_DM_ROLE_CHG;
576
577/* Structure associated with BTA_DM_SIG_STRENGTH_EVT */
578typedef struct
579{
580    BD_ADDR         bd_addr;            /* BD address peer device. */
581    tBTA_SIG_STRENGTH_MASK mask;        /* mask for the values that are valid */
582    tBTA_DM_RSSI_VALUE  rssi_value;
583    tBTA_DM_LINK_QUALITY_VALUE link_quality_value;
584
585} tBTA_DM_SIG_STRENGTH;
586
587/* Structure associated with BTA_DM_BUSY_LEVEL_EVT */
588typedef struct
589{
590    UINT8           level;     /* when paging or inquiring, level is 10.
591                                    Otherwise, the number of ACL links */
592} tBTA_DM_BUSY_LEVEL;
593
594#define BTA_IO_CAP_OUT      BTM_IO_CAP_OUT      /* DisplayOnly */
595#define BTA_IO_CAP_IO       BTM_IO_CAP_IO       /* DisplayYesNo */
596#define BTA_IO_CAP_IN       BTM_IO_CAP_IN       /* KeyboardOnly */
597#define BTA_IO_CAP_NONE     BTM_IO_CAP_NONE     /* NoInputNoOutput */
598typedef tBTM_IO_CAP     tBTA_IO_CAP;
599
600#define BTA_AUTH_SP_NO    BTM_AUTH_SP_NO      /* 0 MITM Protection Not Required - Single Profile/non-bonding
601                                                Numeric comparison with automatic accept allowed */
602#define BTA_AUTH_SP_YES   BTM_AUTH_SP_YES     /* 1 MITM Protection Required - Single Profile/non-bonding
603                                                Use IO Capabilities to determine authentication procedure */
604#define BTA_AUTH_AP_NO    BTM_AUTH_AP_NO      /* 2 MITM Protection Not Required - All Profiles/dedicated bonding
605                                                Numeric comparison with automatic accept allowed */
606#define BTA_AUTH_AP_YES   BTM_AUTH_AP_YES     /* 3 MITM Protection Required - All Profiles/dedicated bonding
607                                                Use IO Capabilities to determine authentication procedure */
608#define BTA_AUTH_SPGB_NO  BTM_AUTH_SPGB_NO    /* 4 MITM Protection Not Required - Single Profiles/general bonding
609                                                Numeric comparison with automatic accept allowed */
610#define BTA_AUTH_SPGB_YES BTM_AUTH_SPGB_YES   /* 5 MITM Protection Required - Single Profiles/general bonding
611                                                Use IO Capabilities to determine authentication procedure */
612typedef tBTM_AUTH_REQ   tBTA_AUTH_REQ;
613
614#define BTA_AUTH_DD_BOND    BTM_AUTH_DD_BOND  /* 2 this bit is set for dedicated bonding */
615#define BTA_AUTH_GEN_BOND   BTM_AUTH_SPGB_NO  /* 4 this bit is set for general bonding */
616#define BTA_AUTH_BONDS      BTM_AUTH_BONDS    /* 6 the general/dedicated bonding bits  */
617
618#define BTA_LE_AUTH_NO_BOND    BTM_LE_AUTH_REQ_NO_BOND  /* 0*/
619#define BTA_LE_AUTH_BOND       BTM_LE_AUTH_REQ_BOND     /* 1 << 0 */
620#define BTA_LE_AUTH_REQ_MITM   BTM_LE_AUTH_REQ_MITM    /* 1 << 2 */
621typedef tBTM_LE_AUTH_REQ       tBTA_LE_AUTH_REQ;       /* combination of the above bit pattern */
622
623#define BTA_OOB_NONE        BTM_OOB_NONE
624#define BTA_OOB_PRESENT     BTM_OOB_PRESENT
625#if BTM_OOB_INCLUDED == TRUE
626#define BTA_OOB_UNKNOWN     BTM_OOB_UNKNOWN
627#endif
628typedef tBTM_OOB_DATA   tBTA_OOB_DATA;
629
630/* Structure associated with BTA_DM_SP_CFM_REQ_EVT */
631typedef struct
632{
633    BD_ADDR         bd_addr;        /* peer address */
634    DEV_CLASS       dev_class;      /* peer CoD */
635    BD_NAME         bd_name;        /* peer device name */
636    UINT32          num_val;        /* the numeric value for comparison. If just_works, do not show this number to UI */
637    BOOLEAN         just_works;     /* TRUE, if "Just Works" association model */
638    tBTA_AUTH_REQ   loc_auth_req;   /* Authentication required for local device */
639    tBTA_AUTH_REQ   rmt_auth_req;   /* Authentication required for peer device */
640    tBTA_IO_CAP     loc_io_caps;    /* IO Capabilities of local device */
641    tBTA_AUTH_REQ   rmt_io_caps;    /* IO Capabilities of remote device */
642} tBTA_DM_SP_CFM_REQ;
643
644enum
645{
646    BTA_SP_KEY_STARTED,         /* passkey entry started */
647    BTA_SP_KEY_ENTERED,         /* passkey digit entered */
648    BTA_SP_KEY_ERASED,          /* passkey digit erased */
649    BTA_SP_KEY_CLEARED,         /* passkey cleared */
650    BTA_SP_KEY_COMPLT           /* passkey entry completed */
651};
652typedef UINT8   tBTA_SP_KEY_TYPE;
653
654/* Structure associated with BTA_DM_SP_KEYPRESS_EVT */
655typedef struct
656{
657    BD_ADDR             bd_addr;        /* peer address */
658    tBTA_SP_KEY_TYPE   notif_type;
659}tBTA_DM_SP_KEY_PRESS;
660
661/* Structure associated with BTA_DM_SP_KEY_NOTIF_EVT */
662typedef struct
663{
664    BD_ADDR         bd_addr;        /* peer address */
665    DEV_CLASS       dev_class;      /* peer CoD */
666    BD_NAME         bd_name;        /* peer device name */
667    UINT32          passkey;        /* the numeric value for comparison. If just_works, do not show this number to UI */
668} tBTA_DM_SP_KEY_NOTIF;
669
670/* Structure associated with BTA_DM_SP_RMT_OOB_EVT */
671typedef struct
672{
673    BD_ADDR         bd_addr;        /* peer address */
674    DEV_CLASS       dev_class;      /* peer CoD */
675    BD_NAME         bd_name;        /* peer device name */
676} tBTA_DM_SP_RMT_OOB;
677
678/* Structure associated with BTA_DM_BOND_CANCEL_CMPL_EVT */
679typedef struct
680{
681    tBTA_STATUS     result;    /* TRUE of bond cancel succeeded, FALSE if failed. */
682} tBTA_DM_BOND_CANCEL_CMPL;
683
684/* Union of all security callback structures */
685typedef union
686{
687    tBTA_DM_ENABLE      enable;         /* BTA enabled */
688    tBTA_DM_PIN_REQ     pin_req;        /* PIN request. */
689    tBTA_DM_AUTH_CMPL   auth_cmpl;      /* Authentication complete indication. */
690    tBTA_DM_AUTHORIZE   authorize;      /* Authorization request. */
691    tBTA_DM_LINK_UP     link_up;       /* ACL connection down event */
692    tBTA_DM_LINK_DOWN   link_down;       /* ACL connection down event */
693    tBTA_DM_SIG_STRENGTH sig_strength;  /* rssi and link quality value */
694    tBTA_DM_BUSY_LEVEL  busy_level;     /* System busy level */
695    tBTA_DM_SP_CFM_REQ  cfm_req;        /* user confirm request */
696    tBTA_DM_SP_KEY_NOTIF key_notif;     /* passkey notification */
697    tBTA_DM_SP_RMT_OOB  rmt_oob;        /* remote oob */
698    tBTA_DM_BOND_CANCEL_CMPL bond_cancel_cmpl; /* Bond Cancel Complete indication */
699    tBTA_DM_SP_KEY_PRESS   key_press;   /* key press notification event */
700    tBTA_DM_ROLE_CHG     role_chg;       /* role change event */
701    tBTA_DM_BLE_SEC_REQ  ble_req;        /* BLE SMP related request */
702    tBTA_DM_BLE_KEY      ble_key;        /* BLE SMP keys used when pairing */
703    tBTA_BLE_LOCAL_ID_KEYS  ble_id_keys;  /* IR event */
704    BT_OCTET16              ble_er;       /* ER event data */
705} tBTA_DM_SEC;
706
707/* Security callback */
708typedef void (tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data);
709
710/* Vendor Specific Command Callback */
711typedef tBTM_VSC_CMPL_CB        tBTA_VENDOR_CMPL_CBACK;
712
713/* Search callback events */
714#define BTA_DM_INQ_RES_EVT              0       /* Inquiry result for a peer device. */
715#define BTA_DM_INQ_CMPL_EVT             1       /* Inquiry complete. */
716#define BTA_DM_DISC_RES_EVT             2       /* Discovery result for a peer device. */
717#define BTA_DM_DISC_BLE_RES_EVT         3       /* Discovery result for BLE GATT based servoce on a peer device. */
718#define BTA_DM_DISC_CMPL_EVT            4       /* Discovery complete. */
719#define BTA_DM_DI_DISC_CMPL_EVT         5       /* Discovery complete. */
720#define BTA_DM_SEARCH_CANCEL_CMPL_EVT   6       /* Search cancelled */
721
722typedef UINT8 tBTA_DM_SEARCH_EVT;
723
724#define BTA_DM_INQ_RES_IGNORE_RSSI      BTM_INQ_RES_IGNORE_RSSI /* 0x7f RSSI value not supplied (ignore it) */
725
726/* Structure associated with BTA_DM_INQ_RES_EVT */
727typedef struct
728{
729    BD_ADDR         bd_addr;                /* BD address peer device. */
730    DEV_CLASS       dev_class;              /* Device class of peer device. */
731    BOOLEAN         remt_name_not_required; /* Application sets this flag if it already knows the name of the device */
732                                            /* If the device name is known to application BTA skips the remote name request */
733    BOOLEAN         is_limited;             /* TRUE, if the limited inquiry bit is set in the CoD */
734    INT8            rssi;                   /* The rssi value */
735    UINT8           *p_eir;                 /* received EIR */
736#if (BLE_INCLUDED == TRUE)
737    UINT8               inq_result_type;
738    UINT8               ble_addr_type;
739    tBTM_BLE_EVT_TYPE   ble_evt_type;
740    tBT_DEVICE_TYPE     device_type;
741#endif
742
743} tBTA_DM_INQ_RES;
744
745/* Structure associated with BTA_DM_INQ_CMPL_EVT */
746typedef struct
747{
748    UINT8           num_resps;          /* Number of inquiry responses. */
749} tBTA_DM_INQ_CMPL;
750
751/* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
752typedef struct
753{
754    BD_ADDR             bd_addr;        /* BD address peer device. */
755    UINT8               num_record;     /* Number of DI record */
756    tBTA_STATUS         result;
757} tBTA_DM_DI_DISC_CMPL;
758
759/* Structure associated with BTA_DM_DISC_RES_EVT */
760typedef struct
761{
762    BD_ADDR             bd_addr;        /* BD address peer device. */
763    BD_NAME             bd_name;        /* Name of peer device. */
764    tBTA_SERVICE_MASK   services;       /* Services found on peer device. */
765// btla-specific ++
766    UINT8           *   p_raw_data;     /* Raw data for discovery DB */
767    UINT32              raw_data_size;  /* size of raw data */
768    tBT_DEVICE_TYPE     device_type;    /* device type in case it is BLE device */
769    UINT32              num_uuids;
770    UINT8               *p_uuid_list;
771// btla-specific --
772    tBTA_STATUS         result;
773} tBTA_DM_DISC_RES;
774
775/* Structure associated with tBTA_DM_DISC_BLE_RES */
776typedef struct
777{
778    BD_ADDR             bd_addr;        /* BD address peer device. */
779    BD_NAME             bd_name;        /* Name of peer device. */
780    tBT_UUID            service;        /* GATT based Services UUID found on peer device. */
781} tBTA_DM_DISC_BLE_RES;
782
783
784/* Union of all search callback structures */
785typedef union
786{
787    tBTA_DM_INQ_RES     inq_res;        /* Inquiry result for a peer device. */
788    tBTA_DM_INQ_CMPL    inq_cmpl;       /* Inquiry complete. */
789    tBTA_DM_DISC_RES    disc_res;       /* Discovery result for a peer device. */
790    tBTA_DM_DISC_BLE_RES    disc_ble_res;   /* discovery result for GATT based service */
791    tBTA_DM_DI_DISC_CMPL    di_disc;        /* DI discovery result for a peer device */
792
793} tBTA_DM_SEARCH;
794
795/* Search callback */
796typedef void (tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data);
797
798/* Execute call back */
799typedef void (tBTA_DM_EXEC_CBACK) (void * p_param);
800
801/* Encryption callback*/
802typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_STATUS result);
803
804#if BLE_INCLUDED == TRUE
805#define BTA_DM_BLE_SEC_NONE         BTM_BLE_SEC_NONE
806#define BTA_DM_BLE_SEC_ENCRYPT      BTM_BLE_SEC_ENCRYPT
807#define BTA_DM_BLE_SEC_NO_MITM      BTM_BLE_SEC_ENCRYPT_NO_MITM
808#define BTA_DM_BLE_SEC_MITM         BTM_BLE_SEC_ENCRYPT_MITM
809typedef tBTM_BLE_SEC_ACT            tBTA_DM_BLE_SEC_ACT;
810#else
811typedef UINT8                       tBTA_DM_BLE_SEC_ACT;
812#endif
813
814/* Maximum service name length */
815#define BTA_SERVICE_NAME_LEN    35
816#define BTA_SERVICE_DESP_LEN    BTA_SERVICE_NAME_LEN
817#define BTA_PROVIDER_NAME_LEN   BTA_SERVICE_NAME_LEN
818
819
820/* link policy masks  */
821#define BTA_DM_LP_SWITCH        HCI_ENABLE_MASTER_SLAVE_SWITCH
822#define BTA_DM_LP_HOLD          HCI_ENABLE_HOLD_MODE
823#define BTA_DM_LP_SNIFF         HCI_ENABLE_SNIFF_MODE
824#define BTA_DM_LP_PARK          HCI_ENABLE_PARK_MODE
825typedef UINT16 tBTA_DM_LP_MASK;
826
827/* power mode actions  */
828#define BTA_DM_PM_NO_ACTION    0x00       /* no change to the current pm setting */
829#define BTA_DM_PM_PARK         0x10       /* prefers park mode */
830#define BTA_DM_PM_SNIFF        0x20       /* prefers sniff mode */
831#define BTA_DM_PM_SNIFF1       0x21       /* prefers sniff1 mode */
832#define BTA_DM_PM_SNIFF2       0x22       /* prefers sniff2 mode */
833#define BTA_DM_PM_SNIFF3       0x23       /* prefers sniff3 mode */
834#define BTA_DM_PM_SNIFF4       0x24       /* prefers sniff4 mode */
835#define BTA_DM_PM_SNIFF5       0x25       /* prefers sniff5 mode */
836#define BTA_DM_PM_SNIFF6       0x26       /* prefers sniff6 mode */
837#define BTA_DM_PM_SNIFF7       0x27       /* prefers sniff7 mode */
838#define BTA_DM_PM_SNIFF_USER0  0x28       /* prefers user-defined sniff0 mode (testtool only) */
839#define BTA_DM_PM_SNIFF_USER1  0x29       /* prefers user-defined sniff1 mode (testtool only) */
840#define BTA_DM_PM_ACTIVE       0x40       /* prefers active mode */
841#define BTA_DM_PM_RETRY        0x80       /* retry power mode based on current settings */
842#define BTA_DM_PM_NO_PREF      0x01       /* service has no prefernce on power mode setting. eg. connection to service got closed */
843
844typedef UINT8 tBTA_DM_PM_ACTTION;
845
846/* index to bta_dm_ssr_spec */
847#define BTA_DM_PM_SSR0          0
848#define BTA_DM_PM_SSR1          1
849#define BTA_DM_PM_SSR2          2
850#define BTA_DM_PM_SSR3          3
851#define BTA_DM_PM_SSR4          4
852#define BTA_DM_PM_SSR5          5
853#define BTA_DM_PM_SSR6          6
854
855#define BTA_DM_PM_NUM_EVTS      9
856
857#ifndef BTA_DM_PM_PARK_IDX
858#define BTA_DM_PM_PARK_IDX      5 /* the actual index to bta_dm_pm_md[] for PARK mode */
859#endif
860
861#define BTA_DM_SW_BB_TO_MM      BTM_SW_BB_TO_MM
862#define BTA_DM_SW_MM_TO_BB      BTM_SW_MM_TO_BB
863#define BTA_DM_SW_BB_TO_BTC     BTM_SW_BB_TO_BTC
864#define BTA_DM_SW_BTC_TO_BB     BTM_SW_BTC_TO_BB
865
866typedef tBTM_SW_DIR tBTA_DM_SW_DIR;
867
868/* Switch callback events */
869#define BTA_DM_SWITCH_CMPL_EVT      0       /* Completion of the Switch API */
870
871typedef UINT8 tBTA_DM_SWITCH_EVT;
872typedef void (tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event, tBTA_STATUS status);
873
874/* Audio routing out configuration */
875#define BTA_DM_ROUTE_NONE       0x00    /* No Audio output */
876#define BTA_DM_ROUTE_DAC        0x01    /* routing over analog output */
877#define BTA_DM_ROUTE_I2S        0x02    /* routing over digital (I2S) output */
878#define BTA_DM_ROUTE_BT_MONO    0x04    /* routing over SCO */
879#define BTA_DM_ROUTE_BT_STEREO  0x08    /* routing over BT Stereo */
880#define BTA_DM_ROUTE_HOST       0x10    /* routing over Host */
881#define BTA_DM_ROUTE_FMTX       0x20    /* routing over FMTX */
882#define BTA_DM_ROUTE_FMRX       0x40    /* routing over FMRX */
883#define BTA_DM_ROUTE_BTSNK      0x80    /* routing over BT SNK */
884
885typedef UINT8 tBTA_DM_ROUTE_PATH;
886
887
888/* Device Identification (DI) data structure
889*/
890/* Used to set the DI record */
891typedef tSDP_DI_RECORD          tBTA_DI_RECORD;
892/* Used to get the DI record */
893typedef tSDP_DI_GET_RECORD      tBTA_DI_GET_RECORD;
894/* SDP discovery database */
895typedef tSDP_DISCOVERY_DB       tBTA_DISCOVERY_DB;
896
897#ifndef         BTA_DI_NUM_MAX
898#define         BTA_DI_NUM_MAX       3
899#endif
900
901/*****************************************************************************
902**  External Function Declarations
903*****************************************************************************/
904#ifdef __cplusplus
905extern "C"
906{
907#endif
908
909/*******************************************************************************
910**
911** Function         BTA_EnableBluetooth
912**
913** Description      This function initializes BTA and prepares BTA and the
914**                  Bluetooth protocol stack for use.  This function is
915**                  typically called at startup or when Bluetooth services
916**                  are required by the phone.  This function must be called
917**                  before calling any other API function.
918**
919**
920** Returns          BTA_SUCCESS if successful.
921**                  BTA_FAIL if internal failure.
922**
923*******************************************************************************/
924BTA_API extern tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback);
925
926/*******************************************************************************
927**
928** Function         BTA_DisableBluetooth
929**
930** Description      This function disables BTA and the Bluetooth protocol
931**                  stack.  It is called when BTA is no longer being used
932**                  by any application in the system.
933**
934**
935** Returns          void
936**
937*******************************************************************************/
938BTA_API extern tBTA_STATUS BTA_DisableBluetooth(void);
939
940/*******************************************************************************
941**
942** Function         BTA_EnableTestMode
943**
944** Description      Enables bluetooth device under test mode
945**
946**
947** Returns          tBTA_STATUS
948**
949*******************************************************************************/
950BTA_API extern tBTA_STATUS BTA_EnableTestMode(void);
951
952/*******************************************************************************
953**
954** Function         BTA_DisableTestMode
955**
956** Description      Disable bluetooth device under test mode
957**
958**
959** Returns          None
960**
961*******************************************************************************/
962BTA_API extern void BTA_DisableTestMode(void);
963
964/*******************************************************************************
965**
966** Function         BTA_DmIsDeviceUp
967**
968** Description      This function tests whether the Bluetooth module is up
969**                  and ready.  This is a direct execution function that
970**                  may lock task scheduling on some platforms.
971**
972**
973** Returns          TRUE if the module is ready.
974**                  FALSE if the module is not ready.
975**
976*******************************************************************************/
977BTA_API extern BOOLEAN BTA_DmIsDeviceUp(void);
978
979/*******************************************************************************
980**
981** Function         BTA_DmSetDeviceName
982**
983** Description      This function sets the Bluetooth name of the local device.
984**
985**
986** Returns          void
987**
988*******************************************************************************/
989BTA_API extern void BTA_DmSetDeviceName(char *p_name);
990
991/*******************************************************************************
992**
993** Function         BTA_DmSetVisibility
994**
995** Description      This function sets the Bluetooth connectable,discoverable,
996**                  pairable and conn paired only modesmodes of the local device.
997**                  This controls whether other Bluetooth devices can find and connect to
998**                  the local device.
999**
1000**
1001** Returns          void
1002**
1003*******************************************************************************/
1004BTA_API extern void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 pairable_mode, UINT8 conn_filter);
1005
1006/*******************************************************************************
1007**
1008** Function         BTA_DmSetScanParam
1009**
1010** Description      This function sets the parameters for page scan and
1011**                  inquiry scan.
1012**
1013**
1014** Returns          void
1015**
1016*******************************************************************************/
1017BTA_API extern void BTA_DmSetScanParam (UINT16 page_scan_interval, UINT16 page_scan_window,
1018                                  UINT16 inquiry_scan_interval, UINT16 inquiry_scan_window);
1019
1020/*******************************************************************************
1021**
1022** Function         BTA_DmSetAfhChannels
1023**
1024** Description      This function sets the AFH first and
1025**                  last disable channel, so channels within
1026**                  that range are disabled.
1027**                  In order to use this API, BTM_BYPASS_AMP_AUTO_AFH must be set
1028**                  to be TRUE
1029**
1030** Returns          void
1031**
1032*******************************************************************************/
1033BTA_API extern void BTA_DmSetAfhChannels(UINT8 first, UINT8 last);
1034
1035
1036/*******************************************************************************
1037**
1038** Function         BTA_DmVendorSpecificCommand
1039**
1040** Description      This function sends the vendor specific command
1041**                  to the controller
1042**
1043**
1044** Returns          tBTA_STATUS
1045**
1046*******************************************************************************/
1047BTA_API extern tBTA_STATUS BTA_DmVendorSpecificCommand (UINT16 opcode, UINT8 param_len,UINT8 *p_param_buf, tBTA_VENDOR_CMPL_CBACK *p_cback);
1048
1049
1050/*******************************************************************************
1051**
1052** Function         BTA_DmSearch
1053**
1054** Description      This function searches for peer Bluetooth devices.  It
1055**                  first performs an inquiry; for each device found from the
1056**                  inquiry it gets the remote name of the device.  If
1057**                  parameter services is nonzero, service discovery will be
1058**                  performed on each device for the services specified.
1059**
1060**
1061** Returns          void
1062**
1063*******************************************************************************/
1064BTA_API extern void BTA_DmSearch(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK services,
1065                                 tBTA_DM_SEARCH_CBACK *p_cback);
1066
1067/*******************************************************************************
1068**
1069** Function         BTA_DmSearchCancel
1070**
1071** Description      This function cancels a search that has been initiated
1072**                  by calling BTA_DmSearch().
1073**
1074**
1075** Returns          void
1076**
1077*******************************************************************************/
1078BTA_API extern void BTA_DmSearchCancel(void);
1079
1080/*******************************************************************************
1081**
1082** Function         BTA_DmDiscover
1083**
1084** Description      This function performs service discovery for the services
1085**                  of a particular peer device.
1086**
1087**
1088** Returns          void
1089**
1090*******************************************************************************/
1091BTA_API extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
1092                                   tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
1093
1094// btla-specific ++
1095/*******************************************************************************
1096**
1097** Function         BTA_DmDiscoverUUID
1098**
1099** Description      This function performs service discovery for the services
1100**                  of a particular peer device.
1101**
1102**
1103** Returns          void
1104**
1105*******************************************************************************/
1106BTA_API extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
1107                    tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
1108
1109/*******************************************************************************
1110**
1111** Function         BTA_DmGetCachedRemoteName
1112**
1113** Description      Retieve cached remote name if available
1114**
1115** Returns          BTA_SUCCESS if cached name was retrieved
1116**                  BTA_FAILURE if cached name is not available
1117**
1118*******************************************************************************/
1119tBTA_STATUS BTA_DmGetCachedRemoteName(BD_ADDR remote_device, UINT8 **pp_cached_name);
1120// btla-specific --
1121
1122/*******************************************************************************
1123**
1124** Function         BTA_DmIsMaster
1125**
1126** Description      This function checks if the local device is the master of
1127**                  the link to the given device
1128**
1129** Returns          TRUE if master.
1130**                  FALSE if not.
1131**
1132*******************************************************************************/
1133BTA_API extern BOOLEAN BTA_DmIsMaster(BD_ADDR bd_addr);
1134
1135/*******************************************************************************
1136**
1137** Function         BTA_DmBond
1138**
1139** Description      This function initiates a bonding procedure with a peer
1140**                  device.  The bonding procedure enables authentication
1141**                  and optionally encryption on the Bluetooth link.
1142**
1143**
1144** Returns          void
1145**
1146*******************************************************************************/
1147BTA_API extern void BTA_DmBond(BD_ADDR bd_addr);
1148
1149/*******************************************************************************
1150**
1151** Function         BTA_DmBondCancel
1152**
1153** Description      This function cancels a bonding procedure with a peer
1154**                  device.
1155**
1156**
1157** Returns          void
1158**
1159*******************************************************************************/
1160BTA_API extern void BTA_DmBondCancel(BD_ADDR bd_addr);
1161
1162/*******************************************************************************
1163**
1164** Function         BTA_DmPinReply
1165**
1166** Description      This function provides a PIN when one is requested by DM
1167**                  during a bonding procedure.  The application should call
1168**                  this function after the security callback is called with
1169**                  a BTA_DM_PIN_REQ_EVT.
1170**
1171**
1172** Returns          void
1173**
1174*******************************************************************************/
1175BTA_API extern void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len,
1176                                   UINT8 *p_pin);
1177
1178/*******************************************************************************
1179**
1180** Function         BTA_DmLinkPolicy
1181**
1182** Description      This function sets/clears the link policy mask to the given
1183**                  bd_addr.
1184**                  If clearing the sniff or park mode mask, the link is put
1185**                  in active mode.
1186**
1187** Returns          void
1188**
1189*******************************************************************************/
1190BTA_API extern void BTA_DmLinkPolicy(BD_ADDR bd_addr, tBTA_DM_LP_MASK policy_mask,
1191                                     BOOLEAN set);
1192
1193#if (BTM_OOB_INCLUDED == TRUE)
1194/*******************************************************************************
1195**
1196** Function         BTA_DmLocalOob
1197**
1198** Description      This function retrieves the OOB data from local controller.
1199**                  The result is reported by bta_dm_co_loc_oob().
1200**
1201** Returns          void
1202**
1203*******************************************************************************/
1204BTA_API extern void BTA_DmLocalOob(void);
1205#endif /* BTM_OOB_INCLUDED */
1206
1207/*******************************************************************************
1208**
1209** Function         BTA_DmConfirm
1210**
1211** Description      This function accepts or rejects the numerical value of the
1212**                  Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT
1213**
1214** Returns          void
1215**
1216*******************************************************************************/
1217BTA_API extern void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept);
1218
1219/*******************************************************************************
1220**
1221** Function         BTA_DmPasskeyCancel
1222**
1223** Description      This function is called to cancel the simple pairing process
1224**                  reported by BTA_DM_SP_KEY_NOTIF_EVT
1225**
1226** Returns          void
1227**
1228*******************************************************************************/
1229BTA_API extern void BTA_DmPasskeyCancel(BD_ADDR bd_addr);
1230
1231/*******************************************************************************
1232**
1233** Function         BTA_DmAddDevice
1234**
1235** Description      This function adds a device to the security database list
1236**                  of peer devices. This function would typically be called
1237**                  at system startup to initialize the security database with
1238**                  known peer devices.  This is a direct execution function
1239**                  that may lock task scheduling on some platforms.
1240**
1241** Returns          void
1242**
1243*******************************************************************************/
1244BTA_API extern void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class,
1245                                    LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
1246                                    BOOLEAN is_trusted, UINT8 key_type,
1247                                    tBTA_IO_CAP io_cap);
1248
1249/*******************************************************************************
1250**
1251** Function         BTA_DmAddDevWithName
1252**
1253** Description      This function is newer version of  BTA_DmAddDevice()
1254**                  which added bd_name and features as input parameters.
1255**
1256**
1257** Returns          void
1258**
1259*******************************************************************************/
1260BTA_API extern void BTA_DmAddDevWithName (BD_ADDR bd_addr, DEV_CLASS dev_class,
1261                                      BD_NAME bd_name, BD_FEATURES features,
1262                                      LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask,
1263                                      BOOLEAN is_trusted, UINT8 key_type, tBTA_IO_CAP io_cap);
1264
1265/*******************************************************************************
1266**
1267** Function         BTA_DmRemoveDevice
1268**
1269** Description      This function removes a device from the security database.
1270**                  This is a direct execution function that may lock task
1271**                  scheduling on some platforms.
1272**
1273**
1274** Returns          BTA_SUCCESS if successful.
1275**                  BTA_FAIL if operation failed.
1276**
1277*******************************************************************************/
1278BTA_API extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr);
1279
1280/*******************************************************************************
1281**
1282** Function         BTA_DmAuthorizeReply
1283**
1284** Description      This function provides an authorization reply when
1285**                  authorization is requested by BTA.  The application calls
1286**                  this function after the security callback is called with
1287**                  a BTA_DM_AUTHORIZE_EVT.
1288**
1289**
1290** Returns          void
1291**
1292*******************************************************************************/
1293BTA_API extern void BTA_DmAuthorizeReply(BD_ADDR bd_addr, tBTA_SERVICE_ID service,
1294                                         tBTA_AUTH_RESP response);
1295
1296/*******************************************************************************
1297**
1298** Function         BTA_DmSignalStrength
1299**
1300** Description      This function initiates RSSI and channnel quality
1301**                  measurments. BTA_DM_SIG_STRENGTH_EVT is sent to
1302**                  application with the values of RSSI and channel
1303**                  quality
1304**
1305**
1306** Returns          void
1307**
1308*******************************************************************************/
1309BTA_API extern void BTA_DmSignalStrength(tBTA_SIG_STRENGTH_MASK mask, UINT16 period, BOOLEAN start);
1310
1311/*******************************************************************************
1312**
1313** Function         BTA_DmWriteInqTxPower
1314**
1315** Description      This command is used to write the inquiry transmit power level
1316**                  used to transmit the inquiry (ID) data packets.
1317**
1318** Parameters       tx_power - tx inquiry power to use, valid value is -70 ~ 20
1319
1320** Returns          void
1321**
1322*******************************************************************************/
1323BTA_API extern void BTA_DmWriteInqTxPower(INT8 tx_power);
1324
1325/*******************************************************************************
1326**
1327** Function         BTA_DmEirAddUUID
1328**
1329** Description      This function is called to add UUID into EIR.
1330**
1331** Parameters       tBT_UUID - UUID
1332**
1333** Returns          None
1334**
1335*******************************************************************************/
1336BTA_API extern void BTA_DmEirAddUUID (tBT_UUID *p_uuid);
1337
1338/*******************************************************************************
1339**
1340** Function         BTA_DmEirRemoveUUID
1341**
1342** Description      This function is called to remove UUID from EIR.
1343**
1344** Parameters       tBT_UUID - UUID
1345**
1346** Returns          None
1347**
1348*******************************************************************************/
1349BTA_API extern void BTA_DmEirRemoveUUID (tBT_UUID *p_uuid);
1350
1351/*******************************************************************************
1352**
1353** Function         BTA_DmSetEIRConfig
1354**
1355** Description      This function is called to override the BTA default EIR parameters.
1356**                  This funciton is only valid in a system where BTU & App task
1357**                  are in the same memory space.
1358**
1359** Parameters       Pointer to User defined EIR config
1360**
1361** Returns          None
1362**
1363*******************************************************************************/
1364BTA_API extern void BTA_DmSetEIRConfig (tBTA_DM_EIR_CONF *p_eir_cfg);
1365
1366/*******************************************************************************
1367**
1368** Function         BTA_CheckEirData
1369**
1370** Description      This function is called to get EIR data from significant part.
1371**
1372** Parameters       p_eir - pointer of EIR significant part
1373**                  type   - finding EIR data type
1374**                  p_length - return the length of EIR data
1375**
1376** Returns          pointer of EIR data
1377**
1378*******************************************************************************/
1379BTA_API extern UINT8 *BTA_CheckEirData( UINT8 *p_eir, UINT8 tag, UINT8 *p_length );
1380
1381/*******************************************************************************
1382**
1383** Function         BTA_GetEirService
1384**
1385** Description      This function is called to get BTA service mask from EIR.
1386**
1387** Parameters       p_eir - pointer of EIR significant part
1388**                  p_services - return the BTA service mask
1389**
1390** Returns          None
1391**
1392*******************************************************************************/
1393BTA_API extern void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services );
1394
1395/*******************************************************************************
1396**
1397** Function         BTA_DmUseSsr
1398**
1399** Description      This function is called to check if the connected peer device
1400**                  supports SSR or not.
1401**
1402** Returns          TRUE, if SSR is supported
1403**
1404*******************************************************************************/
1405BTA_API extern BOOLEAN BTA_DmUseSsr( BD_ADDR bd_addr );
1406
1407
1408/*******************************************************************************
1409**
1410** Function         BTA_DmSetLocalDiRecord
1411**
1412** Description      This function adds a DI record to the local SDP database.
1413**
1414** Returns          BTA_SUCCESS if record set sucessfully, otherwise error code.
1415**
1416*******************************************************************************/
1417BTA_API extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
1418	                          UINT32 *p_handle );
1419
1420/*******************************************************************************
1421**
1422** Function         BTA_DmGetLocalDiRecord
1423**
1424** Description      Get a specified DI record to the local SDP database. If no
1425**                  record handle is provided, the primary DI record will be
1426**                  returned.
1427**
1428** Returns          BTA_SUCCESS if record set sucessfully, otherwise error code.
1429**
1430*******************************************************************************/
1431BTA_API extern tBTA_STATUS BTA_DmGetLocalDiRecord( tBTA_DI_GET_RECORD *p_device_info,
1432	                          UINT32 *p_handle );
1433
1434/*******************************************************************************
1435**
1436** Function         BTA_DmDiDiscover
1437**
1438** Description      This function queries a remote device for DI information.
1439**
1440** Returns          None.
1441**
1442*******************************************************************************/
1443BTA_API extern void BTA_DmDiDiscover( BD_ADDR remote_device, tBTA_DISCOVERY_DB *p_db,
1444                       UINT32 len, tBTA_DM_SEARCH_CBACK *p_cback );
1445
1446/*******************************************************************************
1447**
1448** Function         BTA_DmGetDiRecord
1449**
1450** Description      This function retrieves a remote device's DI record from
1451**                  the specified database.
1452**
1453** Returns          None.
1454**
1455*******************************************************************************/
1456BTA_API extern tBTA_STATUS BTA_DmGetDiRecord( UINT8 get_record_index, tBTA_DI_GET_RECORD *p_device_info,
1457                        tBTA_DISCOVERY_DB *p_db );
1458
1459/*******************************************************************************
1460**
1461** Function         BTA_SysFeatures
1462**
1463** Description      This function is called to set system features.
1464**
1465** Returns          void
1466**
1467*******************************************************************************/
1468BTA_API extern void BTA_SysFeatures (UINT16 sys_features);
1469
1470/*******************************************************************************
1471**
1472** Function         bta_dmexecutecallback
1473**
1474** Description      This function will request BTA to execute a call back in the context of BTU task
1475**                  This API was named in lower case because it is only intended
1476**                  for the internal customers(like BTIF).
1477**
1478** Returns          void
1479**
1480*******************************************************************************/
1481BTA_API extern void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param);
1482
1483#if (BTM_SCO_HCI_INCLUDED == TRUE)
1484/*******************************************************************************
1485**
1486** Function         BTA_DmPcmInitSamples
1487**
1488** Description      initialize the down sample converter.
1489**
1490**                  src_sps: original samples per second (source audio data)
1491**                            (ex. 44100, 48000)
1492**                  bits: number of bits per pcm sample (16)
1493**                  n_channels: number of channels (i.e. mono(1), stereo(2)...)
1494**
1495** Returns          none
1496**
1497*******************************************************************************/
1498BTA_API extern void BTA_DmPcmInitSamples (UINT32 src_sps, UINT32 bits, UINT32 n_channels);
1499
1500/**************************************************************************************
1501** Function         BTA_DmPcmResample
1502**
1503** Description      Down sampling utility to convert higher sampling rate into 8K/16bits
1504**                  PCM samples.
1505**
1506** Parameters       p_src: pointer to the buffer where the original sampling PCM
1507**                              are stored.
1508**                  in_bytes:  Length of the input PCM sample buffer in byte.
1509**                  p_dst:      pointer to the buffer which is to be used to store
1510**                              the converted PCM samples.
1511**
1512**
1513** Returns          INT32: number of samples converted.
1514**
1515**************************************************************************************/
1516BTA_API extern INT32 BTA_DmPcmResample (void *p_src, UINT32 in_bytes, void *p_dst);
1517#endif
1518
1519#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
1520/* BLE related API functions */
1521/*******************************************************************************
1522**
1523** Function         BTA_DmBleSecurityGrant
1524**
1525** Description      Grant security request access.
1526**
1527** Parameters:      bd_addr          - BD address of the peer
1528**                  res              - security grant status.
1529**
1530** Returns          void
1531**
1532*******************************************************************************/
1533BTA_API extern void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res);
1534
1535
1536
1537/*******************************************************************************
1538**
1539** Function         BTA_DmBleSetBgConnType
1540**
1541** Description      This function is called to set BLE connectable mode for a
1542**                  peripheral device.
1543**
1544** Parameters       bg_conn_type: it can be auto connection, or selective connection.
1545**                  p_select_cback: callback function when selective connection procedure
1546**                              is being used.
1547**
1548** Returns          void
1549**
1550*******************************************************************************/
1551BTA_API extern void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_CBACK *p_select_cback);
1552
1553/*******************************************************************************
1554**
1555** Function         BTA_DmBlePasskeyReply
1556**
1557** Description      Send BLE SMP passkey reply.
1558**
1559** Parameters:      bd_addr          - BD address of the peer
1560**                  accept           - passkey entry sucessful or declined.
1561**                  passkey          - passkey value, must be a 6 digit number,
1562**                                     can be lead by 0.
1563**
1564** Returns          void
1565**
1566*******************************************************************************/
1567BTA_API extern void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey);
1568
1569/*******************************************************************************
1570**
1571** Function         BTA_DmAddBleDevice
1572**
1573** Description      Add a BLE device.  This function will be normally called
1574**                  during host startup to restore all required information
1575**                  for a LE device stored in the NVRAM.
1576**
1577** Parameters:      bd_addr          - BD address of the peer
1578**                  dev_type         - Remote device's device type.
1579**                  addr_type        - LE device address type.
1580**
1581** Returns          void
1582**
1583*******************************************************************************/
1584BTA_API extern void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type,
1585                                       tBT_DEVICE_TYPE dev_type);
1586
1587
1588/*******************************************************************************
1589**
1590** Function         BTA_DmAddBleKey
1591**
1592** Description      Add/modify LE device information.  This function will be
1593**                  normally called during host startup to restore all required
1594**                  information stored in the NVRAM.
1595**
1596** Parameters:      bd_addr          - BD address of the peer
1597**                  p_le_key         - LE key values.
1598**                  key_type         - LE SMP key type.
1599**
1600** Returns          void
1601**
1602*******************************************************************************/
1603BTA_API extern void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key,
1604                                     tBTA_LE_KEY_TYPE key_type);
1605
1606/*******************************************************************************
1607**
1608** Function         BTA_DmSetBlePrefConnParams
1609**
1610** Description      This function is called to set the preferred connection
1611**                  parameters when default connection parameter is not desired.
1612**
1613** Parameters:      bd_addr          - BD address of the peripheral
1614**                  min_conn_int     - minimum preferred connection interval
1615**                  max_conn_int     - maximum preferred connection interval
1616**                  slave_latency    - preferred slave latency
1617**                  supervision_tout - preferred supervision timeout
1618**
1619**
1620** Returns          void
1621**
1622*******************************************************************************/
1623BTA_API extern void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
1624                               UINT16 min_conn_int, UINT16 max_conn_int,
1625                               UINT16 slave_latency, UINT16 supervision_tout );
1626
1627/*******************************************************************************
1628**
1629** Function         BTA_DmSetBleConnScanParams
1630**
1631** Description      This function is called to set scan parameters used in
1632**                  BLE connection request
1633**
1634** Parameters:      bd_addr          - BD address of the peripheral
1635**                  scan_interval    - scan interval
1636**                  scan_window      - scan window
1637**
1638** Returns          void
1639**
1640*******************************************************************************/
1641BTA_API extern void BTA_DmSetBleConnScanParams(UINT16 scan_interval,
1642                                               UINT16 scan_window );
1643
1644/*******************************************************************************
1645**
1646** Function         BTA_DmSearchExt
1647**
1648** Description      This function searches for peer Bluetooth devices. It performs
1649**                  an inquiry and gets the remote name for devices. Service
1650**                  discovery is done if services is non zero
1651**
1652** Parameters       p_dm_inq: inquiry conditions
1653**                  services: if service is not empty, service discovery will be done.
1654**                            for all GATT based service condition, put num_uuid, and
1655**                            p_uuid is the pointer to the list of UUID values.
1656**                  p_cback: callback functino when search is completed.
1657**
1658**
1659**
1660** Returns          void
1661**
1662*******************************************************************************/
1663BTA_API extern void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services,
1664                                    tBTA_DM_SEARCH_CBACK *p_cback);
1665
1666/*******************************************************************************
1667**
1668** Function         BTA_DmDiscoverExt
1669**
1670** Description      This function does service discovery for services of a
1671**                  peer device. When services.num_uuid is 0, it indicates all
1672**                  GATT based services are to be searched; other wise a list of
1673**                  UUID of interested services should be provided through
1674**                  services.p_uuid.
1675**
1676**
1677**
1678** Returns          void
1679**
1680*******************************************************************************/
1681BTA_API extern void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
1682                                    tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
1683
1684
1685/*******************************************************************************
1686**
1687** Function         BTA_DmSetEncryption
1688**
1689** Description      This function is called to ensure that connection is
1690**                  encrypted.  Should be called only on an open connection.
1691**                  Typically only needed for connections that first want to
1692**                  bring up unencrypted links, then later encrypt them.
1693**
1694** Parameters:      bd_addr       - Address of the peer device
1695**                  p_callback    - Pointer to callback function to indicat the
1696**                                  link encryption status
1697**                  sec_act       - This is the security action to indicate
1698**                                  what knid of BLE security level is required for
1699**                                  the BLE link if the BLE is supported
1700**                                  Note: This parameter is ignored for the BR/EDR link
1701**                                        or the BLE is not supported
1702**
1703** Returns          void
1704**
1705**
1706*******************************************************************************/
1707BTA_API extern void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_DM_ENCRYPT_CBACK *p_callback,
1708                            tBTA_DM_BLE_SEC_ACT sec_act);
1709
1710#endif
1711
1712// btla-specific ++
1713/*******************************************************************************
1714**
1715** Function         BTA_DmSetAfhChannelAssessment
1716**
1717** Description      This function is called to set the channel assessment mode on or off
1718**
1719** Returns          status
1720**
1721*******************************************************************************/
1722BTA_API extern void BTA_DmSetAfhChannelAssessment (BOOLEAN enable_or_disable);
1723// btla-specific --
1724
1725#ifdef __cplusplus
1726}
1727#endif
1728
1729#endif /* BTA_API_H */
1730
1731