btm_api.h revision e5ba8841cd39e17c05aeb4ab65b5b761d41577da
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*/
414#ifndef BTM_EIR_UUID_LKUP_TBL
415enum
416{
417    BTM_EIR_UUID_SERVCLASS_SERVICE_DISCOVERY_SERVER,
418/*    BTM_EIR_UUID_SERVCLASS_BROWSE_GROUP_DESCRIPTOR,   */
419/*    BTM_EIR_UUID_SERVCLASS_PUBLIC_BROWSE_GROUP,       */
420    BTM_EIR_UUID_SERVCLASS_SERIAL_PORT,
421    BTM_EIR_UUID_SERVCLASS_LAN_ACCESS_USING_PPP,
422    BTM_EIR_UUID_SERVCLASS_DIALUP_NETWORKING,
423    BTM_EIR_UUID_SERVCLASS_IRMC_SYNC,
424    BTM_EIR_UUID_SERVCLASS_OBEX_OBJECT_PUSH,
425    BTM_EIR_UUID_SERVCLASS_OBEX_FILE_TRANSFER,
426    BTM_EIR_UUID_SERVCLASS_IRMC_SYNC_COMMAND,
427    BTM_EIR_UUID_SERVCLASS_HEADSET,
428    BTM_EIR_UUID_SERVCLASS_CORDLESS_TELEPHONY,
429    BTM_EIR_UUID_SERVCLASS_AUDIO_SOURCE,
430    BTM_EIR_UUID_SERVCLASS_AUDIO_SINK,
431    BTM_EIR_UUID_SERVCLASS_AV_REM_CTRL_TARGET,
432/*    BTM_EIR_UUID_SERVCLASS_ADV_AUDIO_DISTRIBUTION,    */
433    BTM_EIR_UUID_SERVCLASS_AV_REMOTE_CONTROL,
434/*    BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING,        */
435    BTM_EIR_UUID_SERVCLASS_INTERCOM,
436    BTM_EIR_UUID_SERVCLASS_FAX,
437    BTM_EIR_UUID_SERVCLASS_HEADSET_AUDIO_GATEWAY,
438/*    BTM_EIR_UUID_SERVCLASS_WAP,                       */
439/*    BTM_EIR_UUID_SERVCLASS_WAP_CLIENT,                */
440    BTM_EIR_UUID_SERVCLASS_PANU,
441    BTM_EIR_UUID_SERVCLASS_NAP,
442    BTM_EIR_UUID_SERVCLASS_GN,
443    BTM_EIR_UUID_SERVCLASS_DIRECT_PRINTING,
444/*    BTM_EIR_UUID_SERVCLASS_REFERENCE_PRINTING,        */
445    BTM_EIR_UUID_SERVCLASS_IMAGING,
446    BTM_EIR_UUID_SERVCLASS_IMAGING_RESPONDER,
447    BTM_EIR_UUID_SERVCLASS_IMAGING_AUTO_ARCHIVE,
448    BTM_EIR_UUID_SERVCLASS_IMAGING_REF_OBJECTS,
449    BTM_EIR_UUID_SERVCLASS_HF_HANDSFREE,
450    BTM_EIR_UUID_SERVCLASS_AG_HANDSFREE,
451    BTM_EIR_UUID_SERVCLASS_DIR_PRT_REF_OBJ_SERVICE,
452/*    BTM_EIR_UUID_SERVCLASS_REFLECTED_UI,              */
453    BTM_EIR_UUID_SERVCLASS_BASIC_PRINTING,
454    BTM_EIR_UUID_SERVCLASS_PRINTING_STATUS,
455    BTM_EIR_UUID_SERVCLASS_HUMAN_INTERFACE,
456    BTM_EIR_UUID_SERVCLASS_CABLE_REPLACEMENT,
457    BTM_EIR_UUID_SERVCLASS_HCRP_PRINT,
458    BTM_EIR_UUID_SERVCLASS_HCRP_SCAN,
459/*    BTM_EIR_UUID_SERVCLASS_COMMON_ISDN_ACCESS,        */
460/*    BTM_EIR_UUID_SERVCLASS_VIDEO_CONFERENCING_GW,     */
461/*    BTM_EIR_UUID_SERVCLASS_UDI_MT,                    */
462/*    BTM_EIR_UUID_SERVCLASS_UDI_TA,                    */
463/*    BTM_EIR_UUID_SERVCLASS_VCP,                       */
464    BTM_EIR_UUID_SERVCLASS_SAP,
465    BTM_EIR_UUID_SERVCLASS_PBAP_PCE,
466    BTM_EIR_UUID_SERVCLASS_PBAP_PSE,
467/*    BTM_EIR_UUID_SERVCLASS_TE_PHONE_ACCESS,           */
468/*    BTM_EIR_UUID_SERVCLASS_ME_PHONE_ACCESS,           */
469    BTM_EIR_UUID_SERVCLASS_PHONE_ACCESS,
470    BTM_EIR_UUID_SERVCLASS_HEADSET_HS,
471    BTM_EIR_UUID_SERVCLASS_PNP_INFORMATION,
472/*    BTM_EIR_UUID_SERVCLASS_GENERIC_NETWORKING,        */
473/*    BTM_EIR_UUID_SERVCLASS_GENERIC_FILETRANSFER,      */
474/*    BTM_EIR_UUID_SERVCLASS_GENERIC_AUDIO,             */
475/*    BTM_EIR_UUID_SERVCLASS_GENERIC_TELEPHONY,         */
476/*    BTM_EIR_UUID_SERVCLASS_UPNP_SERVICE,              */
477/*    BTM_EIR_UUID_SERVCLASS_UPNP_IP_SERVICE,           */
478/*    BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_PAN,          */
479/*    BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_LAP,          */
480/*    BTM_EIR_UUID_SERVCLASS_ESDP_UPNP_IP_L2CAP,        */
481    BTM_EIR_UUID_SERVCLASS_VIDEO_SOURCE,
482    BTM_EIR_UUID_SERVCLASS_VIDEO_SINK,
483/*    BTM_EIR_UUID_SERVCLASS_VIDEO_DISTRIBUTION         */
484/*    BTM_EIR_UUID_SERVCLASS_HDP_PROFILE                */
485    BTM_EIR_UUID_SERVCLASS_MESSAGE_ACCESS,
486    BTM_EIR_UUID_SERVCLASS_MESSAGE_NOTIFICATION,
487    BTM_EIR_UUID_SERVCLASS_HDP_SOURCE,
488    BTM_EIR_UUID_SERVCLASS_HDP_SINK,
489    BTM_EIR_MAX_SERVICES
490};
491#endif /* BTM_EIR_UUID_LKUP_TBL */
492
493/* search result in EIR of inquiry database */
494#define BTM_EIR_FOUND           0
495#define BTM_EIR_NOT_FOUND       1
496#define BTM_EIR_UNKNOWN         2
497
498typedef UINT8 tBTM_EIR_SEARCH_RESULT;
499
500#define BTM_EIR_FLAGS_TYPE                  HCI_EIR_FLAGS_TYPE                  /* 0x01 */
501#define BTM_EIR_MORE_16BITS_UUID_TYPE       HCI_EIR_MORE_16BITS_UUID_TYPE       /* 0x02 */
502#define BTM_EIR_COMPLETE_16BITS_UUID_TYPE   HCI_EIR_COMPLETE_16BITS_UUID_TYPE   /* 0x03 */
503#define BTM_EIR_MORE_32BITS_UUID_TYPE       HCI_EIR_MORE_32BITS_UUID_TYPE       /* 0x04 */
504#define BTM_EIR_COMPLETE_32BITS_UUID_TYPE   HCI_EIR_COMPLETE_32BITS_UUID_TYPE   /* 0x05 */
505#define BTM_EIR_MORE_128BITS_UUID_TYPE      HCI_EIR_MORE_128BITS_UUID_TYPE      /* 0x06 */
506#define BTM_EIR_COMPLETE_128BITS_UUID_TYPE  HCI_EIR_COMPLETE_128BITS_UUID_TYPE  /* 0x07 */
507#define BTM_EIR_SHORTENED_LOCAL_NAME_TYPE   HCI_EIR_SHORTENED_LOCAL_NAME_TYPE   /* 0x08 */
508#define BTM_EIR_COMPLETE_LOCAL_NAME_TYPE    HCI_EIR_COMPLETE_LOCAL_NAME_TYPE    /* 0x09 */
509#define BTM_EIR_TX_POWER_LEVEL_TYPE         HCI_EIR_TX_POWER_LEVEL_TYPE         /* 0x0A */
510#define BTM_EIR_MANUFACTURER_SPECIFIC_TYPE  HCI_EIR_MANUFACTURER_SPECIFIC_TYPE  /* 0xFF */
511
512/* the following EIR tags are defined to OOB, not regular EIR data */
513#define BTM_EIR_OOB_BD_ADDR_TYPE            HCI_EIR_OOB_BD_ADDR_TYPE    /* 6 bytes */
514#define BTM_EIR_OOB_COD_TYPE                HCI_EIR_OOB_COD_TYPE        /* 3 bytes */
515#define BTM_EIR_OOB_SSP_HASH_C_TYPE         HCI_EIR_OOB_SSP_HASH_C_TYPE /* 16 bytes */
516#define BTM_EIR_OOB_SSP_RAND_R_TYPE         HCI_EIR_OOB_SSP_RAND_R_TYPE /* 16 bytes */
517
518#define BTM_OOB_MANDATORY_SIZE      8   /* include 2 bytes length & 6 bytes bd_addr */
519#define BTM_OOB_DATA_LEN_SIZE       2
520#define BTM_OOB_BD_ADDR_SIZE        6
521#define BTM_OOB_COD_SIZE            BT_OOB_COD_SIZE
522#define BTM_OOB_HASH_C_SIZE         BT_OOB_HASH_C_SIZE
523#define BTM_OOB_RAND_R_SIZE         BT_OOB_RAND_R_SIZE
524
525
526#if BLE_INCLUDED == TRUE
527#define BTM_BLE_SEC_NONE                0
528#define BTM_BLE_SEC_ENCRYPT             1 /* encrypt the link using current key */
529#define BTM_BLE_SEC_ENCRYPT_NO_MITM     2
530#define BTM_BLE_SEC_ENCRYPT_MITM        3
531typedef UINT8   tBTM_BLE_SEC_ACT;
532#endif
533/************************************************************************************************
534** BTM Services MACROS handle array of UINT32 bits for more than 32 services
535*************************************************************************************************/
536/* Determine the number of UINT32's necessary for services */
537#define BTM_EIR_ARRAY_BITS          32          /* Number of bits in each array element */
538#define BTM_EIR_SERVICE_ARRAY_SIZE  (((UINT32)BTM_EIR_MAX_SERVICES / BTM_EIR_ARRAY_BITS) + \
539                                    (((UINT32)BTM_EIR_MAX_SERVICES % BTM_EIR_ARRAY_BITS) ? 1 : 0))
540
541/* MACRO to set the service bit mask in a bit stream */
542#define BTM_EIR_SET_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] |=  \
543                                    ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
544
545
546/* MACRO to clear the service bit mask in a bit stream */
547#define BTM_EIR_CLR_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] &=  \
548                                    ~((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS)))
549
550/* MACRO to check the service bit mask in a bit stream */
551#define BTM_EIR_HAS_SERVICE(p, service)  ((((UINT32 *)(p))[(((UINT32)(service)) / BTM_EIR_ARRAY_BITS)] &  \
552                                    ((UINT32)1 << (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))) >> (((UINT32)(service)) % BTM_EIR_ARRAY_BITS))
553
554/* start of EIR in HCI buffer, 4 bytes = HCI Command(2) + Length(1) + FEC_Req(1) */
555#define BTM_HCI_EIR_OFFSET          (BT_HDR_SIZE + 4)
556
557/***************************
558**  Device Discovery Types
559****************************/
560/* Definitions of the parameters passed to BTM_StartInquiry and
561** BTM_SetPeriodicInquiryMode.
562*/
563typedef struct              /* contains the two device class condition fields */
564{
565    DEV_CLASS       dev_class;
566    DEV_CLASS       dev_class_mask;
567} tBTM_COD_COND;
568
569
570typedef union               /* contains the inquiry filter condition */
571{
572    BD_ADDR         bdaddr_cond;
573    tBTM_COD_COND   cod_cond;
574} tBTM_INQ_FILT_COND;
575
576
577typedef struct              /* contains the parameters passed to the inquiry functions */
578{
579    UINT8   mode;                       /* general or limited */
580    UINT8   duration;                   /* duration of the inquiry (1.28 sec increments) */
581    UINT8   max_resps;                  /* maximum number of responses to return */
582    BOOLEAN report_dup;                 /* report duplicated inquiry response with higher RSSI value */
583    UINT8   filter_cond_type;           /* new devices, BD ADDR, COD, or No filtering */
584    tBTM_INQ_FILT_COND  filter_cond;    /* filter value based on filter cond type */
585#if (defined(BTA_HOST_INTERLEAVE_SEARCH) && BTA_HOST_INTERLEAVE_SEARCH == TRUE)
586    UINT8   intl_duration[4];              /*duration array storing the interleave scan's time portions*/
587#endif
588} tBTM_INQ_PARMS;
589
590#define BTM_INQ_RESULT_BR       0x01
591#define BTM_INQ_RESULT_BLE      0x02
592
593#if (BLE_INCLUDED == TRUE)
594#define BTM_BLE_EVT_CONN_ADV        0x00
595#define BTM_BLE_EVT_CONN_DIR_ADV    0x01
596#define BTM_BLE_EVT_DISC_ADV        0x02
597#define BTM_BLE_EVT_NON_CONN_ADV    0x03
598#define BTM_BLE_EVT_SCAN_RSP        0x04
599typedef UINT8 tBTM_BLE_EVT_TYPE;
600#endif
601
602/* These are the fields returned in each device's response to the inquiry.  It
603** is returned in the results callback if registered.
604*/
605typedef struct
606{
607    UINT16      clock_offset;
608    BD_ADDR     remote_bd_addr;
609    DEV_CLASS   dev_class;
610    UINT8       page_scan_rep_mode;
611    UINT8       page_scan_per_mode;
612    UINT8       page_scan_mode;
613    INT8        rssi;       /* Set to BTM_INQ_RES_IGNORE_RSSI if  not valid */
614#if (BTM_EIR_CLIENT_INCLUDED == TRUE)
615    UINT32      eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
616    BOOLEAN     eir_complete_list;
617#endif
618#if (BLE_INCLUDED == TRUE)
619    tBT_DEVICE_TYPE         device_type;
620    UINT8       inq_result_type;
621    UINT8       ble_addr_type;
622    tBTM_BLE_EVT_TYPE       ble_evt_type;
623    UINT8                   flag;
624#endif
625} tBTM_INQ_RESULTS;
626
627
628/* This is the inquiry response information held in its database by BTM, and available
629** to applications via BTM_InqDbRead, BTM_InqDbFirst, and BTM_InqDbNext.
630*/
631typedef struct
632{
633    tBTM_INQ_RESULTS    results;
634
635    BOOLEAN             appl_knows_rem_name;    /* set by application if it knows the remote name of the peer device.
636                                                   This is later used by application to determine if remote name request is
637                                                   required to be done. Having the flag here avoid duplicate store of inquiry results */
638
639
640#if (BTM_INQ_GET_REMOTE_NAME == TRUE || BLE_INCLUDED == TRUE)
641    UINT16          remote_name_len;
642    tBTM_BD_NAME    remote_name;
643    UINT8           remote_name_state;
644    UINT8           remote_name_type;
645#endif
646
647} tBTM_INQ_INFO;
648
649
650/* Structure returned with inquiry complete callback */
651typedef struct
652{
653    tBTM_STATUS status;
654    UINT8       num_resp;       /* Number of results from the current inquiry */
655} tBTM_INQUIRY_CMPL;
656
657
658/* Structure returned with remote name  request */
659typedef struct
660{
661    UINT16      status;
662    BD_ADDR     bd_addr;
663    UINT16      length;
664    BD_NAME     remote_bd_name;
665} tBTM_REMOTE_DEV_NAME;
666
667typedef struct
668{
669    UINT8   pcm_intf_rate;  /* PCM interface rate: 0: 128kbps, 1: 256 kbps;
670                                2:512 bps; 3: 1024kbps; 4: 2048kbps */
671    UINT8   frame_type;     /* frame type: 0: short; 1: long */
672    UINT8   sync_mode;      /* sync mode: 0: slave; 1: master */
673    UINT8   clock_mode;     /* clock mode: 0: slave; 1: master */
674
675}tBTM_SCO_PCM_PARAM;
676
677/****************************************
678**  Device Discovery Callback Functions
679*****************************************/
680/* Callback function for asynchronous notifications when the BTM inquiry DB
681** changes. First param is inquiry database, second is if added to or removed
682** from the inquiry database.
683*/
684typedef void (tBTM_INQ_DB_CHANGE_CB) (void *p1, BOOLEAN is_new);
685
686/* Callback function for notifications when the BTM gets inquiry response.
687** First param is inquiry results database, second is pointer of EIR.
688*/
689typedef void (tBTM_INQ_RESULTS_CB) (tBTM_INQ_RESULTS *p_inq_results, UINT8 *p_eir);
690
691/*****************************************************************************
692**  ACL CHANNEL MANAGEMENT
693*****************************************************************************/
694/******************
695**  ACL Constants
696*******************/
697
698/* ACL modes */
699#define BTM_ACL_MODE_NORMAL     HCI_MODE_ACTIVE
700#define BTM_ACL_MODE_HOLD       HCI_MODE_HOLD
701#define BTM_ACL_MODE_SNIFF      HCI_MODE_SNIFF
702#define BTM_ACL_MODE_PARK       HCI_MODE_PARK
703
704/* Returned with structure in role switch callback (tBTM_ROLE_SWITCH_CMPL) */
705#define BTM_ROLE_MASTER         HCI_ROLE_MASTER
706#define BTM_ROLE_SLAVE          HCI_ROLE_SLAVE
707#define BTM_ROLE_UNDEFINED      0xff     /* undefined value (error status) */
708
709/* ACL Packet Types */
710#define BTM_ACL_PKT_TYPES_MASK_DM1      HCI_PKT_TYPES_MASK_DM1
711#define BTM_ACL_PKT_TYPES_MASK_DH1      HCI_PKT_TYPES_MASK_DH1
712#define BTM_ACL_PKT_TYPES_MASK_DM3      HCI_PKT_TYPES_MASK_DM3
713#define BTM_ACL_PKT_TYPES_MASK_DH3      HCI_PKT_TYPES_MASK_DH3
714#define BTM_ACL_PKT_TYPES_MASK_DM5      HCI_PKT_TYPES_MASK_DM5
715#define BTM_ACL_PKT_TYPES_MASK_DH5      HCI_PKT_TYPES_MASK_DH5
716#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 HCI_PKT_TYPES_MASK_NO_2_DH1
717#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 HCI_PKT_TYPES_MASK_NO_3_DH1
718#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 HCI_PKT_TYPES_MASK_NO_2_DH3
719#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 HCI_PKT_TYPES_MASK_NO_3_DH3
720#define BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 HCI_PKT_TYPES_MASK_NO_2_DH5
721#define BTM_ACL_PKT_TYPES_MASK_NO_3_DH5 HCI_PKT_TYPES_MASK_NO_3_DH5
722
723/***************
724**  ACL Types
725****************/
726
727/* Structure returned with link policy information (in tBTM_CMPL_CB callback function)
728** in response to BTM_ReadLinkPolicy call.
729*/
730typedef struct
731{
732    tBTM_STATUS status;
733    UINT8       hci_status;
734    BD_ADDR     rem_bda;
735    UINT16      settings;
736} tBTM_LNK_POLICY_RESULTS;
737
738/* Structure returned with Role Switch information (in tBTM_CMPL_CB callback function)
739** in response to BTM_SwitchRole call.
740*/
741typedef struct
742{
743    UINT8   hci_status;     /* HCI status returned with the event */
744    UINT8   role;           /* BTM_ROLE_MASTER or BTM_ROLE_SLAVE */
745    BD_ADDR remote_bd_addr; /* Remote BD addr involved with the switch */
746} tBTM_ROLE_SWITCH_CMPL;
747
748
749/* Structure returned with Change Link Key information (in tBTM_CMPL_CB callback function)
750** in response to BTM_ChangeLinkKey call.
751*/
752typedef struct
753{
754    UINT8   hci_status;     /* HCI status returned with the event */
755    BD_ADDR remote_bd_addr; /* Remote BD addr involved with the change link key */
756} tBTM_CHANGE_KEY_CMPL;
757
758
759/* Structure returned with QoS information (in tBTM_CMPL_CB callback function)
760** in response to BTM_SetQoS call.
761*/
762typedef struct
763{
764    FLOW_SPEC flow;
765    UINT16 handle;
766    UINT8 status;
767} tBTM_QOS_SETUP_CMPL;
768
769
770/* Structure returned with read RSSI event (in tBTM_CMPL_CB callback function)
771** in response to BTM_ReadRSSI call.
772*/
773typedef struct
774{
775    tBTM_STATUS status;
776    UINT8       hci_status;
777    INT8        rssi;
778    BD_ADDR     rem_bda;
779} tBTM_RSSI_RESULTS;
780
781/* Structure returned with read current TX power event (in tBTM_CMPL_CB callback function)
782** in response to BTM_ReadTxPower call.
783*/
784typedef struct
785{
786    tBTM_STATUS status;
787    UINT8       hci_status;
788    INT8        tx_power;
789    BD_ADDR     rem_bda;
790} tBTM_TX_POWER_RESULTS;
791
792/* Structure returned with read link quality event (in tBTM_CMPL_CB callback function)
793** in response to BTM_ReadLinkQuality call.
794*/
795typedef struct
796{
797    tBTM_STATUS status;
798    UINT8       hci_status;
799    UINT8       link_quality;
800    BD_ADDR     rem_bda;
801} tBTM_LINK_QUALITY_RESULTS;
802
803/* Structure returned with read inq tx power quality event (in tBTM_CMPL_CB callback function)
804** in response to BTM_ReadInquiryRspTxPower call.
805*/
806typedef struct
807{
808    tBTM_STATUS status;
809    UINT8       hci_status;
810    INT8        tx_power;
811} tBTM_INQ_TXPWR_RESULTS;
812
813enum
814{
815    BTM_BL_CONN_EVT,
816    BTM_BL_DISCN_EVT,
817    BTM_BL_UPDATE_EVT,
818    BTM_BL_ROLE_CHG_EVT,
819    BTM_BL_COLLISION_EVT
820};
821typedef UINT8 tBTM_BL_EVENT;
822typedef UINT16 tBTM_BL_EVENT_MASK;
823
824#define BTM_BL_CONN_MASK        0x0001
825#define BTM_BL_DISCN_MASK       0x0002
826#define BTM_BL_UPDATE_MASK      0x0004
827#define BTM_BL_ROLE_CHG_MASK    0x0008
828
829/* Device features mask definitions */
830#define BTM_FEATURE_BYTES_PER_PAGE  HCI_FEATURE_BYTES_PER_PAGE
831#define BTM_EXT_FEATURES_PAGE_MAX   HCI_EXT_FEATURES_PAGE_MAX
832
833/* the data type associated with BTM_BL_CONN_EVT */
834typedef struct
835{
836    tBTM_BL_EVENT   event;      /* The event reported. */
837    BD_ADDR_PTR     p_bda;      /* The address of the newly connected device */
838    DEV_CLASS_PTR   p_dc;       /* The device class */
839    BD_NAME_PTR     p_bdn;      /* The device name */
840    UINT8          *p_features; /* pointer to the remote device's features page[0] (supported features page) */
841#if BLE_INCLUDED == TRUE
842    UINT16          handle;     /* connection handle */
843    tBT_TRANSPORT   transport; /* link is LE or not */
844#endif
845} tBTM_BL_CONN_DATA;
846
847/* the data type associated with BTM_BL_DISCN_EVT */
848typedef struct
849{
850    tBTM_BL_EVENT   event;  /* The event reported. */
851    BD_ADDR_PTR     p_bda;  /* The address of the disconnected device */
852#if BLE_INCLUDED == TRUE
853    UINT16          handle; /* disconnected connection handle */
854    tBT_TRANSPORT   transport; /* link is LE link or not */
855#endif
856} tBTM_BL_DISCN_DATA;
857
858/* Busy-Level shall have the inquiry_paging mask set when
859 * inquiry/paging is in progress, Else the number of ACL links */
860#define BTM_BL_INQUIRY_PAGING_MASK 0x10
861#define BTM_BL_INQUIRY_STARTED   (BTM_BL_INQUIRY_PAGING_MASK | 0x1)
862#define BTM_BL_INQUIRY_CANCELLED (BTM_BL_INQUIRY_PAGING_MASK | 0x2)
863#define BTM_BL_INQUIRY_COMPLETE  (BTM_BL_INQUIRY_PAGING_MASK | 0x3)
864#define BTM_BL_PAGING_STARTED    (BTM_BL_INQUIRY_PAGING_MASK | 0x4)
865#define BTM_BL_PAGING_COMPLETE   (BTM_BL_INQUIRY_PAGING_MASK | 0x5)
866/* the data type associated with BTM_BL_UPDATE_EVT */
867typedef struct
868{
869    tBTM_BL_EVENT   event;  /* The event reported. */
870    UINT8           busy_level;/* when paging or inquiring, level is 10.
871                                * Otherwise, the number of ACL links. */
872    UINT8           busy_level_flags; /* Notifies actual inquiry/page activities */
873} tBTM_BL_UPDATE_DATA;
874
875/* the data type associated with BTM_BL_ROLE_CHG_EVT */
876typedef struct
877{
878    tBTM_BL_EVENT   event;      /* The event reported. */
879    BD_ADDR_PTR     p_bda;      /* The address of the peer connected device */
880    UINT8           new_role;
881    UINT8           hci_status; /* HCI status returned with the event */
882} tBTM_BL_ROLE_CHG_DATA;
883
884typedef union
885{
886    tBTM_BL_EVENT           event;  /* The event reported. */
887    tBTM_BL_CONN_DATA       conn;   /* The data associated with BTM_BL_CONN_EVT */
888    tBTM_BL_DISCN_DATA      discn;  /* The data associated with BTM_BL_DISCN_EVT */
889    tBTM_BL_UPDATE_DATA     update; /* The data associated with BTM_BL_UPDATE_EVT */
890    tBTM_BL_ROLE_CHG_DATA   role_chg;/*The data associated with BTM_BL_ROLE_CHG_EVT */
891} tBTM_BL_EVENT_DATA;
892
893/* Callback function for notifications when the BTM busy level
894** changes.
895*/
896typedef void (tBTM_BL_CHANGE_CB) (tBTM_BL_EVENT_DATA *p_data);
897
898/***************************
899**  ACL Callback Functions
900****************************/
901/* Callback function for notifications when the BTM ACL connection DB
902** changes. First param is BD address, second is if added or removed.
903** Registered through BTM_AclRegisterForChanges call.
904*/
905#if BLE_INCLUDED == TRUE
906typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
907                                      BD_NAME p_bdn, UINT8 *features,
908                                      BOOLEAN is_new, UINT16 handle,
909                                      tBT_TRANSPORT transport);
910#else
911typedef void (tBTM_ACL_DB_CHANGE_CB) (BD_ADDR p_bda, DEV_CLASS p_dc,
912                                      BD_NAME p_bdn, UINT8 *features,
913                                      BOOLEAN is_new);
914#endif
915/*****************************************************************************
916**  SCO CHANNEL MANAGEMENT
917*****************************************************************************/
918/******************
919**  SCO Constants
920*******************/
921
922/* Define an invalid SCO index and an invalid HCI handle */
923#define BTM_INVALID_SCO_INDEX       0xFFFF
924#define BTM_INVALID_HCI_HANDLE      0xFFFF
925
926/* Define an invalid SCO disconnect reason */
927#define BTM_INVALID_SCO_DISC_REASON 0xFFFF
928
929/* Define first active SCO index */
930#define BTM_FIRST_ACTIVE_SCO_INDEX  BTM_MAX_SCO_LINKS
931
932/* Define SCO packet types used in APIs */
933#define BTM_SCO_PKT_TYPES_MASK_HV1  HCI_ESCO_PKT_TYPES_MASK_HV1
934#define BTM_SCO_PKT_TYPES_MASK_HV2  HCI_ESCO_PKT_TYPES_MASK_HV2
935#define BTM_SCO_PKT_TYPES_MASK_HV3  HCI_ESCO_PKT_TYPES_MASK_HV3
936#define BTM_SCO_PKT_TYPES_MASK_EV3  HCI_ESCO_PKT_TYPES_MASK_EV3
937#define BTM_SCO_PKT_TYPES_MASK_EV4  HCI_ESCO_PKT_TYPES_MASK_EV4
938#define BTM_SCO_PKT_TYPES_MASK_EV5  HCI_ESCO_PKT_TYPES_MASK_EV5
939#define BTM_SCO_PKT_TYPES_MASK_NO_2_EV3  HCI_ESCO_PKT_TYPES_MASK_NO_2_EV3
940#define BTM_SCO_PKT_TYPES_MASK_NO_3_EV3  HCI_ESCO_PKT_TYPES_MASK_NO_3_EV3
941#define BTM_SCO_PKT_TYPES_MASK_NO_2_EV5  HCI_ESCO_PKT_TYPES_MASK_NO_2_EV5
942#define BTM_SCO_PKT_TYPES_MASK_NO_3_EV5  HCI_ESCO_PKT_TYPES_MASK_NO_3_EV5
943
944#define BTM_SCO_LINK_ONLY_MASK  (BTM_SCO_PKT_TYPES_MASK_HV1 | \
945                                 BTM_SCO_PKT_TYPES_MASK_HV2 | \
946                                 BTM_SCO_PKT_TYPES_MASK_HV3)
947
948#define BTM_ESCO_LINK_ONLY_MASK (BTM_SCO_PKT_TYPES_MASK_EV3 | \
949                                 BTM_SCO_PKT_TYPES_MASK_EV4 | \
950                                 BTM_SCO_PKT_TYPES_MASK_EV5)
951
952#define BTM_SCO_LINK_ALL_PKT_MASK   (BTM_SCO_LINK_ONLY_MASK     | \
953                                     BTM_ESCO_LINK_ONLY_MASK)
954
955#define BTM_VALID_SCO_ALL_PKT_TYPE HCI_VALID_SCO_ALL_PKT_TYPE
956
957/* Passed in BTM_CreateSco if the packet type parameter should be ignored */
958#define BTM_IGNORE_SCO_PKT_TYPE     0
959
960/***************
961**  SCO Types
962****************/
963#define BTM_LINK_TYPE_SCO           HCI_LINK_TYPE_SCO
964#define BTM_LINK_TYPE_ESCO          HCI_LINK_TYPE_ESCO
965typedef UINT8 tBTM_SCO_TYPE;
966
967
968/*******************
969** SCO Routing Path
970********************/
971#define BTM_SCO_ROUTE_PCM           HCI_BRCM_SCO_ROUTE_PCM
972#define BTM_SCO_ROUTE_HCI           HCI_BRCM_SCO_ROUTE_HCI
973typedef UINT8 tBTM_SCO_ROUTE_TYPE;
974
975
976/*******************
977** SCO Codec Types
978********************/
979#define BTM_SCO_CODEC_NONE          0x0000
980#define BTM_SCO_CODEC_CVSD          0x0001
981#define BTM_SCO_CODEC_MSBC          0x0002
982typedef UINT16 tBTM_SCO_CODEC_TYPE;
983
984
985
986/*******************
987** SCO Air Mode Types
988********************/
989#define BTM_SCO_AIR_MODE_U_LAW          0
990#define BTM_SCO_AIR_MODE_A_LAW          1
991#define BTM_SCO_AIR_MODE_CVSD           2
992#define BTM_SCO_AIR_MODE_TRANSPNT       3
993typedef UINT8 tBTM_SCO_AIR_MODE_TYPE;
994
995/*******************
996** SCO Voice Settings
997********************/
998#define BTM_VOICE_SETTING_CVSD  ((UINT16)  (HCI_INP_CODING_LINEAR          |   \
999                                            HCI_INP_DATA_FMT_2S_COMPLEMENT |   \
1000                                            HCI_INP_SAMPLE_SIZE_16BIT      |   \
1001                                            HCI_AIR_CODING_FORMAT_CVSD))
1002
1003#define BTM_VOICE_SETTING_TRANS ((UINT16)  (HCI_INP_CODING_LINEAR          |   \
1004                                            HCI_INP_DATA_FMT_2S_COMPLEMENT |   \
1005                                            HCI_INP_SAMPLE_SIZE_16BIT      |   \
1006                                            HCI_AIR_CODING_FORMAT_TRANSPNT))
1007
1008/*******************
1009** SCO Data Status
1010********************/
1011enum
1012{
1013    BTM_SCO_DATA_CORRECT,
1014    BTM_SCO_DATA_PAR_ERR,
1015    BTM_SCO_DATA_NONE,
1016    BTM_SCO_DATA_PAR_LOST
1017};
1018typedef UINT8 tBTM_SCO_DATA_FLAG;
1019
1020/***************************
1021**  SCO Callback Functions
1022****************************/
1023typedef void (tBTM_SCO_CB) (UINT16 sco_inx);
1024typedef void (tBTM_SCO_DATA_CB) (UINT16 sco_inx, BT_HDR *p_data, tBTM_SCO_DATA_FLAG status);
1025
1026/******************
1027**  eSCO Constants
1028*******************/
1029#define BTM_64KBITS_RATE            0x00001f40  /* 64 kbits/sec data rate */
1030
1031/* Retransmission effort */
1032#define BTM_ESCO_RETRANS_OFF        0
1033#define BTM_ESCO_RETRANS_POWER      1
1034#define BTM_ESCO_RETRANS_QUALITY    2
1035#define BTM_ESCO_RETRANS_DONTCARE   0xff
1036
1037/* Max Latency Don't Care */
1038#define BTM_ESCO_MAX_LAT_DONTCARE   0xffff
1039
1040/***************
1041**  eSCO Types
1042****************/
1043/* tBTM_ESCO_CBACK event types */
1044#define BTM_ESCO_CHG_EVT        1
1045#define BTM_ESCO_CONN_REQ_EVT   2
1046typedef UINT8 tBTM_ESCO_EVT;
1047
1048/* Passed into BTM_SetEScoMode() */
1049typedef struct
1050{
1051    UINT32 tx_bw;
1052    UINT32 rx_bw;
1053    UINT16 max_latency;
1054    UINT16 voice_contfmt;  /* Voice Settings or Content Format */
1055    UINT16 packet_types;
1056    UINT8  retrans_effort;
1057} tBTM_ESCO_PARAMS;
1058
1059typedef struct
1060{
1061    UINT16 max_latency;
1062    UINT16 packet_types;
1063    UINT8  retrans_effort;
1064} tBTM_CHG_ESCO_PARAMS;
1065
1066/* Returned by BTM_ReadEScoLinkParms() */
1067typedef struct
1068{
1069    UINT16  rx_pkt_len;
1070    UINT16  tx_pkt_len;
1071    BD_ADDR bd_addr;
1072    UINT8   link_type;  /* BTM_LINK_TYPE_SCO or BTM_LINK_TYPE_ESCO */
1073    UINT8   tx_interval;
1074    UINT8   retrans_window;
1075    UINT8   air_mode;
1076} tBTM_ESCO_DATA;
1077
1078typedef struct
1079{
1080    UINT16  sco_inx;
1081    UINT16  rx_pkt_len;
1082    UINT16  tx_pkt_len;
1083    BD_ADDR bd_addr;
1084    UINT8   hci_status;
1085    UINT8   tx_interval;
1086    UINT8   retrans_window;
1087} tBTM_CHG_ESCO_EVT_DATA;
1088
1089typedef struct
1090{
1091    UINT16        sco_inx;
1092    BD_ADDR       bd_addr;
1093    DEV_CLASS     dev_class;
1094    tBTM_SCO_TYPE link_type;
1095} tBTM_ESCO_CONN_REQ_EVT_DATA;
1096
1097typedef union
1098{
1099    tBTM_CHG_ESCO_EVT_DATA      chg_evt;
1100    tBTM_ESCO_CONN_REQ_EVT_DATA conn_evt;
1101} tBTM_ESCO_EVT_DATA;
1102
1103/***************************
1104**  eSCO Callback Functions
1105****************************/
1106typedef void (tBTM_ESCO_CBACK) (tBTM_ESCO_EVT event, tBTM_ESCO_EVT_DATA *p_data);
1107
1108
1109/*****************************************************************************
1110**  SECURITY MANAGEMENT
1111*****************************************************************************/
1112/*******************************
1113**  Security Manager Constants
1114********************************/
1115
1116/* Security Mode (BTM_SetSecurityMode) */
1117#define BTM_SEC_MODE_UNDEFINED      0
1118#define BTM_SEC_MODE_NONE           1
1119#define BTM_SEC_MODE_SERVICE        2
1120#define BTM_SEC_MODE_LINK           3
1121#define BTM_SEC_MODE_SP             4
1122#define BTM_SEC_MODE_SP_DEBUG       5
1123
1124/* Security Service Levels [bit mask] (BTM_SetSecurityLevel)
1125** Encryption should not be used without authentication
1126*/
1127#define BTM_SEC_NONE               0x0000 /* Nothing required */
1128#define BTM_SEC_IN_AUTHORIZE       0x0001 /* Inbound call requires authorization */
1129#define BTM_SEC_IN_AUTHENTICATE    0x0002 /* Inbound call requires authentication */
1130#define BTM_SEC_IN_ENCRYPT         0x0004 /* Inbound call requires encryption */
1131#define BTM_SEC_OUT_AUTHORIZE      0x0008 /* Outbound call requires authorization */
1132#define BTM_SEC_OUT_AUTHENTICATE   0x0010 /* Outbound call requires authentication */
1133#define BTM_SEC_OUT_ENCRYPT        0x0020 /* Outbound call requires encryption */
1134#define BTM_SEC_BOND               0x0040 /* Bonding */
1135#define BTM_SEC_BOND_CONN          0x0080 /* bond_created_connection */
1136#define BTM_SEC_FORCE_MASTER       0x0100 /* Need to switch connection to be master */
1137#define BTM_SEC_ATTEMPT_MASTER     0x0200 /* Try to switch connection to be master */
1138#define BTM_SEC_FORCE_SLAVE        0x0400 /* Need to switch connection to be master */
1139#define BTM_SEC_ATTEMPT_SLAVE      0x0800 /* Try to switch connection to be slave */
1140#define BTM_SEC_IN_MITM            0x1000 /* inbound Do man in the middle protection */
1141#define BTM_SEC_OUT_MITM           0x2000 /* outbound Do man in the middle protection */
1142
1143/* Security Flags [bit mask] (BTM_GetSecurityFlags)
1144*/
1145#define BTM_SEC_FLAG_AUTHORIZED     0x01
1146#define BTM_SEC_FLAG_AUTHENTICATED  0x02
1147#define BTM_SEC_FLAG_ENCRYPTED      0x04
1148#define BTM_SEC_FLAG_LKEY_KNOWN     0x10
1149#define BTM_SEC_FLAG_LKEY_AUTHED    0x20
1150
1151/* PIN types */
1152#define BTM_PIN_TYPE_VARIABLE       HCI_PIN_TYPE_VARIABLE
1153#define BTM_PIN_TYPE_FIXED          HCI_PIN_TYPE_FIXED
1154
1155/* Link Key types used to generate the new link key.
1156** returned in link key notification callback function
1157*/
1158#define BTM_LKEY_TYPE_COMBINATION   HCI_LKEY_TYPE_COMBINATION
1159#define BTM_LKEY_TYPE_LOCAL_UNIT    HCI_LKEY_TYPE_LOCAL_UNIT
1160#define BTM_LKEY_TYPE_REMOTE_UNIT   HCI_LKEY_TYPE_REMOTE_UNIT
1161#define BTM_LKEY_TYPE_DEBUG_COMB    HCI_LKEY_TYPE_DEBUG_COMB
1162#define BTM_LKEY_TYPE_UNAUTH_COMB   HCI_LKEY_TYPE_UNAUTH_COMB
1163#define BTM_LKEY_TYPE_AUTH_COMB     HCI_LKEY_TYPE_AUTH_COMB
1164#define BTM_LKEY_TYPE_CHANGED_COMB  HCI_LKEY_TYPE_CHANGED_COMB
1165#define BTM_LKEY_TYPE_IGNORE        0xff    /* used when event is response from
1166                                               hci return link keys request */
1167
1168/* Protocol level security (BTM_SetSecurityLevel) */
1169#define BTM_SEC_PROTO_L2CAP         0
1170#define BTM_SEC_PROTO_SDP           1
1171#define BTM_SEC_PROTO_TCS           2
1172#define BTM_SEC_PROTO_RFCOMM        3
1173#define BTM_SEC_PROTO_OBEX          4
1174#define BTM_SEC_PROTO_BNEP          5
1175#define BTM_SEC_PROTO_HID           6   /* HID      */
1176#define BTM_SEC_PROTO_AVDT          7
1177#define BTM_SEC_PROTO_MCA           8
1178
1179/* Determine the number of UINT32's necessary for security services */
1180#define BTM_SEC_ARRAY_BITS          32          /* Number of bits in each array element */
1181#define BTM_SEC_SERVICE_ARRAY_SIZE  (((UINT32)BTM_SEC_MAX_SERVICES / BTM_SEC_ARRAY_BITS) + \
1182                                    (((UINT32)BTM_SEC_MAX_SERVICES % BTM_SEC_ARRAY_BITS) ? 1 : 0))
1183
1184/* Security service definitions (BTM_SetSecurityLevel)
1185** Used for Authorization APIs
1186*/
1187#define BTM_SEC_SERVICE_SDP_SERVER      0
1188#define BTM_SEC_SERVICE_SERIAL_PORT     1
1189#define BTM_SEC_SERVICE_LAN_ACCESS      2
1190#define BTM_SEC_SERVICE_DUN             3
1191#define BTM_SEC_SERVICE_IRMC_SYNC       4
1192#define BTM_SEC_SERVICE_IRMC_SYNC_CMD   5
1193#define BTM_SEC_SERVICE_OBEX            6
1194#define BTM_SEC_SERVICE_OBEX_FTP        7
1195#define BTM_SEC_SERVICE_HEADSET         8
1196#define BTM_SEC_SERVICE_CORDLESS        9
1197#define BTM_SEC_SERVICE_INTERCOM        10
1198#define BTM_SEC_SERVICE_FAX             11
1199#define BTM_SEC_SERVICE_HEADSET_AG      12
1200#define BTM_SEC_SERVICE_PNP_INFO        13
1201#define BTM_SEC_SERVICE_GEN_NET         14
1202#define BTM_SEC_SERVICE_GEN_FILE        15
1203#define BTM_SEC_SERVICE_GEN_AUDIO       16
1204#define BTM_SEC_SERVICE_GEN_TEL         17
1205#define BTM_SEC_SERVICE_CTP_DATA        18
1206#define BTM_SEC_SERVICE_HCRP_CTRL       19
1207#define BTM_SEC_SERVICE_HCRP_DATA       20
1208#define BTM_SEC_SERVICE_HCRP_NOTIF      21
1209#define BTM_SEC_SERVICE_BPP_JOB         22
1210#define BTM_SEC_SERVICE_BPP_STATUS      23
1211#define BTM_SEC_SERVICE_BPP_REF         24
1212#define BTM_SEC_SERVICE_BNEP_PANU       25
1213#define BTM_SEC_SERVICE_BNEP_GN         26
1214#define BTM_SEC_SERVICE_BNEP_NAP        27
1215#define BTM_SEC_SERVICE_HF_HANDSFREE    28
1216#define BTM_SEC_SERVICE_AG_HANDSFREE    29
1217#define BTM_SEC_SERVICE_TE_PHONE_ACCESS 30
1218#define BTM_SEC_SERVICE_ME_PHONE_ACCESS 31
1219
1220#define BTM_SEC_SERVICE_HIDH_SEC_CTRL   32
1221#define BTM_SEC_SERVICE_HIDH_NOSEC_CTRL 33
1222#define BTM_SEC_SERVICE_HIDH_INTR       34
1223#define BTM_SEC_SERVICE_BIP             35
1224#define BTM_SEC_SERVICE_BIP_REF         36
1225#define BTM_SEC_SERVICE_AVDTP           37
1226#define BTM_SEC_SERVICE_AVDTP_NOSEC     38
1227#define BTM_SEC_SERVICE_AVCTP           39
1228#define BTM_SEC_SERVICE_SAP             40
1229#define BTM_SEC_SERVICE_PBAP            41
1230#define BTM_SEC_SERVICE_RFC_MUX         42
1231#define BTM_SEC_SERVICE_AVCTP_BROWSE    43
1232#define BTM_SEC_SERVICE_MAP             44
1233#define BTM_SEC_SERVICE_MAP_NOTIF       45
1234#define BTM_SEC_SERVICE_MCAP_CTRL       46
1235#define BTM_SEC_SERVICE_MCAP_DATA       47
1236#define BTM_SEC_SERVICE_HDP_SNK         48
1237#define BTM_SEC_SERVICE_HDP_SRC         49
1238#define BTM_SEC_SERVICE_ATT             50
1239
1240/* Update these as services are added */
1241#define BTM_SEC_SERVICE_FIRST_EMPTY     51
1242
1243#ifndef BTM_SEC_MAX_SERVICES
1244#define BTM_SEC_MAX_SERVICES            65
1245#endif
1246
1247/************************************************************************************************
1248** Security Services MACROS handle array of UINT32 bits for more than 32 trusted services
1249*************************************************************************************************/
1250/* MACRO to set the security service bit mask in a bit stream */
1251#define BTM_SEC_SET_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] |=  \
1252                                    ((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
1253
1254
1255/* MACRO to clear the security service bit mask in a bit stream */
1256#define BTM_SEC_CLR_SERVICE(p, service)  (((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)] &=  \
1257                                    ~((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))
1258
1259/* MACRO to check the security service bit mask in a bit stream (Returns TRUE or FALSE) */
1260#define BTM_SEC_IS_SERVICE_TRUSTED(p, service)    (((((UINT32 *)(p))[(((UINT32)(service)) / BTM_SEC_ARRAY_BITS)]) &   \
1261                                        (UINT32)(((UINT32)1 << (((UINT32)(service)) % BTM_SEC_ARRAY_BITS)))) ? TRUE : FALSE)
1262
1263/* MACRO to copy two trusted device bitmask */
1264#define BTM_SEC_COPY_TRUSTED_DEVICE(p_src, p_dst)   {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
1265                                                        ((UINT32 *)(p_dst))[trst] = ((UINT32 *)(p_src))[trst];}
1266
1267/* MACRO to clear two trusted device bitmask */
1268#define BTM_SEC_CLR_TRUSTED_DEVICE(p_dst)   {UINT32 trst; for (trst = 0; trst < BTM_SEC_SERVICE_ARRAY_SIZE; trst++) \
1269                                                        ((UINT32 *)(p_dst))[trst] = 0;}
1270
1271/* Following bits can be provided by host in the trusted_mask array */
1272/* 0..31 bits of mask[0] (Least Significant Word) */
1273#define BTM_SEC_TRUST_SDP_SERVER        (1 << BTM_SEC_SERVICE_SDP_SERVER)
1274#define BTM_SEC_TRUST_SERIAL_PORT       (1 << BTM_SEC_SERVICE_SERIAL_PORT)
1275#define BTM_SEC_TRUST_LAN_ACCESS        (1 << BTM_SEC_SERVICE_LAN_ACCESS)
1276#define BTM_SEC_TRUST_DUN               (1 << BTM_SEC_SERVICE_DUN)
1277#define BTM_SEC_TRUST_IRMC_SYNC         (1 << BTM_SEC_SERVICE_IRMC_SYNC)
1278#define BTM_SEC_TRUST_IRMC_SYNC_CMD     (1 << BTM_SEC_SERVICE_IRMC_SYNC_CMD)
1279#define BTM_SEC_TRUST_OBEX              (1 << BTM_SEC_SERVICE_OBEX)
1280#define BTM_SEC_TRUST_OBEX_FTP          (1 << BTM_SEC_SERVICE_OBEX_FTP)
1281#define BTM_SEC_TRUST_HEADSET           (1 << BTM_SEC_SERVICE_HEADSET)
1282#define BTM_SEC_TRUST_CORDLESS          (1 << BTM_SEC_SERVICE_CORDLESS)
1283#define BTM_SEC_TRUST_INTERCOM          (1 << BTM_SEC_SERVICE_INTERCOM)
1284#define BTM_SEC_TRUST_FAX               (1 << BTM_SEC_SERVICE_FAX)
1285#define BTM_SEC_TRUST_HEADSET_AG        (1 << BTM_SEC_SERVICE_HEADSET_AG)
1286#define BTM_SEC_TRUST_PNP_INFO          (1 << BTM_SEC_SERVICE_PNP_INFO)
1287#define BTM_SEC_TRUST_GEN_NET           (1 << BTM_SEC_SERVICE_GEN_NET)
1288#define BTM_SEC_TRUST_GEN_FILE          (1 << BTM_SEC_SERVICE_GEN_FILE)
1289#define BTM_SEC_TRUST_GEN_AUDIO         (1 << BTM_SEC_SERVICE_GEN_AUDIO)
1290#define BTM_SEC_TRUST_GEN_TEL           (1 << BTM_SEC_SERVICE_GEN_TEL)
1291#define BTM_SEC_TRUST_CTP_DATA          (1 << BTM_SEC_SERVICE_CTP_DATA)
1292#define BTM_SEC_TRUST_HCRP_CTRL         (1 << BTM_SEC_SERVICE_HCRP_CTRL)
1293#define BTM_SEC_TRUST_HCRP_DATA         (1 << BTM_SEC_SERVICE_HCRP_DATA)
1294#define BTM_SEC_TRUST_HCRP_NOTIF        (1 << BTM_SEC_SERVICE_HCRP_NOTIF)
1295#define BTM_SEC_TRUST_BPP_JOB           (1 << BTM_SEC_SERVICE_JOB)
1296#define BTM_SEC_TRUST_BPP_STATUS        (1 << BTM_SEC_SERVICE_STATUS)
1297#define BTM_SEC_TRUST_BPP_REF           (1 << BTM_SEC_SERVICE_REF)
1298#define BTM_SEC_TRUST_BNEP_PANU         (1 << BTM_SEC_SERVICE_BNEP_PANU)
1299#define BTM_SEC_TRUST_BNEP_GN           (1 << BTM_SEC_SERVICE_BNEP_GN)
1300#define BTM_SEC_TRUST_BNEP_NAP          (1 << BTM_SEC_SERVICE_BNEP_NAP)
1301#define BTM_SEC_TRUST_HFP_HF            (1 << BTM_SEC_SERVICE_HF_HANDSFREE)
1302#define BTM_SEC_TRUST_HFP_AG            (1 << BTM_SEC_SERVICE_AG_HANDSFREE)
1303#define BTM_SEC_TRUST_TE_PHONE_ACCESS   (1 << BTM_SEC_SERVICE_TE_PHONE_ACCESS)
1304#define BTM_SEC_TRUST_ME_PHONE_ACCESS   (1 << BTM_SEC_SERVICE_ME_PHONE_ACCESS)
1305
1306/* 0..31 bits of mask[1] (Most Significant Word) */
1307#define BTM_SEC_TRUST_HIDH_CTRL         (1 << (BTM_SEC_SERVICE_HIDH_SEC_CTRL - 32))
1308#define BTM_SEC_TRUST_HIDH_NOSEC_CTRL   (1 << (BTM_SEC_SERVICE_HIDH_NOSEC_CTRL - 32))
1309#define BTM_SEC_TRUST_HIDH_INTR         (1 << (BTM_SEC_SERVICE_HIDH_INTR - 32))
1310#define BTM_SEC_TRUST_BIP               (1 << (BTM_SEC_SERVICE_BIP - 32))
1311#define BTM_SEC_TRUST_BIP_REF           (1 << (BTM_SEC_SERVICE_BIP_REF - 32))
1312#define BTM_SEC_TRUST_AVDTP             (1 << (BTM_SEC_SERVICE_AVDTP - 32))
1313#define BTM_SEC_TRUST_AVDTP_NOSEC       (1 << (BTM_SEC_SERVICE_AVDTP_NOSEC - 32))
1314#define BTM_SEC_TRUST_AVCTP             (1 << (BTM_SEC_SERVICE_AVCTP - 32))
1315#define BTM_SEC_TRUST_SAP               (1 << (BTM_SEC_SERVICE_SAP - 32))
1316#define BTM_SEC_TRUST_PBAP              (1 << (BTM_SEC_SERVICE_PBAP - 32))
1317#define BTM_SEC_TRUST_RFC_MUX           (1 << (BTM_SEC_SERVICE_RFC_MUX - 32))
1318#define BTM_SEC_TRUST_AVCTP_BROWSE      (1 << (BTM_SEC_SERVICE_AVCTP_BROWSE - 32))
1319#define BTM_SEC_TRUST_MAP               (1 << (BTM_SEC_SERVICE_MAP - 32))
1320#define BTM_SEC_TRUST_MAP_NOTIF         (1 << (BTM_SEC_SERVICE_MAP_NOTIF - 32))
1321#define BTM_SEC_TRUST_MCAP_CTRL         (1 << (BTM_SEC_SERVICE_MCAP_CTRL - 32))
1322#define BTM_SEC_TRUST_MCAP_DATA         (1 << (BTM_SEC_SERVICE_MCAP_DATA - 32))
1323#define BTM_SEC_TRUST_HDP_SNK           (1 << (BTM_SEC_SERVICE_HDP_SNK - 32))
1324#define BTM_SEC_TRUST_HDP_SRC           (1 << (BTM_SEC_SERVICE_HDP_SRC - 32))
1325
1326#define BTM_SEC_TRUST_ALL               0xFFFFFFFF  /* for each array element */
1327
1328/****************************************
1329**  Security Manager Callback Functions
1330*****************************************/
1331/* Authorize device for service.  Parameters are
1332**              BD Address of remote
1333**              Device Class of remote
1334**              BD Name of remote
1335**              Service name
1336**              Service Id (NULL - unknown service or unused
1337**                                 [BTM_SEC_SERVICE_NAME_LEN set to 0])
1338**              Is originator of the connection
1339**              Result of the operation
1340*/
1341typedef UINT8 (tBTM_AUTHORIZE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1342                                         tBTM_BD_NAME bd_name, UINT8 *service_name,
1343                                         UINT8 service_id, BOOLEAN is_originator);
1344
1345/* Get PIN for the connection.  Parameters are
1346**              BD Address of remote
1347**              Device Class of remote
1348**              BD Name of remote
1349*/
1350typedef UINT8 (tBTM_PIN_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1351                                   tBTM_BD_NAME bd_name);
1352
1353
1354/* Get Link Key for the connection.  Parameters are
1355**              BD Address of remote
1356**              Link Key
1357*/
1358typedef UINT8 (tBTM_LINK_KEY_REQ_CALLBACK) (BD_ADDR bd_addr, LINK_KEY key);
1359
1360/* New Link Key for the connection.  Parameters are
1361**              BD Address of remote
1362**              Link Key
1363**              Key Type: Combination, Local Unit, or Remote Unit
1364*/
1365typedef UINT8 (tBTM_LINK_KEY_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1366                                        tBTM_BD_NAME bd_name, UINT8 *key,
1367                                        UINT8 key_type);
1368
1369
1370/* Remote Name Resolved.  Parameters are
1371**              BD Address of remote
1372**              BD Name of remote
1373*/
1374typedef void (tBTM_RMT_NAME_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dc,
1375                                       tBTM_BD_NAME bd_name);
1376
1377
1378/* Authentication complete for the connection.  Parameters are
1379**              BD Address of remote
1380**              Device Class of remote
1381**              BD Name of remote
1382**
1383*/
1384typedef UINT8 (tBTM_AUTH_COMPLETE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1385                                             tBTM_BD_NAME bd_name, int result);
1386
1387/* Operation abort.  Called by the stack when link goes down during.  Pin code
1388** request or authorization.  Parameters are
1389**              BD Address of remote
1390**
1391*/
1392typedef UINT8 (tBTM_ABORT_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
1393                                     tBTM_BD_NAME bd_name);
1394
1395enum
1396{
1397    BTM_SP_IO_REQ_EVT,      /* received IO_CAPABILITY_REQUEST event */
1398    BTM_SP_IO_RSP_EVT,      /* received IO_CAPABILITY_RESPONSE event */
1399    BTM_SP_CFM_REQ_EVT,     /* received USER_CONFIRMATION_REQUEST event */
1400    BTM_SP_KEY_NOTIF_EVT,   /* received USER_PASSKEY_NOTIFY event */
1401    BTM_SP_KEY_REQ_EVT,     /* received USER_PASSKEY_REQUEST event */
1402    BTM_SP_KEYPRESS_EVT,    /* received KEYPRESS_NOTIFY event */
1403    BTM_SP_LOC_OOB_EVT,     /* received result for READ_LOCAL_OOB_DATA command */
1404    BTM_SP_RMT_OOB_EVT,     /* received REMOTE_OOB_DATA_REQUEST event */
1405    BTM_SP_COMPLT_EVT,      /* received SIMPLE_PAIRING_COMPLETE event */
1406    BTM_SP_UPGRADE_EVT      /* check if the application wants to upgrade the link key */
1407};
1408typedef UINT8 tBTM_SP_EVT;
1409
1410#define BTM_IO_CAP_OUT      0   /* DisplayOnly */
1411#define BTM_IO_CAP_IO       1   /* DisplayYesNo */
1412#define BTM_IO_CAP_IN       2   /* KeyboardOnly */
1413#define BTM_IO_CAP_NONE     3   /* NoInputNoOutput */
1414#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
1415#define BTM_IO_CAP_KBDISP   4   /* Keyboard display */
1416#define BTM_IO_CAP_MAX      5
1417#else
1418#define BTM_IO_CAP_MAX      4
1419#endif
1420
1421typedef UINT8 tBTM_IO_CAP;
1422
1423#define BTM_MAX_PASSKEY_VAL (999999)
1424#define BTM_MIN_PASSKEY_VAL (0)
1425
1426#define BTM_AUTH_SP_NO      0   /* MITM Protection Not Required - Single Profile/non-bonding
1427                                Numeric comparison with automatic accept allowed */
1428#define BTM_AUTH_SP_YES     1   /* MITM Protection Required - Single Profile/non-bonding
1429                                Use IO Capabilities to determine authentication procedure */
1430#define BTM_AUTH_AP_NO      2   /* MITM Protection Not Required - All Profiles/dedicated bonding
1431                                Numeric comparison with automatic accept allowed */
1432#define BTM_AUTH_AP_YES     3   /* MITM Protection Required - All Profiles/dedicated bonding
1433                                Use IO Capabilities to determine authentication procedure */
1434#define BTM_AUTH_SPGB_NO    4   /* MITM Protection Not Required - Single Profiles/general bonding
1435                                Numeric comparison with automatic accept allowed */
1436#define BTM_AUTH_SPGB_YES   5   /* MITM Protection Required - Single Profiles/general bonding
1437                                Use IO Capabilities to determine authentication procedure */
1438#define BTM_AUTH_DD_BOND    2   /* this bit is ORed to the BTM_AUTH_SP_* when IO exchange for dedicated bonding */
1439#define BTM_AUTH_GB_BIT     4   /* the genernal bonding bit */
1440#define BTM_AUTH_BONDS      6   /* the general/dedicated bonding bits  */
1441#define BTM_AUTH_YN_BIT     1   /* this is the Yes or No bit  */
1442
1443typedef UINT8 tBTM_AUTH_REQ;
1444
1445enum
1446{
1447    BTM_OOB_NONE,
1448    BTM_OOB_PRESENT
1449#if BTM_OOB_INCLUDED == TRUE
1450    ,BTM_OOB_UNKNOWN
1451#endif
1452};
1453typedef UINT8 tBTM_OOB_DATA;
1454
1455/* data type for BTM_SP_IO_REQ_EVT */
1456typedef struct
1457{
1458    BD_ADDR         bd_addr;        /* peer address */
1459    tBTM_IO_CAP     io_cap;         /* local IO capabilities */
1460    tBTM_OOB_DATA   oob_data;       /* OOB data present (locally) for the peer device */
1461    tBTM_AUTH_REQ   auth_req;       /* Authentication required (for local device) */
1462    BOOLEAN         is_orig;        /* TRUE, if local device initiated the SP process */
1463} tBTM_SP_IO_REQ;
1464
1465/* data type for BTM_SP_IO_RSP_EVT */
1466typedef struct
1467{
1468    BD_ADDR         bd_addr;        /* peer address */
1469    tBTM_IO_CAP     io_cap;         /* peer IO capabilities */
1470    tBTM_OOB_DATA   oob_data;       /* OOB data present at peer device for the local device */
1471    tBTM_AUTH_REQ   auth_req;       /* Authentication required for peer device */
1472} tBTM_SP_IO_RSP;
1473
1474/* data type for BTM_SP_CFM_REQ_EVT */
1475typedef struct
1476{
1477    BD_ADDR         bd_addr;        /* peer address */
1478    DEV_CLASS       dev_class;      /* peer CoD */
1479    tBTM_BD_NAME    bd_name;        /* peer device name */
1480    UINT32          num_val;        /* the numeric value for comparison. If just_works, do not show this number to UI */
1481    BOOLEAN         just_works;     /* TRUE, if "Just Works" association model */
1482    tBTM_AUTH_REQ   loc_auth_req;   /* Authentication required for local device */
1483    tBTM_AUTH_REQ   rmt_auth_req;   /* Authentication required for peer device */
1484    tBTM_IO_CAP     loc_io_caps;    /* IO Capabilities of the local device */
1485    tBTM_IO_CAP     rmt_io_caps;    /* IO Capabilities of the remot device */
1486} tBTM_SP_CFM_REQ;
1487
1488/* data type for BTM_SP_KEY_REQ_EVT */
1489typedef struct
1490{
1491    BD_ADDR         bd_addr;        /* peer address */
1492    DEV_CLASS       dev_class;      /* peer CoD */
1493    tBTM_BD_NAME    bd_name;        /* peer device name */
1494} tBTM_SP_KEY_REQ;
1495
1496/* data type for BTM_SP_KEY_NOTIF_EVT */
1497typedef struct
1498{
1499    BD_ADDR         bd_addr;        /* peer address */
1500    DEV_CLASS       dev_class;      /* peer CoD */
1501    tBTM_BD_NAME    bd_name;        /* peer device name */
1502    UINT32          passkey;        /* passkey */
1503} tBTM_SP_KEY_NOTIF;
1504
1505enum
1506{
1507    BTM_SP_KEY_STARTED,         /* passkey entry started */
1508    BTM_SP_KEY_ENTERED,         /* passkey digit entered */
1509    BTM_SP_KEY_ERASED,          /* passkey digit erased */
1510    BTM_SP_KEY_CLEARED,         /* passkey cleared */
1511    BTM_SP_KEY_COMPLT           /* passkey entry completed */
1512};
1513typedef UINT8   tBTM_SP_KEY_TYPE;
1514
1515/* data type for BTM_SP_KEYPRESS_EVT */
1516typedef struct
1517{
1518    BD_ADDR             bd_addr;        /* peer address */
1519    tBTM_SP_KEY_TYPE   notif_type;
1520} tBTM_SP_KEYPRESS;
1521
1522/* data type for BTM_SP_LOC_OOB_EVT */
1523typedef struct
1524{
1525    tBTM_STATUS     status;         /* */
1526    BT_OCTET16      c;              /* Simple Pairing Hash C */
1527    BT_OCTET16      r;              /* Simple Pairing Randomnizer R */
1528} tBTM_SP_LOC_OOB;
1529
1530/* data type for BTM_SP_RMT_OOB_EVT */
1531typedef struct
1532{
1533    BD_ADDR         bd_addr;        /* peer address */
1534    DEV_CLASS       dev_class;      /* peer CoD */
1535    tBTM_BD_NAME    bd_name;        /* peer device name */
1536} tBTM_SP_RMT_OOB;
1537
1538
1539/* data type for BTM_SP_COMPLT_EVT */
1540typedef struct
1541{
1542    BD_ADDR         bd_addr;        /* peer address */
1543    DEV_CLASS       dev_class;      /* peer CoD */
1544    tBTM_BD_NAME    bd_name;        /* peer device name */
1545    tBTM_STATUS     status;         /* status of the simple pairing process */
1546} tBTM_SP_COMPLT;
1547
1548/* data type for BTM_SP_UPGRADE_EVT */
1549typedef struct
1550{
1551    BD_ADDR         bd_addr;        /* peer address */
1552    BOOLEAN         upgrade;        /* TRUE, to upgrade the link key */
1553} tBTM_SP_UPGRADE;
1554
1555typedef union
1556{
1557    tBTM_SP_IO_REQ      io_req;     /* BTM_SP_IO_REQ_EVT      */
1558    tBTM_SP_IO_RSP      io_rsp;     /* BTM_SP_IO_RSP_EVT      */
1559    tBTM_SP_CFM_REQ     cfm_req;    /* BTM_SP_CFM_REQ_EVT     */
1560    tBTM_SP_KEY_NOTIF   key_notif;  /* BTM_SP_KEY_NOTIF_EVT   */
1561    tBTM_SP_KEY_REQ     key_req;    /* BTM_SP_KEY_REQ_EVT     */
1562    tBTM_SP_KEYPRESS    key_press;  /* BTM_SP_KEYPRESS_EVT    */
1563    tBTM_SP_LOC_OOB     loc_oob;    /* BTM_SP_LOC_OOB_EVT     */
1564    tBTM_SP_RMT_OOB     rmt_oob;    /* BTM_SP_RMT_OOB_EVT     */
1565    tBTM_SP_COMPLT      complt;     /* BTM_SP_COMPLT_EVT      */
1566    tBTM_SP_UPGRADE     upgrade;    /* BTM_SP_UPGRADE_EVT      */
1567} tBTM_SP_EVT_DATA;
1568
1569/* Simple Pairing Events.  Called by the stack when Simple Pairing related
1570** events occur.
1571*/
1572typedef UINT8 (tBTM_SP_CALLBACK) (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
1573
1574
1575typedef void (tBTM_MKEY_CALLBACK) (BD_ADDR bd_addr, UINT8 status, UINT8 key_flag) ;
1576
1577/* Encryption enabled/disabled complete: Optionally passed with BTM_SetEncryption.
1578** Parameters are
1579**              BD Address of remote
1580**              optional data passed in by BTM_SetEncryption
1581**              tBTM_STATUS - result of the operation
1582*/
1583typedef void (tBTM_SEC_CBACK) (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
1584                                void *p_ref_data, tBTM_STATUS result);
1585
1586/* Bond Cancel complete. Parameters are
1587**              Result of the cancel operation
1588**
1589*/
1590typedef void (tBTM_BOND_CANCEL_CMPL_CALLBACK) (tBTM_STATUS result);
1591
1592/* LE related event and data structure
1593*/
1594enum
1595{
1596    BTM_LE_IO_REQ_EVT = 1,      /* received IO_CAPABILITY_REQUEST event */
1597    BTM_LE_SEC_REQUEST_EVT, /* security request event */
1598    BTM_LE_KEY_NOTIF_EVT,   /* received USER_PASSKEY_NOTIFY event */
1599    BTM_LE_KEY_REQ_EVT,     /* received USER_PASSKEY_REQUEST event */
1600    BTM_LE_OOB_REQ_EVT,     /* OOB data request event */
1601    BTM_LE_COMPLT_EVT,      /* received SIMPLE_PAIRING_COMPLETE event */
1602    BTM_LE_KEY_EVT         /* KEY update event */
1603};
1604typedef UINT8 tBTM_LE_EVT;
1605
1606#define BTM_LE_KEY_PENC      SMP_SEC_KEY_TYPE_ENC        /* encryption information of peer device */
1607#define BTM_LE_KEY_PID       SMP_SEC_KEY_TYPE_ID         /* identity key of the peer device */
1608#define BTM_LE_KEY_PCSRK      SMP_SEC_KEY_TYPE_CSRK        /* peer SRK */
1609#define BTM_LE_KEY_LENC      (SMP_SEC_KEY_TYPE_ENC << 3)       /* master role security information:div */
1610#define BTM_LE_KEY_LID       (SMP_SEC_KEY_TYPE_ID << 3)        /* master device ID key */
1611#define BTM_LE_KEY_LCSRK     (SMP_SEC_KEY_TYPE_CSRK << 3)       /* local CSRK has been deliver to peer */
1612typedef UINT8 tBTM_LE_KEY_TYPE;
1613
1614#define BTM_LE_AUTH_REQ_NO_BOND SMP_AUTH_NO_BOND   /* 0 */
1615#define BTM_LE_AUTH_REQ_BOND    SMP_AUTH_GEN_BOND  /* 1 << 0 */
1616#define BTM_LE_AUTH_REQ_MITM    SMP_AUTH_YN_BIT    /* 1 << 2 */
1617typedef UINT8 tBTM_LE_AUTH_REQ;
1618
1619#define BTM_LE_AUTH_REQ_MASK SMP_AUTH_MASK  /* 0x03*/
1620
1621/* LE security level */
1622#define BTM_LE_SEC_NONE             SMP_SEC_NONE
1623#define BTM_LE_SEC_UNAUTHENTICATE   SMP_SEC_UNAUTHENTICATE      /* 1 */
1624#define BTM_LE_SEC_AUTHENTICATED    SMP_SEC_AUTHENTICATED       /* 4 */
1625typedef UINT8 tBTM_LE_SEC;
1626
1627
1628typedef struct
1629{
1630    tBTM_IO_CAP         io_cap;         /* local IO capabilities */
1631    UINT8               oob_data;       /* OOB data present (locally) for the peer device */
1632    tBTM_LE_AUTH_REQ    auth_req;       /* Authentication request (for local device) contain bonding and MITM info */
1633    UINT8               max_key_size;   /* max encryption key size */
1634    tBTM_LE_KEY_TYPE    init_keys;      /* keys to be distributed, bit mask */
1635    tBTM_LE_KEY_TYPE    resp_keys;      /* keys to be distributed, bit mask */
1636} tBTM_LE_IO_REQ;
1637
1638#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
1639/* data type for tBTM_LE_COMPLT */
1640typedef struct
1641{
1642    UINT8       reason;
1643    UINT8       sec_level;
1644    BOOLEAN     privacy_supported;
1645    BOOLEAN     is_pair_cancel;
1646}tBTM_LE_COMPLT;
1647#endif
1648
1649/* BLE encryption keys */
1650typedef struct
1651{
1652    BT_OCTET16  ltk;
1653    BT_OCTET8   rand;
1654    UINT16      ediv;
1655    UINT8       sec_level;
1656    UINT8       key_size;
1657}tBTM_LE_PENC_KEYS;
1658
1659/* BLE CSRK keys */
1660typedef struct
1661{
1662    UINT32          counter;
1663    BT_OCTET16      csrk;
1664    UINT8           sec_level;
1665}tBTM_LE_PCSRK_KEYS;
1666
1667/* BLE Encryption reproduction keys */
1668typedef struct
1669{
1670    UINT16      div;
1671    UINT8       key_size;
1672    UINT8       sec_level;
1673}tBTM_LE_LENC_KEYS;
1674
1675/* BLE SRK keys */
1676typedef struct
1677{
1678    UINT32          counter;
1679    UINT16          div;
1680    UINT8           sec_level;
1681
1682}tBTM_LE_LCSRK_KEYS;
1683
1684typedef struct
1685{
1686    BT_OCTET16          irk;
1687    tBLE_ADDR_TYPE      addr_type;
1688    BD_ADDR             static_addr;
1689}tBTM_LE_PID_KEYS;
1690
1691typedef union
1692{
1693    tBTM_LE_PENC_KEYS   penc_key;       /* received peer encryption key */
1694    tBTM_LE_PCSRK_KEYS  pcsrk_key;       /* received peer device SRK */
1695    tBTM_LE_PID_KEYS    pid_key;        /* peer device ID key */
1696    tBTM_LE_LENC_KEYS   lenc_key;       /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
1697    tBTM_LE_LCSRK_KEYS   lcsrk_key;      /* local device CSRK = d1(ER,DIV,1)*/
1698}tBTM_LE_KEY_VALUE;
1699
1700typedef struct
1701{
1702    tBTM_LE_KEY_TYPE        key_type;
1703    tBTM_LE_KEY_VALUE       *p_key_value;
1704}tBTM_LE_KEY;
1705
1706typedef union
1707{
1708    tBTM_LE_IO_REQ      io_req;     /* BTM_LE_IO_REQ_EVT      */
1709    UINT32              key_notif;  /* BTM_LE_KEY_NOTIF_EVT   */
1710                                    /* no callback dta for BTM_LE_KEY_REQ_EVT & BTM_LE_OOB_REQ_EVT  */
1711#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
1712    tBTM_LE_COMPLT      complt;     /* BTM_LE_COMPLT_EVT      */
1713#endif
1714    tBTM_LE_KEY         key;
1715} tBTM_LE_EVT_DATA;
1716
1717/* Simple Pairing Events.  Called by the stack when Simple Pairing related
1718** events occur.
1719*/
1720typedef UINT8 (tBTM_LE_CALLBACK) (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data);
1721
1722#define BTM_BLE_KEY_TYPE_ID         1
1723#define BTM_BLE_KEY_TYPE_ER         2
1724#define BTM_BLE_KEY_TYPE_COUNTER    3  //tobe obsolete
1725
1726typedef struct
1727{
1728    BT_OCTET16       ir;
1729    BT_OCTET16       irk;
1730    BT_OCTET16       dhk;
1731
1732}tBTM_BLE_LOCAL_ID_KEYS;
1733
1734typedef union
1735{
1736    tBTM_BLE_LOCAL_ID_KEYS  id_keys;
1737    BT_OCTET16              er;
1738}tBTM_BLE_LOCAL_KEYS;
1739
1740
1741/* New LE identity key for local device.
1742*/
1743typedef void (tBTM_LE_KEY_CALLBACK) (UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
1744
1745
1746/***************************
1747**  Security Manager Types
1748****************************/
1749/* Structure that applications use to register with BTM_SecRegister */
1750typedef struct
1751{
1752    tBTM_AUTHORIZE_CALLBACK     *p_authorize_callback;
1753    tBTM_PIN_CALLBACK           *p_pin_callback;
1754    tBTM_LINK_KEY_CALLBACK      *p_link_key_callback;
1755    tBTM_LINK_KEY_REQ_CALLBACK  *p_link_key_req_callback;
1756    tBTM_AUTH_COMPLETE_CALLBACK *p_auth_complete_callback;
1757    tBTM_ABORT_CALLBACK         *p_abort_callback;
1758    tBTM_BOND_CANCEL_CMPL_CALLBACK *p_bond_cancel_cmpl_callback;
1759    tBTM_SP_CALLBACK            *p_sp_callback;
1760#if BLE_INCLUDED == TRUE
1761#if SMP_INCLUDED == TRUE
1762    tBTM_LE_CALLBACK            *p_le_callback;
1763#endif
1764    tBTM_LE_KEY_CALLBACK        *p_le_key_callback;
1765#endif
1766} tBTM_APPL_INFO;
1767
1768/* Callback function for when a link supervision timeout event occurs.
1769** This asynchronous event is enabled/disabled by calling BTM_RegForLstoEvt().
1770*/
1771typedef void (tBTM_LSTO_CBACK) (BD_ADDR remote_bda, UINT16 timeout);
1772
1773/*****************************************************************************
1774**  POWER MANAGEMENT
1775*****************************************************************************/
1776/****************************
1777**  Power Manager Constants
1778*****************************/
1779/* BTM Power manager status codes */
1780enum
1781{
1782    BTM_PM_STS_ACTIVE = HCI_MODE_ACTIVE,
1783    BTM_PM_STS_HOLD   = HCI_MODE_HOLD,
1784    BTM_PM_STS_SNIFF  = HCI_MODE_SNIFF,
1785    BTM_PM_STS_PARK   = HCI_MODE_PARK,
1786    BTM_PM_STS_SSR,     /* report the SSR parameters in HCI_SNIFF_SUB_RATE_EVT */
1787    BTM_PM_STS_PENDING,   /* when waiting for status from controller */
1788    BTM_PM_STS_ERROR   /* when HCI command status returns error */
1789};
1790typedef UINT8 tBTM_PM_STATUS;
1791
1792/* BTM Power manager modes */
1793enum
1794{
1795    BTM_PM_MD_ACTIVE = BTM_PM_STS_ACTIVE,
1796    BTM_PM_MD_HOLD   = BTM_PM_STS_HOLD,
1797    BTM_PM_MD_SNIFF  = BTM_PM_STS_SNIFF,
1798    BTM_PM_MD_PARK   = BTM_PM_STS_PARK,
1799    BTM_PM_MD_FORCE  = 0x10 /* OR this to force ACL link to a certain mode */
1800};
1801typedef UINT8 tBTM_PM_MODE;
1802
1803#define BTM_PM_SET_ONLY_ID  0x80
1804
1805/* Operation codes */
1806#define BTM_PM_REG_SET      1 /* The module wants to set the desired power mode */
1807#define BTM_PM_REG_NOTIF    2 /* The module wants to receive mode change event */
1808#define BTM_PM_DEREG        4 /* The module does not want to involve with PM anymore */
1809
1810/************************
1811**  Power Manager Types
1812*************************/
1813typedef struct
1814{
1815    UINT16          max;
1816    UINT16          min;
1817    UINT16          attempt;
1818    UINT16          timeout;
1819    tBTM_PM_MODE    mode;
1820} tBTM_PM_PWR_MD;
1821
1822/*************************************
1823**  Power Manager Callback Functions
1824**************************************/
1825typedef void (tBTM_PM_STATUS_CBACK) (BD_ADDR p_bda, tBTM_PM_STATUS status,
1826                                     UINT16 value, UINT8 hci_status);
1827
1828
1829/************************
1830**  Stored Linkkey Types
1831*************************/
1832#define BTM_CB_EVT_RETURN_LINK_KEYS         1
1833#define BTM_CB_EVT_READ_STORED_LINK_KEYS    2
1834#define BTM_CB_EVT_WRITE_STORED_LINK_KEYS   3
1835#define BTM_CB_EVT_DELETE_STORED_LINK_KEYS  4
1836
1837typedef struct
1838{
1839    UINT8          event;
1840
1841} tBTM_STORED_LINK_KEYS_EVT;
1842
1843
1844typedef struct
1845{
1846    UINT8          event;
1847    UINT8          num_keys;
1848
1849} tBTM_RETURN_LINK_KEYS_EVT;
1850
1851
1852typedef struct
1853{
1854    BD_ADDR         bd_addr;
1855    LINK_KEY        link_key;
1856
1857} tBTM_BD_ADDR_LINK_KEY_PAIR;
1858
1859
1860typedef struct
1861{
1862    UINT8          event;
1863    UINT8          status;
1864    UINT16         max_keys;
1865    UINT16         read_keys;
1866
1867} tBTM_READ_STORED_LINK_KEY_COMPLETE;
1868
1869
1870typedef struct
1871{
1872    UINT8          event;
1873    UINT8          status;
1874    UINT8          num_keys;
1875
1876} tBTM_WRITE_STORED_LINK_KEY_COMPLETE;
1877
1878
1879typedef struct
1880{
1881    UINT8          event;
1882    UINT8          status;
1883    UINT16         num_keys;
1884
1885} tBTM_DELETE_STORED_LINK_KEY_COMPLETE;
1886
1887
1888/* These macros are defined to check the Broadcom features supported in controller
1889 * (the return value for BTM_ReadBrcmFeatures() */
1890/* multi-av */
1891#define BTM_FEATURE_MULTI_AV_MASK 0x01
1892#define BTM_FEATURE_MULTI_AV_OFF  0
1893#define BTM_VSC_MULTI_AV_SUPPORTED(x) ((x)[BTM_FEATURE_MULTI_AV_OFF] & BTM_FEATURE_MULTI_AV_MASK)
1894
1895/* WBS SBC codec */
1896#define BTM_FEATURE_WBS_SBC_MASK 0x02
1897#define BTM_FEATURE_WBS_SBC_OFF  0
1898#define BTM_VSC_WBS_SBC_SUPPORTED(x) ((x)[BTM_FEATURE_WBS_SBC_OFF] & BTM_FEATURE_WBS_SBC_MASK)
1899
1900/* Advanced Audio LC-PLC */
1901#define BTM_FEATURE_AUDIO_LC_PLC_MASK 0x04
1902#define BTM_FEATURE_AUDIO_LC_PLC_OFF  0
1903#define BTM_VSC_AUDIO_LC_PLC_SUPPORTED(x) ((x)[BTM_FEATURE_AUDIO_LC_PLC_OFF] & BTM_FEATURE_AUDIO_LC_PLC_MASK)
1904
1905/* Light stack for audio routing in Controller */
1906#define BTM_FEATURE_LIGHT_STACK_MASK 0x08
1907#define BTM_FEATURE_LIGHT_STACK_OFF  0
1908#define BTM_VSC_LIGHT_STACK_SUPPORTED(x) ((x)[BTM_FEATURE_LIGHT_STACK_OFF] & BTM_FEATURE_LIGHT_STACK_MASK)
1909
1910/* NFC support */
1911#define BTM_FEATURE_NFC_MASK        (HCI_BRCM_FEATURE_NFC_MASK) /* 0x10 */
1912#define BTM_FEATURE_NFC_OFF         (HCI_BRCM_FEATURE_NFC_OFF)  /* 0    */
1913#define BTM_VSC_NFC_SUPPORTED(x) ((x)[BTM_FEATURE_NFC_OFF] & BTM_FEATURE_NFC_MASK)
1914
1915
1916/* MIP evnets, callbacks    */
1917enum
1918{
1919    BTM_MIP_MODE_CHG_EVT,
1920    BTM_MIP_DISCONNECT_EVT,
1921    BTM_MIP_PKTS_COMPL_EVT,
1922    BTM_MIP_RXDATA_EVT
1923};
1924typedef UINT8 tBTM_MIP_EVT;
1925
1926typedef struct
1927{
1928    tBTM_MIP_EVT    event;
1929    BD_ADDR         bd_addr;
1930    UINT16          mip_id;
1931} tBTM_MIP_MODE_CHANGE;
1932
1933typedef struct
1934{
1935    tBTM_MIP_EVT    event;
1936    UINT16          mip_id;
1937    UINT8           disc_reason;
1938} tBTM_MIP_CONN_TIMEOUT;
1939
1940#define BTM_MIP_MAX_RX_LEN  17
1941
1942typedef struct
1943{
1944    tBTM_MIP_EVT    event;
1945    UINT16          mip_id;
1946    UINT8           rx_len;
1947    UINT8           rx_data[BTM_MIP_MAX_RX_LEN];
1948} tBTM_MIP_RXDATA;
1949
1950typedef struct
1951{
1952    tBTM_MIP_EVT    event;
1953    BD_ADDR         bd_addr;
1954    UINT8           data[11];       /* data[0] shows Vender-specific device type */
1955} tBTM_MIP_EIR_HANDSHAKE;
1956
1957typedef struct
1958{
1959    tBTM_MIP_EVT    event;
1960    UINT16          num_sent;       /* Number of packets completed at the controller */
1961} tBTM_MIP_PKTS_COMPL;
1962
1963typedef union
1964{
1965    tBTM_MIP_EVT            event;
1966    tBTM_MIP_MODE_CHANGE    mod_chg;
1967    tBTM_MIP_CONN_TIMEOUT   conn_tmo;
1968    tBTM_MIP_EIR_HANDSHAKE  eir;
1969    tBTM_MIP_PKTS_COMPL     completed;
1970    tBTM_MIP_RXDATA         rxdata;
1971} tBTM_MIP_EVENT_DATA;
1972
1973/* MIP event callback function  */
1974typedef void (tBTM_MIP_EVENTS_CB) (tBTM_MIP_EVT event, tBTM_MIP_EVENT_DATA data);
1975
1976/* MIP Device query callback function  */
1977typedef BOOLEAN (tBTM_MIP_QUERY_CB) (BD_ADDR dev_addr, UINT8 *p_mode, LINK_KEY link_key);
1978
1979#define BTM_CONTRL_ACTIVE  1       /* ACL link on, SCO link ongoing, sniff mode */
1980#define BTM_CONTRL_SCAN    2       /* Scan state - paging/inquiry/trying to connect*/
1981#define BTM_CONTRL_IDLE    3       /* Idle state - page scan, LE advt, inquiry scan */
1982
1983typedef UINT8 tBTM_CONTRL_STATE;
1984
1985/*****************************************************************************
1986**  EXTERNAL FUNCTION DECLARATIONS
1987*****************************************************************************/
1988#ifdef __cplusplus
1989extern "C" {
1990#endif
1991
1992/*****************************************************************************
1993**  DEVICE CONTROL and COMMON FUNCTIONS
1994*****************************************************************************/
1995
1996/*******************************************************************************
1997**
1998** Function         BTM_SetAfhChannels
1999**
2000** Description      This function is called to disable channels
2001**
2002** Returns          status
2003**
2004*******************************************************************************/
2005    BTM_API extern tBTM_STATUS BTM_SetAfhChannels (UINT8 first, UINT8 last);
2006
2007/*******************************************************************************
2008**
2009** Function         BTM_SetAfhChannelAssessment
2010**
2011** Description      This function is called to set the channel assessment mode on or off
2012**
2013** Returns          status
2014**
2015*******************************************************************************/
2016    BTM_API extern tBTM_STATUS BTM_SetAfhChannelAssessment (BOOLEAN enable_or_disable);
2017
2018/*******************************************************************************
2019**
2020** Function         BTM_DeviceReset
2021**
2022** Description      This function is called to reset the controller.The Callback function
2023**                  if provided is called when startup of the device has
2024**                  completed.
2025**
2026** Returns          void
2027**
2028*******************************************************************************/
2029    BTM_API extern void BTM_DeviceReset (tBTM_CMPL_CB *p_cb);
2030
2031
2032/*******************************************************************************
2033**
2034** Function         BTM_IsDeviceUp
2035**
2036** Description      This function is called to check if the device is up.
2037**
2038** Returns          TRUE if device is up, else FALSE
2039**
2040*******************************************************************************/
2041    BTM_API extern BOOLEAN BTM_IsDeviceUp (void);
2042
2043
2044/*******************************************************************************
2045**
2046** Function         BTM_SetLocalDeviceName
2047**
2048** Description      This function is called to set the local device name.
2049**
2050** Returns          BTM_CMD_STARTED if successful, otherwise an error
2051**
2052*******************************************************************************/
2053    BTM_API extern tBTM_STATUS BTM_SetLocalDeviceName (char *p_name);
2054
2055/*******************************************************************************
2056**
2057** Function         BTM_SetDeviceClass
2058**
2059** Description      This function is called to set the local device class
2060**
2061** Returns          BTM_SUCCESS if successful, otherwise an error
2062**
2063*******************************************************************************/
2064    BTM_API extern tBTM_STATUS  BTM_SetDeviceClass (DEV_CLASS dev_class);
2065
2066
2067/*******************************************************************************
2068**
2069** Function         BTM_ReadLocalDeviceName
2070**
2071** Description      This function is called to read the local device name.
2072**
2073** Returns          status of the operation
2074**                  If success, BTM_SUCCESS is returned and p_name points stored
2075**                              local device name
2076**                  If BTM doesn't store local device name, BTM_NO_RESOURCES is
2077**                              is returned and p_name is set to NULL
2078**
2079*******************************************************************************/
2080    BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name);
2081
2082/*******************************************************************************
2083**
2084** Function         BTM_ReadLocalDeviceNameFromController
2085**
2086** Description      Get local device name from controller. Do not use cached
2087**                  name (used to get chip-id prior to btm reset complete).
2088**
2089** Returns          BTM_CMD_STARTED if successful, otherwise an error
2090**
2091*******************************************************************************/
2092    BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController (tBTM_CMPL_CB *p_rln_cmpl_cback);
2093
2094/*******************************************************************************
2095**
2096** Function         BTM_ReadLocalVersion
2097**
2098** Description      This function is called to read the local device version
2099**
2100** Returns          BTM_SUCCESS if successful, otherwise an error
2101**
2102*******************************************************************************/
2103    BTM_API extern tBTM_STATUS BTM_ReadLocalVersion (tBTM_VERSION_INFO *p_vers);
2104
2105
2106/*******************************************************************************
2107**
2108** Function         BTM_ReadLocalDeviceAddr
2109**
2110** Description      This function is called to read the local device address
2111**
2112** Returns          BTM_SUCCESS
2113**                  Callback returns the local device address
2114**
2115*******************************************************************************/
2116    BTM_API extern tBTM_STATUS BTM_ReadLocalDeviceAddr (tBTM_CMPL_CB *p_cb);
2117
2118
2119/*******************************************************************************
2120**
2121** Function         BTM_GetLocalDeviceAddr
2122**
2123** Description      This function is called to read the local device address
2124**
2125** Returns          void
2126**                  the local device address is copied into bd_addr
2127**
2128*******************************************************************************/
2129    BTM_API extern void BTM_GetLocalDeviceAddr (BD_ADDR bd_addr);
2130
2131
2132/*******************************************************************************
2133**
2134** Function         BTM_ReadDeviceClass
2135**
2136** Description      This function is called to read the local device class
2137**
2138** Returns          pointer to the device class
2139**
2140*******************************************************************************/
2141    BTM_API extern UINT8 *BTM_ReadDeviceClass (void);
2142
2143
2144/*******************************************************************************
2145**
2146** Function         BTM_ReadLocalFeatures
2147**
2148** Description      This function is called to read the local features
2149**
2150** Returns          pointer to the local features string
2151**
2152*******************************************************************************/
2153    BTM_API extern UINT8 *BTM_ReadLocalFeatures (void);
2154
2155/*******************************************************************************
2156**
2157** Function         BTM_ReadLocalExtendedFeatures
2158**
2159** Description      This function is called to read the local extended features
2160**
2161** Returns          pointer to the local extended features mask or NULL if bad
2162**                  page
2163**
2164*******************************************************************************/
2165    BTM_API extern UINT8 *BTM_ReadLocalExtendedFeatures (UINT8 page_number);
2166
2167/*******************************************************************************
2168**
2169** Function         BTM_ReadBrcmFeatures
2170**
2171** Description      This function is called to read the Broadcom specific features
2172**
2173** Returns          pointer to the Broadcom features string
2174**
2175*******************************************************************************/
2176    BTM_API extern UINT8 *BTM_ReadBrcmFeatures (void);
2177
2178/*******************************************************************************
2179**
2180** Function         BTM_RegisterForDeviceStatusNotif
2181**
2182** Description      This function is called to register for device status
2183**                  change notifications.
2184**
2185** Returns          pointer to previous caller's callback function or NULL if first
2186**                  registration.
2187**
2188*******************************************************************************/
2189    BTM_API extern tBTM_DEV_STATUS_CB *BTM_RegisterForDeviceStatusNotif (tBTM_DEV_STATUS_CB *p_cb);
2190
2191
2192/*******************************************************************************
2193**
2194** Function         BTM_RegisterForVSEvents
2195**
2196** Description      This function is called to register/deregister for vendor
2197**                  specific HCI events.
2198**
2199**                  If is_register=TRUE, then the function will be registered;
2200**                  if is_register=FALSE, then the function will be deregistered.
2201**
2202** Returns          BTM_SUCCESS if successful,
2203**                  BTM_BUSY if maximum number of callbacks have already been
2204**                           registered.
2205**
2206*******************************************************************************/
2207    BTM_API extern tBTM_STATUS BTM_RegisterForVSEvents (tBTM_VS_EVT_CB *p_cb, BOOLEAN is_register);
2208
2209
2210/*******************************************************************************
2211**
2212** Function         BTM_ContinueReset
2213**
2214** Description      Instructs stack to continue its stack initialization after
2215**                  an application has completed any vender specific commands
2216**                  sent to the controller.
2217**
2218**                  Note: This function is only called if an application
2219**                      initialization function has been inserted in the reset
2220**                      sequence.  (BTM_APP_DEV_INIT is defined with a function).
2221**
2222** Returns          void
2223**
2224*******************************************************************************/
2225    BTM_API extern void BTM_ContinueReset (void);
2226
2227
2228/*******************************************************************************
2229**
2230** Function         BTM_VendorSpecificCommand
2231**
2232** Description      Send a vendor specific HCI command to the controller.
2233**
2234** Returns
2235**      BTM_SUCCESS         Command sent. Does not expect command complete
2236**                              event. (command cmpl callback param is NULL)
2237**      BTM_CMD_STARTED     Command sent. Waiting for command cmpl event.
2238**      BTM_BUSY            Command not sent. Waiting for cmd cmpl event for
2239**                              prior command.
2240**
2241*******************************************************************************/
2242    BTM_API extern tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
2243                                                         UINT8 param_len,
2244                                                         UINT8 *p_param_buf,
2245                                                         tBTM_VSC_CMPL_CB *p_cb);
2246
2247
2248/*******************************************************************************
2249**
2250** Function         BTM_AllocateSCN
2251**
2252** Description      Look through the Server Channel Numbers for a free one to be
2253**                  used with an RFCOMM connection.
2254**
2255** Returns          Allocated SCN number or 0 if none.
2256**
2257*******************************************************************************/
2258    BTM_API extern UINT8 BTM_AllocateSCN(void);
2259
2260// btla-specific ++
2261/*******************************************************************************
2262**
2263** Function         BTM_TryAllocateSCN
2264**
2265** Description      Try to allocate a fixed server channel
2266**
2267** Returns          Returns TRUE if server channel was available
2268**
2269*******************************************************************************/
2270BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn);
2271// btla-specific --
2272
2273
2274/*******************************************************************************
2275**
2276** Function         BTM_FreeSCN
2277**
2278** Description      Free the specified SCN.
2279**
2280** Returns          TRUE if successful, FALSE if SCN is not in use or invalid
2281**
2282*******************************************************************************/
2283    BTM_API extern BOOLEAN BTM_FreeSCN(UINT8 scn);
2284
2285
2286/*******************************************************************************
2287**
2288** Function         BTM_SetTraceLevel
2289**
2290** Description      This function sets the trace level for BTM.  If called with
2291**                  a value of 0xFF, it simply returns the current trace level.
2292**
2293** Returns          The new or current trace level
2294**
2295*******************************************************************************/
2296    BTM_API extern UINT8 BTM_SetTraceLevel (UINT8 new_level);
2297
2298
2299/*******************************************************************************
2300**
2301** Function         BTM_WritePageTimeout
2302**
2303** Description      Send HCI Wite Page Timeout.
2304**
2305** Returns
2306**      BTM_SUCCESS         Command sent.
2307**      BTM_NO_RESOURCES    If out of resources to send the command.
2308**
2309*******************************************************************************/
2310    BTM_API extern tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout);
2311
2312/*******************************************************************************
2313**
2314** Function         BTM_WriteVoiceSettings
2315**
2316** Description      Send HCI Write Voice Settings command.
2317**                  See hcidefs.h for settings bitmask values.
2318**
2319** Returns
2320**      BTM_SUCCESS         Command sent.
2321**      BTM_NO_RESOURCES     If out of resources to send the command.
2322**
2323**
2324*******************************************************************************/
2325    BTM_API extern tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings);
2326
2327/*******************************************************************************
2328**
2329** Function         BTM_EnableTestMode
2330**
2331** Description      Send HCI the enable device under test command.
2332**
2333**                  Note: Controller can only be taken out of this mode by
2334**                      resetting the controller.
2335**
2336** Returns
2337**      BTM_SUCCESS         Command sent.
2338**      BTM_NO_RESOURCES    If out of resources to send the command.
2339**
2340**
2341*******************************************************************************/
2342    BTM_API extern tBTM_STATUS BTM_EnableTestMode(void);
2343
2344
2345/*****************************************************************************
2346**  DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
2347*****************************************************************************/
2348
2349/*******************************************************************************
2350**
2351** Function         BTM_SetDiscoverability
2352**
2353** Description      This function is called to set the device into or out of
2354**                  discoverable mode. Discoverable mode means inquiry
2355**                  scans are enabled.  If a value of '0' is entered for window or
2356**                  interval, the default values are used.
2357**
2358** Returns          BTM_SUCCESS if successful
2359**                  BTM_BUSY if a setting of the filter is already in progress
2360**                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
2361**                  BTM_ILLEGAL_VALUE if a bad parameter was detected
2362**                  BTM_WRONG_MODE if the device is not up.
2363**
2364*******************************************************************************/
2365    BTM_API extern tBTM_STATUS  BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window,
2366                                                        UINT16 interval);
2367
2368
2369/*******************************************************************************
2370**
2371** Function         BTM_ReadDiscoverability
2372**
2373** Description      This function is called to read the current discoverability
2374**                  mode of the device.
2375**
2376** Output Params:   p_window - current inquiry scan duration
2377**                  p_interval - current inquiry scan interval
2378**
2379** Returns          BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or
2380**                  BTM_GENERAL_DISCOVERABLE
2381**
2382*******************************************************************************/
2383    BTM_API extern UINT16       BTM_ReadDiscoverability (UINT16 *p_window,
2384                                                         UINT16 *p_interval);
2385
2386
2387/*******************************************************************************
2388**
2389** Function         BTM_SetPeriodicInquiryMode
2390**
2391** Description      This function is called to set the device periodic inquiry mode.
2392**                  If the duration is zero, the periodic inquiry mode is cancelled.
2393**
2394** Parameters:      p_inqparms - pointer to the inquiry information
2395**                      mode - GENERAL or LIMITED inquiry
2396**                      duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
2397**                      max_resps - maximum amount of devices to search for before ending the inquiry
2398**                      filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
2399**                                         BTM_FILTER_COND_BD_ADDR
2400**                      filter_cond - value for the filter (based on filter_cond_type)
2401**
2402**                  max_delay - maximum amount of time between successive inquiries
2403**                  min_delay - minimum amount of time between successive inquiries
2404**                  p_results_cb - callback returning pointer to results (tBTM_INQ_RESULTS)
2405**
2406** Returns          BTM_CMD_STARTED if successfully started
2407**                  BTM_ILLEGAL_VALUE if a bad parameter is detected
2408**                  BTM_NO_RESOURCES if could not allocate a message buffer
2409**                  BTM_SUCCESS - if cancelling the periodic inquiry
2410**                  BTM_BUSY - if an inquiry is already active
2411**                  BTM_WRONG_MODE if the device is not up.
2412**
2413*******************************************************************************/
2414    BTM_API extern tBTM_STATUS  BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms,
2415                                                            UINT16 max_delay, UINT16 min_delay,
2416                                                            tBTM_INQ_RESULTS_CB *p_results_cb);
2417
2418
2419/*******************************************************************************
2420**
2421** Function         BTM_StartInquiry
2422**
2423** Description      This function is called to start an inquiry.
2424**
2425** Parameters:      p_inqparms - pointer to the inquiry information
2426**                      mode - GENERAL or LIMITED inquiry
2427**                      duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
2428**                      max_resps - maximum amount of devices to search for before ending the inquiry
2429**                      filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
2430**                                         BTM_FILTER_COND_BD_ADDR
2431**                      filter_cond - value for the filter (based on filter_cond_type)
2432**
2433**                  p_results_cb   - Pointer to the callback routine which gets called
2434**                                upon receipt of an inquiry result. If this field is
2435**                                NULL, the application is not notified.
2436**
2437**                  p_cmpl_cb   - Pointer to the callback routine which gets called
2438**                                upon completion.  If this field is NULL, the
2439**                                application is not notified when completed.
2440** Returns          tBTM_STATUS
2441**                  BTM_CMD_STARTED if successfully initiated
2442**                  BTM_BUSY if already in progress
2443**                  BTM_ILLEGAL_VALUE if parameter(s) are out of range
2444**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2445**                  BTM_WRONG_MODE if the device is not up.
2446**
2447*******************************************************************************/
2448    BTM_API extern tBTM_STATUS  BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms,
2449                                                  tBTM_INQ_RESULTS_CB *p_results_cb,
2450                                                  tBTM_CMPL_CB *p_cmpl_cb);
2451
2452
2453/*******************************************************************************
2454**
2455** Function         BTM_IsInquiryActive
2456**
2457** Description      This function returns a bit mask of the current inquiry state
2458**
2459** Returns          BTM_INQUIRY_INACTIVE if inactive (0)
2460**                  BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
2461**                  BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
2462**                  BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
2463**
2464*******************************************************************************/
2465    BTM_API extern UINT16 BTM_IsInquiryActive (void);
2466
2467
2468/*******************************************************************************
2469**
2470** Function         BTM_CancelInquiry
2471**
2472** Description      This function cancels an inquiry if active
2473**
2474** Returns          BTM_SUCCESS if successful
2475**                  BTM_NO_RESOURCES if could not allocate a message buffer
2476**                  BTM_WRONG_MODE if the device is not up.
2477**
2478*******************************************************************************/
2479    BTM_API extern tBTM_STATUS BTM_CancelInquiry(void);
2480
2481
2482/*******************************************************************************
2483**
2484** Function         BTM_CancelPeriodicInquiry
2485**
2486** Description      This function cancels a periodic inquiry
2487**
2488** Returns
2489**                  BTM_NO_RESOURCES if could not allocate a message buffer
2490**                  BTM_SUCCESS - if cancelling the periodic inquiry
2491**                  BTM_WRONG_MODE if the device is not up.
2492**
2493*******************************************************************************/
2494    BTM_API extern tBTM_STATUS BTM_CancelPeriodicInquiry(void);
2495
2496
2497/*******************************************************************************
2498**
2499** Function         BTM_SetInquiryFilterCallback
2500**
2501** Description      Host can register to be asked whenever an inquiry result
2502**                  is received.  If host does not like the device no name
2503**                  request is issued for the device
2504**
2505** Returns          void
2506**
2507*******************************************************************************/
2508    BTM_API extern void BTM_SetInquiryFilterCallback(tBTM_FILTER_CB *p_callback);
2509
2510
2511/*******************************************************************************
2512**
2513** Function         BTM_SetConnectability
2514**
2515** Description      This function is called to set the device into or out of
2516**                  connectable mode. Discoverable mode means page scans enabled.
2517**
2518** Returns          BTM_SUCCESS if successful
2519**                  BTM_ILLEGAL_VALUE if a bad parameter is detected
2520**                  BTM_NO_RESOURCES if could not allocate a message buffer
2521**                  BTM_WRONG_MODE if the device is not up.
2522**
2523*******************************************************************************/
2524    BTM_API extern tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window,
2525                                                      UINT16 interval);
2526
2527
2528/*******************************************************************************
2529**
2530** Function         BTM_ReadConnectability
2531**
2532** Description      This function is called to read the current discoverability
2533**                  mode of the device.
2534** Output Params    p_window - current page scan duration
2535**                  p_interval - current time between page scans
2536**
2537** Returns          BTM_NON_CONNECTABLE or BTM_CONNECTABLE
2538**
2539*******************************************************************************/
2540    BTM_API extern UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval);
2541
2542
2543/*******************************************************************************
2544**
2545** Function         BTM_SetInquiryMode
2546**
2547** Description      This function is called to set standard, with RSSI
2548**                  mode or extended of the inquiry for local device.
2549**
2550** Input Params:    BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
2551**                  BTM_INQ_RESULT_EXTENDED
2552**
2553** Returns          BTM_SUCCESS if successful
2554**                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
2555**                  BTM_ILLEGAL_VALUE if a bad parameter was detected
2556**                  BTM_WRONG_MODE if the device is not up.
2557**
2558*******************************************************************************/
2559    BT_API extern tBTM_STATUS  BTM_SetInquiryMode (UINT8 mode);
2560
2561/*******************************************************************************
2562**
2563** Function         BTM_SetInquiryScanType
2564**
2565** Description      This function is called to set the iquiry scan-type to
2566**                  standard or interlaced.
2567**
2568** Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
2569**
2570** Returns          BTM_SUCCESS if successful
2571**                  BTM_MODE_UNSUPPORTED if not a 1.2 device
2572**                  BTM_WRONG_MODE if the device is not up.
2573**
2574*******************************************************************************/
2575    BT_API extern tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type);
2576
2577/*******************************************************************************
2578**
2579** Function         BTM_SetPageScanType
2580**
2581** Description      This function is called to set the page scan-type to
2582**                  standard or interlaced.
2583**
2584** Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
2585**
2586** Returns          BTM_SUCCESS if successful
2587**                  BTM_MODE_UNSUPPORTED if not a 1.2 device
2588**                  BTM_WRONG_MODE if the device is not up.
2589**
2590*******************************************************************************/
2591
2592    BT_API extern tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type);
2593
2594/*******************************************************************************
2595**
2596** Function         BTM_ReadRemoteDeviceName
2597**
2598** Description      This function initiates a remote device HCI command to the
2599**                  controller and calls the callback when the process has completed.
2600**
2601** Input Params:    remote_bda      - device address of name to retrieve
2602**                  p_cb            - callback function called when BTM_CMD_STARTED
2603**                                    is returned.
2604**                                    A pointer to tBTM_REMOTE_DEV_NAME is passed to the
2605**                                    callback.
2606**
2607** Returns
2608**                  BTM_CMD_STARTED is returned if the request was successfully sent
2609**                                  to HCI.
2610**                  BTM_BUSY if already in progress
2611**                  BTM_UNKNOWN_ADDR if device address is bad
2612**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2613**                  BTM_WRONG_MODE if the device is not up.
2614**
2615*******************************************************************************/
2616    BTM_API extern tBTM_STATUS  BTM_ReadRemoteDeviceName (BD_ADDR remote_bda,
2617                                                          tBTM_CMPL_CB *p_cb,
2618                                                          tBT_TRANSPORT transport);
2619
2620
2621/*******************************************************************************
2622**
2623** Function         BTM_CancelRemoteDeviceName
2624**
2625** Description      This function initiates the cancel request for the specified
2626**                  remote device.
2627**
2628** Input Params:    None
2629**
2630** Returns
2631**                  BTM_CMD_STARTED is returned if the request was successfully sent
2632**                                  to HCI.
2633**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2634**                  BTM_WRONG_MODE if there is not an active remote name request.
2635**
2636*******************************************************************************/
2637    BTM_API extern tBTM_STATUS  BTM_CancelRemoteDeviceName (void);
2638
2639/*******************************************************************************
2640**
2641** Function         BTM_ReadRemoteVersion
2642**
2643** Description      This function is called to read a remote device's version
2644**
2645** Returns          BTM_SUCCESS if successful, otherwise an error
2646**
2647*******************************************************************************/
2648    BTM_API extern tBTM_STATUS BTM_ReadRemoteVersion (BD_ADDR addr,
2649                                                      UINT8 *lmp_version,
2650                                                      UINT16 *manufacturer,
2651                                                      UINT16 *lmp_sub_version);
2652
2653/*******************************************************************************
2654**
2655** Function         BTM_ReadRemoteFeatures
2656**
2657** Description      This function is called to read a remote device's
2658**                  supported features mask (features mask located at page 0)
2659**
2660**                  Note: The size of device features mask page is
2661**                  BTM_FEATURE_BYTES_PER_PAGE bytes.
2662**
2663** Returns          pointer to the remote supported features mask
2664**
2665*******************************************************************************/
2666    BTM_API extern UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr);
2667
2668/*******************************************************************************
2669**
2670** Function         BTM_ReadRemoteExtendedFeatures
2671**
2672** Description      This function is called to read a specific extended features
2673**                  page of the remote device
2674**
2675**                  Note1: The size of device features mask page is
2676**                  BTM_FEATURE_BYTES_PER_PAGE bytes.
2677**                  Note2: The valid device features mask page number depends on
2678**                  the remote device capabilities. It is expected to be in the
2679**                  range [0 - BTM_EXT_FEATURES_PAGE_MAX].
2680
2681** Returns          pointer to the remote extended features mask
2682**                  or NULL if page_number is not valid
2683**
2684*******************************************************************************/
2685    BTM_API extern UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number);
2686
2687/*******************************************************************************
2688**
2689** Function         BTM_ReadNumberRemoteFeaturesPages
2690**
2691** Description      This function is called to retrieve the number of feature pages
2692**                  read from the remote device
2693**
2694** Returns          number of features pages read from the remote device
2695**
2696*******************************************************************************/
2697    BTM_API extern UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr);
2698
2699/*******************************************************************************
2700**
2701** Function         BTM_ReadAllRemoteFeatures
2702**
2703** Description      This function is called to read all features of the remote device
2704**
2705** Returns          pointer to the byte[0] of the page[0] of the remote device
2706**                  feature mask.
2707**
2708** Note:            the function returns the pointer to the array of the size
2709**                  BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1).
2710**
2711*******************************************************************************/
2712    BTM_API extern UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr);
2713
2714/*******************************************************************************
2715**
2716** Function         BTM_InqFirstResult
2717**
2718** Description      This function looks through the inquiry database for the first
2719**                  used entrysince the LAST inquiry. This is used in conjunction
2720**                  with BTM_InqNext by applications as a way to walk through the
2721**                  inquiry results database.
2722**
2723** Returns          pointer to first in-use entry, or NULL if DB is empty
2724**
2725*******************************************************************************/
2726    BTM_API extern tBTM_INQ_INFO *BTM_InqFirstResult (void);
2727
2728
2729/*******************************************************************************
2730**
2731** Function         BTM_InqNextResult
2732**
2733** Description      This function looks through the inquiry database for the next
2734**                  used entrysince the LAST inquiry. If the input parameter is NULL,
2735**                  the first entry is returned.
2736**
2737** Returns          pointer to next in-use entry, or NULL if no more found.
2738**
2739*******************************************************************************/
2740    BTM_API extern tBTM_INQ_INFO *BTM_InqNextResult (tBTM_INQ_INFO *p_cur);
2741
2742
2743/*******************************************************************************
2744**
2745** Function         BTM_InqDbRead
2746**
2747** Description      This function looks through the inquiry database for a match
2748**                  based on Bluetooth Device Address. This is the application's
2749**                  interface to get the inquiry details of a specific BD address.
2750**
2751** Returns          pointer to entry, or NULL if not found
2752**
2753*******************************************************************************/
2754    BTM_API extern tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda);
2755
2756
2757/*******************************************************************************
2758**
2759** Function         BTM_InqDbFirst
2760**
2761** Description      This function looks through the inquiry database for the first
2762**                  used entry, and returns that. This is used in conjunction with
2763**                  BTM_InqDbNext by applications as a way to walk through the
2764**                  inquiry database.
2765**
2766** Returns          pointer to first in-use entry, or NULL if DB is empty
2767**
2768*******************************************************************************/
2769    BTM_API extern tBTM_INQ_INFO *BTM_InqDbFirst (void);
2770
2771
2772/*******************************************************************************
2773**
2774** Function         BTM_InqDbNext
2775**
2776** Description      This function looks through the inquiry database for the next
2777**                  used entry, and returns that.  If the input parameter is NULL,
2778**                  the first entry is returned.
2779**
2780** Returns          pointer to next in-use entry, or NULL if no more found.
2781**
2782*******************************************************************************/
2783    BTM_API extern tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur);
2784
2785
2786/*******************************************************************************
2787**
2788** Function         BTM_ClearInqDb
2789**
2790** Description      This function is called to clear out a device or all devices
2791**                  from the inquiry database.
2792**
2793** Parameter        p_bda - (input) BD_ADDR ->  Address of device to clear
2794**                                              (NULL clears all entries)
2795**
2796** Returns          BTM_BUSY if an inquiry, get remote name, or event filter
2797**                          is active, otherwise BTM_SUCCESS
2798**
2799*******************************************************************************/
2800    BTM_API extern tBTM_STATUS  BTM_ClearInqDb (BD_ADDR p_bda);
2801
2802
2803/*******************************************************************************
2804**
2805** Function         BTM_ReadNumInqDbEntries
2806**
2807** Returns          This function returns the number of entries in the inquiry database.
2808**
2809*******************************************************************************/
2810    BTM_API extern UINT8 BTM_ReadNumInqDbEntries (void);
2811
2812
2813/*******************************************************************************
2814**
2815** Function         BTM_InquiryRegisterForChanges
2816**
2817** Description      This function is called to register a callback for when the
2818**                  inquiry database changes, i.e. new entry or entry deleted.
2819**
2820** Returns          BTM_SUCCESS if successful, otherwise error code
2821**
2822*******************************************************************************/
2823    BTM_API extern tBTM_STATUS BTM_InquiryRegisterForChanges (tBTM_INQ_DB_CHANGE_CB *p_cb);
2824
2825/*******************************************************************************
2826**
2827** Function         BTM_ReadInquiryRspTxPower
2828**
2829** Description      This command will read the inquiry Transmit Power level used
2830**                  to transmit the FHS and EIR data packets.
2831**                  This can be used directly in the Tx Power Level EIR data type.
2832**
2833** Returns          BTM_SUCCESS if successful
2834**
2835*******************************************************************************/
2836    BTM_API extern tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb);
2837
2838/*******************************************************************************
2839**
2840** Function         BTM_WriteInquiryTxPower
2841**
2842** Description      This command is used to write the inquiry transmit power level
2843**                  used to transmit the inquiry (ID) data packets. The Controller
2844**                  should use the supported TX power level closest to the Tx_Power
2845**                  parameter.
2846**
2847** Returns          BTM_SUCCESS if successful
2848**
2849*******************************************************************************/
2850    BTM_API extern tBTM_STATUS  BTM_WriteInquiryTxPower (INT8 tx_power);
2851
2852/*******************************************************************************
2853**
2854** Function         BTM_StartDiscovery
2855**
2856** Description      This function is called by an application (or profile)
2857**                  when it wants to trigger an service discovery using the
2858**                  BTM's discovery database.
2859**
2860** Returns          tBTM_STATUS
2861**                      BTM_CMD_STARTED if the discovery was initiated
2862**                      BTM_BUSY if one is already in progress
2863**                      BTM_UNKNOWN_ADDR if no addresses are in the INQ DB
2864**                      BTM_ERR_PROCESSING if err initiating the command
2865**
2866*******************************************************************************/
2867    BTM_API extern tBTM_STATUS BTM_StartDiscovery (tBTM_CMPL_CB *p_cmpl_cb,
2868                                                   BD_ADDR_PTR p_rem_addr);
2869
2870
2871/*******************************************************************************
2872**
2873** Function         BTM_FindAttribute
2874**
2875** Description      This function is called by an application (or profile)
2876**                  when it wants to see if an attribute exists in the BTM
2877**                  discovery database.
2878**
2879** Returns          Pointer to matching record, or NULL
2880**
2881*******************************************************************************/
2882    BTM_API extern tSDP_DISC_REC *BTM_FindAttribute (UINT16 attr_id,
2883                                                     tSDP_DISC_REC *p_start_rec);
2884
2885
2886/*******************************************************************************
2887**
2888** Function         BTM_FindService
2889**
2890** Description      This function is called by an application (or profile)
2891**                  when it wants to see if a service exists in the BTM
2892**                  discovery database.
2893**
2894** Returns          Pointer to matching record, or NULL
2895**
2896*******************************************************************************/
2897    BTM_API extern tSDP_DISC_REC *BTM_FindService (UINT16 service_uuid,
2898                                                   tSDP_DISC_REC *p_start_rec);
2899
2900
2901/*******************************************************************************
2902**
2903** Function         BTM_SetDiscoveryParams
2904**
2905** Description      This function is called to set the BTM default discovery parameters.
2906**                  These UUID and attribute filters are used during the call to
2907**                  BTM_StartDiscovery.
2908**
2909** Returns          void
2910**
2911*******************************************************************************/
2912    BTM_API extern void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list,
2913                                                UINT16 num_attr, UINT16 *p_attr_list);
2914
2915
2916/*****************************************************************************
2917**  ACL CHANNEL MANAGEMENT FUNCTIONS
2918*****************************************************************************/
2919/*******************************************************************************
2920**
2921** Function         BTM_SetLinkPolicy
2922**
2923** Description      Create and send HCI "Write Policy Set" command
2924**
2925** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2926**
2927*******************************************************************************/
2928    BTM_API extern tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda,
2929                                                  UINT16 *settings);
2930
2931
2932/*******************************************************************************
2933**
2934** Function         BTM_ReadLinkPolicy
2935**
2936** Description      This function is called to read the link policy settings.
2937**                  The address of link policy results are returned in the callback.
2938**                  (tBTM_LNK_POLICY_RESULTS)
2939**
2940** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2941**
2942*******************************************************************************/
2943    BTM_API extern tBTM_STATUS BTM_ReadLinkPolicy (BD_ADDR remote_bda,
2944                                                   tBTM_CMPL_CB *p_cb);
2945
2946
2947/*******************************************************************************
2948**
2949** Function         BTM_SetDefaultLinkPolicy
2950**
2951** Description      Set the default value for HCI "Write Policy Set" command
2952**                  to use when an ACL link is created.
2953**
2954** Returns          void
2955**
2956*******************************************************************************/
2957    BTM_API extern void BTM_SetDefaultLinkPolicy (UINT16 settings);
2958
2959
2960/*******************************************************************************
2961**
2962** Function         BTM_SetDefaultLinkSuperTout
2963**
2964** Description      Set the default value for HCI "Write Link Supervision Timeout"
2965**                  command to use when an ACL link is created.
2966**
2967** Returns          void
2968**
2969*******************************************************************************/
2970    BTM_API extern void BTM_SetDefaultLinkSuperTout (UINT16 timeout);
2971
2972
2973/*******************************************************************************
2974**
2975** Function         BTM_SetLinkSuperTout
2976**
2977** Description      Create and send HCI "Write Link Supervision Timeout" command
2978**
2979** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2980**
2981*******************************************************************************/
2982    BTM_API extern tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda,
2983                                                     UINT16 timeout);
2984/*******************************************************************************
2985**
2986** Function         BTM_GetLinkSuperTout
2987**
2988** Description      Read the link supervision timeout value of the connection
2989**
2990** Returns          status of the operation
2991**
2992*******************************************************************************/
2993    BTM_API extern tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda,
2994                                                     UINT16 *p_timeout);
2995
2996/*******************************************************************************
2997**
2998** Function         BTM_RegForLstoEvt
2999**
3000** Description      register for the HCI "Link Supervision Timeout Change" event
3001**
3002** Returns          void
3003**
3004*******************************************************************************/
3005    BTM_API extern void BTM_RegForLstoEvt (tBTM_LSTO_CBACK *p_cback);
3006
3007
3008/* These next APIs are available if the power manager is not compiled in */
3009#if BTM_PWR_MGR_INCLUDED == FALSE
3010/*******************************************************************************
3011**
3012** Function         BTM_SetHoldMode
3013**
3014** Description      This function is called to set a connection into hold mode.
3015**                  A check is made if the connection is in sniff or park mode,
3016**                  and if yes, the hold mode is ignored.
3017**
3018** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3019**
3020*******************************************************************************/
3021    BTM_API extern tBTM_STATUS BTM_SetHoldMode (BD_ADDR remote_bda, UINT16 min_interval,
3022                                                UINT16 max_interval);
3023
3024
3025/*******************************************************************************
3026**
3027** Function         BTM_SetSniffMode
3028**
3029** Description      This function is called to set a connection into sniff mode.
3030**                  A check is made if the connection is already in sniff or park
3031**                  mode, and if yes, the sniff mode is ignored.
3032**
3033** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3034**
3035*******************************************************************************/
3036    BTM_API extern tBTM_STATUS BTM_SetSniffMode (BD_ADDR remote_bda, UINT16 min_period,
3037                                                 UINT16 max_period, UINT16 attempt,
3038                                                 UINT16 timeout);
3039
3040
3041/*******************************************************************************
3042**
3043** Function         BTM_CancelSniffMode
3044**
3045** Description      This function is called to put a connection out of sniff mode.
3046**                  A check is made if the connection is already in sniff mode,
3047**                  and if not, the cancel sniff mode is ignored.
3048**
3049** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3050**
3051*******************************************************************************/
3052    BTM_API extern tBTM_STATUS BTM_CancelSniffMode (BD_ADDR remote_bda);
3053
3054
3055/*******************************************************************************
3056**
3057** Function         BTM_SetParkMode
3058**
3059** Description      This function is called to set a connection into park mode.
3060**                  A check is made if the connection is already in sniff or park
3061**                  mode, and if yes, the park mode is ignored.
3062**
3063** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3064**
3065*******************************************************************************/
3066    BTM_API extern tBTM_STATUS BTM_SetParkMode (BD_ADDR remote_bda,
3067                                                UINT16 beacon_min_period,
3068                                                UINT16 beacon_max_period);
3069
3070
3071/*******************************************************************************
3072**
3073** Function         BTM_CancelParkMode
3074**
3075** Description      This function is called to put a connection out of park mode.
3076**                  A check is made if the connection is already in park mode,
3077**                  and if not, the cancel sniff mode is ignored.
3078**
3079** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3080**
3081*******************************************************************************/
3082    BTM_API extern tBTM_STATUS BTM_CancelParkMode (BD_ADDR remote_bda);
3083
3084
3085/*******************************************************************************
3086**
3087** Function         BTM_ReadAclMode
3088**
3089** Description      This returns the current mode for a specific
3090**                  ACL connection.
3091**
3092** Input Param      remote_bda - device address of desired ACL connection
3093**
3094** Output Param     p_mode - address where the current mode is copied into.
3095**                          BTM_ACL_MODE_NORMAL
3096**                          BTM_ACL_MODE_HOLD
3097**                          BTM_ACL_MODE_SNIFF
3098**                          BTM_ACL_MODE_PARK
3099**                          (valid only if return code is BTM_SUCCESS)
3100**
3101** Returns          BTM_SUCCESS if successful,
3102**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
3103**
3104*******************************************************************************/
3105    BTM_API extern tBTM_STATUS BTM_ReadAclMode (BD_ADDR remote_bda, UINT8 *p_mode);
3106
3107#endif /* if BTM_PWR_MGR_INCLUDED == FALSE */
3108
3109
3110/*******************************************************************************
3111**
3112** Function         BTM_SetPacketTypes
3113**
3114** Description      This function is set the packet types used for a specific
3115**                  ACL connection,
3116**
3117** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3118**
3119*******************************************************************************/
3120    BTM_API extern tBTM_STATUS BTM_SetPacketTypes (BD_ADDR remote_bda, UINT16 pkt_types);
3121
3122
3123/*******************************************************************************
3124**
3125** Function         BTM_ReadPacketTypes
3126**
3127** Description      This function is set the packet types used for the specified
3128**                  ACL connection,
3129**
3130** Returns          packet types supported for the connection, or 0 if no BD address
3131**
3132*******************************************************************************/
3133    BTM_API extern UINT16 BTM_ReadPacketTypes (BD_ADDR remote_bda);
3134
3135
3136/*******************************************************************************
3137**
3138** Function         BTM_IsAclConnectionUp
3139**
3140** Description      This function is called to check if an ACL connection exists
3141**                  to a specific remote BD Address.
3142**
3143** Returns          TRUE if connection is up, else FALSE.
3144**
3145*******************************************************************************/
3146    BTM_API extern BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport);
3147
3148
3149/*******************************************************************************
3150**
3151** Function         BTM_GetRole
3152**
3153** Description      This function is called to get the role of the local device
3154**                  for the ACL connection with the specified remote device
3155**
3156** Returns          BTM_SUCCESS if connection exists.
3157**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3158**
3159*******************************************************************************/
3160    BTM_API extern tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role);
3161
3162
3163
3164/*******************************************************************************
3165**
3166** Function         BTM_SwitchRole
3167**
3168** Description      This function is called to switch role between master and
3169**                  slave.  If role is already set it will do nothing.  If the
3170**                  command was initiated, the callback function is called upon
3171**                  completion.
3172**
3173** Returns          BTM_SUCCESS if already in specified role.
3174**                  BTM_CMD_STARTED if command issued to controller.
3175**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3176**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3177**                  BTM_MODE_UNSUPPORTED if local device does not support role switching
3178**
3179*******************************************************************************/
3180    BTM_API extern tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
3181                                               UINT8 new_role,
3182                                               tBTM_CMPL_CB *p_cb);
3183
3184/*******************************************************************************
3185**
3186** Function         BTM_ChangeLinkKey
3187**
3188** Description      This function is called to change the link key of the
3189**                  connection.
3190**
3191** Returns          BTM_CMD_STARTED if command issued to controller.
3192**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3193**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3194**                  BTM_BUSY if the previous command is not completed
3195**
3196*******************************************************************************/
3197    BTM_API extern tBTM_STATUS BTM_ChangeLinkKey (BD_ADDR remote_bd_addr,
3198                                                  tBTM_CMPL_CB *p_cb);
3199
3200/*******************************************************************************
3201**
3202** Function         BTM_ReadRSSI
3203**
3204** Description      This function is called to read the link policy settings.
3205**                  The address of link policy results are returned in the callback.
3206**                  (tBTM_RSSI_RESULTS)
3207**
3208** Returns          BTM_CMD_STARTED if command issued to controller.
3209**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3210**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3211**                  BTM_BUSY if command is already in progress
3212**
3213*******************************************************************************/
3214    BTM_API extern tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
3215
3216
3217/*******************************************************************************
3218**
3219** Function         BTM_ReadTxPower
3220**
3221** Description      This function is called to read the current connection
3222**                  TX power of the connection. The TX power level results
3223**                  are returned in the callback.
3224**                  (tBTM_RSSI_RESULTS)
3225**
3226** Returns          BTM_CMD_STARTED if command issued to controller.
3227**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3228**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3229**                  BTM_BUSY if command is already in progress
3230**
3231*******************************************************************************/
3232    BTM_API extern tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda,
3233                                                      tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
3234
3235/*******************************************************************************
3236**
3237** Function         BTM_ReadLinkQuality
3238**
3239** Description      This function is called to read the link quality.
3240**                  The value of the link quality is returned in the callback.
3241**                  (tBTM_LINK_QUALITY_RESULTS)
3242**
3243** Returns          BTM_CMD_STARTED if command issued to controller.
3244**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3245**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3246**                  BTM_BUSY if command is already in progress
3247**
3248*******************************************************************************/
3249    BTM_API extern tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
3250
3251/*******************************************************************************
3252**
3253** Function         BTM_RegBusyLevelNotif
3254**
3255** Description      This function is called to register a callback to receive
3256**                  busy level change events.
3257**
3258** Returns          BTM_SUCCESS if successfully registered, otherwise error
3259**
3260*******************************************************************************/
3261    BTM_API extern tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
3262                                                      tBTM_BL_EVENT_MASK evt_mask);
3263
3264/*******************************************************************************
3265**
3266** Function         BTM_AclRegisterForChanges
3267**
3268** Description      This function is called to register a callback to receive
3269**                  ACL database change events, i.e. new connection or removed.
3270**
3271** Returns          BTM_SUCCESS if successfully initiated, otherwise error
3272**
3273*******************************************************************************/
3274    BTM_API extern tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb);
3275
3276/*******************************************************************************
3277**
3278** Function         BTM_GetNumAclLinks
3279**
3280** Description      This function is called to count the number of
3281**                  ACL links that are active.
3282**
3283** Returns          UINT16  Number of active ACL links
3284**
3285*******************************************************************************/
3286    BTM_API extern UINT16 BTM_GetNumAclLinks (void);
3287
3288
3289/*******************************************************************************
3290**
3291** Function         BTM_ReadClockOffset
3292**
3293** Description      This returns the clock offset for a specific
3294**                  ACL connection.
3295**
3296** Returns          clock-offset or 0 if unknown
3297**
3298*******************************************************************************/
3299    BTM_API extern UINT16 BTM_ReadClockOffset (BD_ADDR remote_bda);
3300
3301
3302/*******************************************************************************
3303**
3304** Function         BTM_SetQoS
3305**
3306** Description      This function is called to setup QoS
3307**
3308** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3309**
3310*******************************************************************************/
3311    BTM_API extern tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC *p_flow,
3312                                          tBTM_CMPL_CB *p_cb);
3313
3314
3315/*****************************************************************************
3316**  (e)SCO CHANNEL MANAGEMENT FUNCTIONS
3317*****************************************************************************/
3318/*******************************************************************************
3319**
3320** Function         BTM_CreateSco
3321**
3322** Description      This function is called to create an SCO connection. If the
3323**                  "is_orig" flag is TRUE, the connection will be originated,
3324**                  otherwise BTM will wait for the other side to connect.
3325**
3326** Returns          BTM_UNKNOWN_ADDR if the ACL connection is not up
3327**                  BTM_BUSY         if another SCO being set up to
3328**                                   the same BD address
3329**                  BTM_NO_RESOURCES if the max SCO limit has been reached
3330**                  BTM_CMD_STARTED  if the connection establishment is started.
3331**                                   In this case, "*p_sco_inx" is filled in
3332**                                   with the sco index used for the connection.
3333**
3334*******************************************************************************/
3335    BTM_API extern tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig,
3336                                              UINT16 pkt_types, UINT16 *p_sco_inx,
3337                                              tBTM_SCO_CB *p_conn_cb,
3338                                              tBTM_SCO_CB *p_disc_cb);
3339
3340
3341/*******************************************************************************
3342**
3343** Function         BTM_RemoveSco
3344**
3345** Description      This function is called to remove a specific SCO connection.
3346**
3347** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3348**
3349*******************************************************************************/
3350    BTM_API extern tBTM_STATUS BTM_RemoveSco (UINT16 sco_inx);
3351
3352
3353/*******************************************************************************
3354**
3355** Function         BTM_SetScoPacketTypes
3356**
3357** Description      This function is called to set the packet types used for
3358**                  a specific SCO connection,
3359**
3360** Parameters       pkt_types - One or more of the following
3361**                  BTM_SCO_PKT_TYPES_MASK_HV1
3362**                  BTM_SCO_PKT_TYPES_MASK_HV2
3363**                  BTM_SCO_PKT_TYPES_MASK_HV3
3364**                  BTM_SCO_PKT_TYPES_MASK_EV3
3365**                  BTM_SCO_PKT_TYPES_MASK_EV4
3366**                  BTM_SCO_PKT_TYPES_MASK_EV5
3367**
3368**                  BTM_SCO_LINK_ALL_MASK   - enables all supported types
3369**
3370** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3371**
3372*******************************************************************************/
3373    BTM_API extern tBTM_STATUS BTM_SetScoPacketTypes (UINT16 sco_inx, UINT16 pkt_types);
3374
3375
3376/*******************************************************************************
3377**
3378** Function         BTM_ReadScoPacketTypes
3379**
3380** Description      This function is read the packet types used for a specific
3381**                  SCO connection.
3382**
3383** Returns       One or more of the following (bitmask)
3384**                  BTM_SCO_PKT_TYPES_MASK_HV1
3385**                  BTM_SCO_PKT_TYPES_MASK_HV2
3386**                  BTM_SCO_PKT_TYPES_MASK_HV3
3387**                  BTM_SCO_PKT_TYPES_MASK_EV3
3388**                  BTM_SCO_PKT_TYPES_MASK_EV4
3389**                  BTM_SCO_PKT_TYPES_MASK_EV5
3390**
3391** Returns          packet types supported for the connection
3392**
3393*******************************************************************************/
3394    BTM_API extern UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx);
3395
3396
3397/*******************************************************************************
3398**
3399** Function         BTM_ReadDeviceScoPacketTypes
3400**
3401** Description      This function is read the SCO packet types that
3402**                  the device supports.
3403**
3404** Returns          packet types supported by the device.
3405**
3406*******************************************************************************/
3407    BTM_API extern UINT16 BTM_ReadDeviceScoPacketTypes (void);
3408
3409
3410/*******************************************************************************
3411**
3412** Function         BTM_ReadScoHandle
3413**
3414** Description      This function is used to read the HCI handle used for a specific
3415**                  SCO connection,
3416**
3417** Returns          handle for the connection, or 0xFFFF if invalid SCO index.
3418**
3419*******************************************************************************/
3420    BTM_API extern UINT16 BTM_ReadScoHandle (UINT16 sco_inx);
3421
3422
3423/*******************************************************************************
3424**
3425** Function         BTM_ReadScoBdAddr
3426**
3427** Description      This function is read the remote BD Address for a specific
3428**                  SCO connection,
3429**
3430** Returns          pointer to BD address or NULL if not known
3431**
3432*******************************************************************************/
3433    BTM_API extern UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx);
3434
3435
3436/*******************************************************************************
3437**
3438** Function         BTM_ReadScoDiscReason
3439**
3440** Description      This function is returns the reason why an (e)SCO connection
3441**                  has been removed. It contains the value until read, or until
3442**                  another (e)SCO connection has disconnected.
3443**
3444** Returns          HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
3445**
3446*******************************************************************************/
3447    BTM_API extern UINT16 BTM_ReadScoDiscReason (void);
3448
3449
3450/*******************************************************************************
3451**
3452** Function         BTM_SetEScoMode
3453**
3454** Description      This function sets up the negotiated parameters for SCO or
3455**                  eSCO, and sets as the default mode used for calls to
3456**                  BTM_CreateSco.  It can be called only when there are no
3457**                  active (e)SCO links.
3458**
3459** Returns          BTM_SUCCESS if the successful.
3460**                  BTM_BUSY if there are one or more active (e)SCO links.
3461**
3462*******************************************************************************/
3463    BTM_API extern tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode,
3464                                                tBTM_ESCO_PARAMS *p_parms);
3465
3466/*******************************************************************************
3467**
3468** Function         BTM_SetWBSCodec
3469**
3470** Description      This function sends command to the controller to setup
3471**                  WBS codec for the upcoming eSCO connection.
3472**
3473** Returns          BTM_SUCCESS.
3474**
3475**
3476*******************************************************************************/
3477BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type);
3478
3479/*******************************************************************************
3480**
3481** Function         BTM_RegForEScoEvts
3482**
3483** Description      This function registers a SCO event callback with the
3484**                  specified instance.  It should be used to received
3485**                  connection indication events and change of link parameter
3486**                  events.
3487**
3488** Returns          BTM_SUCCESS if the successful.
3489**                  BTM_ILLEGAL_VALUE if there is an illegal sco_inx
3490**
3491*******************************************************************************/
3492    BTM_API extern tBTM_STATUS BTM_RegForEScoEvts (UINT16 sco_inx,
3493                                                   tBTM_ESCO_CBACK *p_esco_cback);
3494
3495/*******************************************************************************
3496**
3497** Function         BTM_ReadEScoLinkParms
3498**
3499** Description      This function returns the current eSCO link parameters for
3500**                  the specified handle.  This can be called anytime a connection
3501**                  is active, but is typically called after receiving the SCO
3502**                  opened callback.
3503**
3504**                  Note: If called over a 1.1 controller, only the packet types
3505**                        field has meaning.
3506**                  Note: If the upper layer doesn't know the current sco index,
3507**                  BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first parameter to
3508**                  find the first active SCO index
3509**
3510** Returns          BTM_SUCCESS if returned data is valid connection.
3511**                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
3512**                  BTM_MODE_UNSUPPORTED if local controller does not support
3513**                      1.2 specification.
3514**
3515*******************************************************************************/
3516    BTM_API extern tBTM_STATUS BTM_ReadEScoLinkParms (UINT16 sco_inx,
3517                                                      tBTM_ESCO_DATA *p_parms);
3518
3519/*******************************************************************************
3520**
3521** Function         BTM_ChangeEScoLinkParms
3522**
3523** Description      This function requests renegotiation of the parameters on
3524**                  the current eSCO Link.  If any of the changes are accepted
3525**                  by the controllers, the BTM_ESCO_CHG_EVT event is sent in
3526**                  the tBTM_ESCO_CBACK function with the current settings of
3527**                  the link. The callback is registered through the call to
3528**                  BTM_SetEScoMode.
3529**
3530**
3531** Returns          BTM_CMD_STARTED if command is successfully initiated.
3532**                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
3533**                  BTM_NO_RESOURCES - not enough resources to initiate command.
3534**                  BTM_MODE_UNSUPPORTED if local controller does not support
3535**                      1.2 specification.
3536**
3537*******************************************************************************/
3538    BTM_API extern tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx,
3539                                                        tBTM_CHG_ESCO_PARAMS *p_parms);
3540
3541/*******************************************************************************
3542**
3543** Function         BTM_EScoConnRsp
3544**
3545** Description      This function is called upon receipt of an (e)SCO connection
3546**                  request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
3547**                  the request. Parameters used to negotiate eSCO links.
3548**                  If p_parms is NULL, then values set through BTM_SetEScoMode
3549**                  are used.
3550**                  If the link type of the incoming request is SCO, then only
3551**                  the tx_bw, max_latency, content format, and packet_types are
3552**                  valid.  The hci_status parameter should be
3553**                  ([0x0] to accept, [0x0d..0x0f] to reject)
3554**
3555**
3556** Returns          void
3557**
3558*******************************************************************************/
3559    BTM_API extern void BTM_EScoConnRsp (UINT16 sco_inx, UINT8 hci_status,
3560                                         tBTM_ESCO_PARAMS *p_parms);
3561
3562/*******************************************************************************
3563**
3564** Function         BTM_GetNumScoLinks
3565**
3566** Description      This function returns the number of active SCO links.
3567**
3568** Returns          UINT8
3569**
3570*******************************************************************************/
3571    BTM_API extern UINT8 BTM_GetNumScoLinks (void);
3572
3573/*****************************************************************************
3574**  SECURITY MANAGEMENT FUNCTIONS
3575*****************************************************************************/
3576/*******************************************************************************
3577**
3578** Function         BTM_SecRegister
3579**
3580** Description      Application manager calls this function to register for
3581**                  security services.  There can be one and only one application
3582**                  saving link keys.  BTM allows only first registration.
3583**
3584** Returns          TRUE if registered OK, else FALSE
3585**
3586*******************************************************************************/
3587    BTM_API extern BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info);
3588
3589
3590/*******************************************************************************
3591**
3592** Function         BTM_SecRegisterLinkKeyNotificationCallback
3593**
3594** Description      Profiles can register to be notified when a new Link Key
3595**                  is generated per connection.
3596**
3597** Returns          TRUE if registered OK, else FALSE
3598**
3599*******************************************************************************/
3600    BTM_API extern BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback (
3601                                                        tBTM_LINK_KEY_CALLBACK *p_callback);
3602
3603
3604/*******************************************************************************
3605**
3606** Function         BTM_SecAddRmtNameNotifyCallback
3607**
3608** Description      Profiles can register to be notified when name of the
3609**                  remote device is resolved (up to BTM_SEC_MAX_RMT_NAME_CALLBACKS).
3610**
3611** Returns          TRUE if registered OK, else FALSE
3612**
3613*******************************************************************************/
3614    BTM_API extern BOOLEAN BTM_SecAddRmtNameNotifyCallback (
3615                                                               tBTM_RMT_NAME_CALLBACK *p_callback);
3616
3617
3618/*******************************************************************************
3619**
3620** Function         BTM_SecDeleteRmtNameNotifyCallback
3621**
3622** Description      A profile can deregister notification when a new Link Key
3623**                  is generated per connection.
3624**
3625** Returns          TRUE if OK, else FALSE
3626**
3627*******************************************************************************/
3628    BTM_API extern BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (
3629                                                            tBTM_RMT_NAME_CALLBACK *p_callback);
3630
3631
3632/*******************************************************************************
3633**
3634** Function         BTM_SecSetConnectFilterCallback
3635**
3636** Description      Host can register to be asked whenever an HCI connection
3637**                  request is received.  In the registered function host
3638**                  suppose to check connectibility filters.  Yes/No result
3639**                  should be returned synchronously.
3640**
3641** Returns          void
3642**
3643*******************************************************************************/
3644    BTM_API extern void BTM_SecSetConnectFilterCallback (tBTM_FILTER_CB *p_callback);
3645
3646
3647/*******************************************************************************
3648**
3649** Function         BTM_GetSecurityMode
3650**
3651** Description      Get security mode for the device
3652**
3653** Returns          void
3654**
3655*******************************************************************************/
3656    BTM_API extern UINT8 BTM_GetSecurityMode (void);
3657
3658
3659/*******************************************************************************
3660**
3661** Function         BTM_GetSecurityFlags
3662**
3663** Description      Get security flags for the device
3664**
3665** Returns          BOOLEAN TRUE or FALSE is device found
3666**
3667*******************************************************************************/
3668    BTM_API extern BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 * p_sec_flags);
3669
3670/*******************************************************************************
3671**
3672** Function         BTM_GetSecurityFlagsByTransport
3673**
3674** Description      Get security flags for the device on a particular transport
3675**
3676** Parameters      bd_addr: BD address of remote device
3677**                  p_sec_flags : Out parameter to be filled with security flags for the connection
3678**                  transport :  Physical transport of the connection (BR/EDR or LE)
3679**
3680** Returns          BOOLEAN TRUE or FALSE is device found
3681**
3682*******************************************************************************/
3683    BTM_API extern BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr,
3684                                UINT8 * p_sec_flags, tBT_TRANSPORT transport);
3685
3686/*******************************************************************************
3687**
3688** Function         BTM_ReadTrustedMask
3689**
3690** Description      Get trusted mask for the device
3691**
3692** Returns          NULL, if the device record is not found.
3693**                  otherwise, the trusted mask
3694**
3695*******************************************************************************/
3696    BTM_API extern UINT32 * BTM_ReadTrustedMask (BD_ADDR bd_addr);
3697
3698
3699/*******************************************************************************
3700**
3701** Function         BTM_SetSecurityMode
3702**
3703** Description      Set security mode for the device
3704**
3705** Returns          void
3706**
3707*******************************************************************************/
3708    BTM_API extern void BTM_SetSecurityMode (UINT8 sec_mode);
3709
3710
3711/*******************************************************************************
3712**
3713** Function         BTM_SetPinType
3714**
3715** Description      Set PIN type for the device.
3716**
3717** Returns          void
3718**
3719*******************************************************************************/
3720    BTM_API extern void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len);
3721
3722
3723/*******************************************************************************
3724**
3725** Function         BTM_SetPairableMode
3726**
3727** Description      Enable or disable pairing
3728**
3729** Parameters       allow_pairing - (TRUE or FALSE) whether or not the device
3730**                      allows pairing.
3731**                  connect_only_paired - (TRUE or FALSE) whether or not to
3732**                      only allow paired devices to connect.
3733**
3734** Returns          void
3735**
3736*******************************************************************************/
3737    BTM_API extern void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired);
3738
3739/*******************************************************************************
3740**
3741** Function         BTM_SetSecurityLevel
3742**
3743** Description      Register service security level with Security Manager.  Each
3744**                  service must register its requirements regardless of the
3745**                  security level that is used.  This API is called once for originators
3746**                  nad again for acceptors of connections.
3747**
3748** Returns          TRUE if registered OK, else FALSE
3749**
3750*******************************************************************************/
3751    BTM_API extern BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name,
3752                                                 UINT8 service_id, UINT16 sec_level,
3753                                                 UINT16 psm, UINT32 mx_proto_id,
3754                                                 UINT32 mx_chan_id);
3755
3756/*******************************************************************************
3757**
3758** Function         BTM_SetUCDSecurityLevel
3759**
3760** Description      Register UCD service security level with Security Manager.  Each
3761**                  service must register its requirements regardless of the
3762**                  security level that is used.  This API is called once for originators
3763**                  and again for acceptors of connections.
3764**
3765** Returns          TRUE if registered OK, else FALSE
3766**
3767*******************************************************************************/
3768    BTM_API extern BOOLEAN BTM_SetUCDSecurityLevel (BOOLEAN is_originator, char *p_name,
3769                                                          UINT8 service_id, UINT16 sec_level,
3770                                                          UINT16 psm, UINT32 mx_proto_id,
3771                                                          UINT32 mx_chan_id);
3772
3773/*******************************************************************************
3774**
3775** Function         BTM_SetOutService
3776**
3777** Description      This function is called to set the service for
3778**                  outgoing connection.
3779**
3780** Returns          void
3781**
3782*******************************************************************************/
3783    BTM_API extern void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id);
3784
3785/*******************************************************************************
3786**
3787** Function         BTM_SecClrService
3788**
3789** Description      Removes specified service record(s) from the security database.
3790**                  All service records with the specified name are removed.
3791**                  Typically used only by devices with limited RAM so that it can
3792**                  reuse an old security service record.
3793**                          records (except SDP).
3794**
3795** Returns          Number of records that were freed.
3796**
3797*******************************************************************************/
3798    BTM_API extern UINT8 BTM_SecClrService (UINT8 service_id);
3799
3800/*******************************************************************************
3801**
3802** Function         BTM_SecClrUCDService
3803**
3804** Description
3805**
3806** Parameters       Service ID - Id of the service to remove. ('0' removes all service
3807**                          records.
3808**
3809** Returns          Number of records that were freed.
3810**
3811*******************************************************************************/
3812    BTM_API extern UINT8 BTM_SecClrUCDService (UINT8 service_id);
3813
3814/*******************************************************************************
3815**
3816** Function         BTM_SecAddDevice
3817**
3818** Description      Add/modify device.  This function will be normally called
3819**                  during host startup to restore all required information
3820**                  stored in the NVRAM.
3821**                  dev_class, bd_name, link_key, and features are NULL if unknown
3822**
3823** Returns          TRUE if added OK, else FALSE
3824**
3825*******************************************************************************/
3826    BTM_API extern BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
3827                                             BD_NAME bd_name, UINT8 *features,
3828                                             UINT32 trusted_mask[], LINK_KEY link_key,
3829                                             UINT8 key_type, tBTM_IO_CAP io_cap);
3830
3831
3832/*******************************************************************************
3833**
3834** Function         BTM_SecDeleteDevice
3835**
3836** Description      Free resources associated with the device.
3837**
3838** Returns          TRUE if rmoved OK, FALSE if not found
3839**
3840*******************************************************************************/
3841    BTM_API extern BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr);
3842
3843
3844/*******************************************************************************
3845**
3846** Function         BTM_SecUseMasterLinkKey
3847**
3848** Description      This function is called to tell master of the piconet to
3849**                  switch to master link key
3850**
3851** Returns          BTM_SUCCESS if command is successully initiated
3852**
3853*******************************************************************************/
3854    BTM_API extern tBTM_STATUS BTM_SecUseMasterLinkKey (BOOLEAN use_master_key);
3855
3856
3857/*******************************************************************************
3858**
3859** Function         BTM_SetMasterKeyCompCback
3860**
3861** Description      This function is called to register for the master key complete
3862**                  status event.
3863**
3864** Parameters:      mkey_cback - callback registered with the security manager
3865**
3866** Returns          void
3867**
3868*******************************************************************************/
3869    BTM_API extern void BTM_SetMasterKeyCompCback(tBTM_MKEY_CALLBACK *mkey_cback );
3870
3871
3872/*******************************************************************************
3873**
3874** Function         BTM_SecGetDeviceLinkKey
3875**
3876** Description      This function is called to obtain link key for the device
3877**                  it returns BTM_SUCCESS if link key is available, or
3878**                  BTM_UNKNOWN_ADDR if Security Manager does not know about
3879**                  the device or device record does not contain link key info
3880**
3881** Returns          BTM_SUCCESS if successful, otherwise error code
3882**
3883*******************************************************************************/
3884    BTM_API extern tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr,
3885                                                        LINK_KEY link_key);
3886
3887
3888/*******************************************************************************
3889**
3890** Function         BTM_PINCodeReply
3891**
3892** Description      This function is called after Security Manager submitted
3893**                  PIN code request to the UI.
3894**
3895** Parameters:      bd_addr      - Address of the device for which PIN was requested
3896**                  res          - result of the operation BTM_SUCCESS if success
3897**                  pin_len      - length in bytes of the PIN Code
3898**                  p_pin        - pointer to array with the PIN Code
3899**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3900**
3901** Returns          void
3902**
3903*******************************************************************************/
3904    BTM_API extern void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
3905                                          UINT8 *p_pin, UINT32 trusted_mask[]);
3906
3907
3908/*******************************************************************************
3909**
3910** Function         BTM_DeviceAuthorized
3911**
3912** Description      This function is called after Security Manager submitted
3913**                  authorization request to the UI.
3914**
3915** Parameters:      bd_addr     - Address of the device for which PIN was requested
3916**                  res         - result of the operation BTM_SUCCESS if success
3917**
3918** Returns          void
3919**
3920*******************************************************************************/
3921    BTM_API extern void BTM_DeviceAuthorized (BD_ADDR bd_addr, UINT8 res,
3922                                              UINT32 trusted_mask[]);
3923
3924
3925/*******************************************************************************
3926**
3927** Function         BTM_SecBond
3928**
3929** Description      This function is called to perform bonding with peer device.
3930**
3931** Parameters:      bd_addr      - Address of the device to bond
3932**                  pin_len      - length in bytes of the PIN Code
3933**                  p_pin        - pointer to array with the PIN Code
3934**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3935
3936** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3937**
3938*******************************************************************************/
3939    BTM_API extern tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr,
3940                                            UINT8 pin_len, UINT8 *p_pin,
3941                                            UINT32 trusted_mask[]);
3942
3943/*******************************************************************************
3944**
3945** Function         BTM_SecBondByTransport
3946**
3947** Description      This function is called to perform bonding by designated transport
3948**
3949** Parameters:      bd_addr      - Address of the device to bond
3950**                  pin_len      - length in bytes of the PIN Code
3951**                  p_pin        - pointer to array with the PIN Code
3952**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3953**                  transport :  Physical transport to use for bonding (BR/EDR or LE)
3954**
3955** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3956**
3957*******************************************************************************/
3958    BTM_API extern tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr,
3959                                            tBT_TRANSPORT transport,
3960                                            UINT8 pin_len, UINT8 *p_pin,
3961                                            UINT32 trusted_mask[]);
3962
3963/*******************************************************************************
3964**
3965** Function         BTM_SecBondCancel
3966**
3967** Description      This function is called to cancel ongoing bonding process
3968**                  with peer device.
3969**
3970** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3971**
3972*******************************************************************************/
3973    BTM_API extern tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr);
3974
3975/*******************************************************************************
3976**
3977** Function         BTM_SetEncryption
3978**
3979** Description      This function is called to ensure that connection is
3980**                  encrypted.  Should be called only on an open connection.
3981**                  Typically only needed for connections that first want to
3982**                  bring up unencrypted links, then later encrypt them.
3983**
3984** Parameters:      bd_addr       - Address of the peer device
3985**                  p_callback    - Pointer to callback function called if
3986**                                  this function returns PENDING after required
3987**                                  procedures are completed.  Can be set to NULL
3988**                                  if status is not desired.
3989**                  p_ref_data    - pointer to any data the caller wishes to receive
3990**                                  in the callback function upon completion.
3991*                                   can be set to NULL if not used.
3992**
3993** Returns          BTM_SUCCESS   - already encrypted
3994**                  BTM_PENDING   - command will be returned in the callback
3995**                  BTM_WRONG_MODE- connection not up.
3996**                  BTM_BUSY      - security procedures are currently active
3997**                  BTM_MODE_UNSUPPORTED - if security manager not linked in.
3998**
3999*******************************************************************************/
4000    BTM_API extern tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport,
4001                                                  tBTM_SEC_CBACK *p_callback, void *p_ref_data);
4002
4003/*******************************************************************************
4004**
4005** Function         BTM_ConfirmReqReply
4006**
4007** Description      This function is called to confirm the numeric value for
4008**                  Simple Pairing in response to BTM_SP_CFM_REQ_EVT
4009**
4010** Parameters:      res           - result of the operation BTM_SUCCESS if success
4011**                  bd_addr       - Address of the peer device
4012**
4013*******************************************************************************/
4014    BTM_API extern void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr);
4015
4016/*******************************************************************************
4017**
4018** Function         BTM_PasskeyReqReply
4019**
4020** Description      This function is called to provide the passkey for
4021**                  Simple Pairing in response to BTM_SP_KEY_REQ_EVT
4022**
4023** Parameters:      res           - result of the operation BTM_SUCCESS if success
4024**                  bd_addr       - Address of the peer device
4025**                  passkey       - numeric value in the range of 0 - 999999(0xF423F).
4026**
4027*******************************************************************************/
4028    BTM_API extern void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey);
4029
4030/*******************************************************************************
4031**
4032** Function         BTM_SendKeypressNotif
4033**
4034** Description      This function is used during the passkey entry model
4035**                  by a device with KeyboardOnly IO capabilities
4036**                  (very likely to be a HID Device).
4037**                  It is called by a HID Device to inform the remote device when
4038**                  a key has been entered or erased.
4039**
4040** Parameters:      bd_addr - Address of the peer device
4041**                  type - notification type
4042**
4043*******************************************************************************/
4044    BTM_API extern void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type);
4045
4046/*******************************************************************************
4047**
4048** Function         BTM_IoCapRsp
4049**
4050** Description      This function is called in response to BTM_SP_IO_REQ_EVT
4051**                  When the event data io_req.oob_data is set to BTM_OOB_UNKNOWN
4052**                  by the tBTM_SP_CALLBACK implementation, this function is
4053**                  called to provide the actual response
4054**
4055** Parameters:      bd_addr - Address of the peer device
4056**                  io_cap  - The IO capability of local device.
4057**                  oob     - BTM_OOB_NONE or BTM_OOB_PRESENT.
4058**                  auth_req- MITM protection required or not.
4059**
4060*******************************************************************************/
4061    BTM_API extern void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap,
4062                                     tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
4063
4064/*******************************************************************************
4065**
4066** Function         BTM_ReadLocalOobData
4067**
4068** Description      This function is called to read the local OOB data from
4069**                  LM
4070**
4071*******************************************************************************/
4072    BTM_API extern tBTM_STATUS BTM_ReadLocalOobData(void);
4073
4074/*******************************************************************************
4075**
4076** Function         BTM_RemoteOobDataReply
4077**
4078** Description      This function is called to provide the remote OOB data for
4079**                  Simple Pairing in response to BTM_SP_RMT_OOB_EVT
4080**
4081** Parameters:      bd_addr     - Address of the peer device
4082**                  c           - simple pairing Hash C.
4083**                  r           - simple pairing Randomizer  C.
4084**
4085*******************************************************************************/
4086    BTM_API extern void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr,
4087                                                        BT_OCTET16 c, BT_OCTET16 r);
4088
4089/*******************************************************************************
4090**
4091** Function         BTM_BuildOobData
4092**
4093** Description      This function is called to build the OOB data payload to
4094**                  be sent over OOB (non-Bluetooth) link
4095**
4096** Parameters:      p_data  - the location for OOB data
4097**                  max_len - p_data size.
4098**                  c       - simple pairing Hash C.
4099**                  r       - simple pairing Randomizer  C.
4100**                  name_len- 0, local device name would not be included.
4101**                            otherwise, the local device name is included for
4102**                            up to this specified length
4103**
4104** Returns          Number of bytes in p_data.
4105**
4106*******************************************************************************/
4107    BTM_API extern UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
4108                                           BT_OCTET16 r, UINT8 name_len);
4109
4110/*******************************************************************************
4111**
4112** Function         BTM_ReadOobData
4113**
4114** Description      This function is called to parse the OOB data payload
4115**                  received over OOB (non-Bluetooth) link
4116**
4117** Parameters:      p_data  - the location for OOB data
4118**                  eir_tag - The associated EIR tag to read the data.
4119**                  *p_len(output) - the length of the data with the given tag.
4120**
4121** Returns          the beginning of the data with the given tag.
4122**                  NULL, if the tag is not found.
4123**
4124*******************************************************************************/
4125    BTM_API extern UINT8 * BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len);
4126
4127/*******************************************************************************
4128**
4129** Function         BTM_SecReadDevName
4130**
4131** Description      Looks for the device name in the security database for the
4132**                  specified BD address.
4133**
4134** Returns          Pointer to the name or NULL
4135**
4136*******************************************************************************/
4137    BTM_API extern char *BTM_SecReadDevName (BD_ADDR bd_addr);
4138
4139
4140/*****************************************************************************
4141**  POWER MANAGEMENT FUNCTIONS
4142*****************************************************************************/
4143/*******************************************************************************
4144**
4145** Function         BTM_PmRegister
4146**
4147** Description      register or deregister with power manager
4148**
4149** Returns          BTM_SUCCESS if successful,
4150**                  BTM_NO_RESOURCES if no room to hold registration
4151**                  BTM_ILLEGAL_VALUE
4152**
4153*******************************************************************************/
4154    BTM_API extern tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id,
4155                                               tBTM_PM_STATUS_CBACK *p_cb);
4156
4157
4158/*******************************************************************************
4159**
4160** Function         BTM_SetPowerMode
4161**
4162** Description      store the mode in control block or
4163**                  alter ACL connection behavior.
4164**
4165** Returns          BTM_SUCCESS if successful,
4166**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
4167**
4168*******************************************************************************/
4169    BTM_API extern tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda,
4170                                                 tBTM_PM_PWR_MD *p_mode);
4171
4172
4173/*******************************************************************************
4174**
4175** Function         BTM_ReadPowerMode
4176**
4177** Description      This returns the current mode for a specific
4178**                  ACL connection.
4179**
4180** Input Param      remote_bda - device address of desired ACL connection
4181**
4182** Output Param     p_mode - address where the current mode is copied into.
4183**                          BTM_ACL_MODE_NORMAL
4184**                          BTM_ACL_MODE_HOLD
4185**                          BTM_ACL_MODE_SNIFF
4186**                          BTM_ACL_MODE_PARK
4187**                          (valid only if return code is BTM_SUCCESS)
4188**
4189** Returns          BTM_SUCCESS if successful,
4190**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
4191**
4192*******************************************************************************/
4193    BTM_API extern tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda,
4194                                                  tBTM_PM_MODE *p_mode);
4195
4196/*******************************************************************************
4197**
4198** Function         BTM_SetSsrParams
4199**
4200** Description      This sends the given SSR parameters for the given ACL
4201**                  connection if it is in ACTIVE mode.
4202**
4203** Input Param      remote_bda - device address of desired ACL connection
4204**                  max_lat    - maximum latency (in 0.625ms)(0-0xFFFE)
4205**                  min_rmt_to - minimum remote timeout
4206**                  min_loc_to - minimum local timeout
4207**
4208**
4209** Returns          BTM_SUCCESS if the HCI command is issued successful,
4210**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
4211**                  BTM_CMD_STORED if the command is stored
4212**
4213*******************************************************************************/
4214    BTM_API extern tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
4215                                                 UINT16 min_rmt_to, UINT16 min_loc_to);
4216
4217/*******************************************************************************
4218**
4219** Function         BTM_IsPowerManagerOn
4220**
4221** Description      This function is called to check if power manager is included.
4222**                  in the BTE version.
4223**
4224** Returns          TRUE if power manager is compiled in, otherwise FALSE.
4225**
4226*******************************************************************************/
4227    BTM_API extern BOOLEAN BTM_IsPowerManagerOn (void);
4228
4229
4230/*******************************************************************************
4231**
4232** Function         BTM_GetHCIConnHandle
4233**
4234** Description      This function is called to get the handle for an ACL connection
4235**                  to a specific remote BD Address.
4236**
4237** Returns          the handle of the connection, or 0xFFFF if none.
4238**
4239*******************************************************************************/
4240    BTM_API extern UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
4241
4242
4243/*******************************************************************************
4244**
4245** Function         BTM_ReadStoredLinkKey
4246**
4247** Description      This function is called to obtain link key for the specified
4248**                  device from the NVRAM storage attached to the Bluetooth
4249**                  controller.
4250**
4251** Parameters:      bd_addr      - Address of the device
4252**                  p_cb         - Call back function to be called to return
4253**                                 the results
4254**
4255*******************************************************************************/
4256    BTM_API extern tBTM_STATUS BTM_ReadStoredLinkKey (BD_ADDR bd_addr,  tBTM_CMPL_CB *p_cb);
4257
4258
4259/*******************************************************************************
4260**
4261** Function         BTM_WriteStoredLinkKey
4262**
4263** Description      This function is called to write link keys for the specified
4264**                  device addresses to the NVRAM storage attached to the Bluetooth
4265**                  controller.
4266**
4267** Parameters:      num_keys     - Number of link keys
4268**                  bd_addr      - Addresses of the devices
4269**                  link_key     - Link Keys to be stored
4270**                  p_cb         - Call back function to be called to return
4271**                                 the results
4272**
4273*******************************************************************************/
4274    BTM_API extern tBTM_STATUS BTM_WriteStoredLinkKey (UINT8 num_keys,
4275                                                       BD_ADDR *bd_addr,
4276                                                       LINK_KEY *link_key,
4277                                                       tBTM_CMPL_CB *p_cb);
4278
4279
4280/*******************************************************************************
4281**
4282** Function         BTM_DeleteStoredLinkKey
4283**
4284** Description      This function is called to delete link key for the specified
4285**                  device addresses from the NVRAM storage attached to the Bluetooth
4286**                  controller.
4287**
4288** Parameters:      bd_addr      - Addresses of the devices
4289**                  p_cb         - Call back function to be called to return
4290**                                 the results
4291**
4292*******************************************************************************/
4293    BTM_API extern tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
4294
4295/*******************************************************************************
4296**
4297** Function         BTM_WriteEIR
4298**
4299** Description      This function is called to write EIR data to controller.
4300**
4301** Parameters       p_buff - allocated HCI command buffer including extended
4302**                           inquriry response
4303**
4304** Returns          BTM_SUCCESS  - if successful
4305**                  BTM_MODE_UNSUPPORTED - if local device cannot support it
4306**
4307*******************************************************************************/
4308    BTM_API extern tBTM_STATUS BTM_WriteEIR( BT_HDR * p_buff );
4309
4310/*******************************************************************************
4311**
4312** Function         BTM_CheckEirData
4313**
4314** Description      This function is called to get EIR data from significant part.
4315**
4316** Parameters       p_eir - pointer of EIR significant part
4317**                  type   - finding EIR data type
4318**                  p_length - return the length of EIR data
4319**
4320** Returns          pointer of EIR data
4321**
4322*******************************************************************************/
4323    BTM_API extern UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length );
4324
4325/*******************************************************************************
4326**
4327** Function         BTM_HasEirService
4328**
4329** Description      This function is called to know if UUID in bit map of UUID.
4330**
4331** Parameters       p_eir_uuid - bit map of UUID list
4332**                  uuid16 - UUID 16-bit
4333**
4334** Returns          TRUE - if found
4335**                  FALSE - if not found
4336**
4337*******************************************************************************/
4338    BTM_API extern BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
4339
4340/*******************************************************************************
4341**
4342** Function         BTM_HasInquiryEirService
4343**
4344** Description      This function is called to know if UUID in bit map of UUID list.
4345**
4346** Parameters       p_results - inquiry results
4347**                  uuid16 - UUID 16-bit
4348**
4349** Returns          BTM_EIR_FOUND - if found
4350**                  BTM_EIR_NOT_FOUND - if not found and it is complete list
4351**                  BTM_EIR_UNKNOWN - if not found and it is not complete list
4352**
4353*******************************************************************************/
4354    BTM_API extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
4355                                                                    UINT16 uuid16 );
4356
4357/*******************************************************************************
4358**
4359** Function         BTM_AddEirService
4360**
4361** Description      This function is called to add a service in bit map of UUID list.
4362**
4363** Parameters       p_eir_uuid - bit mask of UUID list for EIR
4364**                  uuid16 - UUID 16-bit
4365**
4366** Returns          None
4367**
4368*******************************************************************************/
4369    BTM_API extern void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
4370
4371/*******************************************************************************
4372**
4373** Function         BTM_RemoveEirService
4374**
4375** Description      This function is called to remove a service in bit map of UUID list.
4376**
4377** Parameters       p_eir_uuid - bit mask of UUID list for EIR
4378**                  uuid16 - UUID 16-bit
4379**
4380** Returns          None
4381**
4382*******************************************************************************/
4383    BTM_API extern void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
4384
4385/*******************************************************************************
4386**
4387** Function         BTM_GetEirSupportedServices
4388**
4389** Description      This function is called to get UUID list from bit map of UUID list.
4390**
4391** Parameters       p_eir_uuid - bit mask of UUID list for EIR
4392**                  p - reference of current pointer of EIR
4393**                  max_num_uuid16 - max number of UUID can be written in EIR
4394**                  num_uuid16 - number of UUID have been written in EIR
4395**
4396** Returns          BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
4397**                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
4398**
4399*******************************************************************************/
4400    BTM_API extern UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid,    UINT8 **p,
4401                                                      UINT8  max_num_uuid16, UINT8 *p_num_uuid16);
4402
4403/*******************************************************************************
4404**
4405** Function         BTM_GetEirUuidList
4406**
4407** Description      This function parses EIR and returns UUID list.
4408**
4409** Parameters       p_eir - EIR
4410**                  uuid_size - LEN_UUID_16, LEN_UUID_32, LEN_UUID_128
4411**                  p_num_uuid - return number of UUID in found list
4412**                  p_uuid_list - return UUID 16-bit list
4413**                  max_num_uuid - maximum number of UUID to be returned
4414**
4415** Returns          0 - if not found
4416**                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE
4417**                  BTM_EIR_MORE_16BITS_UUID_TYPE
4418**                  BTM_EIR_COMPLETE_32BITS_UUID_TYPE
4419**                  BTM_EIR_MORE_32BITS_UUID_TYPE
4420**                  BTM_EIR_COMPLETE_128BITS_UUID_TYPE
4421**                  BTM_EIR_MORE_128BITS_UUID_TYPE
4422**
4423*******************************************************************************/
4424    BTM_API extern UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid,
4425                                             UINT8 *p_uuid_list, UINT8 max_num_uuid);
4426
4427/*****************************************************************************
4428**  SCO OVER HCI
4429*****************************************************************************/
4430/*******************************************************************************
4431**
4432** Function         BTM_ConfigScoPath
4433**
4434** Description      This function enable/disable SCO over HCI and registers SCO
4435**                  data callback if SCO over HCI is enabled.
4436**
4437** Parameter        path: SCO or HCI
4438**                  p_sco_data_cb: callback function or SCO data if path is set
4439**                                 to transport.
4440**                  p_pcm_param: pointer to the PCM interface parameter. If a NULL
4441**                               pointer is used, PCM parameter maintained in
4442**                               the control block will be used; otherwise update
4443**                               control block value.
4444**                  err_data_rpt: Lisbon feature to enable the erronous data report
4445**                                or not.
4446**
4447** Returns          BTM_SUCCESS if the successful.
4448**                  BTM_NO_RESOURCES: no rsource to start the command.
4449**                  BTM_ILLEGAL_VALUE: invalid callback function pointer.
4450**                  BTM_CMD_STARTED :Command sent. Waiting for command cmpl event.
4451**
4452**
4453*******************************************************************************/
4454    BTM_API extern tBTM_STATUS BTM_ConfigScoPath (tBTM_SCO_ROUTE_TYPE path,
4455                                                  tBTM_SCO_DATA_CB *p_sco_data_cb,
4456                                                  tBTM_SCO_PCM_PARAM *p_pcm_param,
4457                                                  BOOLEAN err_data_rpt);
4458
4459/*******************************************************************************
4460**
4461** Function         BTM_WriteScoData
4462**
4463** Description      This function write SCO data to a specified instance. The data
4464**                  to be written p_buf needs to carry an offset of
4465**                  HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
4466**                  exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is set
4467**                  to 60 and is configurable. Data longer than the maximum bytes
4468**                  will be truncated.
4469**
4470** Returns          BTM_SUCCESS: data write is successful
4471**                  BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
4472**                  BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO packet
4473**                                      size.
4474**                  BTM_NO_RESOURCES: no resources.
4475**                  BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is not
4476**                                    routed via HCI.
4477**
4478**
4479*******************************************************************************/
4480    BTM_API extern tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf);
4481
4482/*******************************************************************************
4483**
4484** Function         BTM_SetARCMode
4485**
4486** Description      Send Audio Routing Control command.
4487**
4488** Returns          void
4489**
4490*******************************************************************************/
4491BTM_API extern void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_CB *p_arc_cb);
4492
4493
4494/*******************************************************************************
4495**
4496** Function         BTM_PCM2Setup_Write
4497**
4498** Description      Send PCM2_Setup write command.
4499**
4500** Returns          void
4501**
4502*******************************************************************************/
4503BTM_API extern void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb);
4504
4505
4506/*******************************************************************************
4507**
4508** Function         BTM_PM_ReadControllerState
4509**
4510** Description      This function is called to obtain the controller state
4511**
4512** Returns          Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and BTM_CONTRL_IDLE)
4513**
4514*******************************************************************************/
4515BTM_API extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
4516
4517#ifdef __cplusplus
4518}
4519#endif
4520
4521#endif /* BTM_API_H */
4522