btm_api.h revision 6afb248849399cfba59fb1e683a06e31d88e5d1d
1/******************************************************************************
2 *
3 *  Copyright (C) 1999-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 file contains the Bluetooth Manager (BTM) API function external
22 *  definitions.
23 *
24 ******************************************************************************/
25#ifndef BTM_API_H
26#define BTM_API_H
27
28#include "bt_target.h"
29#include "sdp_api.h"
30#include "hcidefs.h"
31
32#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
33#include "smp_api.h"
34#endif
35/*****************************************************************************
36**  DEVICE CONTROL and COMMON
37*****************************************************************************/
38/*****************************
39**  Device Control Constants
40******************************/
41/* Maximum number of bytes allowed for vendor specific command parameters */
42#define BTM_MAX_VENDOR_SPECIFIC_LEN  HCI_COMMAND_SIZE
43
44/* BTM application return status codes */
45enum
46{
47    BTM_SUCCESS = 0,                    /* 0  Command succeeded                 */
48    BTM_CMD_STARTED,                    /* 1  Command started OK.               */
49    BTM_BUSY,                           /* 2  Device busy with another command  */
50    BTM_NO_RESOURCES,                   /* 3  No resources to issue command     */
51    BTM_MODE_UNSUPPORTED,               /* 4  Request for 1 or more unsupported modes */
52    BTM_ILLEGAL_VALUE,                  /* 5  Illegal parameter value           */
53    BTM_WRONG_MODE,                     /* 6  Device in wrong mode for request  */
54    BTM_UNKNOWN_ADDR,                   /* 7  Unknown remote BD address         */
55    BTM_DEVICE_TIMEOUT,                 /* 8  Device timeout                    */
56    BTM_BAD_VALUE_RET,                  /* 9  A bad value was received from HCI */
57    BTM_ERR_PROCESSING,                 /* 10 Generic error                     */
58    BTM_NOT_AUTHORIZED,                 /* 11 Authorization failed              */
59    BTM_DEV_RESET,                      /* 12 Device has been reset             */
60    BTM_CMD_STORED,                     /* 13 request is stored in control block */
61    BTM_ILLEGAL_ACTION,                 /* 14 state machine gets illegal command */
62    BTM_DELAY_CHECK,                    /* 15 delay the check on encryption */
63    BTM_SCO_BAD_LENGTH,                 /* 16 Bad SCO over HCI data length */
64    BTM_SUCCESS_NO_SECURITY,            /* 17 security passed, no security set  */
65    BTM_FAILED_ON_SECURITY ,             /* 18 security failed                   */
66    BTM_REPEATED_ATTEMPTS               /* 19 repeated attempts for LE security requests */
67};
68typedef UINT8 tBTM_STATUS;
69
70#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
71typedef enum
72{
73    BTM_BR_ONE,                         /*0 First state or BR/EDR scan 1*/
74    BTM_BLE_ONE,                        /*1BLE scan 1*/
75    BTM_BR_TWO,                         /*2 BR/EDR scan 2*/
76    BTM_BLE_TWO,                        /*3 BLE scan 2*/
77    BTM_FINISH,                         /*4 End of Interleave Scan, or normal scan*/
78    BTM_NO_INTERLEAVING                 /*5 No Interleaving*/
79}btm_inq_state;
80#endif
81
82
83
84/*************************
85**  Device Control Types
86**************************/
87#define BTM_DEVICE_ROLE_BR      0x01
88#define BTM_DEVICE_ROLE_DUAL    0x02
89#define BTM_MAX_DEVICE_ROLE     BTM_DEVICE_ROLE_DUAL
90typedef UINT8 tBTM_DEVICE_ROLE;
91
92/* Device name of peer (may be truncated to save space in BTM database) */
93typedef UINT8 tBTM_BD_NAME[BTM_MAX_REM_BD_NAME_LEN + 1];
94
95/* Structure returned with local version information */
96typedef struct
97{
98    UINT8       hci_version;
99    UINT16      hci_revision;
100    UINT8       lmp_version;
101    UINT16      manufacturer;
102    UINT16      lmp_subversion;
103} tBTM_VERSION_INFO;
104
105/* Structure returned with Vendor Specific Command complete callback */
106typedef struct
107{
108    UINT16  opcode;
109    UINT16  param_len;
110    UINT8   *p_param_buf;
111} tBTM_VSC_CMPL;
112
113#define  BTM_VSC_CMPL_DATA_SIZE  (BTM_MAX_VENDOR_SPECIFIC_LEN + sizeof(tBTM_VSC_CMPL))
114/**************************************************
115**  Device Control and General Callback Functions
116***************************************************/
117/* Callback function for when device status changes. Appl must poll for
118** what the new state is (BTM_IsDeviceUp). The event occurs whenever the stack
119** has detected that the controller status has changed. This asynchronous event
120** is enabled/disabled by calling BTM_RegisterForDeviceStatusNotif().
121*/
122enum
123{
124    BTM_DEV_STATUS_UP,
125    BTM_DEV_STATUS_DOWN,
126    BTM_DEV_STATUS_CMD_TOUT
127};
128
129typedef UINT8 tBTM_DEV_STATUS;
130
131
132typedef void (tBTM_DEV_STATUS_CB) (tBTM_DEV_STATUS status);
133
134
135/* Callback function for when a vendor specific event occurs. The length and
136** array of returned parameter bytes are included. This asynchronous event
137** is enabled/disabled by calling BTM_RegisterForVSEvents().
138*/
139typedef void (tBTM_VS_EVT_CB) (UINT8 len, UINT8 *p);
140
141
142/* General callback function for notifying an application that a synchronous
143** BTM function is complete. The pointer contains the address of any returned data.
144*/
145typedef void (tBTM_CMPL_CB) (void *p1);
146
147/* VSC callback function for notifying an application that a synchronous
148** BTM function is complete. The pointer contains the address of any returned data.
149*/
150typedef void (tBTM_VSC_CMPL_CB) (tBTM_VSC_CMPL *p1);
151
152/* Callback for apps to check connection and inquiry filters.
153** Parameters are the BD Address of remote and the Dev Class of remote.
154** If the app returns none zero, the connection or inquiry result will be dropped.
155*/
156typedef UINT8 (tBTM_FILTER_CB) (BD_ADDR bd_addr, DEV_CLASS dc);
157
158/*****************************************************************************
159**  DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device
160*****************************************************************************/
161/*******************************
162**  Device Discovery Constants
163********************************/
164/* Discoverable modes */
165#define BTM_NON_DISCOVERABLE        0
166#define BTM_LIMITED_DISCOVERABLE    1
167#define BTM_GENERAL_DISCOVERABLE    2
168#define BTM_DISCOVERABLE_MASK       (BTM_LIMITED_DISCOVERABLE|BTM_GENERAL_DISCOVERABLE)
169#define BTM_MAX_DISCOVERABLE        BTM_GENERAL_DISCOVERABLE
170/* high byte for BLE Discoverable modes */
171#define BTM_BLE_NON_DISCOVERABLE        0x0000
172#define BTM_BLE_LIMITED_DISCOVERABLE    0x0100
173#define BTM_BLE_GENERAL_DISCOVERABLE    0x0200
174#define BTM_BLE_MAX_DISCOVERABLE        BTM_BLE_GENERAL_DISCOVERABLE
175#define BTM_BLE_DISCOVERABLE_MASK       (BTM_BLE_NON_DISCOVERABLE|BTM_BLE_LIMITED_DISCOVERABLE|BTM_BLE_GENERAL_DISCOVERABLE)
176
177/* Connectable modes */
178#define BTM_NON_CONNECTABLE         0
179#define BTM_CONNECTABLE             1
180#define BTM_CONNECTABLE_MASK        (BTM_NON_CONNECTABLE | BTM_CONNECTABLE)
181/* high byte for BLE Connectable modes */
182#define BTM_BLE_NON_CONNECTABLE      0x0000
183#define BTM_BLE_CONNECTABLE          0x0100
184#define BTM_BLE_MAX_CONNECTABLE      BTM_BLE_CONNECTABLE
185#define BTM_BLE_CONNECTABLE_MASK    (BTM_BLE_NON_CONNECTABLE | BTM_BLE_CONNECTABLE)
186
187/* Inquiry modes
188 * Note: These modes are associated with the inquiry active values (BTM_*ACTIVE) */
189#define BTM_INQUIRY_NONE            0
190#define BTM_GENERAL_INQUIRY         0x01
191#define BTM_LIMITED_INQUIRY         0x02
192#define BTM_BR_INQUIRY_MASK         (BTM_GENERAL_INQUIRY | BTM_LIMITED_INQUIRY)
193
194/* high byte of inquiry mode for BLE inquiry mode */
195#define BTM_BLE_INQUIRY_NONE         0x00
196#define BTM_BLE_GENERAL_INQUIRY      0x10
197#define BTM_BLE_LIMITED_INQUIRY      0x20
198#define BTM_BLE_INQUIRY_MASK         (BTM_BLE_GENERAL_INQUIRY|BTM_BLE_LIMITED_INQUIRY)
199
200/* BTM_IsInquiryActive return values (Bit Mask)
201 * Note: These bit masks are associated with the inquiry modes (BTM_*_INQUIRY) */
202#define BTM_INQUIRY_INACTIVE        0x0     /* no inquiry in progress */
203#define BTM_GENERAL_INQUIRY_ACTIVE  BTM_GENERAL_INQUIRY     /* a general inquiry is in progress */
204#define BTM_LIMITED_INQUIRY_ACTIVE  BTM_LIMITED_INQUIRY     /* a limited inquiry is in progress */
205#define BTM_PERIODIC_INQUIRY_ACTIVE 0x8     /* a periodic inquiry is active */
206#define BTM_SSP_INQUIRY_ACTIVE      0x4     /* SSP is active, so inquiry is disallowed (work around for FW bug) */
207#define BTM_LE_GENERAL_INQUIRY_ACTIVE  BTM_BLE_GENERAL_INQUIRY     /* a general inquiry is in progress */
208#define BTM_LE_LIMITED_INQUIRY_ACTIVE  BTM_BLE_LIMITED_INQUIRY      /* a limited inquiry is in progress */
209#define BTM_LE_SELECT_CONN_ACTIVE   0x40     /* selection connection is in progress */
210#define BTM_LE_OBSERVE_ACTIVE       0x80     /* selection connection is in progress */
211
212/* inquiry activity mask */
213#define BTM_BR_INQ_ACTIVE_MASK        (BTM_GENERAL_INQUIRY_ACTIVE|BTM_LIMITED_INQUIRY_ACTIVE|BTM_PERIODIC_INQUIRY_ACTIVE) /* BR/EDR inquiry activity mask */
214#define BTM_BLE_SCAN_ACTIVE_MASK      0xF0     /* LE scan activity mask */
215#define BTM_BLE_INQ_ACTIVE_MASK       (BTM_LE_GENERAL_INQUIRY_ACTIVE|BTM_LE_LIMITED_INQUIRY_ACTIVE) /* LE inquiry activity mask*/
216#define BTM_INQUIRY_ACTIVE_MASK       (BTM_BR_INQ_ACTIVE_MASK | BTM_BLE_INQ_ACTIVE_MASK) /* inquiry activity mask */
217
218/* Define scan types */
219#define BTM_SCAN_TYPE_STANDARD      0
220#define BTM_SCAN_TYPE_INTERLACED    1       /* 1.2 devices only */
221
222/* Define inquiry results mode */
223#define BTM_INQ_RESULT_STANDARD     0
224#define BTM_INQ_RESULT_WITH_RSSI    1
225#define BTM_INQ_RESULT_EXTENDED     2
226
227#define BTM_INQ_RES_IGNORE_RSSI     0x7f    /* RSSI value not supplied (ignore it) */
228
229/* Inquiry Filter Condition types (see tBTM_INQ_PARMS) */
230#define BTM_CLR_INQUIRY_FILTER          0                   /* Inquiry Filtering is turned off */
231#define BTM_FILTER_COND_DEVICE_CLASS    HCI_FILTER_COND_DEVICE_CLASS /* Filter on device class */
232#define BTM_FILTER_COND_BD_ADDR         HCI_FILTER_COND_BD_ADDR /* Filter on device addr */
233
234/* State of the remote name retrieval during inquiry operations.
235** Used in the tBTM_INQ_INFO structure, and returned in the
236** BTM_InqDbRead, BTM_InqDbFirst, and BTM_InqDbNext functions.
237** The name field is valid when the state returned is
238** BTM_INQ_RMT_NAME_DONE */
239#define BTM_INQ_RMT_NAME_EMPTY      0
240#define BTM_INQ_RMT_NAME_PENDING    1
241#define BTM_INQ_RMT_NAME_DONE       2
242#define BTM_INQ_RMT_NAME_FAILED     3
243
244/*********************************
245 *** Class of Device constants ***
246 *********************************/
247#define BTM_FORMAT_TYPE_1   0x00
248
249/****************************
250** minor device class field
251*****************************/
252
253/* 0x00 is used as unclassified for all minor device classes */
254#define BTM_COD_MINOR_UNCLASSIFIED          0x00
255
256/* minor device class field for Computer Major Class */
257/* #define BTM_COD_MINOR_UNCLASSIFIED       0x00    */
258#define BTM_COD_MINOR_DESKTOP_WORKSTATION   0x04
259#define BTM_COD_MINOR_SERVER_COMPUTER       0x08
260#define BTM_COD_MINOR_LAPTOP                0x0C
261#define BTM_COD_MINOR_HANDHELD_PC_PDA       0x10    /* clam shell */
262#define BTM_COD_MINOR_PALM_SIZE_PC_PDA      0x14
263#define BTM_COD_MINOR_WEARABLE_COMPUTER     0x18    /* watch sized */
264
265/* minor device class field for Phone Major Class */
266/* #define BTM_COD_MINOR_UNCLASSIFIED       0x00    */
267#define BTM_COD_MINOR_CELLULAR              0x04
268#define BTM_COD_MINOR_CORDLESS              0x08
269#define BTM_COD_MINOR_SMART_PHONE           0x0C
270#define BTM_COD_MINOR_WIRED_MDM_V_GTWY      0x10 /* wired modem or voice gatway */
271#define BTM_COD_MINOR_ISDN_ACCESS           0x14
272
273/* minor device class field for LAN Access Point Major Class */
274/* Load Factor Field bit 5-7 */
275#define BTM_COD_MINOR_FULLY_AVAILABLE       0x00
276#define BTM_COD_MINOR_1_17_UTILIZED         0x20
277#define BTM_COD_MINOR_17_33_UTILIZED        0x40
278#define BTM_COD_MINOR_33_50_UTILIZED        0x60
279#define BTM_COD_MINOR_50_67_UTILIZED        0x80
280#define BTM_COD_MINOR_67_83_UTILIZED        0xA0
281#define BTM_COD_MINOR_83_99_UTILIZED        0xC0
282#define BTM_COD_MINOR_NO_SERVICE_AVAILABLE  0xE0
283/* sub-Field bit 2-4 */
284/* #define BTM_COD_MINOR_UNCLASSIFIED       0x00    */
285
286/* minor device class field for Audio/Video Major Class */
287/* #define BTM_COD_MINOR_UNCLASSIFIED       0x00    */
288#define BTM_COD_MINOR_CONFM_HEADSET         0x04
289#define BTM_COD_MINOR_CONFM_HANDSFREE       0x08
290#define BTM_COD_MINOR_MICROPHONE            0x10
291#define BTM_COD_MINOR_LOUDSPEAKER           0x14
292#define BTM_COD_MINOR_HEADPHONES            0x18
293#define BTM_COD_MINOR_PORTABLE_AUDIO        0x1C
294#define BTM_COD_MINOR_CAR_AUDIO             0x20
295#define BTM_COD_MINOR_SET_TOP_BOX           0x24
296#define BTM_COD_MINOR_HIFI_AUDIO            0x28
297#define BTM_COD_MINOR_VCR                   0x2C
298#define BTM_COD_MINOR_VIDEO_CAMERA          0x30
299#define BTM_COD_MINOR_CAMCORDER             0x34
300#define BTM_COD_MINOR_VIDEO_MONITOR         0x38
301#define BTM_COD_MINOR_VIDDISP_LDSPKR        0x3C
302#define BTM_COD_MINOR_VIDEO_CONFERENCING    0x40
303#define BTM_COD_MINOR_GAMING_TOY            0x48
304
305/* minor device class field for Peripheral Major Class */
306/* Bits 6-7 independently specify mouse, keyboard, or combo mouse/keyboard */
307#define BTM_COD_MINOR_KEYBOARD              0x40
308#define BTM_COD_MINOR_POINTING              0x80
309#define BTM_COD_MINOR_COMBO                 0xC0
310/* Bits 2-5 OR'd with selection from bits 6-7 */
311/* #define BTM_COD_MINOR_UNCLASSIFIED       0x00    */
312#define BTM_COD_MINOR_JOYSTICK              0x04
313#define BTM_COD_MINOR_GAMEPAD               0x08
314#define BTM_COD_MINOR_REMOTE_CONTROL        0x0C
315#define BTM_COD_MINOR_SENSING_DEVICE        0x10
316#define BTM_COD_MINOR_DIGITIZING_TABLET     0x14
317#define BTM_COD_MINOR_CARD_READER           0x18    /* e.g. SIM card reader */
318#define BTM_COD_MINOR_DIGITAL_PAN           0x1C
319#define BTM_COD_MINOR_HAND_SCANNER          0x20
320#define BTM_COD_MINOR_HAND_GESTURAL_INPUT   0x24
321
322/* minor device class field for Imaging Major Class */
323/* Bits 5-7 independently specify display, camera, scanner, or printer */
324#define BTM_COD_MINOR_DISPLAY               0x10
325#define BTM_COD_MINOR_CAMERA                0x20
326#define BTM_COD_MINOR_SCANNER               0x40
327#define BTM_COD_MINOR_PRINTER               0x80
328/* Bits 2-3 Reserved */
329/* #define BTM_COD_MINOR_UNCLASSIFIED       0x00    */
330
331/* minor device class field for Wearable Major Class */
332/* Bits 2-7 meaningful    */
333#define BTM_COD_MINOR_WRIST_WATCH           0x04
334#define BTM_COD_MINOR_PAGER                 0x08
335#define BTM_COD_MINOR_JACKET                0x0C
336#define BTM_COD_MINOR_HELMET                0x10
337#define BTM_COD_MINOR_GLASSES               0x14
338
339/* minor device class field for Toy Major Class */
340/* Bits 2-7 meaningful    */
341#define BTM_COD_MINOR_ROBOT                 0x04
342#define BTM_COD_MINOR_VEHICLE               0x08
343#define BTM_COD_MINOR_DOLL_ACTION_FIGURE    0x0C
344#define BTM_COD_MINOR_CONTROLLER            0x10
345#define BTM_COD_MINOR_GAME                  0x14
346
347/* minor device class field for Health Major Class */
348/* Bits 2-7 meaningful    */
349#define BTM_COD_MINOR_BLOOD_MONITOR         0x04
350#define BTM_COD_MINOR_THERMOMETER           0x08
351#define BTM_COD_MINOR_WEIGHING_SCALE        0x0C
352#define BTM_COD_MINOR_GLUCOSE_METER         0x10
353#define BTM_COD_MINOR_PULSE_OXIMETER        0x14
354#define BTM_COD_MINOR_HEART_PULSE_MONITOR   0x18
355#define BTM_COD_MINOR_HEALTH_DATA_DISPLAY   0x1C
356#define BTM_COD_MINOR_STEP_COUNTER          0x20
357#define BTM_COD_MINOR_BODY_COM_ANALYZER     0x24
358#define BTM_COD_MINOR_PEAK_FLOW_MONITOR     0x28
359#define BTM_COD_MINOR_MEDICATION_MONITOR    0x2C
360#define BTM_COD_MINOR_KNEE_PROSTHESIS       0x30
361#define BTM_COD_MINOR_ANKLE_PROSTHESIS      0x34
362
363
364/***************************
365** major device class field
366****************************/
367#define BTM_COD_MAJOR_MISCELLANEOUS         0x00
368#define BTM_COD_MAJOR_COMPUTER              0x01
369#define BTM_COD_MAJOR_PHONE                 0x02
370#define BTM_COD_MAJOR_LAN_ACCESS_PT         0x03
371#define BTM_COD_MAJOR_AUDIO                 0x04
372#define BTM_COD_MAJOR_PERIPHERAL            0x05
373#define BTM_COD_MAJOR_IMAGING               0x06
374#define BTM_COD_MAJOR_WEARABLE              0x07
375#define BTM_COD_MAJOR_TOY                   0x08
376#define BTM_COD_MAJOR_HEALTH                0x09
377#define BTM_COD_MAJOR_UNCLASSIFIED          0x1F
378
379/***************************
380** service class fields
381****************************/
382#define BTM_COD_SERVICE_LMTD_DISCOVER       0x0020
383#define BTM_COD_SERVICE_POSITIONING         0x0100
384#define BTM_COD_SERVICE_NETWORKING          0x0200
385#define BTM_COD_SERVICE_RENDERING           0x0400
386#define BTM_COD_SERVICE_CAPTURING           0x0800
387#define BTM_COD_SERVICE_OBJ_TRANSFER        0x1000
388#define BTM_COD_SERVICE_AUDIO               0x2000
389#define BTM_COD_SERVICE_TELEPHONY           0x4000
390#define BTM_COD_SERVICE_INFORMATION         0x8000
391
392/* class of device field macros */
393#define BTM_COD_FORMAT_TYPE(u8, pd)         {u8  = pd[2]&0x03;}
394#define BTM_COD_MINOR_CLASS(u8, pd)         {u8  = pd[2]&0xFC;}
395#define BTM_COD_MAJOR_CLASS(u8, pd)         {u8  = pd[1]&0x1F;}
396#define BTM_COD_SERVICE_CLASS(u16, pd)      {u16 = pd[0]; u16<<=8; u16 += pd[1]&0xE0;}
397
398/* to set the fields (assumes that format type is always 0) */
399#define FIELDS_TO_COD(pd, mn, mj, sv) {pd[2] = mn; pd[1] =              \
400                                       mj+ ((sv)&BTM_COD_SERVICE_CLASS_LO_B); \
401                                       pd[0] = (sv) >> 8;}
402
403/* the COD masks */
404#define BTM_COD_FORMAT_TYPE_MASK      0x03
405#define BTM_COD_MINOR_CLASS_MASK      0xFC
406#define BTM_COD_MAJOR_CLASS_MASK      0x1F
407#define BTM_COD_SERVICE_CLASS_LO_B    0x00E0
408#define BTM_COD_SERVICE_CLASS_MASK    0xFFE0
409
410
411/* BTM service definitions
412** Used for storing EIR data to bit mask
413*/
414enum
415{
416    BTM_EIR_UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER,
417/*    BTM_EIR_UUID_SERVCLASS_BROWSE_GROUP_DESCRIPTOR,   */
418/*    BTM_EIR_UUID_SERVCLASS_PUBLIC_BROWSE_GROUP,       */
419    BTM_EIR_UUID_SERVCLASS_SERIAL_PORT,
420    BTM_EIR_UUID_SERVCLASS_LAN_ACCESS_USING_PPP,
421    BTM_EIR_UUID_SERVCLASS_DIALUP_NETWORKING,
422    BTM_EIR_UUID_SERVCLASS_IRMC_SYNC,
423    BTM_EIR_UUID_SERVCLASS_OBEX_OBJECT_PUSH,
424    BTM_EIR_UUID_SERVCLASS_OBEX_FILE_TRANSFER,
425    BTM_EIR_UUID_SERVCLASS_IRMC_SYNC_COMMAND,
426    BTM_EIR_UUID_SERVCLASS_HEADSET,
427    BTM_EIR_UUID_SERVCLASS_CORDLESS_TELEPHONY,
428    BTM_EIR_UUID_SERVCLASS_AUDIO_SOURCE,
429    BTM_EIR_UUID_SERVCLASS_AUDIO_SINK,
430    BTM_EIR_UUID_SERVCLASS_AV_REM_CTRL_TARGET,
431/*    BTM_EIR_UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION,    */
432    BTM_EIR_UUID_SERVCLASS_AV_REMOTE_CONTROL,
433/*    BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING,        */
434    BTM_EIR_UUID_SERVCLASS_INTERCOM,
435    BTM_EIR_UUID_SERVCLASS_FAX,
436    BTM_EIR_UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY,
437/*    BTM_EIR_UUID_SERVCLASS_WAP,                       */
438/*    BTM_EIR_UUID_SERVCLASS_WAP_CLIENT,                */
439    BTM_EIR_UUID_SERVCLASS_PANU,
440    BTM_EIR_UUID_SERVCLASS_NAP,
441    BTM_EIR_UUID_SERVCLASS_GN,
442    BTM_EIR_UUID_SERVCLASS_DIRECT_PRINTING,
443/*    BTM_EIR_UUID_SERVCLASS_REFERENCE_PRINTING,        */
444    BTM_EIR_UUID_SERVCLASS_IMAGING,
445    BTM_EIR_UUID_SERVCLASS_IMAGING_RESPONDER,
446    BTM_EIR_UUID_SERVCLASS_IMAGING_AUTO_ARCHIVE,
447    BTM_EIR_UUID_SERVCLASS_IMAGING_REF_OBJECTS,
448    BTM_EIR_UUID_SERVCLASS_HF_HANDSFREE,
449    BTM_EIR_UUID_SERVCLASS_AG_HANDSFREE,
450    BTM_EIR_UUID_SERVCLASS_DIR_PRT_REF_OBJ_SERVICE,
451/*    BTM_EIR_UUID_SERVCLASS_REFLECTED_UI,              */
452    BTM_EIR_UUID_SERVCLASS_BASIC_PRINTING,
453    BTM_EIR_UUID_SERVCLASS_PRINTING_STATUS,
454    BTM_EIR_UUID_SERVCLASS_HUMAN_INTERFACE,
455    BTM_EIR_UUID_SERVCLASS_CABLE_REPLACEMENT,
456    BTM_EIR_UUID_SERVCLASS_HCRP_PRINT,
457    BTM_EIR_UUID_SERVCLASS_HCRP_SCAN,
458/*    BTM_EIR_UUID_SERVCLASS_COMMON_ISDN_ACCESS,        */
459/*    BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING_GW,     */
460/*    BTM_EIR_UUID_SERVCLASS_UDI_MT,                    */
461/*    BTM_EIR_UUID_SERVCLASS_UDI_TA,                    */
462/*    BTM_EIR_UUID_SERVCLASS_VCP,                       */
463    BTM_EIR_UUID_SERVCLASS_SAP,
464    BTM_EIR_UUID_SERVCLASS_PBAP_PCE,
465    BTM_EIR_UUID_SERVCLASS_PBAP_PSE,
466/*    BTM_EIR_UUID_SERVCLASS_TE_PHONE_ACCESS,           */
467/*    BTM_EIR_UUID_SERVCLASS_ME_PHONE_ACCESS,           */
468    BTM_EIR_UUID_SERVCLASS_PHONE_ACCESS,
469    BTM_EIR_UUID_SERVCLASS_HEADSET_HS,
470    BTM_EIR_UUID_SERVCLASS_PNP_INFORMATION,
471/*    BTM_EIR_UUID_SERVCLASS_GENERIC_NETWORKING,        */
472/*    BTM_EIR_UUID_SERVCLASS_GENERIC_FILETRANSFER,      */
473/*    BTM_EIR_UUID_SERVCLASS_GENERIC_AUDIO,             */
474/*    BTM_EIR_UUID_SERVCLASS_GENERIC_TELEPHONY,         */
475/*    BTM_EIR_UUID_SERVCLASS_UPNP_SERVICE,              */
476/*    BTM_EIR_UUID_SERVCLASS_UPNP_IP_SERVICE,           */
477/*    BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_PAN,          */
478/*    BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_LAP,          */
479/*    BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_L2CAP,        */
480    BTM_EIR_UUID_SERVCLASS_VIDEO_SOURCE,
481    BTM_EIR_UUID_SERVCLASS_VIDEO_SINK,
482/*    BTM_EIR_UUID_SERVCLASS_VIDEO_DISTRIBUTION         */
483/*    BTM_EIR_UUID_SERVCLASS_HDP_PROFILE                */
484    BTM_EIR_UUID_SERVCLASS_MESSAGE_ACCESS,
485    BTM_EIR_UUID_SERVCLASS_MESSAGE_NOTIFICATION,
486    BTM_EIR_UUID_SERVCLASS_HDP_SOURCE,
487    BTM_EIR_UUID_SERVCLASS_HDP_SINK,
488    BTM_EIR_MAX_SERVICES
489};
490
491/* search result in EIR of inquiry database */
492#define BTM_EIR_FOUND           0
493#define BTM_EIR_NOT_FOUND       1
494#define BTM_EIR_UNKNOWN         2
495
496typedef UINT8 tBTM_EIR_SEARCH_RESULT;
497
498#define BTM_EIR_FLAGS_TYPE                  HCI_EIR_FLAGS_TYPE                  /* 0x01 */
499#define BTM_EIR_MORE_16BITS_UUID_TYPE       HCI_EIR_MORE_16BITS_UUID_TYPE       /* 0x02 */
500#define BTM_EIR_COMPLETE_16BITS_UUID_TYPE   HCI_EIR_COMPLETE_16BITS_UUID_TYPE   /* 0x03 */
501#define BTM_EIR_MORE_32BITS_UUID_TYPE       HCI_EIR_MORE_32BITS_UUID_TYPE       /* 0x04 */
502#define BTM_EIR_COMPLETE_32BITS_UUID_TYPE   HCI_EIR_COMPLETE_32BITS_UUID_TYPE   /* 0x05 */
503#define BTM_EIR_MORE_128BITS_UUID_TYPE      HCI_EIR_MORE_128BITS_UUID_TYPE      /* 0x06 */
504#define BTM_EIR_COMPLETE_128BITS_UUID_TYPE  HCI_EIR_COMPLETE_128BITS_UUID_TYPE  /* 0x07 */
505#define BTM_EIR_SHORTENED_LOCAL_NAME_TYPE   HCI_EIR_SHORTENED_LOCAL_NAME_TYPE   /* 0x08 */
506#define BTM_EIR_COMPLETE_LOCAL_NAME_TYPE    HCI_EIR_COMPLETE_LOCAL_NAME_TYPE    /* 0x09 */
507#define BTM_EIR_TX_POWER_LEVEL_TYPE         HCI_EIR_TX_POWER_LEVEL_TYPE         /* 0x0A */
508#define BTM_EIR_MANUFACTURER_SPECIFIC_TYPE  HCI_EIR_MANUFACTURER_SPECIFIC_TYPE  /* 0xFF */
509
510/* the following EIR tags are defined to OOB, not regular EIR data */
511#define BTM_EIR_OOB_BD_ADDR_TYPE            HCI_EIR_OOB_BD_ADDR_TYPE    /* 6 bytes */
512#define BTM_EIR_OOB_COD_TYPE                HCI_EIR_OOB_COD_TYPE        /* 3 bytes */
513#define BTM_EIR_OOB_SSP_HASH_C_TYPE         HCI_EIR_OOB_SSP_HASH_C_TYPE /* 16 bytes */
514#define BTM_EIR_OOB_SSP_RAND_R_TYPE         HCI_EIR_OOB_SSP_RAND_R_TYPE /* 16 bytes */
515
516#define BTM_OOB_MANDATORY_SIZE      8   /* include 2 bytes length & 6 bytes bd_addr */
517#define BTM_OOB_DATA_LEN_SIZE       2
518#define BTM_OOB_BD_ADDR_SIZE        6
519#define BTM_OOB_COD_SIZE            BT_OOB_COD_SIZE
520#define BTM_OOB_HASH_C_SIZE         BT_OOB_HASH_C_SIZE
521#define BTM_OOB_RAND_R_SIZE         BT_OOB_RAND_R_SIZE
522
523
524#if BLE_INCLUDED == TRUE
525#define BTM_BLE_SEC_NONE                0
526#define BTM_BLE_SEC_ENCRYPT             1 /* encrypt the link using current key */
527#define BTM_BLE_SEC_ENCRYPT_NO_MITM     2
528#define BTM_BLE_SEC_ENCRYPT_MITM        3
529typedef UINT8   tBTM_BLE_SEC_ACT;
530#endif
531/************************************************************************************************
532** BTM Services MACROS handle array of UINT32 bits for more than 32 services
533*************************************************************************************************/
534/* Determine the number of UINT32's necessary for services */
535#define BTM_EIR_ARRAY_BITS          32          /* Number of bits in each array element */
536#define BTM_EIR_SERVICE_ARRAY_SIZE  (((UINT32)BTM_EIR_MAX_SERVICES / BTM_EIR_ARRAY_BITS) + \
537                                    (((UINT32)BTM_EIR_MAX_SERVICES % BTM_EIR_ARRAY_BITS) ? 1 : 0))
538
539/* MACRO to set the service bit mask in a bit stream */
540#define BTM_EIR_SET_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] |=  \
541                                    ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
542
543
544/* MACRO to clear the service bit mask in a bit stream */
545#define BTM_EIR_CLR_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] &=  \
546                                    ~((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
547
548/* MACRO to check the service bit mask in a bit stream */
549#define BTM_EIR_HAS_SERVICE(p, service)  ((((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] &  \
550                                    ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))) >> (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))
551
552/* start of EIR in HCI buffer, 4 bytes = HCI Command(2) + Length(1) + FEC_Req(1) */
553#define BTM_HCI_EIR_OFFSET          (BT_HDR_SIZE + 4)
554
555/***************************
556**  Device Discovery Types
557****************************/
558/* Definitions of the parameters passed to BTM_StartInquiry and
559** BTM_SetPeriodicInquiryMode.
560*/
561typedef struct              /* contains the two device class condition fields */
562{
563    DEV_CLASS       dev_class;
564    DEV_CLASS       dev_class_mask;
565} tBTM_COD_COND;
566
567
568typedef union               /* contains the inquiry filter condition */
569{
570    BD_ADDR         bdaddr_cond;
571    tBTM_COD_COND   cod_cond;
572} tBTM_INQ_FILT_COND;
573
574
575typedef struct              /* contains the parameters passed to the inquiry functions */
576{
577    UINT8   mode;                       /* general or limited */
578    UINT8   duration;                   /* duration of the inquiry (1.28 sec increments) */
579    UINT8   max_resps;                  /* maximum number of responses to return */
580    BOOLEAN report_dup;                 /* report duplicated inquiry response with higher RSSI value */
581    UINT8   filter_cond_type;           /* new devices, BD ADDR, COD, or No filtering */
582    tBTM_INQ_FILT_COND  filter_cond;    /* filter value based on filter cond type */
583#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
584    UINT8   intl_duration[4];              /*duration array storing the interleave scan's time portions*/
585#endif
586} tBTM_INQ_PARMS;
587
588#define BTM_INQ_RESULT_BR       0x01
589#define BTM_INQ_RESULT_BLE      0x02
590
591#if (BLE_INCLUDED == TRUE)
592#define BTM_BLE_EVT_CONN_ADV        0x00
593#define BTM_BLE_EVT_CONN_DIR_ADV    0x01
594#define BTM_BLE_EVT_DISC_ADV        0x02
595#define BTM_BLE_EVT_NON_CONN_ADV    0x03
596#define BTM_BLE_EVT_SCAN_RSP        0x04
597typedef UINT8 tBTM_BLE_EVT_TYPE;
598#endif
599
600/* These are the fields returned in each device's response to the inquiry.  It
601** is returned in the results callback if registered.
602*/
603typedef struct
604{
605    UINT16      clock_offset;
606    BD_ADDR     remote_bd_addr;
607    DEV_CLASS   dev_class;
608    UINT8       page_scan_rep_mode;
609    UINT8       page_scan_per_mode;
610    UINT8       page_scan_mode;
611    INT8        rssi;       /* Set to BTM_INQ_RES_IGNORE_RSSI if  not valid */
612    UINT32      eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
613    BOOLEAN     eir_complete_list;
614#if (BLE_INCLUDED == TRUE)
615    tBT_DEVICE_TYPE         device_type;
616    UINT8       inq_result_type;
617    UINT8       ble_addr_type;
618    tBTM_BLE_EVT_TYPE       ble_evt_type;
619    UINT8                   flag;
620#endif
621} tBTM_INQ_RESULTS;
622
623
624/* This is the inquiry response information held in its database by BTM, and available
625** to applications via BTM_InqDbRead, BTM_InqDbFirst, and BTM_InqDbNext.
626*/
627typedef struct
628{
629    tBTM_INQ_RESULTS    results;
630
631    BOOLEAN             appl_knows_rem_name;    /* set by application if it knows the remote name of the peer device.
632                                                   This is later used by application to determine if remote name request is
633                                                   required to be done. Having the flag here avoid duplicate store of inquiry results */
634} tBTM_INQ_INFO;
635
636
637/* Structure returned with inquiry complete callback */
638typedef struct
639{
640    tBTM_STATUS status;
641    UINT8       num_resp;       /* Number of results from the current inquiry */
642} tBTM_INQUIRY_CMPL;
643
644
645/* Structure returned with remote name  request */
646typedef struct
647{
648    UINT16      status;
649    BD_ADDR     bd_addr;
650    UINT16      length;
651    BD_NAME     remote_bd_name;
652} tBTM_REMOTE_DEV_NAME;
653
654typedef struct
655{
656    UINT8   pcm_intf_rate;  /* PCM interface rate: 0: 128kbps, 1: 256 kbps;
657                                2:512 bps; 3: 1024kbps; 4: 2048kbps */
658    UINT8   frame_type;     /* frame type: 0: short; 1: long */
659    UINT8   sync_mode;      /* sync mode: 0: slave; 1: master */
660    UINT8   clock_mode;     /* clock mode: 0: slave; 1: master */
661
662}tBTM_SCO_PCM_PARAM;
663
664/****************************************
665**  Device Discovery Callback Functions
666*****************************************/
667/* Callback function for asynchronous notifications when the BTM inquiry DB
668** changes. First param is inquiry database, second is if added to or removed
669** from the inquiry database.
670*/
671typedef void (tBTM_INQ_DB_CHANGE_CB) (void *p1, BOOLEAN is_new);
672
673/* Callback function for notifications when the BTM gets inquiry response.
674** First param is inquiry results database, second is pointer of EIR.
675*/
676typedef void (tBTM_INQ_RESULTS_CB) (tBTM_INQ_RESULTS *p_inq_results, UINT8 *p_eir);
677
678/*****************************************************************************
679**  ACL CHANNEL MANAGEMENT
680*****************************************************************************/
681/******************
682**  ACL Constants
683*******************/
684
685/* ACL modes */
686#define BTM_ACL_MODE_NORMAL     HCI_MODE_ACTIVE
687#define BTM_ACL_MODE_HOLD       HCI_MODE_HOLD
688#define BTM_ACL_MODE_SNIFF      HCI_MODE_SNIFF
689#define BTM_ACL_MODE_PARK       HCI_MODE_PARK
690
691/* Returned with structure in role switch callback (tBTM_ROLE_SWITCH_CMPL) */
692#define BTM_ROLE_MASTER         HCI_ROLE_MASTER
693#define BTM_ROLE_SLAVE          HCI_ROLE_SLAVE
694#define BTM_ROLE_UNDEFINED      0xff     /* undefined value (error status) */
695
696/* ACL Packet Types */
697#define BTM_ACL_PKT_TYPES_MASK_DM1      HCI_PKT_TYPES_MASK_DM1
698#define BTM_ACL_PKT_TYPES_MASK_DH1      HCI_PKT_TYPES_MASK_DH1
699#define BTM_ACL_PKT_TYPES_MASK_DM3      HCI_PKT_TYPES_MASK_DM3
700#define BTM_ACL_PKT_TYPES_MASK_DH3      HCI_PKT_TYPES_MASK_DH3
701#define BTM_ACL_PKT_TYPES_MASK_DM5      HCI_PKT_TYPES_MASK_DM5
702#define BTM_ACL_PKT_TYPES_MASK_DH5      HCI_PKT_TYPES_MASK_DH5
703#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 HCI_PKT_TYPES_MASK_NO_2_DH1
704#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 HCI_PKT_TYPES_MASK_NO_3_DH1
705#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 HCI_PKT_TYPES_MASK_NO_2_DH3
706#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 HCI_PKT_TYPES_MASK_NO_3_DH3
707#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 HCI_PKT_TYPES_MASK_NO_2_DH5
708#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH5 HCI_PKT_TYPES_MASK_NO_3_DH5
709
710/***************
711**  ACL Types
712****************/
713
714/* Structure returned with Role Switch information (in tBTM_CMPL_CB callback function)
715** in response to BTM_SwitchRole call.
716*/
717typedef struct
718{
719    UINT8   hci_status;     /* HCI status returned with the event */
720    UINT8   role;           /* BTM_ROLE_MASTER or BTM_ROLE_SLAVE */
721    BD_ADDR remote_bd_addr; /* Remote BD addr involved with the switch */
722} tBTM_ROLE_SWITCH_CMPL;
723
724/* Structure returned with QoS information (in tBTM_CMPL_CB callback function)
725** in response to BTM_SetQoS call.
726*/
727typedef struct
728{
729    FLOW_SPEC flow;
730    UINT16 handle;
731    UINT8 status;
732} tBTM_QOS_SETUP_CMPL;
733
734
735/* Structure returned with read RSSI event (in tBTM_CMPL_CB callback function)
736** in response to BTM_ReadRSSI call.
737*/
738typedef struct
739{
740    tBTM_STATUS status;
741    UINT8       hci_status;
742    INT8        rssi;
743    BD_ADDR     rem_bda;
744} tBTM_RSSI_RESULTS;
745
746/* Structure returned with read current TX power event (in tBTM_CMPL_CB callback function)
747** in response to BTM_ReadTxPower call.
748*/
749typedef struct
750{
751    tBTM_STATUS status;
752    UINT8       hci_status;
753    INT8        tx_power;
754    BD_ADDR     rem_bda;
755} tBTM_TX_POWER_RESULTS;
756
757/* Structure returned with read link quality event (in tBTM_CMPL_CB callback function)
758** in response to BTM_ReadLinkQuality call.
759*/
760typedef struct
761{
762    tBTM_STATUS status;
763    UINT8       hci_status;
764    UINT8       link_quality;
765    BD_ADDR     rem_bda;
766} tBTM_LINK_QUALITY_RESULTS;
767
768/* Structure returned with read inq tx power quality event (in tBTM_CMPL_CB callback function)
769** in response to BTM_ReadInquiryRspTxPower call.
770*/
771typedef struct
772{
773    tBTM_STATUS status;
774    UINT8       hci_status;
775    INT8        tx_power;
776} tBTM_INQ_TXPWR_RESULTS;
777
778enum
779{
780    BTM_BL_CONN_EVT,
781    BTM_BL_DISCN_EVT,
782    BTM_BL_UPDATE_EVT,
783    BTM_BL_ROLE_CHG_EVT,
784    BTM_BL_COLLISION_EVT
785};
786typedef UINT8 tBTM_BL_EVENT;
787typedef UINT16 tBTM_BL_EVENT_MASK;
788
789#define BTM_BL_CONN_MASK        0x0001
790#define BTM_BL_DISCN_MASK       0x0002
791#define BTM_BL_UPDATE_MASK      0x0004
792#define BTM_BL_ROLE_CHG_MASK    0x0008
793
794/* Device features mask definitions */
795#define BTM_FEATURE_BYTES_PER_PAGE  HCI_FEATURE_BYTES_PER_PAGE
796#define BTM_EXT_FEATURES_PAGE_MAX   HCI_EXT_FEATURES_PAGE_MAX
797
798/* the data type associated with BTM_BL_CONN_EVT */
799typedef struct
800{
801    tBTM_BL_EVENT   event;      /* The event reported. */
802    BD_ADDR_PTR     p_bda;      /* The address of the newly connected device */
803    DEV_CLASS_PTR   p_dc;       /* The device class */
804    BD_NAME_PTR     p_bdn;      /* The device name */
805    UINT8          *p_features; /* pointer to the remote device's features page[0] (supported features page) */
806#if BLE_INCLUDED == TRUE
807    UINT16          handle;     /* connection handle */
808    tBT_TRANSPORT   transport; /* link is LE or not */
809#endif
810} tBTM_BL_CONN_DATA;
811
812/* the data type associated with BTM_BL_DISCN_EVT */
813typedef struct
814{
815    tBTM_BL_EVENT   event;  /* The event reported. */
816    BD_ADDR_PTR     p_bda;  /* The address of the disconnected device */
817#if BLE_INCLUDED == TRUE
818    UINT16          handle; /* disconnected connection handle */
819    tBT_TRANSPORT   transport; /* link is LE link or not */
820#endif
821} tBTM_BL_DISCN_DATA;
822
823/* Busy-Level shall have the inquiry_paging mask set when
824 * inquiry/paging is in progress, Else the number of ACL links */
825#define BTM_BL_INQUIRY_PAGING_MASK 0x10
826#define BTM_BL_INQUIRY_STARTED   (BTM_BL_INQUIRY_PAGING_MASK | 0x1)
827#define BTM_BL_INQUIRY_CANCELLED (BTM_BL_INQUIRY_PAGING_MASK | 0x2)
828#define BTM_BL_INQUIRY_COMPLETE  (BTM_BL_INQUIRY_PAGING_MASK | 0x3)
829#define BTM_BL_PAGING_STARTED    (BTM_BL_INQUIRY_PAGING_MASK | 0x4)
830#define BTM_BL_PAGING_COMPLETE   (BTM_BL_INQUIRY_PAGING_MASK | 0x5)
831/* the data type associated with BTM_BL_UPDATE_EVT */
832typedef struct
833{
834    tBTM_BL_EVENT   event;  /* The event reported. */
835    UINT8           busy_level;/* when paging or inquiring, level is 10.
836                                * Otherwise, the number of ACL links. */
837    UINT8           busy_level_flags; /* Notifies actual inquiry/page activities */
838} tBTM_BL_UPDATE_DATA;
839
840/* the data type associated with BTM_BL_ROLE_CHG_EVT */
841typedef struct
842{
843    tBTM_BL_EVENT   event;      /* The event reported. */
844    BD_ADDR_PTR     p_bda;      /* The address of the peer connected device */
845    UINT8           new_role;
846    UINT8           hci_status; /* HCI status returned with the event */
847} tBTM_BL_ROLE_CHG_DATA;
848
849typedef union
850{
851    tBTM_BL_EVENT           event;  /* The event reported. */
852    tBTM_BL_CONN_DATA       conn;   /* The data associated with BTM_BL_CONN_EVT */
853    tBTM_BL_DISCN_DATA      discn;  /* The data associated with BTM_BL_DISCN_EVT */
854    tBTM_BL_UPDATE_DATA     update; /* The data associated with BTM_BL_UPDATE_EVT */
855    tBTM_BL_ROLE_CHG_DATA   role_chg;/*The data associated with BTM_BL_ROLE_CHG_EVT */
856} tBTM_BL_EVENT_DATA;
857
858/* Callback function for notifications when the BTM busy level
859** changes.
860*/
861typedef void (tBTM_BL_CHANGE_CB) (tBTM_BL_EVENT_DATA *p_data);
862
863/***************************
864**  ACL Callback Functions
865****************************/
866/* Callback function for notifications when the BTM ACL connection DB
867** changes. First param is BD address, second is if added or removed.
868** Registered through BTM_AclRegisterForChanges call.
869*/
870#if BLE_INCLUDED == TRUE
871typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
872                                      BD_NAME p_bdn, UINT8 *features,
873                                      BOOLEAN is_new, UINT16 handle,
874                                      tBT_TRANSPORT transport);
875#else
876typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
877                                      BD_NAME p_bdn, UINT8 *features,
878                                      BOOLEAN is_new);
879#endif
880/*****************************************************************************
881**  SCO CHANNEL MANAGEMENT
882*****************************************************************************/
883/******************
884**  SCO Constants
885*******************/
886
887/* Define an invalid SCO index and an invalid HCI handle */
888#define BTM_INVALID_SCO_INDEX       0xFFFF
889#define BTM_INVALID_HCI_HANDLE      0xFFFF
890
891/* Define an invalid SCO disconnect reason */
892#define BTM_INVALID_SCO_DISC_REASON 0xFFFF
893
894/* Define first active SCO index */
895#define BTM_FIRST_ACTIVE_SCO_INDEX  BTM_MAX_SCO_LINKS
896
897/* Define SCO packet types used in APIs */
898#define BTM_SCO_PKT_TYPES_MASK_HV1  HCI_ESCO_PKT_TYPES_MASK_HV1
899#define BTM_SCO_PKT_TYPES_MASK_HV2  HCI_ESCO_PKT_TYPES_MASK_HV2
900#define BTM_SCO_PKT_TYPES_MASK_HV3  HCI_ESCO_PKT_TYPES_MASK_HV3
901#define BTM_SCO_PKT_TYPES_MASK_EV3  HCI_ESCO_PKT_TYPES_MASK_EV3
902#define BTM_SCO_PKT_TYPES_MASK_EV4  HCI_ESCO_PKT_TYPES_MASK_EV4
903#define BTM_SCO_PKT_TYPES_MASK_EV5  HCI_ESCO_PKT_TYPES_MASK_EV5
904#define BTM_SCO_PKT_TYPES_MASK_NO_2_EV3  HCI_ESCO_PKT_TYPES_MASK_NO_2_EV3
905#define BTM_SCO_PKT_TYPES_MASK_NO_3_EV3  HCI_ESCO_PKT_TYPES_MASK_NO_3_EV3
906#define BTM_SCO_PKT_TYPES_MASK_NO_2_EV5  HCI_ESCO_PKT_TYPES_MASK_NO_2_EV5
907#define BTM_SCO_PKT_TYPES_MASK_NO_3_EV5  HCI_ESCO_PKT_TYPES_MASK_NO_3_EV5
908
909#define BTM_SCO_LINK_ONLY_MASK  (BTM_SCO_PKT_TYPES_MASK_HV1 | \
910                                 BTM_SCO_PKT_TYPES_MASK_HV2 | \
911                                 BTM_SCO_PKT_TYPES_MASK_HV3)
912
913#define BTM_ESCO_LINK_ONLY_MASK (BTM_SCO_PKT_TYPES_MASK_EV3 | \
914                                 BTM_SCO_PKT_TYPES_MASK_EV4 | \
915                                 BTM_SCO_PKT_TYPES_MASK_EV5)
916
917#define BTM_SCO_LINK_ALL_PKT_MASK   (BTM_SCO_LINK_ONLY_MASK     | \
918                                     BTM_ESCO_LINK_ONLY_MASK)
919
920#define BTM_VALID_SCO_ALL_PKT_TYPE HCI_VALID_SCO_ALL_PKT_TYPE
921
922/* Passed in BTM_CreateSco if the packet type parameter should be ignored */
923#define BTM_IGNORE_SCO_PKT_TYPE     0
924
925/***************
926**  SCO Types
927****************/
928#define BTM_LINK_TYPE_SCO           HCI_LINK_TYPE_SCO
929#define BTM_LINK_TYPE_ESCO          HCI_LINK_TYPE_ESCO
930typedef UINT8 tBTM_SCO_TYPE;
931
932
933/*******************
934** SCO Routing Path
935********************/
936#define BTM_SCO_ROUTE_PCM           HCI_BRCM_SCO_ROUTE_PCM
937#define BTM_SCO_ROUTE_HCI           HCI_BRCM_SCO_ROUTE_HCI
938typedef UINT8 tBTM_SCO_ROUTE_TYPE;
939
940
941/*******************
942** SCO Codec Types
943********************/
944// TODO(google) This should use common definitions
945// in hci/include/hci_audio.h
946#define BTM_SCO_CODEC_NONE          0x0000
947#define BTM_SCO_CODEC_CVSD          0x0001
948#define BTM_SCO_CODEC_MSBC          0x0002
949typedef UINT16 tBTM_SCO_CODEC_TYPE;
950
951
952
953/*******************
954** SCO Air Mode Types
955********************/
956#define BTM_SCO_AIR_MODE_U_LAW          0
957#define BTM_SCO_AIR_MODE_A_LAW          1
958#define BTM_SCO_AIR_MODE_CVSD           2
959#define BTM_SCO_AIR_MODE_TRANSPNT       3
960typedef UINT8 tBTM_SCO_AIR_MODE_TYPE;
961
962/*******************
963** SCO Voice Settings
964********************/
965#define BTM_VOICE_SETTING_CVSD  ((UINT16)  (HCI_INP_CODING_LINEAR          |   \
966                                            HCI_INP_DATA_FMT_2S_COMPLEMENT |   \
967                                            HCI_INP_SAMPLE_SIZE_16BIT      |   \
968                                            HCI_AIR_CODING_FORMAT_CVSD))
969
970#define BTM_VOICE_SETTING_TRANS ((UINT16)  (HCI_INP_CODING_LINEAR          |   \
971                                            HCI_INP_DATA_FMT_2S_COMPLEMENT |   \
972                                            HCI_INP_SAMPLE_SIZE_16BIT      |   \
973                                            HCI_AIR_CODING_FORMAT_TRANSPNT))
974
975/*******************
976** SCO Data Status
977********************/
978enum
979{
980    BTM_SCO_DATA_CORRECT,
981    BTM_SCO_DATA_PAR_ERR,
982    BTM_SCO_DATA_NONE,
983    BTM_SCO_DATA_PAR_LOST
984};
985typedef UINT8 tBTM_SCO_DATA_FLAG;
986
987/***************************
988**  SCO Callback Functions
989****************************/
990typedef void (tBTM_SCO_CB) (UINT16 sco_inx);
991typedef void (tBTM_SCO_DATA_CB) (UINT16 sco_inx, BT_HDR *p_data, tBTM_SCO_DATA_FLAG status);
992
993/******************
994**  eSCO Constants
995*******************/
996#define BTM_64KBITS_RATE            0x00001f40  /* 64 kbits/sec data rate */
997
998/* Retransmission effort */
999#define BTM_ESCO_RETRANS_OFF        0
1000#define BTM_ESCO_RETRANS_POWER      1
1001#define BTM_ESCO_RETRANS_QUALITY    2
1002#define BTM_ESCO_RETRANS_DONTCARE   0xff
1003
1004/* Max Latency Don't Care */
1005#define BTM_ESCO_MAX_LAT_DONTCARE   0xffff
1006
1007/***************
1008**  eSCO Types
1009****************/
1010/* tBTM_ESCO_CBACK event types */
1011#define BTM_ESCO_CHG_EVT        1
1012#define BTM_ESCO_CONN_REQ_EVT   2
1013typedef UINT8 tBTM_ESCO_EVT;
1014
1015/* Passed into BTM_SetEScoMode() */
1016typedef struct
1017{
1018    UINT32 tx_bw;
1019    UINT32 rx_bw;
1020    UINT16 max_latency;
1021    UINT16 voice_contfmt;  /* Voice Settings or Content Format */
1022    UINT16 packet_types;
1023    UINT8  retrans_effort;
1024} tBTM_ESCO_PARAMS;
1025
1026typedef struct
1027{
1028    UINT16 max_latency;
1029    UINT16 packet_types;
1030    UINT8  retrans_effort;
1031} tBTM_CHG_ESCO_PARAMS;
1032
1033/* Returned by BTM_ReadEScoLinkParms() */
1034typedef struct
1035{
1036    UINT16  rx_pkt_len;
1037    UINT16  tx_pkt_len;
1038    BD_ADDR bd_addr;
1039    UINT8   link_type;  /* BTM_LINK_TYPE_SCO or BTM_LINK_TYPE_ESCO */
1040    UINT8   tx_interval;
1041    UINT8   retrans_window;
1042    UINT8   air_mode;
1043} tBTM_ESCO_DATA;
1044
1045typedef struct
1046{
1047    UINT16  sco_inx;
1048    UINT16  rx_pkt_len;
1049    UINT16  tx_pkt_len;
1050    BD_ADDR bd_addr;
1051    UINT8   hci_status;
1052    UINT8   tx_interval;
1053    UINT8   retrans_window;
1054} tBTM_CHG_ESCO_EVT_DATA;
1055
1056typedef struct
1057{
1058    UINT16        sco_inx;
1059    BD_ADDR       bd_addr;
1060    DEV_CLASS     dev_class;
1061    tBTM_SCO_TYPE link_type;
1062} tBTM_ESCO_CONN_REQ_EVT_DATA;
1063
1064typedef union
1065{
1066    tBTM_CHG_ESCO_EVT_DATA      chg_evt;
1067    tBTM_ESCO_CONN_REQ_EVT_DATA conn_evt;
1068} tBTM_ESCO_EVT_DATA;
1069
1070/***************************
1071**  eSCO Callback Functions
1072****************************/
1073typedef void (tBTM_ESCO_CBACK) (tBTM_ESCO_EVT event, tBTM_ESCO_EVT_DATA *p_data);
1074
1075
1076/*****************************************************************************
1077**  SECURITY MANAGEMENT
1078*****************************************************************************/
1079/*******************************
1080**  Security Manager Constants
1081********************************/
1082
1083/* Security Mode (BTM_SetSecurityMode) */
1084#define BTM_SEC_MODE_UNDEFINED      0
1085#define BTM_SEC_MODE_NONE           1
1086#define BTM_SEC_MODE_SERVICE        2
1087#define BTM_SEC_MODE_LINK           3
1088#define BTM_SEC_MODE_SP             4
1089#define BTM_SEC_MODE_SP_DEBUG       5
1090
1091/* Security Service Levels [bit mask] (BTM_SetSecurityLevel)
1092** Encryption should not be used without authentication
1093*/
1094#define BTM_SEC_NONE               0x0000 /* Nothing required */
1095#define BTM_SEC_IN_AUTHORIZE       0x0001 /* Inbound call requires authorization */
1096#define BTM_SEC_IN_AUTHENTICATE    0x0002 /* Inbound call requires authentication */
1097#define BTM_SEC_IN_ENCRYPT         0x0004 /* Inbound call requires encryption */
1098#define BTM_SEC_OUT_AUTHORIZE      0x0008 /* Outbound call requires authorization */
1099#define BTM_SEC_OUT_AUTHENTICATE   0x0010 /* Outbound call requires authentication */
1100#define BTM_SEC_OUT_ENCRYPT        0x0020 /* Outbound call requires encryption */
1101#define BTM_SEC_BOND               0x0040 /* Bonding */
1102#define BTM_SEC_BOND_CONN          0x0080 /* bond_created_connection */
1103#define BTM_SEC_FORCE_MASTER       0x0100 /* Need to switch connection to be master */
1104#define BTM_SEC_ATTEMPT_MASTER     0x0200 /* Try to switch connection to be master */
1105#define BTM_SEC_FORCE_SLAVE        0x0400 /* Need to switch connection to be master */
1106#define BTM_SEC_ATTEMPT_SLAVE      0x0800 /* Try to switch connection to be slave */
1107#define BTM_SEC_IN_MITM            0x1000 /* inbound Do man in the middle protection */
1108#define BTM_SEC_OUT_MITM           0x2000 /* outbound Do man in the middle protection */
1109
1110/* Security Flags [bit mask] (BTM_GetSecurityFlags)
1111*/
1112#define BTM_SEC_FLAG_AUTHORIZED     0x01
1113#define BTM_SEC_FLAG_AUTHENTICATED  0x02
1114#define BTM_SEC_FLAG_ENCRYPTED      0x04
1115#define BTM_SEC_FLAG_LKEY_KNOWN     0x10
1116#define BTM_SEC_FLAG_LKEY_AUTHED    0x20
1117
1118/* PIN types */
1119#define BTM_PIN_TYPE_VARIABLE       HCI_PIN_TYPE_VARIABLE
1120#define BTM_PIN_TYPE_FIXED          HCI_PIN_TYPE_FIXED
1121
1122/* Link Key types used to generate the new link key.
1123** returned in link key notification callback function
1124*/
1125#define BTM_LKEY_TYPE_COMBINATION   HCI_LKEY_TYPE_COMBINATION
1126#define BTM_LKEY_TYPE_LOCAL_UNIT    HCI_LKEY_TYPE_LOCAL_UNIT
1127#define BTM_LKEY_TYPE_REMOTE_UNIT   HCI_LKEY_TYPE_REMOTE_UNIT
1128#define BTM_LKEY_TYPE_DEBUG_COMB    HCI_LKEY_TYPE_DEBUG_COMB
1129#define BTM_LKEY_TYPE_UNAUTH_COMB   HCI_LKEY_TYPE_UNAUTH_COMB
1130#define BTM_LKEY_TYPE_AUTH_COMB     HCI_LKEY_TYPE_AUTH_COMB
1131#define BTM_LKEY_TYPE_CHANGED_COMB  HCI_LKEY_TYPE_CHANGED_COMB
1132#define BTM_LKEY_TYPE_IGNORE        0xff    /* used when event is response from
1133                                               hci return link keys request */
1134
1135/* Protocol level security (BTM_SetSecurityLevel) */
1136#define BTM_SEC_PROTO_L2CAP         0
1137#define BTM_SEC_PROTO_SDP           1
1138#define BTM_SEC_PROTO_TCS           2
1139#define BTM_SEC_PROTO_RFCOMM        3
1140#define BTM_SEC_PROTO_OBEX          4
1141#define BTM_SEC_PROTO_BNEP          5
1142#define BTM_SEC_PROTO_HID           6   /* HID      */
1143#define BTM_SEC_PROTO_AVDT          7
1144#define BTM_SEC_PROTO_MCA           8
1145
1146/* Determine the number of UINT32's necessary for security services */
1147#define BTM_SEC_ARRAY_BITS          32          /* Number of bits in each array element */
1148#define BTM_SEC_SERVICE_ARRAY_SIZE  (((UINT32)BTM_SEC_MAX_SERVICES / BTM_SEC_ARRAY_BITS) + \
1149                                    (((UINT32)BTM_SEC_MAX_SERVICES % BTM_SEC_ARRAY_BITS) ? 1 : 0))
1150
1151/* Security service definitions (BTM_SetSecurityLevel)
1152** Used for Authorization APIs
1153*/
1154#define BTM_SEC_SERVICE_SDP_SERVER      0
1155#define BTM_SEC_SERVICE_SERIAL_PORT     1
1156#define BTM_SEC_SERVICE_LAN_ACCESS      2
1157#define BTM_SEC_SERVICE_DUN             3
1158#define BTM_SEC_SERVICE_IRMC_SYNC       4
1159#define BTM_SEC_SERVICE_IRMC_SYNC_CMD   5
1160#define BTM_SEC_SERVICE_OBEX            6
1161#define BTM_SEC_SERVICE_OBEX_FTP        7
1162#define BTM_SEC_SERVICE_HEADSET         8
1163#define BTM_SEC_SERVICE_CORDLESS        9
1164#define BTM_SEC_SERVICE_INTERCOM        10
1165#define BTM_SEC_SERVICE_FAX             11
1166#define BTM_SEC_SERVICE_HEADSET_AG      12
1167#define BTM_SEC_SERVICE_PNP_INFO        13
1168#define BTM_SEC_SERVICE_GEN_NET         14
1169#define BTM_SEC_SERVICE_GEN_FILE        15
1170#define BTM_SEC_SERVICE_GEN_AUDIO       16
1171#define BTM_SEC_SERVICE_GEN_TEL         17
1172#define BTM_SEC_SERVICE_CTP_DATA        18
1173#define BTM_SEC_SERVICE_HCRP_CTRL       19
1174#define BTM_SEC_SERVICE_HCRP_DATA       20
1175#define BTM_SEC_SERVICE_HCRP_NOTIF      21
1176#define BTM_SEC_SERVICE_BPP_JOB         22
1177#define BTM_SEC_SERVICE_BPP_STATUS      23
1178#define BTM_SEC_SERVICE_BPP_REF         24
1179#define BTM_SEC_SERVICE_BNEP_PANU       25
1180#define BTM_SEC_SERVICE_BNEP_GN         26
1181#define BTM_SEC_SERVICE_BNEP_NAP        27
1182#define BTM_SEC_SERVICE_HF_HANDSFREE    28
1183#define BTM_SEC_SERVICE_AG_HANDSFREE    29
1184#define BTM_SEC_SERVICE_TE_PHONE_ACCESS 30
1185#define BTM_SEC_SERVICE_ME_PHONE_ACCESS 31
1186
1187#define BTM_SEC_SERVICE_HIDH_SEC_CTRL   32
1188#define BTM_SEC_SERVICE_HIDH_NOSEC_CTRL 33
1189#define BTM_SEC_SERVICE_HIDH_INTR       34
1190#define BTM_SEC_SERVICE_BIP             35
1191#define BTM_SEC_SERVICE_BIP_REF         36
1192#define BTM_SEC_SERVICE_AVDTP           37
1193#define BTM_SEC_SERVICE_AVDTP_NOSEC     38
1194#define BTM_SEC_SERVICE_AVCTP           39
1195#define BTM_SEC_SERVICE_SAP             40
1196#define BTM_SEC_SERVICE_PBAP            41
1197#define BTM_SEC_SERVICE_RFC_MUX         42
1198#define BTM_SEC_SERVICE_AVCTP_BROWSE    43
1199#define BTM_SEC_SERVICE_MAP             44
1200#define BTM_SEC_SERVICE_MAP_NOTIF       45
1201#define BTM_SEC_SERVICE_MCAP_CTRL       46
1202#define BTM_SEC_SERVICE_MCAP_DATA       47
1203#define BTM_SEC_SERVICE_HDP_SNK         48
1204#define BTM_SEC_SERVICE_HDP_SRC         49
1205#define BTM_SEC_SERVICE_ATT             50
1206
1207/* Update these as services are added */
1208#define BTM_SEC_SERVICE_FIRST_EMPTY     51
1209
1210#ifndef BTM_SEC_MAX_SERVICES
1211#define BTM_SEC_MAX_SERVICES            65
1212#endif
1213
1214/************************************************************************************************
1215** Security Services MACROS handle array of UINT32 bits for more than 32 trusted services
1216*************************************************************************************************/
1217/* MACRO to set the security service bit mask in a bit stream */
1218#define BTM_SEC_SET_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] |=  \
1219                                    ((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
1220
1221
1222/* MACRO to clear the security service bit mask in a bit stream */
1223#define BTM_SEC_CLR_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] &=  \
1224                                    ~((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
1225
1226/* MACRO to check the security service bit mask in a bit stream (Returns TRUE or FALSE) */
1227#define BTM_SEC_IS_SERVICE_TRUSTED(p, service)    (((((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)]) &   \
1228                                        (UINT32)(((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))) ? TRUE : FALSE)
1229
1230/* MACRO to copy two trusted device bitmask */
1231#define BTM_SEC_COPY_TRUSTED_DEVICE(p_src, p_dst)   {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
1232                                                        ((UINT32 *)(p_dst))[trst] = ((UINT32 *)(p_src))[trst];}
1233
1234/* MACRO to clear two trusted device bitmask */
1235#define BTM_SEC_CLR_TRUSTED_DEVICE(p_dst)   {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
1236                                                        ((UINT32 *)(p_dst))[trst] = 0;}
1237
1238/* Following bits can be provided by host in the trusted_mask array */
1239/* 0..31 bits of mask[0] (Least Significant Word) */
1240#define BTM_SEC_TRUST_SDP_SERVER        (1 << BTM_SEC_SERVICE_SDP_SERVER)
1241#define BTM_SEC_TRUST_SERIAL_PORT       (1 << BTM_SEC_SERVICE_SERIAL_PORT)
1242#define BTM_SEC_TRUST_LAN_ACCESS        (1 << BTM_SEC_SERVICE_LAN_ACCESS)
1243#define BTM_SEC_TRUST_DUN               (1 << BTM_SEC_SERVICE_DUN)
1244#define BTM_SEC_TRUST_IRMC_SYNC         (1 << BTM_SEC_SERVICE_IRMC_SYNC)
1245#define BTM_SEC_TRUST_IRMC_SYNC_CMD     (1 << BTM_SEC_SERVICE_IRMC_SYNC_CMD)
1246#define BTM_SEC_TRUST_OBEX              (1 << BTM_SEC_SERVICE_OBEX)
1247#define BTM_SEC_TRUST_OBEX_FTP          (1 << BTM_SEC_SERVICE_OBEX_FTP)
1248#define BTM_SEC_TRUST_HEADSET           (1 << BTM_SEC_SERVICE_HEADSET)
1249#define BTM_SEC_TRUST_CORDLESS          (1 << BTM_SEC_SERVICE_CORDLESS)
1250#define BTM_SEC_TRUST_INTERCOM          (1 << BTM_SEC_SERVICE_INTERCOM)
1251#define BTM_SEC_TRUST_FAX               (1 << BTM_SEC_SERVICE_FAX)
1252#define BTM_SEC_TRUST_HEADSET_AG        (1 << BTM_SEC_SERVICE_HEADSET_AG)
1253#define BTM_SEC_TRUST_PNP_INFO          (1 << BTM_SEC_SERVICE_PNP_INFO)
1254#define BTM_SEC_TRUST_GEN_NET           (1 << BTM_SEC_SERVICE_GEN_NET)
1255#define BTM_SEC_TRUST_GEN_FILE          (1 << BTM_SEC_SERVICE_GEN_FILE)
1256#define BTM_SEC_TRUST_GEN_AUDIO         (1 << BTM_SEC_SERVICE_GEN_AUDIO)
1257#define BTM_SEC_TRUST_GEN_TEL           (1 << BTM_SEC_SERVICE_GEN_TEL)
1258#define BTM_SEC_TRUST_CTP_DATA          (1 << BTM_SEC_SERVICE_CTP_DATA)
1259#define BTM_SEC_TRUST_HCRP_CTRL         (1 << BTM_SEC_SERVICE_HCRP_CTRL)
1260#define BTM_SEC_TRUST_HCRP_DATA         (1 << BTM_SEC_SERVICE_HCRP_DATA)
1261#define BTM_SEC_TRUST_HCRP_NOTIF        (1 << BTM_SEC_SERVICE_HCRP_NOTIF)
1262#define BTM_SEC_TRUST_BPP_JOB           (1 << BTM_SEC_SERVICE_JOB)
1263#define BTM_SEC_TRUST_BPP_STATUS        (1 << BTM_SEC_SERVICE_STATUS)
1264#define BTM_SEC_TRUST_BPP_REF           (1 << BTM_SEC_SERVICE_REF)
1265#define BTM_SEC_TRUST_BNEP_PANU         (1 << BTM_SEC_SERVICE_BNEP_PANU)
1266#define BTM_SEC_TRUST_BNEP_GN           (1 << BTM_SEC_SERVICE_BNEP_GN)
1267#define BTM_SEC_TRUST_BNEP_NAP          (1 << BTM_SEC_SERVICE_BNEP_NAP)
1268#define BTM_SEC_TRUST_HFP_HF            (1 << BTM_SEC_SERVICE_HF_HANDSFREE)
1269#define BTM_SEC_TRUST_HFP_AG            (1 << BTM_SEC_SERVICE_AG_HANDSFREE)
1270#define BTM_SEC_TRUST_TE_PHONE_ACCESS   (1 << BTM_SEC_SERVICE_TE_PHONE_ACCESS)
1271#define BTM_SEC_TRUST_ME_PHONE_ACCESS   (1 << BTM_SEC_SERVICE_ME_PHONE_ACCESS)
1272
1273/* 0..31 bits of mask[1] (Most Significant Word) */
1274#define BTM_SEC_TRUST_HIDH_CTRL         (1 << (BTM_SEC_SERVICE_HIDH_SEC_CTRL - 32))
1275#define BTM_SEC_TRUST_HIDH_NOSEC_CTRL   (1 << (BTM_SEC_SERVICE_HIDH_NOSEC_CTRL - 32))
1276#define BTM_SEC_TRUST_HIDH_INTR         (1 << (BTM_SEC_SERVICE_HIDH_INTR - 32))
1277#define BTM_SEC_TRUST_BIP               (1 << (BTM_SEC_SERVICE_BIP - 32))
1278#define BTM_SEC_TRUST_BIP_REF           (1 << (BTM_SEC_SERVICE_BIP_REF - 32))
1279#define BTM_SEC_TRUST_AVDTP             (1 << (BTM_SEC_SERVICE_AVDTP - 32))
1280#define BTM_SEC_TRUST_AVDTP_NOSEC       (1 << (BTM_SEC_SERVICE_AVDTP_NOSEC - 32))
1281#define BTM_SEC_TRUST_AVCTP             (1 << (BTM_SEC_SERVICE_AVCTP - 32))
1282#define BTM_SEC_TRUST_SAP               (1 << (BTM_SEC_SERVICE_SAP - 32))
1283#define BTM_SEC_TRUST_PBAP              (1 << (BTM_SEC_SERVICE_PBAP - 32))
1284#define BTM_SEC_TRUST_RFC_MUX           (1 << (BTM_SEC_SERVICE_RFC_MUX - 32))
1285#define BTM_SEC_TRUST_AVCTP_BROWSE      (1 << (BTM_SEC_SERVICE_AVCTP_BROWSE - 32))
1286#define BTM_SEC_TRUST_MAP               (1 << (BTM_SEC_SERVICE_MAP - 32))
1287#define BTM_SEC_TRUST_MAP_NOTIF         (1 << (BTM_SEC_SERVICE_MAP_NOTIF - 32))
1288#define BTM_SEC_TRUST_MCAP_CTRL         (1 << (BTM_SEC_SERVICE_MCAP_CTRL - 32))
1289#define BTM_SEC_TRUST_MCAP_DATA         (1 << (BTM_SEC_SERVICE_MCAP_DATA - 32))
1290#define BTM_SEC_TRUST_HDP_SNK           (1 << (BTM_SEC_SERVICE_HDP_SNK - 32))
1291#define BTM_SEC_TRUST_HDP_SRC           (1 << (BTM_SEC_SERVICE_HDP_SRC - 32))
1292
1293#define BTM_SEC_TRUST_ALL               0xFFFFFFFF  /* for each array element */
1294
1295/****************************************
1296**  Security Manager Callback Functions
1297*****************************************/
1298/* Authorize device for service.  Parameters are
1299**              BD Address of remote
1300**              Device Class of remote
1301**              BD Name of remote
1302**              Service name
1303**              Service Id (NULL - unknown service or unused
1304**                                 [BTM_SEC_SERVICE_NAME_LEN set to 0])
1305**              Is originator of the connection
1306**              Result of the operation
1307*/
1308typedef UINT8 (tBTM_AUTHORIZE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1309                                         tBTM_BD_NAME bd_name, UINT8 *service_name,
1310                                         UINT8 service_id, BOOLEAN is_originator);
1311
1312/* Get PIN for the connection.  Parameters are
1313**              BD Address of remote
1314**              Device Class of remote
1315**              BD Name of remote
1316*/
1317typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1318                                   tBTM_BD_NAME bd_name);
1319
1320/* New Link Key for the connection.  Parameters are
1321**              BD Address of remote
1322**              Link Key
1323**              Key Type: Combination, Local Unit, or Remote Unit
1324*/
1325typedef UINT8 (tBTM_LINK_KEY_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1326                                        tBTM_BD_NAME bd_name, UINT8 *key,
1327                                        UINT8 key_type);
1328
1329
1330/* Remote Name Resolved.  Parameters are
1331**              BD Address of remote
1332**              BD Name of remote
1333*/
1334typedef void (tBTM_RMT_NAME_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dc,
1335                                       tBTM_BD_NAME bd_name);
1336
1337
1338/* Authentication complete for the connection.  Parameters are
1339**              BD Address of remote
1340**              Device Class of remote
1341**              BD Name of remote
1342**
1343*/
1344typedef UINT8 (tBTM_AUTH_COMPLETE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1345                                             tBTM_BD_NAME bd_name, int result);
1346
1347enum
1348{
1349    BTM_SP_IO_REQ_EVT,      /* received IO_CAPABILITY_REQUEST event */
1350    BTM_SP_IO_RSP_EVT,      /* received IO_CAPABILITY_RESPONSE event */
1351    BTM_SP_CFM_REQ_EVT,     /* received USER_CONFIRMATION_REQUEST event */
1352    BTM_SP_KEY_NOTIF_EVT,   /* received USER_PASSKEY_NOTIFY event */
1353    BTM_SP_KEY_REQ_EVT,     /* received USER_PASSKEY_REQUEST event */
1354    BTM_SP_KEYPRESS_EVT,    /* received KEYPRESS_NOTIFY event */
1355    BTM_SP_LOC_OOB_EVT,     /* received result for READ_LOCAL_OOB_DATA command */
1356    BTM_SP_RMT_OOB_EVT,     /* received REMOTE_OOB_DATA_REQUEST event */
1357    BTM_SP_COMPLT_EVT,      /* received SIMPLE_PAIRING_COMPLETE event */
1358    BTM_SP_UPGRADE_EVT      /* check if the application wants to upgrade the link key */
1359};
1360typedef UINT8 tBTM_SP_EVT;
1361
1362#define BTM_IO_CAP_OUT      0   /* DisplayOnly */
1363#define BTM_IO_CAP_IO       1   /* DisplayYesNo */
1364#define BTM_IO_CAP_IN       2   /* KeyboardOnly */
1365#define BTM_IO_CAP_NONE     3   /* NoInputNoOutput */
1366#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
1367#define BTM_IO_CAP_KBDISP   4   /* Keyboard display */
1368#define BTM_IO_CAP_MAX      5
1369#else
1370#define BTM_IO_CAP_MAX      4
1371#endif
1372
1373typedef UINT8 tBTM_IO_CAP;
1374
1375#define BTM_MAX_PASSKEY_VAL (999999)
1376#define BTM_MIN_PASSKEY_VAL (0)
1377
1378#define BTM_AUTH_SP_NO      0   /* MITM Protection Not Required - Single Profile/non-bonding
1379                                Numeric comparison with automatic accept allowed */
1380#define BTM_AUTH_SP_YES     1   /* MITM Protection Required - Single Profile/non-bonding
1381                                Use IO Capabilities to determine authentication procedure */
1382#define BTM_AUTH_AP_NO      2   /* MITM Protection Not Required - All Profiles/dedicated bonding
1383                                Numeric comparison with automatic accept allowed */
1384#define BTM_AUTH_AP_YES     3   /* MITM Protection Required - All Profiles/dedicated bonding
1385                                Use IO Capabilities to determine authentication procedure */
1386#define BTM_AUTH_SPGB_NO    4   /* MITM Protection Not Required - Single Profiles/general bonding
1387                                Numeric comparison with automatic accept allowed */
1388#define BTM_AUTH_SPGB_YES   5   /* MITM Protection Required - Single Profiles/general bonding
1389                                Use IO Capabilities to determine authentication procedure */
1390#define BTM_AUTH_DD_BOND    2   /* this bit is ORed to the BTM_AUTH_SP_* when IO exchange for dedicated bonding */
1391#define BTM_AUTH_GB_BIT     4   /* the genernal bonding bit */
1392#define BTM_AUTH_BONDS      6   /* the general/dedicated bonding bits  */
1393#define BTM_AUTH_YN_BIT     1   /* this is the Yes or No bit  */
1394
1395typedef UINT8 tBTM_AUTH_REQ;
1396
1397enum
1398{
1399    BTM_OOB_NONE,
1400    BTM_OOB_PRESENT
1401#if BTM_OOB_INCLUDED == TRUE
1402    ,BTM_OOB_UNKNOWN
1403#endif
1404};
1405typedef UINT8 tBTM_OOB_DATA;
1406
1407/* data type for BTM_SP_IO_REQ_EVT */
1408typedef struct
1409{
1410    BD_ADDR         bd_addr;        /* peer address */
1411    tBTM_IO_CAP     io_cap;         /* local IO capabilities */
1412    tBTM_OOB_DATA   oob_data;       /* OOB data present (locally) for the peer device */
1413    tBTM_AUTH_REQ   auth_req;       /* Authentication required (for local device) */
1414    BOOLEAN         is_orig;        /* TRUE, if local device initiated the SP process */
1415} tBTM_SP_IO_REQ;
1416
1417/* data type for BTM_SP_IO_RSP_EVT */
1418typedef struct
1419{
1420    BD_ADDR         bd_addr;        /* peer address */
1421    tBTM_IO_CAP     io_cap;         /* peer IO capabilities */
1422    tBTM_OOB_DATA   oob_data;       /* OOB data present at peer device for the local device */
1423    tBTM_AUTH_REQ   auth_req;       /* Authentication required for peer device */
1424} tBTM_SP_IO_RSP;
1425
1426/* data type for BTM_SP_CFM_REQ_EVT */
1427typedef struct
1428{
1429    BD_ADDR         bd_addr;        /* peer address */
1430    DEV_CLASS       dev_class;      /* peer CoD */
1431    tBTM_BD_NAME    bd_name;        /* peer device name */
1432    UINT32          num_val;        /* the numeric value for comparison. If just_works, do not show this number to UI */
1433    BOOLEAN         just_works;     /* TRUE, if "Just Works" association model */
1434    tBTM_AUTH_REQ   loc_auth_req;   /* Authentication required for local device */
1435    tBTM_AUTH_REQ   rmt_auth_req;   /* Authentication required for peer device */
1436    tBTM_IO_CAP     loc_io_caps;    /* IO Capabilities of the local device */
1437    tBTM_IO_CAP     rmt_io_caps;    /* IO Capabilities of the remot device */
1438} tBTM_SP_CFM_REQ;
1439
1440/* data type for BTM_SP_KEY_REQ_EVT */
1441typedef struct
1442{
1443    BD_ADDR         bd_addr;        /* peer address */
1444    DEV_CLASS       dev_class;      /* peer CoD */
1445    tBTM_BD_NAME    bd_name;        /* peer device name */
1446} tBTM_SP_KEY_REQ;
1447
1448/* data type for BTM_SP_KEY_NOTIF_EVT */
1449typedef struct
1450{
1451    BD_ADDR         bd_addr;        /* peer address */
1452    DEV_CLASS       dev_class;      /* peer CoD */
1453    tBTM_BD_NAME    bd_name;        /* peer device name */
1454    UINT32          passkey;        /* passkey */
1455} tBTM_SP_KEY_NOTIF;
1456
1457enum
1458{
1459    BTM_SP_KEY_STARTED,         /* passkey entry started */
1460    BTM_SP_KEY_ENTERED,         /* passkey digit entered */
1461    BTM_SP_KEY_ERASED,          /* passkey digit erased */
1462    BTM_SP_KEY_CLEARED,         /* passkey cleared */
1463    BTM_SP_KEY_COMPLT           /* passkey entry completed */
1464};
1465typedef UINT8   tBTM_SP_KEY_TYPE;
1466
1467/* data type for BTM_SP_KEYPRESS_EVT */
1468typedef struct
1469{
1470    BD_ADDR             bd_addr;        /* peer address */
1471    tBTM_SP_KEY_TYPE   notif_type;
1472} tBTM_SP_KEYPRESS;
1473
1474/* data type for BTM_SP_LOC_OOB_EVT */
1475typedef struct
1476{
1477    tBTM_STATUS     status;         /* */
1478    BT_OCTET16      c;              /* Simple Pairing Hash C */
1479    BT_OCTET16      r;              /* Simple Pairing Randomnizer R */
1480} tBTM_SP_LOC_OOB;
1481
1482/* data type for BTM_SP_RMT_OOB_EVT */
1483typedef struct
1484{
1485    BD_ADDR         bd_addr;        /* peer address */
1486    DEV_CLASS       dev_class;      /* peer CoD */
1487    tBTM_BD_NAME    bd_name;        /* peer device name */
1488} tBTM_SP_RMT_OOB;
1489
1490
1491/* data type for BTM_SP_COMPLT_EVT */
1492typedef struct
1493{
1494    BD_ADDR         bd_addr;        /* peer address */
1495    DEV_CLASS       dev_class;      /* peer CoD */
1496    tBTM_BD_NAME    bd_name;        /* peer device name */
1497    tBTM_STATUS     status;         /* status of the simple pairing process */
1498} tBTM_SP_COMPLT;
1499
1500/* data type for BTM_SP_UPGRADE_EVT */
1501typedef struct
1502{
1503    BD_ADDR         bd_addr;        /* peer address */
1504    BOOLEAN         upgrade;        /* TRUE, to upgrade the link key */
1505} tBTM_SP_UPGRADE;
1506
1507typedef union
1508{
1509    tBTM_SP_IO_REQ      io_req;     /* BTM_SP_IO_REQ_EVT      */
1510    tBTM_SP_IO_RSP      io_rsp;     /* BTM_SP_IO_RSP_EVT      */
1511    tBTM_SP_CFM_REQ     cfm_req;    /* BTM_SP_CFM_REQ_EVT     */
1512    tBTM_SP_KEY_NOTIF   key_notif;  /* BTM_SP_KEY_NOTIF_EVT   */
1513    tBTM_SP_KEY_REQ     key_req;    /* BTM_SP_KEY_REQ_EVT     */
1514    tBTM_SP_KEYPRESS    key_press;  /* BTM_SP_KEYPRESS_EVT    */
1515    tBTM_SP_LOC_OOB     loc_oob;    /* BTM_SP_LOC_OOB_EVT     */
1516    tBTM_SP_RMT_OOB     rmt_oob;    /* BTM_SP_RMT_OOB_EVT     */
1517    tBTM_SP_COMPLT      complt;     /* BTM_SP_COMPLT_EVT      */
1518    tBTM_SP_UPGRADE     upgrade;    /* BTM_SP_UPGRADE_EVT      */
1519} tBTM_SP_EVT_DATA;
1520
1521/* Simple Pairing Events.  Called by the stack when Simple Pairing related
1522** events occur.
1523*/
1524typedef UINT8 (tBTM_SP_CALLBACK) (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
1525
1526
1527typedef void (tBTM_MKEY_CALLBACK) (BD_ADDR bd_addr, UINT8 status, UINT8 key_flag) ;
1528
1529/* Encryption enabled/disabled complete: Optionally passed with BTM_SetEncryption.
1530** Parameters are
1531**              BD Address of remote
1532**              optional data passed in by BTM_SetEncryption
1533**              tBTM_STATUS - result of the operation
1534*/
1535typedef void (tBTM_SEC_CBACK) (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
1536                                void *p_ref_data, tBTM_STATUS result);
1537
1538/* Bond Cancel complete. Parameters are
1539**              Result of the cancel operation
1540**
1541*/
1542typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result);
1543
1544/* LE related event and data structure
1545*/
1546enum
1547{
1548    BTM_LE_IO_REQ_EVT = 1,      /* received IO_CAPABILITY_REQUEST event */
1549    BTM_LE_SEC_REQUEST_EVT, /* security request event */
1550    BTM_LE_KEY_NOTIF_EVT,   /* received USER_PASSKEY_NOTIFY event */
1551    BTM_LE_KEY_REQ_EVT,     /* received USER_PASSKEY_REQUEST event */
1552    BTM_LE_OOB_REQ_EVT,     /* OOB data request event */
1553    BTM_LE_COMPLT_EVT,      /* received SIMPLE_PAIRING_COMPLETE event */
1554    BTM_LE_KEY_EVT         /* KEY update event */
1555};
1556typedef UINT8 tBTM_LE_EVT;
1557
1558#define BTM_LE_KEY_PENC      SMP_SEC_KEY_TYPE_ENC        /* encryption information of peer device */
1559#define BTM_LE_KEY_PID       SMP_SEC_KEY_TYPE_ID         /* identity key of the peer device */
1560#define BTM_LE_KEY_PCSRK      SMP_SEC_KEY_TYPE_CSRK        /* peer SRK */
1561#define BTM_LE_KEY_LENC      (SMP_SEC_KEY_TYPE_ENC << 3)       /* master role security information:div */
1562#define BTM_LE_KEY_LID       (SMP_SEC_KEY_TYPE_ID << 3)        /* master device ID key */
1563#define BTM_LE_KEY_LCSRK     (SMP_SEC_KEY_TYPE_CSRK << 3)       /* local CSRK has been deliver to peer */
1564typedef UINT8 tBTM_LE_KEY_TYPE;
1565
1566#define BTM_LE_AUTH_REQ_NO_BOND SMP_AUTH_NO_BOND   /* 0 */
1567#define BTM_LE_AUTH_REQ_BOND    SMP_AUTH_GEN_BOND  /* 1 << 0 */
1568#define BTM_LE_AUTH_REQ_MITM    SMP_AUTH_YN_BIT    /* 1 << 2 */
1569typedef UINT8 tBTM_LE_AUTH_REQ;
1570
1571#define BTM_LE_AUTH_REQ_MASK SMP_AUTH_MASK  /* 0x03*/
1572
1573/* LE security level */
1574#define BTM_LE_SEC_NONE             SMP_SEC_NONE
1575#define BTM_LE_SEC_UNAUTHENTICATE   SMP_SEC_UNAUTHENTICATE      /* 1 */
1576#define BTM_LE_SEC_AUTHENTICATED    SMP_SEC_AUTHENTICATED       /* 4 */
1577typedef UINT8 tBTM_LE_SEC;
1578
1579
1580typedef struct
1581{
1582    tBTM_IO_CAP         io_cap;         /* local IO capabilities */
1583    UINT8               oob_data;       /* OOB data present (locally) for the peer device */
1584    tBTM_LE_AUTH_REQ    auth_req;       /* Authentication request (for local device) contain bonding and MITM info */
1585    UINT8               max_key_size;   /* max encryption key size */
1586    tBTM_LE_KEY_TYPE    init_keys;      /* keys to be distributed, bit mask */
1587    tBTM_LE_KEY_TYPE    resp_keys;      /* keys to be distributed, bit mask */
1588} tBTM_LE_IO_REQ;
1589
1590#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
1591/* data type for tBTM_LE_COMPLT */
1592typedef struct
1593{
1594    UINT8       reason;
1595    UINT8       sec_level;
1596    BOOLEAN     privacy_supported;
1597    BOOLEAN     is_pair_cancel;
1598}tBTM_LE_COMPLT;
1599#endif
1600
1601/* BLE encryption keys */
1602typedef struct
1603{
1604    BT_OCTET16  ltk;
1605    BT_OCTET8   rand;
1606    UINT16      ediv;
1607    UINT8       sec_level;
1608    UINT8       key_size;
1609}tBTM_LE_PENC_KEYS;
1610
1611/* BLE CSRK keys */
1612typedef struct
1613{
1614    UINT32          counter;
1615    BT_OCTET16      csrk;
1616    UINT8           sec_level;
1617}tBTM_LE_PCSRK_KEYS;
1618
1619/* BLE Encryption reproduction keys */
1620typedef struct
1621{
1622    UINT16      div;
1623    UINT8       key_size;
1624    UINT8       sec_level;
1625}tBTM_LE_LENC_KEYS;
1626
1627/* BLE SRK keys */
1628typedef struct
1629{
1630    UINT32          counter;
1631    UINT16          div;
1632    UINT8           sec_level;
1633
1634}tBTM_LE_LCSRK_KEYS;
1635
1636typedef struct
1637{
1638    BT_OCTET16          irk;
1639    tBLE_ADDR_TYPE      addr_type;
1640    BD_ADDR             static_addr;
1641}tBTM_LE_PID_KEYS;
1642
1643typedef union
1644{
1645    tBTM_LE_PENC_KEYS   penc_key;       /* received peer encryption key */
1646    tBTM_LE_PCSRK_KEYS  pcsrk_key;       /* received peer device SRK */
1647    tBTM_LE_PID_KEYS    pid_key;        /* peer device ID key */
1648    tBTM_LE_LENC_KEYS   lenc_key;       /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
1649    tBTM_LE_LCSRK_KEYS   lcsrk_key;      /* local device CSRK = d1(ER,DIV,1)*/
1650}tBTM_LE_KEY_VALUE;
1651
1652typedef struct
1653{
1654    tBTM_LE_KEY_TYPE        key_type;
1655    tBTM_LE_KEY_VALUE       *p_key_value;
1656}tBTM_LE_KEY;
1657
1658typedef union
1659{
1660    tBTM_LE_IO_REQ      io_req;     /* BTM_LE_IO_REQ_EVT      */
1661    UINT32              key_notif;  /* BTM_LE_KEY_NOTIF_EVT   */
1662                                    /* no callback dta for BTM_LE_KEY_REQ_EVT & BTM_LE_OOB_REQ_EVT  */
1663#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
1664    tBTM_LE_COMPLT      complt;     /* BTM_LE_COMPLT_EVT      */
1665#endif
1666    tBTM_LE_KEY         key;
1667} tBTM_LE_EVT_DATA;
1668
1669/* Simple Pairing Events.  Called by the stack when Simple Pairing related
1670** events occur.
1671*/
1672typedef UINT8 (tBTM_LE_CALLBACK) (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data);
1673
1674#define BTM_BLE_KEY_TYPE_ID         1
1675#define BTM_BLE_KEY_TYPE_ER         2
1676#define BTM_BLE_KEY_TYPE_COUNTER    3  //tobe obsolete
1677
1678typedef struct
1679{
1680    BT_OCTET16       ir;
1681    BT_OCTET16       irk;
1682    BT_OCTET16       dhk;
1683
1684}tBTM_BLE_LOCAL_ID_KEYS;
1685
1686typedef union
1687{
1688    tBTM_BLE_LOCAL_ID_KEYS  id_keys;
1689    BT_OCTET16              er;
1690}tBTM_BLE_LOCAL_KEYS;
1691
1692
1693/* New LE identity key for local device.
1694*/
1695typedef void (tBTM_LE_KEY_CALLBACK) (UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
1696
1697
1698/***************************
1699**  Security Manager Types
1700****************************/
1701/* Structure that applications use to register with BTM_SecRegister */
1702typedef struct
1703{
1704    tBTM_AUTHORIZE_CALLBACK     *p_authorize_callback;
1705    tBTM_PIN_CALLBACK           *p_pin_callback;
1706    tBTM_LINK_KEY_CALLBACK      *p_link_key_callback;
1707    tBTM_AUTH_COMPLETE_CALLBACK *p_auth_complete_callback;
1708    tBTM_BOND_CANCEL_CMPL_CALLBACK *p_bond_cancel_cmpl_callback;
1709    tBTM_SP_CALLBACK            *p_sp_callback;
1710#if BLE_INCLUDED == TRUE
1711#if SMP_INCLUDED == TRUE
1712    tBTM_LE_CALLBACK            *p_le_callback;
1713#endif
1714    tBTM_LE_KEY_CALLBACK        *p_le_key_callback;
1715#endif
1716} tBTM_APPL_INFO;
1717
1718/* Callback function for when a link supervision timeout event occurs.
1719** This asynchronous event is enabled/disabled by calling BTM_RegForLstoEvt().
1720*/
1721typedef void (tBTM_LSTO_CBACK) (BD_ADDR remote_bda, UINT16 timeout);
1722
1723/*****************************************************************************
1724**  POWER MANAGEMENT
1725*****************************************************************************/
1726/****************************
1727**  Power Manager Constants
1728*****************************/
1729/* BTM Power manager status codes */
1730enum
1731{
1732    BTM_PM_STS_ACTIVE = HCI_MODE_ACTIVE,
1733    BTM_PM_STS_HOLD   = HCI_MODE_HOLD,
1734    BTM_PM_STS_SNIFF  = HCI_MODE_SNIFF,
1735    BTM_PM_STS_PARK   = HCI_MODE_PARK,
1736    BTM_PM_STS_SSR,     /* report the SSR parameters in HCI_SNIFF_SUB_RATE_EVT */
1737    BTM_PM_STS_PENDING,   /* when waiting for status from controller */
1738    BTM_PM_STS_ERROR   /* when HCI command status returns error */
1739};
1740typedef UINT8 tBTM_PM_STATUS;
1741
1742/* BTM Power manager modes */
1743enum
1744{
1745    BTM_PM_MD_ACTIVE = BTM_PM_STS_ACTIVE,
1746    BTM_PM_MD_HOLD   = BTM_PM_STS_HOLD,
1747    BTM_PM_MD_SNIFF  = BTM_PM_STS_SNIFF,
1748    BTM_PM_MD_PARK   = BTM_PM_STS_PARK,
1749    BTM_PM_MD_FORCE  = 0x10 /* OR this to force ACL link to a certain mode */
1750};
1751typedef UINT8 tBTM_PM_MODE;
1752
1753#define BTM_PM_SET_ONLY_ID  0x80
1754
1755/* Operation codes */
1756#define BTM_PM_REG_SET      1 /* The module wants to set the desired power mode */
1757#define BTM_PM_REG_NOTIF    2 /* The module wants to receive mode change event */
1758#define BTM_PM_DEREG        4 /* The module does not want to involve with PM anymore */
1759
1760/************************
1761**  Power Manager Types
1762*************************/
1763typedef struct
1764{
1765    UINT16          max;
1766    UINT16          min;
1767    UINT16          attempt;
1768    UINT16          timeout;
1769    tBTM_PM_MODE    mode;
1770} tBTM_PM_PWR_MD;
1771
1772/*************************************
1773**  Power Manager Callback Functions
1774**************************************/
1775typedef void (tBTM_PM_STATUS_CBACK) (BD_ADDR p_bda, tBTM_PM_STATUS status,
1776                                     UINT16 value, UINT8 hci_status);
1777
1778
1779/************************
1780**  Stored Linkkey Types
1781*************************/
1782#define BTM_CB_EVT_DELETE_STORED_LINK_KEYS  4
1783
1784typedef struct
1785{
1786    UINT8          event;
1787    UINT8          status;
1788    UINT16         num_keys;
1789
1790} tBTM_DELETE_STORED_LINK_KEY_COMPLETE;
1791
1792/* MIP evnets, callbacks    */
1793enum
1794{
1795    BTM_MIP_MODE_CHG_EVT,
1796    BTM_MIP_DISCONNECT_EVT,
1797    BTM_MIP_PKTS_COMPL_EVT,
1798    BTM_MIP_RXDATA_EVT
1799};
1800typedef UINT8 tBTM_MIP_EVT;
1801
1802typedef struct
1803{
1804    tBTM_MIP_EVT    event;
1805    BD_ADDR         bd_addr;
1806    UINT16          mip_id;
1807} tBTM_MIP_MODE_CHANGE;
1808
1809typedef struct
1810{
1811    tBTM_MIP_EVT    event;
1812    UINT16          mip_id;
1813    UINT8           disc_reason;
1814} tBTM_MIP_CONN_TIMEOUT;
1815
1816#define BTM_MIP_MAX_RX_LEN  17
1817
1818typedef struct
1819{
1820    tBTM_MIP_EVT    event;
1821    UINT16          mip_id;
1822    UINT8           rx_len;
1823    UINT8           rx_data[BTM_MIP_MAX_RX_LEN];
1824} tBTM_MIP_RXDATA;
1825
1826typedef struct
1827{
1828    tBTM_MIP_EVT    event;
1829    BD_ADDR         bd_addr;
1830    UINT8           data[11];       /* data[0] shows Vender-specific device type */
1831} tBTM_MIP_EIR_HANDSHAKE;
1832
1833typedef struct
1834{
1835    tBTM_MIP_EVT    event;
1836    UINT16          num_sent;       /* Number of packets completed at the controller */
1837} tBTM_MIP_PKTS_COMPL;
1838
1839typedef union
1840{
1841    tBTM_MIP_EVT            event;
1842    tBTM_MIP_MODE_CHANGE    mod_chg;
1843    tBTM_MIP_CONN_TIMEOUT   conn_tmo;
1844    tBTM_MIP_EIR_HANDSHAKE  eir;
1845    tBTM_MIP_PKTS_COMPL     completed;
1846    tBTM_MIP_RXDATA         rxdata;
1847} tBTM_MIP_EVENT_DATA;
1848
1849/* MIP event callback function  */
1850typedef void (tBTM_MIP_EVENTS_CB) (tBTM_MIP_EVT event, tBTM_MIP_EVENT_DATA data);
1851
1852/* MIP Device query callback function  */
1853typedef BOOLEAN (tBTM_MIP_QUERY_CB) (BD_ADDR dev_addr, UINT8 *p_mode, LINK_KEY link_key);
1854
1855#define BTM_CONTRL_ACTIVE  1       /* ACL link on, SCO link ongoing, sniff mode */
1856#define BTM_CONTRL_SCAN    2       /* Scan state - paging/inquiry/trying to connect*/
1857#define BTM_CONTRL_IDLE    3       /* Idle state - page scan, LE advt, inquiry scan */
1858
1859typedef UINT8 tBTM_CONTRL_STATE;
1860
1861/*****************************************************************************
1862**  EXTERNAL FUNCTION DECLARATIONS
1863*****************************************************************************/
1864#ifdef __cplusplus
1865extern "C" {
1866#endif
1867
1868/*****************************************************************************
1869**  DEVICE CONTROL and COMMON FUNCTIONS
1870*****************************************************************************/
1871
1872/*******************************************************************************
1873**
1874** Function         BTM_DeviceReset
1875**
1876** Description      This function is called to reset the controller.The Callback function
1877**                  if provided is called when startup of the device has
1878**                  completed.
1879**
1880** Returns          void
1881**
1882*******************************************************************************/
1883extern void BTM_DeviceReset (tBTM_CMPL_CB *p_cb);
1884
1885
1886/*******************************************************************************
1887**
1888** Function         BTM_IsDeviceUp
1889**
1890** Description      This function is called to check if the device is up.
1891**
1892** Returns          TRUE if device is up, else FALSE
1893**
1894*******************************************************************************/
1895extern BOOLEAN BTM_IsDeviceUp (void);
1896
1897
1898/*******************************************************************************
1899**
1900** Function         BTM_SetLocalDeviceName
1901**
1902** Description      This function is called to set the local device name.
1903**
1904** Returns          BTM_CMD_STARTED if successful, otherwise an error
1905**
1906*******************************************************************************/
1907extern tBTM_STATUS BTM_SetLocalDeviceName (char *p_name);
1908
1909/*******************************************************************************
1910**
1911** Function         BTM_SetDeviceClass
1912**
1913** Description      This function is called to set the local device class
1914**
1915** Returns          BTM_SUCCESS if successful, otherwise an error
1916**
1917*******************************************************************************/
1918extern tBTM_STATUS  BTM_SetDeviceClass (DEV_CLASS dev_class);
1919
1920
1921/*******************************************************************************
1922**
1923** Function         BTM_ReadLocalDeviceName
1924**
1925** Description      This function is called to read the local device name.
1926**
1927** Returns          status of the operation
1928**                  If success, BTM_SUCCESS is returned and p_name points stored
1929**                              local device name
1930**                  If BTM doesn't store local device name, BTM_NO_RESOURCES is
1931**                              is returned and p_name is set to NULL
1932**
1933*******************************************************************************/
1934extern tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name);
1935
1936/*******************************************************************************
1937**
1938** Function         BTM_ReadLocalDeviceNameFromController
1939**
1940** Description      Get local device name from controller. Do not use cached
1941**                  name (used to get chip-id prior to btm reset complete).
1942**
1943** Returns          BTM_CMD_STARTED if successful, otherwise an error
1944**
1945*******************************************************************************/
1946extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback);
1947
1948/*******************************************************************************
1949**
1950** Function         BTM_ReadDeviceClass
1951**
1952** Description      This function is called to read the local device class
1953**
1954** Returns          pointer to the device class
1955**
1956*******************************************************************************/
1957extern UINT8 *BTM_ReadDeviceClass (void);
1958
1959
1960/*******************************************************************************
1961**
1962** Function         BTM_ReadLocalFeatures
1963**
1964** Description      This function is called to read the local features
1965**
1966** Returns          pointer to the local features string
1967**
1968*******************************************************************************/
1969extern UINT8 *BTM_ReadLocalFeatures (void);
1970
1971/*******************************************************************************
1972**
1973** Function         BTM_RegisterForDeviceStatusNotif
1974**
1975** Description      This function is called to register for device status
1976**                  change notifications.
1977**
1978** Returns          pointer to previous caller's callback function or NULL if first
1979**                  registration.
1980**
1981*******************************************************************************/
1982extern tBTM_DEV_STATUS_CB *BTM_RegisterForDeviceStatusNotif (tBTM_DEV_STATUS_CB *p_cb);
1983
1984
1985/*******************************************************************************
1986**
1987** Function         BTM_RegisterForVSEvents
1988**
1989** Description      This function is called to register/deregister for vendor
1990**                  specific HCI events.
1991**
1992**                  If is_register=TRUE, then the function will be registered;
1993**                  if is_register=FALSE, then the function will be deregistered.
1994**
1995** Returns          BTM_SUCCESS if successful,
1996**                  BTM_BUSY if maximum number of callbacks have already been
1997**                           registered.
1998**
1999*******************************************************************************/
2000extern tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register);
2001
2002
2003/*******************************************************************************
2004**
2005** Function         BTM_VendorSpecificCommand
2006**
2007** Description      Send a vendor specific HCI command to the controller.
2008**
2009** Returns
2010**      BTM_SUCCESS         Command sent. Does not expect command complete
2011**                              event. (command cmpl callback param is NULL)
2012**      BTM_CMD_STARTED     Command sent. Waiting for command cmpl event.
2013**      BTM_BUSY            Command not sent. Waiting for cmd cmpl event for
2014**                              prior command.
2015**
2016*******************************************************************************/
2017extern tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
2018                                             UINT8 param_len,
2019                                             UINT8 *p_param_buf,
2020                                             tBTM_VSC_CMPL_CB *p_cb);
2021
2022
2023/*******************************************************************************
2024**
2025** Function         BTM_AllocateSCN
2026**
2027** Description      Look through the Server Channel Numbers for a free one to be
2028**                  used with an RFCOMM connection.
2029**
2030** Returns          Allocated SCN number or 0 if none.
2031**
2032*******************************************************************************/
2033extern UINT8 BTM_AllocateSCN(void);
2034
2035// btla-specific ++
2036/*******************************************************************************
2037**
2038** Function         BTM_TryAllocateSCN
2039**
2040** Description      Try to allocate a fixed server channel
2041**
2042** Returns          Returns TRUE if server channel was available
2043**
2044*******************************************************************************/
2045extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn);
2046// btla-specific --
2047
2048
2049/*******************************************************************************
2050**
2051** Function         BTM_FreeSCN
2052**
2053** Description      Free the specified SCN.
2054**
2055** Returns          TRUE if successful, FALSE if SCN is not in use or invalid
2056**
2057*******************************************************************************/
2058extern BOOLEAN BTM_FreeSCN(UINT8 scn);
2059
2060
2061/*******************************************************************************
2062**
2063** Function         BTM_SetTraceLevel
2064**
2065** Description      This function sets the trace level for BTM.  If called with
2066**                  a value of 0xFF, it simply returns the current trace level.
2067**
2068** Returns          The new or current trace level
2069**
2070*******************************************************************************/
2071extern UINT8 BTM_SetTraceLevel (UINT8 new_level);
2072
2073
2074/*******************************************************************************
2075**
2076** Function         BTM_WritePageTimeout
2077**
2078** Description      Send HCI Wite Page Timeout.
2079**
2080** Returns
2081**      BTM_SUCCESS         Command sent.
2082**      BTM_NO_RESOURCES    If out of resources to send the command.
2083**
2084*******************************************************************************/
2085extern tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout);
2086
2087/*******************************************************************************
2088**
2089** Function         BTM_WriteVoiceSettings
2090**
2091** Description      Send HCI Write Voice Settings command.
2092**                  See hcidefs.h for settings bitmask values.
2093**
2094** Returns
2095**      BTM_SUCCESS         Command sent.
2096**      BTM_NO_RESOURCES     If out of resources to send the command.
2097**
2098**
2099*******************************************************************************/
2100extern tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings);
2101
2102/*******************************************************************************
2103**
2104** Function         BTM_EnableTestMode
2105**
2106** Description      Send HCI the enable device under test command.
2107**
2108**                  Note: Controller can only be taken out of this mode by
2109**                      resetting the controller.
2110**
2111** Returns
2112**      BTM_SUCCESS         Command sent.
2113**      BTM_NO_RESOURCES    If out of resources to send the command.
2114**
2115**
2116*******************************************************************************/
2117extern tBTM_STATUS BTM_EnableTestMode(void);
2118
2119
2120/*****************************************************************************
2121**  DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
2122*****************************************************************************/
2123
2124/*******************************************************************************
2125**
2126** Function         BTM_SetDiscoverability
2127**
2128** Description      This function is called to set the device into or out of
2129**                  discoverable mode. Discoverable mode means inquiry
2130**                  scans are enabled.  If a value of '0' is entered for window or
2131**                  interval, the default values are used.
2132**
2133** Returns          BTM_SUCCESS if successful
2134**                  BTM_BUSY if a setting of the filter is already in progress
2135**                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
2136**                  BTM_ILLEGAL_VALUE if a bad parameter was detected
2137**                  BTM_WRONG_MODE if the device is not up.
2138**
2139*******************************************************************************/
2140extern tBTM_STATUS  BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window,
2141                                            UINT16 interval);
2142
2143
2144/*******************************************************************************
2145**
2146** Function         BTM_ReadDiscoverability
2147**
2148** Description      This function is called to read the current discoverability
2149**                  mode of the device.
2150**
2151** Output Params:   p_window - current inquiry scan duration
2152**                  p_interval - current inquiry scan interval
2153**
2154** Returns          BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or
2155**                  BTM_GENERAL_DISCOVERABLE
2156**
2157*******************************************************************************/
2158extern UINT16       BTM_ReadDiscoverability (UINT16 *p_window,
2159                                             UINT16 *p_interval);
2160
2161
2162/*******************************************************************************
2163**
2164** Function         BTM_SetPeriodicInquiryMode
2165**
2166** Description      This function is called to set the device periodic inquiry mode.
2167**                  If the duration is zero, the periodic inquiry mode is cancelled.
2168**
2169** Parameters:      p_inqparms - pointer to the inquiry information
2170**                      mode - GENERAL or LIMITED inquiry
2171**                      duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
2172**                      max_resps - maximum amount of devices to search for before ending the inquiry
2173**                      filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
2174**                                         BTM_FILTER_COND_BD_ADDR
2175**                      filter_cond - value for the filter (based on filter_cond_type)
2176**
2177**                  max_delay - maximum amount of time between successive inquiries
2178**                  min_delay - minimum amount of time between successive inquiries
2179**                  p_results_cb - callback returning pointer to results (tBTM_INQ_RESULTS)
2180**
2181** Returns          BTM_CMD_STARTED if successfully started
2182**                  BTM_ILLEGAL_VALUE if a bad parameter is detected
2183**                  BTM_NO_RESOURCES if could not allocate a message buffer
2184**                  BTM_SUCCESS - if cancelling the periodic inquiry
2185**                  BTM_BUSY - if an inquiry is already active
2186**                  BTM_WRONG_MODE if the device is not up.
2187**
2188*******************************************************************************/
2189extern tBTM_STATUS  BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms,
2190                                                UINT16 max_delay, UINT16 min_delay,
2191                                                tBTM_INQ_RESULTS_CB *p_results_cb);
2192
2193
2194/*******************************************************************************
2195**
2196** Function         BTM_StartInquiry
2197**
2198** Description      This function is called to start an inquiry.
2199**
2200** Parameters:      p_inqparms - pointer to the inquiry information
2201**                      mode - GENERAL or LIMITED inquiry
2202**                      duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
2203**                      max_resps - maximum amount of devices to search for before ending the inquiry
2204**                      filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
2205**                                         BTM_FILTER_COND_BD_ADDR
2206**                      filter_cond - value for the filter (based on filter_cond_type)
2207**
2208**                  p_results_cb   - Pointer to the callback routine which gets called
2209**                                upon receipt of an inquiry result. If this field is
2210**                                NULL, the application is not notified.
2211**
2212**                  p_cmpl_cb   - Pointer to the callback routine which gets called
2213**                                upon completion.  If this field is NULL, the
2214**                                application is not notified when completed.
2215** Returns          tBTM_STATUS
2216**                  BTM_CMD_STARTED if successfully initiated
2217**                  BTM_BUSY if already in progress
2218**                  BTM_ILLEGAL_VALUE if parameter(s) are out of range
2219**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2220**                  BTM_WRONG_MODE if the device is not up.
2221**
2222*******************************************************************************/
2223extern tBTM_STATUS  BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms,
2224                                      tBTM_INQ_RESULTS_CB *p_results_cb,
2225                                      tBTM_CMPL_CB *p_cmpl_cb);
2226
2227
2228/*******************************************************************************
2229**
2230** Function         BTM_IsInquiryActive
2231**
2232** Description      This function returns a bit mask of the current inquiry state
2233**
2234** Returns          BTM_INQUIRY_INACTIVE if inactive (0)
2235**                  BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
2236**                  BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
2237**                  BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
2238**
2239*******************************************************************************/
2240extern UINT16 BTM_IsInquiryActive (void);
2241
2242
2243/*******************************************************************************
2244**
2245** Function         BTM_CancelInquiry
2246**
2247** Description      This function cancels an inquiry if active
2248**
2249** Returns          BTM_SUCCESS if successful
2250**                  BTM_NO_RESOURCES if could not allocate a message buffer
2251**                  BTM_WRONG_MODE if the device is not up.
2252**
2253*******************************************************************************/
2254extern tBTM_STATUS BTM_CancelInquiry(void);
2255
2256
2257/*******************************************************************************
2258**
2259** Function         BTM_CancelPeriodicInquiry
2260**
2261** Description      This function cancels a periodic inquiry
2262**
2263** Returns
2264**                  BTM_NO_RESOURCES if could not allocate a message buffer
2265**                  BTM_SUCCESS - if cancelling the periodic inquiry
2266**                  BTM_WRONG_MODE if the device is not up.
2267**
2268*******************************************************************************/
2269extern tBTM_STATUS BTM_CancelPeriodicInquiry(void);
2270
2271
2272/*******************************************************************************
2273**
2274** Function         BTM_SetConnectability
2275**
2276** Description      This function is called to set the device into or out of
2277**                  connectable mode. Discoverable mode means page scans enabled.
2278**
2279** Returns          BTM_SUCCESS if successful
2280**                  BTM_ILLEGAL_VALUE if a bad parameter is detected
2281**                  BTM_NO_RESOURCES if could not allocate a message buffer
2282**                  BTM_WRONG_MODE if the device is not up.
2283**
2284*******************************************************************************/
2285extern tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window,
2286                                          UINT16 interval);
2287
2288
2289/*******************************************************************************
2290**
2291** Function         BTM_ReadConnectability
2292**
2293** Description      This function is called to read the current discoverability
2294**                  mode of the device.
2295** Output Params    p_window - current page scan duration
2296**                  p_interval - current time between page scans
2297**
2298** Returns          BTM_NON_CONNECTABLE or BTM_CONNECTABLE
2299**
2300*******************************************************************************/
2301extern UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval);
2302
2303
2304/*******************************************************************************
2305**
2306** Function         BTM_SetInquiryMode
2307**
2308** Description      This function is called to set standard, with RSSI
2309**                  mode or extended of the inquiry for local device.
2310**
2311** Input Params:    BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
2312**                  BTM_INQ_RESULT_EXTENDED
2313**
2314** Returns          BTM_SUCCESS if successful
2315**                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
2316**                  BTM_ILLEGAL_VALUE if a bad parameter was detected
2317**                  BTM_WRONG_MODE if the device is not up.
2318**
2319*******************************************************************************/
2320extern tBTM_STATUS  BTM_SetInquiryMode (UINT8 mode);
2321
2322/*******************************************************************************
2323**
2324** Function         BTM_SetInquiryScanType
2325**
2326** Description      This function is called to set the iquiry scan-type to
2327**                  standard or interlaced.
2328**
2329** Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
2330**
2331** Returns          BTM_SUCCESS if successful
2332**                  BTM_MODE_UNSUPPORTED if not a 1.2 device
2333**                  BTM_WRONG_MODE if the device is not up.
2334**
2335*******************************************************************************/
2336extern tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type);
2337
2338/*******************************************************************************
2339**
2340** Function         BTM_SetPageScanType
2341**
2342** Description      This function is called to set the page scan-type to
2343**                  standard or interlaced.
2344**
2345** Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
2346**
2347** Returns          BTM_SUCCESS if successful
2348**                  BTM_MODE_UNSUPPORTED if not a 1.2 device
2349**                  BTM_WRONG_MODE if the device is not up.
2350**
2351*******************************************************************************/
2352
2353extern tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type);
2354
2355/*******************************************************************************
2356**
2357** Function         BTM_ReadRemoteDeviceName
2358**
2359** Description      This function initiates a remote device HCI command to the
2360**                  controller and calls the callback when the process has completed.
2361**
2362** Input Params:    remote_bda      - device address of name to retrieve
2363**                  p_cb            - callback function called when BTM_CMD_STARTED
2364**                                    is returned.
2365**                                    A pointer to tBTM_REMOTE_DEV_NAME is passed to the
2366**                                    callback.
2367**
2368** Returns
2369**                  BTM_CMD_STARTED is returned if the request was successfully sent
2370**                                  to HCI.
2371**                  BTM_BUSY if already in progress
2372**                  BTM_UNKNOWN_ADDR if device address is bad
2373**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2374**                  BTM_WRONG_MODE if the device is not up.
2375**
2376*******************************************************************************/
2377extern tBTM_STATUS  BTM_ReadRemoteDeviceName (BD_ADDR remote_bda,
2378                                              tBTM_CMPL_CB *p_cb,
2379                                              tBT_TRANSPORT transport);
2380
2381
2382/*******************************************************************************
2383**
2384** Function         BTM_CancelRemoteDeviceName
2385**
2386** Description      This function initiates the cancel request for the specified
2387**                  remote device.
2388**
2389** Input Params:    None
2390**
2391** Returns
2392**                  BTM_CMD_STARTED is returned if the request was successfully sent
2393**                                  to HCI.
2394**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2395**                  BTM_WRONG_MODE if there is not an active remote name request.
2396**
2397*******************************************************************************/
2398extern tBTM_STATUS  BTM_CancelRemoteDeviceName (void);
2399
2400/*******************************************************************************
2401**
2402** Function         BTM_ReadRemoteVersion
2403**
2404** Description      This function is called to read a remote device's version
2405**
2406** Returns          BTM_SUCCESS if successful, otherwise an error
2407**
2408*******************************************************************************/
2409extern tBTM_STATUS BTM_ReadRemoteVersion (BD_ADDR addr,
2410                                          UINT8 *lmp_version,
2411                                          UINT16 *manufacturer,
2412                                          UINT16 *lmp_sub_version);
2413
2414/*******************************************************************************
2415**
2416** Function         BTM_ReadRemoteFeatures
2417**
2418** Description      This function is called to read a remote device's
2419**                  supported features mask (features mask located at page 0)
2420**
2421**                  Note: The size of device features mask page is
2422**                  BTM_FEATURE_BYTES_PER_PAGE bytes.
2423**
2424** Returns          pointer to the remote supported features mask
2425**
2426*******************************************************************************/
2427extern UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr);
2428
2429/*******************************************************************************
2430**
2431** Function         BTM_ReadRemoteExtendedFeatures
2432**
2433** Description      This function is called to read a specific extended features
2434**                  page of the remote device
2435**
2436**                  Note1: The size of device features mask page is
2437**                  BTM_FEATURE_BYTES_PER_PAGE bytes.
2438**                  Note2: The valid device features mask page number depends on
2439**                  the remote device capabilities. It is expected to be in the
2440**                  range [0 - BTM_EXT_FEATURES_PAGE_MAX].
2441
2442** Returns          pointer to the remote extended features mask
2443**                  or NULL if page_number is not valid
2444**
2445*******************************************************************************/
2446extern UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number);
2447
2448/*******************************************************************************
2449**
2450** Function         BTM_ReadNumberRemoteFeaturesPages
2451**
2452** Description      This function is called to retrieve the number of feature pages
2453**                  read from the remote device
2454**
2455** Returns          number of features pages read from the remote device
2456**
2457*******************************************************************************/
2458extern UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr);
2459
2460/*******************************************************************************
2461**
2462** Function         BTM_ReadAllRemoteFeatures
2463**
2464** Description      This function is called to read all features of the remote device
2465**
2466** Returns          pointer to the byte[0] of the page[0] of the remote device
2467**                  feature mask.
2468**
2469** Note:            the function returns the pointer to the array of the size
2470**                  BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1).
2471**
2472*******************************************************************************/
2473extern UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr);
2474
2475/*******************************************************************************
2476**
2477** Function         BTM_InqDbRead
2478**
2479** Description      This function looks through the inquiry database for a match
2480**                  based on Bluetooth Device Address. This is the application's
2481**                  interface to get the inquiry details of a specific BD address.
2482**
2483** Returns          pointer to entry, or NULL if not found
2484**
2485*******************************************************************************/
2486extern tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda);
2487
2488
2489/*******************************************************************************
2490**
2491** Function         BTM_InqDbFirst
2492**
2493** Description      This function looks through the inquiry database for the first
2494**                  used entry, and returns that. This is used in conjunction with
2495**                  BTM_InqDbNext by applications as a way to walk through the
2496**                  inquiry database.
2497**
2498** Returns          pointer to first in-use entry, or NULL if DB is empty
2499**
2500*******************************************************************************/
2501extern tBTM_INQ_INFO *BTM_InqDbFirst (void);
2502
2503
2504/*******************************************************************************
2505**
2506** Function         BTM_InqDbNext
2507**
2508** Description      This function looks through the inquiry database for the next
2509**                  used entry, and returns that.  If the input parameter is NULL,
2510**                  the first entry is returned.
2511**
2512** Returns          pointer to next in-use entry, or NULL if no more found.
2513**
2514*******************************************************************************/
2515extern tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur);
2516
2517
2518/*******************************************************************************
2519**
2520** Function         BTM_ClearInqDb
2521**
2522** Description      This function is called to clear out a device or all devices
2523**                  from the inquiry database.
2524**
2525** Parameter        p_bda - (input) BD_ADDR ->  Address of device to clear
2526**                                              (NULL clears all entries)
2527**
2528** Returns          BTM_BUSY if an inquiry, get remote name, or event filter
2529**                          is active, otherwise BTM_SUCCESS
2530**
2531*******************************************************************************/
2532extern tBTM_STATUS  BTM_ClearInqDb (BD_ADDR p_bda);
2533
2534/*******************************************************************************
2535**
2536** Function         BTM_ReadInquiryRspTxPower
2537**
2538** Description      This command will read the inquiry Transmit Power level used
2539**                  to transmit the FHS and EIR data packets.
2540**                  This can be used directly in the Tx Power Level EIR data type.
2541**
2542** Returns          BTM_SUCCESS if successful
2543**
2544*******************************************************************************/
2545extern tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb);
2546
2547/*******************************************************************************
2548**
2549** Function         BTM_StartDiscovery
2550**
2551** Description      This function is called by an application (or profile)
2552**                  when it wants to trigger an service discovery using the
2553**                  BTM's discovery database.
2554**
2555** Returns          tBTM_STATUS
2556**                      BTM_CMD_STARTED if the discovery was initiated
2557**                      BTM_BUSY if one is already in progress
2558**                      BTM_UNKNOWN_ADDR if no addresses are in the INQ DB
2559**                      BTM_ERR_PROCESSING if err initiating the command
2560**
2561*******************************************************************************/
2562extern tBTM_STATUS BTM_StartDiscovery (tBTM_CMPL_CB *p_cmpl_cb,
2563                                       BD_ADDR_PTR p_rem_addr);
2564
2565
2566/*******************************************************************************
2567**
2568** Function         BTM_FindAttribute
2569**
2570** Description      This function is called by an application (or profile)
2571**                  when it wants to see if an attribute exists in the BTM
2572**                  discovery database.
2573**
2574** Returns          Pointer to matching record, or NULL
2575**
2576*******************************************************************************/
2577extern tSDP_DISC_REC *BTM_FindAttribute (UINT16 attr_id,
2578                                         tSDP_DISC_REC *p_start_rec);
2579
2580
2581/*******************************************************************************
2582**
2583** Function         BTM_FindService
2584**
2585** Description      This function is called by an application (or profile)
2586**                  when it wants to see if a service exists in the BTM
2587**                  discovery database.
2588**
2589** Returns          Pointer to matching record, or NULL
2590**
2591*******************************************************************************/
2592extern tSDP_DISC_REC *BTM_FindService (UINT16 service_uuid,
2593                                       tSDP_DISC_REC *p_start_rec);
2594
2595
2596/*******************************************************************************
2597**
2598** Function         BTM_SetDiscoveryParams
2599**
2600** Description      This function is called to set the BTM default discovery parameters.
2601**                  These UUID and attribute filters are used during the call to
2602**                  BTM_StartDiscovery.
2603**
2604** Returns          void
2605**
2606*******************************************************************************/
2607extern void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list,
2608                                    UINT16 num_attr, UINT16 *p_attr_list);
2609
2610
2611/*****************************************************************************
2612**  ACL CHANNEL MANAGEMENT FUNCTIONS
2613*****************************************************************************/
2614/*******************************************************************************
2615**
2616** Function         BTM_SetLinkPolicy
2617**
2618** Description      Create and send HCI "Write Policy Set" command
2619**
2620** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2621**
2622*******************************************************************************/
2623extern tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda,
2624                                      UINT16 *settings);
2625
2626/*******************************************************************************
2627**
2628** Function         BTM_SetDefaultLinkPolicy
2629**
2630** Description      Set the default value for HCI "Write Policy Set" command
2631**                  to use when an ACL link is created.
2632**
2633** Returns          void
2634**
2635*******************************************************************************/
2636extern void BTM_SetDefaultLinkPolicy (UINT16 settings);
2637
2638
2639/*******************************************************************************
2640**
2641** Function         BTM_SetDefaultLinkSuperTout
2642**
2643** Description      Set the default value for HCI "Write Link Supervision Timeout"
2644**                  command to use when an ACL link is created.
2645**
2646** Returns          void
2647**
2648*******************************************************************************/
2649extern void BTM_SetDefaultLinkSuperTout (UINT16 timeout);
2650
2651
2652/*******************************************************************************
2653**
2654** Function         BTM_SetLinkSuperTout
2655**
2656** Description      Create and send HCI "Write Link Supervision Timeout" command
2657**
2658** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2659**
2660*******************************************************************************/
2661extern tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda,
2662                                         UINT16 timeout);
2663/*******************************************************************************
2664**
2665** Function         BTM_GetLinkSuperTout
2666**
2667** Description      Read the link supervision timeout value of the connection
2668**
2669** Returns          status of the operation
2670**
2671*******************************************************************************/
2672extern tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda,
2673                                         UINT16 *p_timeout);
2674
2675/*******************************************************************************
2676**
2677** Function         BTM_IsAclConnectionUp
2678**
2679** Description      This function is called to check if an ACL connection exists
2680**                  to a specific remote BD Address.
2681**
2682** Returns          TRUE if connection is up, else FALSE.
2683**
2684*******************************************************************************/
2685extern BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport);
2686
2687
2688/*******************************************************************************
2689**
2690** Function         BTM_GetRole
2691**
2692** Description      This function is called to get the role of the local device
2693**                  for the ACL connection with the specified remote device
2694**
2695** Returns          BTM_SUCCESS if connection exists.
2696**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
2697**
2698*******************************************************************************/
2699extern tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role);
2700
2701
2702
2703/*******************************************************************************
2704**
2705** Function         BTM_SwitchRole
2706**
2707** Description      This function is called to switch role between master and
2708**                  slave.  If role is already set it will do nothing.  If the
2709**                  command was initiated, the callback function is called upon
2710**                  completion.
2711**
2712** Returns          BTM_SUCCESS if already in specified role.
2713**                  BTM_CMD_STARTED if command issued to controller.
2714**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
2715**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
2716**                  BTM_MODE_UNSUPPORTED if local device does not support role switching
2717**
2718*******************************************************************************/
2719extern tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
2720                                   UINT8 new_role,
2721                                   tBTM_CMPL_CB *p_cb);
2722
2723/*******************************************************************************
2724**
2725** Function         BTM_ReadRSSI
2726**
2727** Description      This function is called to read the link policy settings.
2728**                  The address of link policy results are returned in the callback.
2729**                  (tBTM_RSSI_RESULTS)
2730**
2731** Returns          BTM_CMD_STARTED if command issued to controller.
2732**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
2733**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
2734**                  BTM_BUSY if command is already in progress
2735**
2736*******************************************************************************/
2737extern tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
2738
2739
2740/*******************************************************************************
2741**
2742** Function         BTM_ReadTxPower
2743**
2744** Description      This function is called to read the current connection
2745**                  TX power of the connection. The TX power level results
2746**                  are returned in the callback.
2747**                  (tBTM_RSSI_RESULTS)
2748**
2749** Returns          BTM_CMD_STARTED if command issued to controller.
2750**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
2751**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
2752**                  BTM_BUSY if command is already in progress
2753**
2754*******************************************************************************/
2755extern tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda,
2756                                    tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
2757
2758/*******************************************************************************
2759**
2760** Function         BTM_ReadLinkQuality
2761**
2762** Description      This function is called to read the link quality.
2763**                  The value of the link quality is returned in the callback.
2764**                  (tBTM_LINK_QUALITY_RESULTS)
2765**
2766** Returns          BTM_CMD_STARTED if command issued to controller.
2767**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
2768**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
2769**                  BTM_BUSY if command is already in progress
2770**
2771*******************************************************************************/
2772extern tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
2773
2774/*******************************************************************************
2775**
2776** Function         BTM_RegBusyLevelNotif
2777**
2778** Description      This function is called to register a callback to receive
2779**                  busy level change events.
2780**
2781** Returns          BTM_SUCCESS if successfully registered, otherwise error
2782**
2783*******************************************************************************/
2784extern tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
2785                                          tBTM_BL_EVENT_MASK evt_mask);
2786
2787/*******************************************************************************
2788**
2789** Function         BTM_AclRegisterForChanges
2790**
2791** Description      This function is called to register a callback to receive
2792**                  ACL database change events, i.e. new connection or removed.
2793**
2794** Returns          BTM_SUCCESS if successfully initiated, otherwise error
2795**
2796*******************************************************************************/
2797extern tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb);
2798
2799/*******************************************************************************
2800**
2801** Function         BTM_GetNumAclLinks
2802**
2803** Description      This function is called to count the number of
2804**                  ACL links that are active.
2805**
2806** Returns          UINT16  Number of active ACL links
2807**
2808*******************************************************************************/
2809extern UINT16 BTM_GetNumAclLinks (void);
2810
2811/*******************************************************************************
2812**
2813** Function         BTM_SetQoS
2814**
2815** Description      This function is called to setup QoS
2816**
2817** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2818**
2819*******************************************************************************/
2820extern tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC *p_flow,
2821                              tBTM_CMPL_CB *p_cb);
2822
2823
2824/*****************************************************************************
2825**  (e)SCO CHANNEL MANAGEMENT FUNCTIONS
2826*****************************************************************************/
2827/*******************************************************************************
2828**
2829** Function         BTM_CreateSco
2830**
2831** Description      This function is called to create an SCO connection. If the
2832**                  "is_orig" flag is TRUE, the connection will be originated,
2833**                  otherwise BTM will wait for the other side to connect.
2834**
2835** Returns          BTM_UNKNOWN_ADDR if the ACL connection is not up
2836**                  BTM_BUSY         if another SCO being set up to
2837**                                   the same BD address
2838**                  BTM_NO_RESOURCES if the max SCO limit has been reached
2839**                  BTM_CMD_STARTED  if the connection establishment is started.
2840**                                   In this case, "*p_sco_inx" is filled in
2841**                                   with the sco index used for the connection.
2842**
2843*******************************************************************************/
2844extern tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig,
2845                                  UINT16 pkt_types, UINT16 *p_sco_inx,
2846                                  tBTM_SCO_CB *p_conn_cb,
2847                                  tBTM_SCO_CB *p_disc_cb);
2848
2849
2850/*******************************************************************************
2851**
2852** Function         BTM_RemoveSco
2853**
2854** Description      This function is called to remove a specific SCO connection.
2855**
2856** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2857**
2858*******************************************************************************/
2859extern tBTM_STATUS BTM_RemoveSco (UINT16 sco_inx);
2860
2861
2862/*******************************************************************************
2863**
2864** Function         BTM_SetScoPacketTypes
2865**
2866** Description      This function is called to set the packet types used for
2867**                  a specific SCO connection,
2868**
2869** Parameters       pkt_types - One or more of the following
2870**                  BTM_SCO_PKT_TYPES_MASK_HV1
2871**                  BTM_SCO_PKT_TYPES_MASK_HV2
2872**                  BTM_SCO_PKT_TYPES_MASK_HV3
2873**                  BTM_SCO_PKT_TYPES_MASK_EV3
2874**                  BTM_SCO_PKT_TYPES_MASK_EV4
2875**                  BTM_SCO_PKT_TYPES_MASK_EV5
2876**
2877**                  BTM_SCO_LINK_ALL_MASK   - enables all supported types
2878**
2879** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2880**
2881*******************************************************************************/
2882extern tBTM_STATUS BTM_SetScoPacketTypes (UINT16 sco_inx, UINT16 pkt_types);
2883
2884
2885/*******************************************************************************
2886**
2887** Function         BTM_ReadScoPacketTypes
2888**
2889** Description      This function is read the packet types used for a specific
2890**                  SCO connection.
2891**
2892** Returns       One or more of the following (bitmask)
2893**                  BTM_SCO_PKT_TYPES_MASK_HV1
2894**                  BTM_SCO_PKT_TYPES_MASK_HV2
2895**                  BTM_SCO_PKT_TYPES_MASK_HV3
2896**                  BTM_SCO_PKT_TYPES_MASK_EV3
2897**                  BTM_SCO_PKT_TYPES_MASK_EV4
2898**                  BTM_SCO_PKT_TYPES_MASK_EV5
2899**
2900** Returns          packet types supported for the connection
2901**
2902*******************************************************************************/
2903extern UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx);
2904
2905
2906/*******************************************************************************
2907**
2908** Function         BTM_ReadDeviceScoPacketTypes
2909**
2910** Description      This function is read the SCO packet types that
2911**                  the device supports.
2912**
2913** Returns          packet types supported by the device.
2914**
2915*******************************************************************************/
2916extern UINT16 BTM_ReadDeviceScoPacketTypes (void);
2917
2918
2919/*******************************************************************************
2920**
2921** Function         BTM_ReadScoHandle
2922**
2923** Description      This function is used to read the HCI handle used for a specific
2924**                  SCO connection,
2925**
2926** Returns          handle for the connection, or 0xFFFF if invalid SCO index.
2927**
2928*******************************************************************************/
2929extern UINT16 BTM_ReadScoHandle (UINT16 sco_inx);
2930
2931
2932/*******************************************************************************
2933**
2934** Function         BTM_ReadScoBdAddr
2935**
2936** Description      This function is read the remote BD Address for a specific
2937**                  SCO connection,
2938**
2939** Returns          pointer to BD address or NULL if not known
2940**
2941*******************************************************************************/
2942extern UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx);
2943
2944
2945/*******************************************************************************
2946**
2947** Function         BTM_ReadScoDiscReason
2948**
2949** Description      This function is returns the reason why an (e)SCO connection
2950**                  has been removed. It contains the value until read, or until
2951**                  another (e)SCO connection has disconnected.
2952**
2953** Returns          HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
2954**
2955*******************************************************************************/
2956extern UINT16 BTM_ReadScoDiscReason (void);
2957
2958
2959/*******************************************************************************
2960**
2961** Function         BTM_SetEScoMode
2962**
2963** Description      This function sets up the negotiated parameters for SCO or
2964**                  eSCO, and sets as the default mode used for calls to
2965**                  BTM_CreateSco.  It can be called only when there are no
2966**                  active (e)SCO links.
2967**
2968** Returns          BTM_SUCCESS if the successful.
2969**                  BTM_BUSY if there are one or more active (e)SCO links.
2970**
2971*******************************************************************************/
2972extern tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode,
2973                                    tBTM_ESCO_PARAMS *p_parms);
2974
2975/*******************************************************************************
2976**
2977** Function         BTM_SetWBSCodec
2978**
2979** Description      This function sends command to the controller to setup
2980**                  WBS codec for the upcoming eSCO connection.
2981**
2982** Returns          BTM_SUCCESS.
2983**
2984**
2985*******************************************************************************/
2986extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type);
2987
2988/*******************************************************************************
2989**
2990** Function         BTM_RegForEScoEvts
2991**
2992** Description      This function registers a SCO event callback with the
2993**                  specified instance.  It should be used to received
2994**                  connection indication events and change of link parameter
2995**                  events.
2996**
2997** Returns          BTM_SUCCESS if the successful.
2998**                  BTM_ILLEGAL_VALUE if there is an illegal sco_inx
2999**
3000*******************************************************************************/
3001extern tBTM_STATUS BTM_RegForEScoEvts (UINT16 sco_inx,
3002                                       tBTM_ESCO_CBACK *p_esco_cback);
3003
3004/*******************************************************************************
3005**
3006** Function         BTM_ReadEScoLinkParms
3007**
3008** Description      This function returns the current eSCO link parameters for
3009**                  the specified handle.  This can be called anytime a connection
3010**                  is active, but is typically called after receiving the SCO
3011**                  opened callback.
3012**
3013**                  Note: If called over a 1.1 controller, only the packet types
3014**                        field has meaning.
3015**                  Note: If the upper layer doesn't know the current sco index,
3016**                  BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first parameter to
3017**                  find the first active SCO index
3018**
3019** Returns          BTM_SUCCESS if returned data is valid connection.
3020**                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
3021**                  BTM_MODE_UNSUPPORTED if local controller does not support
3022**                      1.2 specification.
3023**
3024*******************************************************************************/
3025extern tBTM_STATUS BTM_ReadEScoLinkParms (UINT16 sco_inx,
3026                                          tBTM_ESCO_DATA *p_parms);
3027
3028/*******************************************************************************
3029**
3030** Function         BTM_ChangeEScoLinkParms
3031**
3032** Description      This function requests renegotiation of the parameters on
3033**                  the current eSCO Link.  If any of the changes are accepted
3034**                  by the controllers, the BTM_ESCO_CHG_EVT event is sent in
3035**                  the tBTM_ESCO_CBACK function with the current settings of
3036**                  the link. The callback is registered through the call to
3037**                  BTM_SetEScoMode.
3038**
3039**
3040** Returns          BTM_CMD_STARTED if command is successfully initiated.
3041**                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
3042**                  BTM_NO_RESOURCES - not enough resources to initiate command.
3043**                  BTM_MODE_UNSUPPORTED if local controller does not support
3044**                      1.2 specification.
3045**
3046*******************************************************************************/
3047extern tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx,
3048                                            tBTM_CHG_ESCO_PARAMS *p_parms);
3049
3050/*******************************************************************************
3051**
3052** Function         BTM_EScoConnRsp
3053**
3054** Description      This function is called upon receipt of an (e)SCO connection
3055**                  request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
3056**                  the request. Parameters used to negotiate eSCO links.
3057**                  If p_parms is NULL, then values set through BTM_SetEScoMode
3058**                  are used.
3059**                  If the link type of the incoming request is SCO, then only
3060**                  the tx_bw, max_latency, content format, and packet_types are
3061**                  valid.  The hci_status parameter should be
3062**                  ([0x0] to accept, [0x0d..0x0f] to reject)
3063**
3064**
3065** Returns          void
3066**
3067*******************************************************************************/
3068extern void BTM_EScoConnRsp (UINT16 sco_inx, UINT8 hci_status,
3069                             tBTM_ESCO_PARAMS *p_parms);
3070
3071/*******************************************************************************
3072**
3073** Function         BTM_GetNumScoLinks
3074**
3075** Description      This function returns the number of active SCO links.
3076**
3077** Returns          UINT8
3078**
3079*******************************************************************************/
3080extern UINT8 BTM_GetNumScoLinks (void);
3081
3082/*****************************************************************************
3083**  SECURITY MANAGEMENT FUNCTIONS
3084*****************************************************************************/
3085/*******************************************************************************
3086**
3087** Function         BTM_SecRegister
3088**
3089** Description      Application manager calls this function to register for
3090**                  security services.  There can be one and only one application
3091**                  saving link keys.  BTM allows only first registration.
3092**
3093** Returns          TRUE if registered OK, else FALSE
3094**
3095*******************************************************************************/
3096extern BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info);
3097
3098
3099/*******************************************************************************
3100**
3101** Function         BTM_SecAddRmtNameNotifyCallback
3102**
3103** Description      Profiles can register to be notified when name of the
3104**                  remote device is resolved (up to BTM_SEC_MAX_RMT_NAME_CALLBACKS).
3105**
3106** Returns          TRUE if registered OK, else FALSE
3107**
3108*******************************************************************************/
3109extern BOOLEAN BTM_SecAddRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback);
3110
3111
3112/*******************************************************************************
3113**
3114** Function         BTM_SecDeleteRmtNameNotifyCallback
3115**
3116** Description      A profile can deregister notification when a new Link Key
3117**                  is generated per connection.
3118**
3119** Returns          TRUE if OK, else FALSE
3120**
3121*******************************************************************************/
3122extern BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (tBTM_RMT_NAME_CALLBACK *p_callback);
3123
3124/*******************************************************************************
3125**
3126** Function         BTM_GetSecurityFlags
3127**
3128** Description      Get security flags for the device
3129**
3130** Returns          BOOLEAN TRUE or FALSE is device found
3131**
3132*******************************************************************************/
3133extern BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 * p_sec_flags);
3134
3135/*******************************************************************************
3136**
3137** Function         BTM_GetSecurityFlagsByTransport
3138**
3139** Description      Get security flags for the device on a particular transport
3140**
3141** Parameters      bd_addr: BD address of remote device
3142**                  p_sec_flags : Out parameter to be filled with security flags for the connection
3143**                  transport :  Physical transport of the connection (BR/EDR or LE)
3144**
3145** Returns          BOOLEAN TRUE or FALSE is device found
3146**
3147*******************************************************************************/
3148extern BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr,
3149                                                UINT8 * p_sec_flags, tBT_TRANSPORT transport);
3150
3151/*******************************************************************************
3152**
3153** Function         BTM_ReadTrustedMask
3154**
3155** Description      Get trusted mask for the device
3156**
3157** Returns          NULL, if the device record is not found.
3158**                  otherwise, the trusted mask
3159**
3160*******************************************************************************/
3161extern UINT32 * BTM_ReadTrustedMask (BD_ADDR bd_addr);
3162
3163/*******************************************************************************
3164**
3165** Function         BTM_SetPinType
3166**
3167** Description      Set PIN type for the device.
3168**
3169** Returns          void
3170**
3171*******************************************************************************/
3172extern void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len);
3173
3174
3175/*******************************************************************************
3176**
3177** Function         BTM_SetPairableMode
3178**
3179** Description      Enable or disable pairing
3180**
3181** Parameters       allow_pairing - (TRUE or FALSE) whether or not the device
3182**                      allows pairing.
3183**                  connect_only_paired - (TRUE or FALSE) whether or not to
3184**                      only allow paired devices to connect.
3185**
3186** Returns          void
3187**
3188*******************************************************************************/
3189extern void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired);
3190
3191/*******************************************************************************
3192**
3193** Function         BTM_SetSecurityLevel
3194**
3195** Description      Register service security level with Security Manager.  Each
3196**                  service must register its requirements regardless of the
3197**                  security level that is used.  This API is called once for originators
3198**                  nad again for acceptors of connections.
3199**
3200** Returns          TRUE if registered OK, else FALSE
3201**
3202*******************************************************************************/
3203extern BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name,
3204                                     UINT8 service_id, UINT16 sec_level,
3205                                     UINT16 psm, UINT32 mx_proto_id,
3206                                     UINT32 mx_chan_id);
3207
3208/*******************************************************************************
3209**
3210** Function         BTM_SetOutService
3211**
3212** Description      This function is called to set the service for
3213**                  outgoing connection.
3214**
3215** Returns          void
3216**
3217*******************************************************************************/
3218extern void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id);
3219
3220/*******************************************************************************
3221**
3222** Function         BTM_SecClrService
3223**
3224** Description      Removes specified service record(s) from the security database.
3225**                  All service records with the specified name are removed.
3226**                  Typically used only by devices with limited RAM so that it can
3227**                  reuse an old security service record.
3228**                          records (except SDP).
3229**
3230** Returns          Number of records that were freed.
3231**
3232*******************************************************************************/
3233extern UINT8 BTM_SecClrService (UINT8 service_id);
3234
3235/*******************************************************************************
3236**
3237** Function         BTM_SecAddDevice
3238**
3239** Description      Add/modify device.  This function will be normally called
3240**                  during host startup to restore all required information
3241**                  stored in the NVRAM.
3242**                  dev_class, bd_name, link_key, and features are NULL if unknown
3243**
3244** Returns          TRUE if added OK, else FALSE
3245**
3246*******************************************************************************/
3247extern BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
3248                                 BD_NAME bd_name, UINT8 *features,
3249                                 UINT32 trusted_mask[], LINK_KEY link_key,
3250                                 UINT8 key_type, tBTM_IO_CAP io_cap);
3251
3252
3253/*******************************************************************************
3254**
3255** Function         BTM_SecDeleteDevice
3256**
3257** Description      Free resources associated with the device.
3258**
3259** Returns          TRUE if rmoved OK, FALSE if not found
3260**
3261*******************************************************************************/
3262extern BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr);
3263
3264
3265/*******************************************************************************
3266**
3267** Function         BTM_SecGetDeviceLinkKey
3268**
3269** Description      This function is called to obtain link key for the device
3270**                  it returns BTM_SUCCESS if link key is available, or
3271**                  BTM_UNKNOWN_ADDR if Security Manager does not know about
3272**                  the device or device record does not contain link key info
3273**
3274** Returns          BTM_SUCCESS if successful, otherwise error code
3275**
3276*******************************************************************************/
3277extern tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr,
3278                                            LINK_KEY link_key);
3279
3280
3281/*******************************************************************************
3282**
3283** Function         BTM_PINCodeReply
3284**
3285** Description      This function is called after Security Manager submitted
3286**                  PIN code request to the UI.
3287**
3288** Parameters:      bd_addr      - Address of the device for which PIN was requested
3289**                  res          - result of the operation BTM_SUCCESS if success
3290**                  pin_len      - length in bytes of the PIN Code
3291**                  p_pin        - pointer to array with the PIN Code
3292**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3293**
3294** Returns          void
3295**
3296*******************************************************************************/
3297extern void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
3298                              UINT8 *p_pin, UINT32 trusted_mask[]);
3299
3300
3301/*******************************************************************************
3302**
3303** Function         BTM_SecBond
3304**
3305** Description      This function is called to perform bonding with peer device.
3306**
3307** Parameters:      bd_addr      - Address of the device to bond
3308**                  pin_len      - length in bytes of the PIN Code
3309**                  p_pin        - pointer to array with the PIN Code
3310**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3311
3312** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3313**
3314*******************************************************************************/
3315extern tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr,
3316                                UINT8 pin_len, UINT8 *p_pin,
3317                                UINT32 trusted_mask[]);
3318
3319/*******************************************************************************
3320**
3321** Function         BTM_SecBondByTransport
3322**
3323** Description      This function is called to perform bonding by designated transport
3324**
3325** Parameters:      bd_addr      - Address of the device to bond
3326**                  pin_len      - length in bytes of the PIN Code
3327**                  p_pin        - pointer to array with the PIN Code
3328**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3329**                  transport :  Physical transport to use for bonding (BR/EDR or LE)
3330**
3331** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3332**
3333*******************************************************************************/
3334extern tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr,
3335                                           tBT_TRANSPORT transport,
3336                                           UINT8 pin_len, UINT8 *p_pin,
3337                                           UINT32 trusted_mask[]);
3338
3339/*******************************************************************************
3340**
3341** Function         BTM_SecBondCancel
3342**
3343** Description      This function is called to cancel ongoing bonding process
3344**                  with peer device.
3345**
3346** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3347**
3348*******************************************************************************/
3349extern tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr);
3350
3351/*******************************************************************************
3352**
3353** Function         BTM_SetEncryption
3354**
3355** Description      This function is called to ensure that connection is
3356**                  encrypted.  Should be called only on an open connection.
3357**                  Typically only needed for connections that first want to
3358**                  bring up unencrypted links, then later encrypt them.
3359**
3360** Parameters:      bd_addr       - Address of the peer device
3361**                  p_callback    - Pointer to callback function called if
3362**                                  this function returns PENDING after required
3363**                                  procedures are completed.  Can be set to NULL
3364**                                  if status is not desired.
3365**                  p_ref_data    - pointer to any data the caller wishes to receive
3366**                                  in the callback function upon completion.
3367*                                   can be set to NULL if not used.
3368**
3369** Returns          BTM_SUCCESS   - already encrypted
3370**                  BTM_PENDING   - command will be returned in the callback
3371**                  BTM_WRONG_MODE- connection not up.
3372**                  BTM_BUSY      - security procedures are currently active
3373**                  BTM_MODE_UNSUPPORTED - if security manager not linked in.
3374**
3375*******************************************************************************/
3376extern tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport,
3377                                      tBTM_SEC_CBACK *p_callback, void *p_ref_data);
3378
3379/*******************************************************************************
3380**
3381** Function         BTM_ConfirmReqReply
3382**
3383** Description      This function is called to confirm the numeric value for
3384**                  Simple Pairing in response to BTM_SP_CFM_REQ_EVT
3385**
3386** Parameters:      res           - result of the operation BTM_SUCCESS if success
3387**                  bd_addr       - Address of the peer device
3388**
3389*******************************************************************************/
3390extern void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr);
3391
3392/*******************************************************************************
3393**
3394** Function         BTM_PasskeyReqReply
3395**
3396** Description      This function is called to provide the passkey for
3397**                  Simple Pairing in response to BTM_SP_KEY_REQ_EVT
3398**
3399** Parameters:      res           - result of the operation BTM_SUCCESS if success
3400**                  bd_addr       - Address of the peer device
3401**                  passkey       - numeric value in the range of 0 - 999999(0xF423F).
3402**
3403*******************************************************************************/
3404extern void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey);
3405
3406/*******************************************************************************
3407**
3408** Function         BTM_SendKeypressNotif
3409**
3410** Description      This function is used during the passkey entry model
3411**                  by a device with KeyboardOnly IO capabilities
3412**                  (very likely to be a HID Device).
3413**                  It is called by a HID Device to inform the remote device when
3414**                  a key has been entered or erased.
3415**
3416** Parameters:      bd_addr - Address of the peer device
3417**                  type - notification type
3418**
3419*******************************************************************************/
3420extern void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type);
3421
3422/*******************************************************************************
3423**
3424** Function         BTM_IoCapRsp
3425**
3426** Description      This function is called in response to BTM_SP_IO_REQ_EVT
3427**                  When the event data io_req.oob_data is set to BTM_OOB_UNKNOWN
3428**                  by the tBTM_SP_CALLBACK implementation, this function is
3429**                  called to provide the actual response
3430**
3431** Parameters:      bd_addr - Address of the peer device
3432**                  io_cap  - The IO capability of local device.
3433**                  oob     - BTM_OOB_NONE or BTM_OOB_PRESENT.
3434**                  auth_req- MITM protection required or not.
3435**
3436*******************************************************************************/
3437extern void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap,
3438                         tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
3439
3440/*******************************************************************************
3441**
3442** Function         BTM_ReadLocalOobData
3443**
3444** Description      This function is called to read the local OOB data from
3445**                  LM
3446**
3447*******************************************************************************/
3448extern tBTM_STATUS BTM_ReadLocalOobData(void);
3449
3450/*******************************************************************************
3451**
3452** Function         BTM_RemoteOobDataReply
3453**
3454** Description      This function is called to provide the remote OOB data for
3455**                  Simple Pairing in response to BTM_SP_RMT_OOB_EVT
3456**
3457** Parameters:      bd_addr     - Address of the peer device
3458**                  c           - simple pairing Hash C.
3459**                  r           - simple pairing Randomizer  C.
3460**
3461*******************************************************************************/
3462extern void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr,
3463                                   BT_OCTET16 c, BT_OCTET16 r);
3464
3465/*******************************************************************************
3466**
3467** Function         BTM_BuildOobData
3468**
3469** Description      This function is called to build the OOB data payload to
3470**                  be sent over OOB (non-Bluetooth) link
3471**
3472** Parameters:      p_data  - the location for OOB data
3473**                  max_len - p_data size.
3474**                  c       - simple pairing Hash C.
3475**                  r       - simple pairing Randomizer  C.
3476**                  name_len- 0, local device name would not be included.
3477**                            otherwise, the local device name is included for
3478**                            up to this specified length
3479**
3480** Returns          Number of bytes in p_data.
3481**
3482*******************************************************************************/
3483extern UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
3484                               BT_OCTET16 r, UINT8 name_len);
3485
3486/*******************************************************************************
3487**
3488** Function         BTM_ReadOobData
3489**
3490** Description      This function is called to parse the OOB data payload
3491**                  received over OOB (non-Bluetooth) link
3492**
3493** Parameters:      p_data  - the location for OOB data
3494**                  eir_tag - The associated EIR tag to read the data.
3495**                  *p_len(output) - the length of the data with the given tag.
3496**
3497** Returns          the beginning of the data with the given tag.
3498**                  NULL, if the tag is not found.
3499**
3500*******************************************************************************/
3501extern UINT8 * BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len);
3502
3503/*******************************************************************************
3504**
3505** Function         BTM_SecReadDevName
3506**
3507** Description      Looks for the device name in the security database for the
3508**                  specified BD address.
3509**
3510** Returns          Pointer to the name or NULL
3511**
3512*******************************************************************************/
3513extern char *BTM_SecReadDevName (BD_ADDR bd_addr);
3514
3515
3516/*****************************************************************************
3517**  POWER MANAGEMENT FUNCTIONS
3518*****************************************************************************/
3519/*******************************************************************************
3520**
3521** Function         BTM_PmRegister
3522**
3523** Description      register or deregister with power manager
3524**
3525** Returns          BTM_SUCCESS if successful,
3526**                  BTM_NO_RESOURCES if no room to hold registration
3527**                  BTM_ILLEGAL_VALUE
3528**
3529*******************************************************************************/
3530extern tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id,
3531                                   tBTM_PM_STATUS_CBACK *p_cb);
3532
3533
3534/*******************************************************************************
3535**
3536** Function         BTM_SetPowerMode
3537**
3538** Description      store the mode in control block or
3539**                  alter ACL connection behavior.
3540**
3541** Returns          BTM_SUCCESS if successful,
3542**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
3543**
3544*******************************************************************************/
3545extern tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda,
3546                                     tBTM_PM_PWR_MD *p_mode);
3547
3548
3549/*******************************************************************************
3550**
3551** Function         BTM_ReadPowerMode
3552**
3553** Description      This returns the current mode for a specific
3554**                  ACL connection.
3555**
3556** Input Param      remote_bda - device address of desired ACL connection
3557**
3558** Output Param     p_mode - address where the current mode is copied into.
3559**                          BTM_ACL_MODE_NORMAL
3560**                          BTM_ACL_MODE_HOLD
3561**                          BTM_ACL_MODE_SNIFF
3562**                          BTM_ACL_MODE_PARK
3563**                          (valid only if return code is BTM_SUCCESS)
3564**
3565** Returns          BTM_SUCCESS if successful,
3566**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
3567**
3568*******************************************************************************/
3569extern tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda,
3570                                      tBTM_PM_MODE *p_mode);
3571
3572/*******************************************************************************
3573**
3574** Function         BTM_SetSsrParams
3575**
3576** Description      This sends the given SSR parameters for the given ACL
3577**                  connection if it is in ACTIVE mode.
3578**
3579** Input Param      remote_bda - device address of desired ACL connection
3580**                  max_lat    - maximum latency (in 0.625ms)(0-0xFFFE)
3581**                  min_rmt_to - minimum remote timeout
3582**                  min_loc_to - minimum local timeout
3583**
3584**
3585** Returns          BTM_SUCCESS if the HCI command is issued successful,
3586**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
3587**                  BTM_CMD_STORED if the command is stored
3588**
3589*******************************************************************************/
3590extern tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
3591                                     UINT16 min_rmt_to, UINT16 min_loc_to);
3592
3593/*******************************************************************************
3594**
3595** Function         BTM_GetHCIConnHandle
3596**
3597** Description      This function is called to get the handle for an ACL connection
3598**                  to a specific remote BD Address.
3599**
3600** Returns          the handle of the connection, or 0xFFFF if none.
3601**
3602*******************************************************************************/
3603extern UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
3604
3605/*******************************************************************************
3606**
3607** Function         BTM_DeleteStoredLinkKey
3608**
3609** Description      This function is called to delete link key for the specified
3610**                  device addresses from the NVRAM storage attached to the Bluetooth
3611**                  controller.
3612**
3613** Parameters:      bd_addr      - Addresses of the devices
3614**                  p_cb         - Call back function to be called to return
3615**                                 the results
3616**
3617*******************************************************************************/
3618extern tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
3619
3620/*******************************************************************************
3621**
3622** Function         BTM_WriteEIR
3623**
3624** Description      This function is called to write EIR data to controller.
3625**
3626** Parameters       p_buff - allocated HCI command buffer including extended
3627**                           inquriry response
3628**
3629** Returns          BTM_SUCCESS  - if successful
3630**                  BTM_MODE_UNSUPPORTED - if local device cannot support it
3631**
3632*******************************************************************************/
3633extern tBTM_STATUS BTM_WriteEIR( BT_HDR * p_buff );
3634
3635/*******************************************************************************
3636**
3637** Function         BTM_CheckEirData
3638**
3639** Description      This function is called to get EIR data from significant part.
3640**
3641** Parameters       p_eir - pointer of EIR significant part
3642**                  type   - finding EIR data type
3643**                  p_length - return the length of EIR data
3644**
3645** Returns          pointer of EIR data
3646**
3647*******************************************************************************/
3648extern UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length );
3649
3650/*******************************************************************************
3651**
3652** Function         BTM_HasEirService
3653**
3654** Description      This function is called to know if UUID in bit map of UUID.
3655**
3656** Parameters       p_eir_uuid - bit map of UUID list
3657**                  uuid16 - UUID 16-bit
3658**
3659** Returns          TRUE - if found
3660**                  FALSE - if not found
3661**
3662*******************************************************************************/
3663extern BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
3664
3665/*******************************************************************************
3666**
3667** Function         BTM_HasInquiryEirService
3668**
3669** Description      This function is called to know if UUID in bit map of UUID list.
3670**
3671** Parameters       p_results - inquiry results
3672**                  uuid16 - UUID 16-bit
3673**
3674** Returns          BTM_EIR_FOUND - if found
3675**                  BTM_EIR_NOT_FOUND - if not found and it is complete list
3676**                  BTM_EIR_UNKNOWN - if not found and it is not complete list
3677**
3678*******************************************************************************/
3679extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
3680                                                        UINT16 uuid16 );
3681
3682/*******************************************************************************
3683**
3684** Function         BTM_AddEirService
3685**
3686** Description      This function is called to add a service in bit map of UUID list.
3687**
3688** Parameters       p_eir_uuid - bit mask of UUID list for EIR
3689**                  uuid16 - UUID 16-bit
3690**
3691** Returns          None
3692**
3693*******************************************************************************/
3694extern void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
3695
3696/*******************************************************************************
3697**
3698** Function         BTM_RemoveEirService
3699**
3700** Description      This function is called to remove a service in bit map of UUID list.
3701**
3702** Parameters       p_eir_uuid - bit mask of UUID list for EIR
3703**                  uuid16 - UUID 16-bit
3704**
3705** Returns          None
3706**
3707*******************************************************************************/
3708extern void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
3709
3710/*******************************************************************************
3711**
3712** Function         BTM_GetEirSupportedServices
3713**
3714** Description      This function is called to get UUID list from bit map of UUID list.
3715**
3716** Parameters       p_eir_uuid - bit mask of UUID list for EIR
3717**                  p - reference of current pointer of EIR
3718**                  max_num_uuid16 - max number of UUID can be written in EIR
3719**                  num_uuid16 - number of UUID have been written in EIR
3720**
3721** Returns          BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
3722**                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
3723**
3724*******************************************************************************/
3725extern UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid,    UINT8 **p,
3726                                          UINT8  max_num_uuid16, UINT8 *p_num_uuid16);
3727
3728/*******************************************************************************
3729**
3730** Function         BTM_GetEirUuidList
3731**
3732** Description      This function parses EIR and returns UUID list.
3733**
3734** Parameters       p_eir - EIR
3735**                  uuid_size - LEN_UUID_16, LEN_UUID_32, LEN_UUID_128
3736**                  p_num_uuid - return number of UUID in found list
3737**                  p_uuid_list - return UUID 16-bit list
3738**                  max_num_uuid - maximum number of UUID to be returned
3739**
3740** Returns          0 - if not found
3741**                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE
3742**                  BTM_EIR_MORE_16BITS_UUID_TYPE
3743**                  BTM_EIR_COMPLETE_32BITS_UUID_TYPE
3744**                  BTM_EIR_MORE_32BITS_UUID_TYPE
3745**                  BTM_EIR_COMPLETE_128BITS_UUID_TYPE
3746**                  BTM_EIR_MORE_128BITS_UUID_TYPE
3747**
3748*******************************************************************************/
3749extern UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid,
3750                                 UINT8 *p_uuid_list, UINT8 max_num_uuid);
3751
3752/*****************************************************************************
3753**  SCO OVER HCI
3754*****************************************************************************/
3755/*******************************************************************************
3756**
3757** Function         BTM_ConfigScoPath
3758**
3759** Description      This function enable/disable SCO over HCI and registers SCO
3760**                  data callback if SCO over HCI is enabled.
3761**
3762** Parameter        path: SCO or HCI
3763**                  p_sco_data_cb: callback function or SCO data if path is set
3764**                                 to transport.
3765**                  p_pcm_param: pointer to the PCM interface parameter. If a NULL
3766**                               pointer is used, PCM parameter maintained in
3767**                               the control block will be used; otherwise update
3768**                               control block value.
3769**                  err_data_rpt: Lisbon feature to enable the erronous data report
3770**                                or not.
3771**
3772** Returns          BTM_SUCCESS if the successful.
3773**                  BTM_NO_RESOURCES: no rsource to start the command.
3774**                  BTM_ILLEGAL_VALUE: invalid callback function pointer.
3775**                  BTM_CMD_STARTED :Command sent. Waiting for command cmpl event.
3776**
3777**
3778*******************************************************************************/
3779extern tBTM_STATUS BTM_ConfigScoPath (tBTM_SCO_ROUTE_TYPE path,
3780                                      tBTM_SCO_DATA_CB *p_sco_data_cb,
3781                                      tBTM_SCO_PCM_PARAM *p_pcm_param,
3782                                      BOOLEAN err_data_rpt);
3783
3784/*******************************************************************************
3785**
3786** Function         BTM_WriteScoData
3787**
3788** Description      This function write SCO data to a specified instance. The data
3789**                  to be written p_buf needs to carry an offset of
3790**                  HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
3791**                  exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is set
3792**                  to 60 and is configurable. Data longer than the maximum bytes
3793**                  will be truncated.
3794**
3795** Returns          BTM_SUCCESS: data write is successful
3796**                  BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
3797**                  BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO packet
3798**                                      size.
3799**                  BTM_NO_RESOURCES: no resources.
3800**                  BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is not
3801**                                    routed via HCI.
3802**
3803**
3804*******************************************************************************/
3805extern tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf);
3806
3807/*******************************************************************************
3808**
3809** Function         BTM_SetARCMode
3810**
3811** Description      Send Audio Routing Control command.
3812**
3813** Returns          void
3814**
3815*******************************************************************************/
3816extern void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_CB *p_arc_cb);
3817
3818
3819/*******************************************************************************
3820**
3821** Function         BTM_PCM2Setup_Write
3822**
3823** Description      Send PCM2_Setup write command.
3824**
3825** Returns          void
3826**
3827*******************************************************************************/
3828extern void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb);
3829
3830
3831/*******************************************************************************
3832**
3833** Function         BTM_PM_ReadControllerState
3834**
3835** Description      This function is called to obtain the controller state
3836**
3837** Returns          Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and BTM_CONTRL_IDLE)
3838**
3839*******************************************************************************/
3840extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
3841
3842#ifdef __cplusplus
3843}
3844#endif
3845
3846#endif /* BTM_API_H */
3847