btm_api.h revision 4eb14ed2eab174998a86ad245d8163d9f03d3c68
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 (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_VendorSpecificCommand
2213**
2214** Description      Send a vendor specific HCI command to the controller.
2215**
2216** Returns
2217**      BTM_SUCCESS         Command sent. Does not expect command complete
2218**                              event. (command cmpl callback param is NULL)
2219**      BTM_CMD_STARTED     Command sent. Waiting for command cmpl event.
2220**      BTM_BUSY            Command not sent. Waiting for cmd cmpl event for
2221**                              prior command.
2222**
2223*******************************************************************************/
2224    BTM_API extern tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode,
2225                                                         UINT8 param_len,
2226                                                         UINT8 *p_param_buf,
2227                                                         tBTM_VSC_CMPL_CB *p_cb);
2228
2229
2230/*******************************************************************************
2231**
2232** Function         BTM_AllocateSCN
2233**
2234** Description      Look through the Server Channel Numbers for a free one to be
2235**                  used with an RFCOMM connection.
2236**
2237** Returns          Allocated SCN number or 0 if none.
2238**
2239*******************************************************************************/
2240    BTM_API extern UINT8 BTM_AllocateSCN(void);
2241
2242// btla-specific ++
2243/*******************************************************************************
2244**
2245** Function         BTM_TryAllocateSCN
2246**
2247** Description      Try to allocate a fixed server channel
2248**
2249** Returns          Returns TRUE if server channel was available
2250**
2251*******************************************************************************/
2252BTM_API extern BOOLEAN BTM_TryAllocateSCN(UINT8 scn);
2253// btla-specific --
2254
2255
2256/*******************************************************************************
2257**
2258** Function         BTM_FreeSCN
2259**
2260** Description      Free the specified SCN.
2261**
2262** Returns          TRUE if successful, FALSE if SCN is not in use or invalid
2263**
2264*******************************************************************************/
2265    BTM_API extern BOOLEAN BTM_FreeSCN(UINT8 scn);
2266
2267
2268/*******************************************************************************
2269**
2270** Function         BTM_SetTraceLevel
2271**
2272** Description      This function sets the trace level for BTM.  If called with
2273**                  a value of 0xFF, it simply returns the current trace level.
2274**
2275** Returns          The new or current trace level
2276**
2277*******************************************************************************/
2278    BTM_API extern UINT8 BTM_SetTraceLevel (UINT8 new_level);
2279
2280
2281/*******************************************************************************
2282**
2283** Function         BTM_WritePageTimeout
2284**
2285** Description      Send HCI Wite Page Timeout.
2286**
2287** Returns
2288**      BTM_SUCCESS         Command sent.
2289**      BTM_NO_RESOURCES    If out of resources to send the command.
2290**
2291*******************************************************************************/
2292    BTM_API extern tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout);
2293
2294/*******************************************************************************
2295**
2296** Function         BTM_WriteVoiceSettings
2297**
2298** Description      Send HCI Write Voice Settings command.
2299**                  See hcidefs.h for settings bitmask values.
2300**
2301** Returns
2302**      BTM_SUCCESS         Command sent.
2303**      BTM_NO_RESOURCES     If out of resources to send the command.
2304**
2305**
2306*******************************************************************************/
2307    BTM_API extern tBTM_STATUS BTM_WriteVoiceSettings(UINT16 settings);
2308
2309/*******************************************************************************
2310**
2311** Function         BTM_EnableTestMode
2312**
2313** Description      Send HCI the enable device under test command.
2314**
2315**                  Note: Controller can only be taken out of this mode by
2316**                      resetting the controller.
2317**
2318** Returns
2319**      BTM_SUCCESS         Command sent.
2320**      BTM_NO_RESOURCES    If out of resources to send the command.
2321**
2322**
2323*******************************************************************************/
2324    BTM_API extern tBTM_STATUS BTM_EnableTestMode(void);
2325
2326
2327/*****************************************************************************
2328**  DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device
2329*****************************************************************************/
2330
2331/*******************************************************************************
2332**
2333** Function         BTM_SetDiscoverability
2334**
2335** Description      This function is called to set the device into or out of
2336**                  discoverable mode. Discoverable mode means inquiry
2337**                  scans are enabled.  If a value of '0' is entered for window or
2338**                  interval, the default values are used.
2339**
2340** Returns          BTM_SUCCESS if successful
2341**                  BTM_BUSY if a setting of the filter is already in progress
2342**                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
2343**                  BTM_ILLEGAL_VALUE if a bad parameter was detected
2344**                  BTM_WRONG_MODE if the device is not up.
2345**
2346*******************************************************************************/
2347    BTM_API extern tBTM_STATUS  BTM_SetDiscoverability (UINT16 inq_mode, UINT16 window,
2348                                                        UINT16 interval);
2349
2350
2351/*******************************************************************************
2352**
2353** Function         BTM_ReadDiscoverability
2354**
2355** Description      This function is called to read the current discoverability
2356**                  mode of the device.
2357**
2358** Output Params:   p_window - current inquiry scan duration
2359**                  p_interval - current inquiry scan interval
2360**
2361** Returns          BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or
2362**                  BTM_GENERAL_DISCOVERABLE
2363**
2364*******************************************************************************/
2365    BTM_API extern UINT16       BTM_ReadDiscoverability (UINT16 *p_window,
2366                                                         UINT16 *p_interval);
2367
2368
2369/*******************************************************************************
2370**
2371** Function         BTM_SetPeriodicInquiryMode
2372**
2373** Description      This function is called to set the device periodic inquiry mode.
2374**                  If the duration is zero, the periodic inquiry mode is cancelled.
2375**
2376** Parameters:      p_inqparms - pointer to the inquiry information
2377**                      mode - GENERAL or LIMITED inquiry
2378**                      duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
2379**                      max_resps - maximum amount of devices to search for before ending the inquiry
2380**                      filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
2381**                                         BTM_FILTER_COND_BD_ADDR
2382**                      filter_cond - value for the filter (based on filter_cond_type)
2383**
2384**                  max_delay - maximum amount of time between successive inquiries
2385**                  min_delay - minimum amount of time between successive inquiries
2386**                  p_results_cb - callback returning pointer to results (tBTM_INQ_RESULTS)
2387**
2388** Returns          BTM_CMD_STARTED if successfully started
2389**                  BTM_ILLEGAL_VALUE if a bad parameter is detected
2390**                  BTM_NO_RESOURCES if could not allocate a message buffer
2391**                  BTM_SUCCESS - if cancelling the periodic inquiry
2392**                  BTM_BUSY - if an inquiry is already active
2393**                  BTM_WRONG_MODE if the device is not up.
2394**
2395*******************************************************************************/
2396    BTM_API extern tBTM_STATUS  BTM_SetPeriodicInquiryMode (tBTM_INQ_PARMS *p_inqparms,
2397                                                            UINT16 max_delay, UINT16 min_delay,
2398                                                            tBTM_INQ_RESULTS_CB *p_results_cb);
2399
2400
2401/*******************************************************************************
2402**
2403** Function         BTM_StartInquiry
2404**
2405** Description      This function is called to start an inquiry.
2406**
2407** Parameters:      p_inqparms - pointer to the inquiry information
2408**                      mode - GENERAL or LIMITED inquiry
2409**                      duration - length in 1.28 sec intervals (If '0', the inquiry is CANCELLED)
2410**                      max_resps - maximum amount of devices to search for before ending the inquiry
2411**                      filter_cond_type - BTM_CLR_INQUIRY_FILTER, BTM_FILTER_COND_DEVICE_CLASS, or
2412**                                         BTM_FILTER_COND_BD_ADDR
2413**                      filter_cond - value for the filter (based on filter_cond_type)
2414**
2415**                  p_results_cb   - Pointer to the callback routine which gets called
2416**                                upon receipt of an inquiry result. If this field is
2417**                                NULL, the application is not notified.
2418**
2419**                  p_cmpl_cb   - Pointer to the callback routine which gets called
2420**                                upon completion.  If this field is NULL, the
2421**                                application is not notified when completed.
2422** Returns          tBTM_STATUS
2423**                  BTM_CMD_STARTED if successfully initiated
2424**                  BTM_BUSY if already in progress
2425**                  BTM_ILLEGAL_VALUE if parameter(s) are out of range
2426**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2427**                  BTM_WRONG_MODE if the device is not up.
2428**
2429*******************************************************************************/
2430    BTM_API extern tBTM_STATUS  BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms,
2431                                                  tBTM_INQ_RESULTS_CB *p_results_cb,
2432                                                  tBTM_CMPL_CB *p_cmpl_cb);
2433
2434
2435/*******************************************************************************
2436**
2437** Function         BTM_IsInquiryActive
2438**
2439** Description      This function returns a bit mask of the current inquiry state
2440**
2441** Returns          BTM_INQUIRY_INACTIVE if inactive (0)
2442**                  BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
2443**                  BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
2444**                  BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
2445**
2446*******************************************************************************/
2447    BTM_API extern UINT16 BTM_IsInquiryActive (void);
2448
2449
2450/*******************************************************************************
2451**
2452** Function         BTM_CancelInquiry
2453**
2454** Description      This function cancels an inquiry if active
2455**
2456** Returns          BTM_SUCCESS if successful
2457**                  BTM_NO_RESOURCES if could not allocate a message buffer
2458**                  BTM_WRONG_MODE if the device is not up.
2459**
2460*******************************************************************************/
2461    BTM_API extern tBTM_STATUS BTM_CancelInquiry(void);
2462
2463
2464/*******************************************************************************
2465**
2466** Function         BTM_CancelPeriodicInquiry
2467**
2468** Description      This function cancels a periodic inquiry
2469**
2470** Returns
2471**                  BTM_NO_RESOURCES if could not allocate a message buffer
2472**                  BTM_SUCCESS - if cancelling the periodic inquiry
2473**                  BTM_WRONG_MODE if the device is not up.
2474**
2475*******************************************************************************/
2476    BTM_API extern tBTM_STATUS BTM_CancelPeriodicInquiry(void);
2477
2478
2479/*******************************************************************************
2480**
2481** Function         BTM_SetConnectability
2482**
2483** Description      This function is called to set the device into or out of
2484**                  connectable mode. Discoverable mode means page scans enabled.
2485**
2486** Returns          BTM_SUCCESS if successful
2487**                  BTM_ILLEGAL_VALUE if a bad parameter is detected
2488**                  BTM_NO_RESOURCES if could not allocate a message buffer
2489**                  BTM_WRONG_MODE if the device is not up.
2490**
2491*******************************************************************************/
2492    BTM_API extern tBTM_STATUS BTM_SetConnectability (UINT16 page_mode, UINT16 window,
2493                                                      UINT16 interval);
2494
2495
2496/*******************************************************************************
2497**
2498** Function         BTM_ReadConnectability
2499**
2500** Description      This function is called to read the current discoverability
2501**                  mode of the device.
2502** Output Params    p_window - current page scan duration
2503**                  p_interval - current time between page scans
2504**
2505** Returns          BTM_NON_CONNECTABLE or BTM_CONNECTABLE
2506**
2507*******************************************************************************/
2508    BTM_API extern UINT16 BTM_ReadConnectability (UINT16 *p_window, UINT16 *p_interval);
2509
2510
2511/*******************************************************************************
2512**
2513** Function         BTM_SetInquiryMode
2514**
2515** Description      This function is called to set standard, with RSSI
2516**                  mode or extended of the inquiry for local device.
2517**
2518** Input Params:    BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
2519**                  BTM_INQ_RESULT_EXTENDED
2520**
2521** Returns          BTM_SUCCESS if successful
2522**                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
2523**                  BTM_ILLEGAL_VALUE if a bad parameter was detected
2524**                  BTM_WRONG_MODE if the device is not up.
2525**
2526*******************************************************************************/
2527    BT_API extern tBTM_STATUS  BTM_SetInquiryMode (UINT8 mode);
2528
2529/*******************************************************************************
2530**
2531** Function         BTM_SetInquiryScanType
2532**
2533** Description      This function is called to set the iquiry scan-type to
2534**                  standard or interlaced.
2535**
2536** Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
2537**
2538** Returns          BTM_SUCCESS if successful
2539**                  BTM_MODE_UNSUPPORTED if not a 1.2 device
2540**                  BTM_WRONG_MODE if the device is not up.
2541**
2542*******************************************************************************/
2543    BT_API extern tBTM_STATUS BTM_SetInquiryScanType (UINT16 scan_type);
2544
2545/*******************************************************************************
2546**
2547** Function         BTM_SetPageScanType
2548**
2549** Description      This function is called to set the page scan-type to
2550**                  standard or interlaced.
2551**
2552** Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
2553**
2554** Returns          BTM_SUCCESS if successful
2555**                  BTM_MODE_UNSUPPORTED if not a 1.2 device
2556**                  BTM_WRONG_MODE if the device is not up.
2557**
2558*******************************************************************************/
2559
2560    BT_API extern tBTM_STATUS BTM_SetPageScanType (UINT16 scan_type);
2561
2562/*******************************************************************************
2563**
2564** Function         BTM_ReadRemoteDeviceName
2565**
2566** Description      This function initiates a remote device HCI command to the
2567**                  controller and calls the callback when the process has completed.
2568**
2569** Input Params:    remote_bda      - device address of name to retrieve
2570**                  p_cb            - callback function called when BTM_CMD_STARTED
2571**                                    is returned.
2572**                                    A pointer to tBTM_REMOTE_DEV_NAME is passed to the
2573**                                    callback.
2574**
2575** Returns
2576**                  BTM_CMD_STARTED is returned if the request was successfully sent
2577**                                  to HCI.
2578**                  BTM_BUSY if already in progress
2579**                  BTM_UNKNOWN_ADDR if device address is bad
2580**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2581**                  BTM_WRONG_MODE if the device is not up.
2582**
2583*******************************************************************************/
2584    BTM_API extern tBTM_STATUS  BTM_ReadRemoteDeviceName (BD_ADDR remote_bda,
2585                                                          tBTM_CMPL_CB *p_cb,
2586                                                          tBT_TRANSPORT transport);
2587
2588
2589/*******************************************************************************
2590**
2591** Function         BTM_CancelRemoteDeviceName
2592**
2593** Description      This function initiates the cancel request for the specified
2594**                  remote device.
2595**
2596** Input Params:    None
2597**
2598** Returns
2599**                  BTM_CMD_STARTED is returned if the request was successfully sent
2600**                                  to HCI.
2601**                  BTM_NO_RESOURCES if could not allocate resources to start the command
2602**                  BTM_WRONG_MODE if there is not an active remote name request.
2603**
2604*******************************************************************************/
2605    BTM_API extern tBTM_STATUS  BTM_CancelRemoteDeviceName (void);
2606
2607/*******************************************************************************
2608**
2609** Function         BTM_ReadRemoteVersion
2610**
2611** Description      This function is called to read a remote device's version
2612**
2613** Returns          BTM_SUCCESS if successful, otherwise an error
2614**
2615*******************************************************************************/
2616    BTM_API extern tBTM_STATUS BTM_ReadRemoteVersion (BD_ADDR addr,
2617                                                      UINT8 *lmp_version,
2618                                                      UINT16 *manufacturer,
2619                                                      UINT16 *lmp_sub_version);
2620
2621/*******************************************************************************
2622**
2623** Function         BTM_ReadRemoteFeatures
2624**
2625** Description      This function is called to read a remote device's
2626**                  supported features mask (features mask located at page 0)
2627**
2628**                  Note: The size of device features mask page is
2629**                  BTM_FEATURE_BYTES_PER_PAGE bytes.
2630**
2631** Returns          pointer to the remote supported features mask
2632**
2633*******************************************************************************/
2634    BTM_API extern UINT8 *BTM_ReadRemoteFeatures (BD_ADDR addr);
2635
2636/*******************************************************************************
2637**
2638** Function         BTM_ReadRemoteExtendedFeatures
2639**
2640** Description      This function is called to read a specific extended features
2641**                  page of the remote device
2642**
2643**                  Note1: The size of device features mask page is
2644**                  BTM_FEATURE_BYTES_PER_PAGE bytes.
2645**                  Note2: The valid device features mask page number depends on
2646**                  the remote device capabilities. It is expected to be in the
2647**                  range [0 - BTM_EXT_FEATURES_PAGE_MAX].
2648
2649** Returns          pointer to the remote extended features mask
2650**                  or NULL if page_number is not valid
2651**
2652*******************************************************************************/
2653    BTM_API extern UINT8 *BTM_ReadRemoteExtendedFeatures (BD_ADDR addr, UINT8 page_number);
2654
2655/*******************************************************************************
2656**
2657** Function         BTM_ReadNumberRemoteFeaturesPages
2658**
2659** Description      This function is called to retrieve the number of feature pages
2660**                  read from the remote device
2661**
2662** Returns          number of features pages read from the remote device
2663**
2664*******************************************************************************/
2665    BTM_API extern UINT8 BTM_ReadNumberRemoteFeaturesPages (BD_ADDR addr);
2666
2667/*******************************************************************************
2668**
2669** Function         BTM_ReadAllRemoteFeatures
2670**
2671** Description      This function is called to read all features of the remote device
2672**
2673** Returns          pointer to the byte[0] of the page[0] of the remote device
2674**                  feature mask.
2675**
2676** Note:            the function returns the pointer to the array of the size
2677**                  BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1).
2678**
2679*******************************************************************************/
2680    BTM_API extern UINT8 *BTM_ReadAllRemoteFeatures (BD_ADDR addr);
2681
2682/*******************************************************************************
2683**
2684** Function         BTM_InqFirstResult
2685**
2686** Description      This function looks through the inquiry database for the first
2687**                  used entrysince the LAST inquiry. This is used in conjunction
2688**                  with BTM_InqNext by applications as a way to walk through the
2689**                  inquiry results database.
2690**
2691** Returns          pointer to first in-use entry, or NULL if DB is empty
2692**
2693*******************************************************************************/
2694    BTM_API extern tBTM_INQ_INFO *BTM_InqFirstResult (void);
2695
2696
2697/*******************************************************************************
2698**
2699** Function         BTM_InqNextResult
2700**
2701** Description      This function looks through the inquiry database for the next
2702**                  used entrysince the LAST inquiry. If the input parameter is NULL,
2703**                  the first entry is returned.
2704**
2705** Returns          pointer to next in-use entry, or NULL if no more found.
2706**
2707*******************************************************************************/
2708    BTM_API extern tBTM_INQ_INFO *BTM_InqNextResult (tBTM_INQ_INFO *p_cur);
2709
2710
2711/*******************************************************************************
2712**
2713** Function         BTM_InqDbRead
2714**
2715** Description      This function looks through the inquiry database for a match
2716**                  based on Bluetooth Device Address. This is the application's
2717**                  interface to get the inquiry details of a specific BD address.
2718**
2719** Returns          pointer to entry, or NULL if not found
2720**
2721*******************************************************************************/
2722    BTM_API extern tBTM_INQ_INFO *BTM_InqDbRead (BD_ADDR p_bda);
2723
2724
2725/*******************************************************************************
2726**
2727** Function         BTM_InqDbFirst
2728**
2729** Description      This function looks through the inquiry database for the first
2730**                  used entry, and returns that. This is used in conjunction with
2731**                  BTM_InqDbNext by applications as a way to walk through the
2732**                  inquiry database.
2733**
2734** Returns          pointer to first in-use entry, or NULL if DB is empty
2735**
2736*******************************************************************************/
2737    BTM_API extern tBTM_INQ_INFO *BTM_InqDbFirst (void);
2738
2739
2740/*******************************************************************************
2741**
2742** Function         BTM_InqDbNext
2743**
2744** Description      This function looks through the inquiry database for the next
2745**                  used entry, and returns that.  If the input parameter is NULL,
2746**                  the first entry is returned.
2747**
2748** Returns          pointer to next in-use entry, or NULL if no more found.
2749**
2750*******************************************************************************/
2751    BTM_API extern tBTM_INQ_INFO *BTM_InqDbNext (tBTM_INQ_INFO *p_cur);
2752
2753
2754/*******************************************************************************
2755**
2756** Function         BTM_ClearInqDb
2757**
2758** Description      This function is called to clear out a device or all devices
2759**                  from the inquiry database.
2760**
2761** Parameter        p_bda - (input) BD_ADDR ->  Address of device to clear
2762**                                              (NULL clears all entries)
2763**
2764** Returns          BTM_BUSY if an inquiry, get remote name, or event filter
2765**                          is active, otherwise BTM_SUCCESS
2766**
2767*******************************************************************************/
2768    BTM_API extern tBTM_STATUS  BTM_ClearInqDb (BD_ADDR p_bda);
2769
2770
2771/*******************************************************************************
2772**
2773** Function         BTM_ReadNumInqDbEntries
2774**
2775** Returns          This function returns the number of entries in the inquiry database.
2776**
2777*******************************************************************************/
2778    BTM_API extern UINT8 BTM_ReadNumInqDbEntries (void);
2779
2780/*******************************************************************************
2781**
2782** Function         BTM_ReadInquiryRspTxPower
2783**
2784** Description      This command will read the inquiry Transmit Power level used
2785**                  to transmit the FHS and EIR data packets.
2786**                  This can be used directly in the Tx Power Level EIR data type.
2787**
2788** Returns          BTM_SUCCESS if successful
2789**
2790*******************************************************************************/
2791    BTM_API extern tBTM_STATUS BTM_ReadInquiryRspTxPower (tBTM_CMPL_CB *p_cb);
2792
2793/*******************************************************************************
2794**
2795** Function         BTM_WriteInquiryTxPower
2796**
2797** Description      This command is used to write the inquiry transmit power level
2798**                  used to transmit the inquiry (ID) data packets. The Controller
2799**                  should use the supported TX power level closest to the Tx_Power
2800**                  parameter.
2801**
2802** Returns          BTM_SUCCESS if successful
2803**
2804*******************************************************************************/
2805    BTM_API extern tBTM_STATUS  BTM_WriteInquiryTxPower (INT8 tx_power);
2806
2807/*******************************************************************************
2808**
2809** Function         BTM_StartDiscovery
2810**
2811** Description      This function is called by an application (or profile)
2812**                  when it wants to trigger an service discovery using the
2813**                  BTM's discovery database.
2814**
2815** Returns          tBTM_STATUS
2816**                      BTM_CMD_STARTED if the discovery was initiated
2817**                      BTM_BUSY if one is already in progress
2818**                      BTM_UNKNOWN_ADDR if no addresses are in the INQ DB
2819**                      BTM_ERR_PROCESSING if err initiating the command
2820**
2821*******************************************************************************/
2822    BTM_API extern tBTM_STATUS BTM_StartDiscovery (tBTM_CMPL_CB *p_cmpl_cb,
2823                                                   BD_ADDR_PTR p_rem_addr);
2824
2825
2826/*******************************************************************************
2827**
2828** Function         BTM_FindAttribute
2829**
2830** Description      This function is called by an application (or profile)
2831**                  when it wants to see if an attribute exists in the BTM
2832**                  discovery database.
2833**
2834** Returns          Pointer to matching record, or NULL
2835**
2836*******************************************************************************/
2837    BTM_API extern tSDP_DISC_REC *BTM_FindAttribute (UINT16 attr_id,
2838                                                     tSDP_DISC_REC *p_start_rec);
2839
2840
2841/*******************************************************************************
2842**
2843** Function         BTM_FindService
2844**
2845** Description      This function is called by an application (or profile)
2846**                  when it wants to see if a service exists in the BTM
2847**                  discovery database.
2848**
2849** Returns          Pointer to matching record, or NULL
2850**
2851*******************************************************************************/
2852    BTM_API extern tSDP_DISC_REC *BTM_FindService (UINT16 service_uuid,
2853                                                   tSDP_DISC_REC *p_start_rec);
2854
2855
2856/*******************************************************************************
2857**
2858** Function         BTM_SetDiscoveryParams
2859**
2860** Description      This function is called to set the BTM default discovery parameters.
2861**                  These UUID and attribute filters are used during the call to
2862**                  BTM_StartDiscovery.
2863**
2864** Returns          void
2865**
2866*******************************************************************************/
2867    BTM_API extern void BTM_SetDiscoveryParams (UINT16 num_uuid, tSDP_UUID *p_uuid_list,
2868                                                UINT16 num_attr, UINT16 *p_attr_list);
2869
2870
2871/*****************************************************************************
2872**  ACL CHANNEL MANAGEMENT FUNCTIONS
2873*****************************************************************************/
2874/*******************************************************************************
2875**
2876** Function         BTM_SetLinkPolicy
2877**
2878** Description      Create and send HCI "Write Policy Set" command
2879**
2880** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2881**
2882*******************************************************************************/
2883    BTM_API extern tBTM_STATUS BTM_SetLinkPolicy (BD_ADDR remote_bda,
2884                                                  UINT16 *settings);
2885
2886
2887/*******************************************************************************
2888**
2889** Function         BTM_ReadLinkPolicy
2890**
2891** Description      This function is called to read the link policy settings.
2892**                  The address of link policy results are returned in the callback.
2893**                  (tBTM_LNK_POLICY_RESULTS)
2894**
2895** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2896**
2897*******************************************************************************/
2898    BTM_API extern tBTM_STATUS BTM_ReadLinkPolicy (BD_ADDR remote_bda,
2899                                                   tBTM_CMPL_CB *p_cb);
2900
2901
2902/*******************************************************************************
2903**
2904** Function         BTM_SetDefaultLinkPolicy
2905**
2906** Description      Set the default value for HCI "Write Policy Set" command
2907**                  to use when an ACL link is created.
2908**
2909** Returns          void
2910**
2911*******************************************************************************/
2912    BTM_API extern void BTM_SetDefaultLinkPolicy (UINT16 settings);
2913
2914
2915/*******************************************************************************
2916**
2917** Function         BTM_SetDefaultLinkSuperTout
2918**
2919** Description      Set the default value for HCI "Write Link Supervision Timeout"
2920**                  command to use when an ACL link is created.
2921**
2922** Returns          void
2923**
2924*******************************************************************************/
2925    BTM_API extern void BTM_SetDefaultLinkSuperTout (UINT16 timeout);
2926
2927
2928/*******************************************************************************
2929**
2930** Function         BTM_SetLinkSuperTout
2931**
2932** Description      Create and send HCI "Write Link Supervision Timeout" command
2933**
2934** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2935**
2936*******************************************************************************/
2937    BTM_API extern tBTM_STATUS BTM_SetLinkSuperTout (BD_ADDR remote_bda,
2938                                                     UINT16 timeout);
2939/*******************************************************************************
2940**
2941** Function         BTM_GetLinkSuperTout
2942**
2943** Description      Read the link supervision timeout value of the connection
2944**
2945** Returns          status of the operation
2946**
2947*******************************************************************************/
2948    BTM_API extern tBTM_STATUS BTM_GetLinkSuperTout (BD_ADDR remote_bda,
2949                                                     UINT16 *p_timeout);
2950
2951/*******************************************************************************
2952**
2953** Function         BTM_RegForLstoEvt
2954**
2955** Description      register for the HCI "Link Supervision Timeout Change" event
2956**
2957** Returns          void
2958**
2959*******************************************************************************/
2960    BTM_API extern void BTM_RegForLstoEvt (tBTM_LSTO_CBACK *p_cback);
2961
2962
2963/* These next APIs are available if the power manager is not compiled in */
2964#if BTM_PWR_MGR_INCLUDED == FALSE
2965/*******************************************************************************
2966**
2967** Function         BTM_SetHoldMode
2968**
2969** Description      This function is called to set a connection into hold mode.
2970**                  A check is made if the connection is in sniff or park mode,
2971**                  and if yes, the hold mode is ignored.
2972**
2973** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2974**
2975*******************************************************************************/
2976    BTM_API extern tBTM_STATUS BTM_SetHoldMode (BD_ADDR remote_bda, UINT16 min_interval,
2977                                                UINT16 max_interval);
2978
2979
2980/*******************************************************************************
2981**
2982** Function         BTM_SetSniffMode
2983**
2984** Description      This function is called to set a connection into sniff mode.
2985**                  A check is made if the connection is already in sniff or park
2986**                  mode, and if yes, the sniff mode is ignored.
2987**
2988** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
2989**
2990*******************************************************************************/
2991    BTM_API extern tBTM_STATUS BTM_SetSniffMode (BD_ADDR remote_bda, UINT16 min_period,
2992                                                 UINT16 max_period, UINT16 attempt,
2993                                                 UINT16 timeout);
2994
2995
2996/*******************************************************************************
2997**
2998** Function         BTM_CancelSniffMode
2999**
3000** Description      This function is called to put a connection out of sniff mode.
3001**                  A check is made if the connection is already in sniff mode,
3002**                  and if not, the cancel sniff mode is ignored.
3003**
3004** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3005**
3006*******************************************************************************/
3007    BTM_API extern tBTM_STATUS BTM_CancelSniffMode (BD_ADDR remote_bda);
3008
3009
3010/*******************************************************************************
3011**
3012** Function         BTM_SetParkMode
3013**
3014** Description      This function is called to set a connection into park mode.
3015**                  A check is made if the connection is already in sniff or park
3016**                  mode, and if yes, the park mode is ignored.
3017**
3018** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3019**
3020*******************************************************************************/
3021    BTM_API extern tBTM_STATUS BTM_SetParkMode (BD_ADDR remote_bda,
3022                                                UINT16 beacon_min_period,
3023                                                UINT16 beacon_max_period);
3024
3025
3026/*******************************************************************************
3027**
3028** Function         BTM_CancelParkMode
3029**
3030** Description      This function is called to put a connection out of park mode.
3031**                  A check is made if the connection is already in park mode,
3032**                  and if not, the cancel sniff mode is ignored.
3033**
3034** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3035**
3036*******************************************************************************/
3037    BTM_API extern tBTM_STATUS BTM_CancelParkMode (BD_ADDR remote_bda);
3038
3039
3040/*******************************************************************************
3041**
3042** Function         BTM_ReadAclMode
3043**
3044** Description      This returns the current mode for a specific
3045**                  ACL connection.
3046**
3047** Input Param      remote_bda - device address of desired ACL connection
3048**
3049** Output Param     p_mode - address where the current mode is copied into.
3050**                          BTM_ACL_MODE_NORMAL
3051**                          BTM_ACL_MODE_HOLD
3052**                          BTM_ACL_MODE_SNIFF
3053**                          BTM_ACL_MODE_PARK
3054**                          (valid only if return code is BTM_SUCCESS)
3055**
3056** Returns          BTM_SUCCESS if successful,
3057**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
3058**
3059*******************************************************************************/
3060    BTM_API extern tBTM_STATUS BTM_ReadAclMode (BD_ADDR remote_bda, UINT8 *p_mode);
3061
3062#endif /* if BTM_PWR_MGR_INCLUDED == FALSE */
3063
3064
3065/*******************************************************************************
3066**
3067** Function         BTM_SetPacketTypes
3068**
3069** Description      This function is set the packet types used for a specific
3070**                  ACL connection,
3071**
3072** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3073**
3074*******************************************************************************/
3075    BTM_API extern tBTM_STATUS BTM_SetPacketTypes (BD_ADDR remote_bda, UINT16 pkt_types);
3076
3077
3078/*******************************************************************************
3079**
3080** Function         BTM_ReadPacketTypes
3081**
3082** Description      This function is set the packet types used for the specified
3083**                  ACL connection,
3084**
3085** Returns          packet types supported for the connection, or 0 if no BD address
3086**
3087*******************************************************************************/
3088    BTM_API extern UINT16 BTM_ReadPacketTypes (BD_ADDR remote_bda);
3089
3090
3091/*******************************************************************************
3092**
3093** Function         BTM_IsAclConnectionUp
3094**
3095** Description      This function is called to check if an ACL connection exists
3096**                  to a specific remote BD Address.
3097**
3098** Returns          TRUE if connection is up, else FALSE.
3099**
3100*******************************************************************************/
3101    BTM_API extern BOOLEAN BTM_IsAclConnectionUp (BD_ADDR remote_bda, tBT_TRANSPORT transport);
3102
3103
3104/*******************************************************************************
3105**
3106** Function         BTM_GetRole
3107**
3108** Description      This function is called to get the role of the local device
3109**                  for the ACL connection with the specified remote device
3110**
3111** Returns          BTM_SUCCESS if connection exists.
3112**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3113**
3114*******************************************************************************/
3115    BTM_API extern tBTM_STATUS BTM_GetRole (BD_ADDR remote_bd_addr, UINT8 *p_role);
3116
3117
3118
3119/*******************************************************************************
3120**
3121** Function         BTM_SwitchRole
3122**
3123** Description      This function is called to switch role between master and
3124**                  slave.  If role is already set it will do nothing.  If the
3125**                  command was initiated, the callback function is called upon
3126**                  completion.
3127**
3128** Returns          BTM_SUCCESS if already in specified role.
3129**                  BTM_CMD_STARTED if command issued to controller.
3130**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3131**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3132**                  BTM_MODE_UNSUPPORTED if local device does not support role switching
3133**
3134*******************************************************************************/
3135    BTM_API extern tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
3136                                               UINT8 new_role,
3137                                               tBTM_CMPL_CB *p_cb);
3138
3139/*******************************************************************************
3140**
3141** Function         BTM_ChangeLinkKey
3142**
3143** Description      This function is called to change the link key of the
3144**                  connection.
3145**
3146** Returns          BTM_CMD_STARTED if command issued to controller.
3147**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3148**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3149**                  BTM_BUSY if the previous command is not completed
3150**
3151*******************************************************************************/
3152    BTM_API extern tBTM_STATUS BTM_ChangeLinkKey (BD_ADDR remote_bd_addr,
3153                                                  tBTM_CMPL_CB *p_cb);
3154
3155/*******************************************************************************
3156**
3157** Function         BTM_ReadRSSI
3158**
3159** Description      This function is called to read the link policy settings.
3160**                  The address of link policy results are returned in the callback.
3161**                  (tBTM_RSSI_RESULTS)
3162**
3163** Returns          BTM_CMD_STARTED if command issued to controller.
3164**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3165**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3166**                  BTM_BUSY if command is already in progress
3167**
3168*******************************************************************************/
3169    BTM_API extern tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
3170
3171
3172/*******************************************************************************
3173**
3174** Function         BTM_ReadTxPower
3175**
3176** Description      This function is called to read the current connection
3177**                  TX power of the connection. The TX power level results
3178**                  are returned in the callback.
3179**                  (tBTM_RSSI_RESULTS)
3180**
3181** Returns          BTM_CMD_STARTED if command issued to controller.
3182**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3183**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3184**                  BTM_BUSY if command is already in progress
3185**
3186*******************************************************************************/
3187    BTM_API extern tBTM_STATUS BTM_ReadTxPower (BD_ADDR remote_bda,
3188                                                      tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
3189
3190/*******************************************************************************
3191**
3192** Function         BTM_ReadLinkQuality
3193**
3194** Description      This function is called to read the link quality.
3195**                  The value of the link quality is returned in the callback.
3196**                  (tBTM_LINK_QUALITY_RESULTS)
3197**
3198** Returns          BTM_CMD_STARTED if command issued to controller.
3199**                  BTM_NO_RESOURCES if couldn't allocate memory to issue command
3200**                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
3201**                  BTM_BUSY if command is already in progress
3202**
3203*******************************************************************************/
3204    BTM_API extern tBTM_STATUS BTM_ReadLinkQuality (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
3205
3206/*******************************************************************************
3207**
3208** Function         BTM_RegBusyLevelNotif
3209**
3210** Description      This function is called to register a callback to receive
3211**                  busy level change events.
3212**
3213** Returns          BTM_SUCCESS if successfully registered, otherwise error
3214**
3215*******************************************************************************/
3216    BTM_API extern tBTM_STATUS BTM_RegBusyLevelNotif (tBTM_BL_CHANGE_CB *p_cb, UINT8 *p_level,
3217                                                      tBTM_BL_EVENT_MASK evt_mask);
3218
3219/*******************************************************************************
3220**
3221** Function         BTM_AclRegisterForChanges
3222**
3223** Description      This function is called to register a callback to receive
3224**                  ACL database change events, i.e. new connection or removed.
3225**
3226** Returns          BTM_SUCCESS if successfully initiated, otherwise error
3227**
3228*******************************************************************************/
3229    BTM_API extern tBTM_STATUS BTM_AclRegisterForChanges (tBTM_ACL_DB_CHANGE_CB *p_cb);
3230
3231/*******************************************************************************
3232**
3233** Function         BTM_GetNumAclLinks
3234**
3235** Description      This function is called to count the number of
3236**                  ACL links that are active.
3237**
3238** Returns          UINT16  Number of active ACL links
3239**
3240*******************************************************************************/
3241    BTM_API extern UINT16 BTM_GetNumAclLinks (void);
3242
3243
3244/*******************************************************************************
3245**
3246** Function         BTM_ReadClockOffset
3247**
3248** Description      This returns the clock offset for a specific
3249**                  ACL connection.
3250**
3251** Returns          clock-offset or 0 if unknown
3252**
3253*******************************************************************************/
3254    BTM_API extern UINT16 BTM_ReadClockOffset (BD_ADDR remote_bda);
3255
3256
3257/*******************************************************************************
3258**
3259** Function         BTM_SetQoS
3260**
3261** Description      This function is called to setup QoS
3262**
3263** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3264**
3265*******************************************************************************/
3266    BTM_API extern tBTM_STATUS BTM_SetQoS(BD_ADDR bd, FLOW_SPEC *p_flow,
3267                                          tBTM_CMPL_CB *p_cb);
3268
3269
3270/*****************************************************************************
3271**  (e)SCO CHANNEL MANAGEMENT FUNCTIONS
3272*****************************************************************************/
3273/*******************************************************************************
3274**
3275** Function         BTM_CreateSco
3276**
3277** Description      This function is called to create an SCO connection. If the
3278**                  "is_orig" flag is TRUE, the connection will be originated,
3279**                  otherwise BTM will wait for the other side to connect.
3280**
3281** Returns          BTM_UNKNOWN_ADDR if the ACL connection is not up
3282**                  BTM_BUSY         if another SCO being set up to
3283**                                   the same BD address
3284**                  BTM_NO_RESOURCES if the max SCO limit has been reached
3285**                  BTM_CMD_STARTED  if the connection establishment is started.
3286**                                   In this case, "*p_sco_inx" is filled in
3287**                                   with the sco index used for the connection.
3288**
3289*******************************************************************************/
3290    BTM_API extern tBTM_STATUS BTM_CreateSco (BD_ADDR remote_bda, BOOLEAN is_orig,
3291                                              UINT16 pkt_types, UINT16 *p_sco_inx,
3292                                              tBTM_SCO_CB *p_conn_cb,
3293                                              tBTM_SCO_CB *p_disc_cb);
3294
3295
3296/*******************************************************************************
3297**
3298** Function         BTM_RemoveSco
3299**
3300** Description      This function is called to remove a specific SCO connection.
3301**
3302** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3303**
3304*******************************************************************************/
3305    BTM_API extern tBTM_STATUS BTM_RemoveSco (UINT16 sco_inx);
3306
3307
3308/*******************************************************************************
3309**
3310** Function         BTM_SetScoPacketTypes
3311**
3312** Description      This function is called to set the packet types used for
3313**                  a specific SCO connection,
3314**
3315** Parameters       pkt_types - One or more of the following
3316**                  BTM_SCO_PKT_TYPES_MASK_HV1
3317**                  BTM_SCO_PKT_TYPES_MASK_HV2
3318**                  BTM_SCO_PKT_TYPES_MASK_HV3
3319**                  BTM_SCO_PKT_TYPES_MASK_EV3
3320**                  BTM_SCO_PKT_TYPES_MASK_EV4
3321**                  BTM_SCO_PKT_TYPES_MASK_EV5
3322**
3323**                  BTM_SCO_LINK_ALL_MASK   - enables all supported types
3324**
3325** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3326**
3327*******************************************************************************/
3328    BTM_API extern tBTM_STATUS BTM_SetScoPacketTypes (UINT16 sco_inx, UINT16 pkt_types);
3329
3330
3331/*******************************************************************************
3332**
3333** Function         BTM_ReadScoPacketTypes
3334**
3335** Description      This function is read the packet types used for a specific
3336**                  SCO connection.
3337**
3338** Returns       One or more of the following (bitmask)
3339**                  BTM_SCO_PKT_TYPES_MASK_HV1
3340**                  BTM_SCO_PKT_TYPES_MASK_HV2
3341**                  BTM_SCO_PKT_TYPES_MASK_HV3
3342**                  BTM_SCO_PKT_TYPES_MASK_EV3
3343**                  BTM_SCO_PKT_TYPES_MASK_EV4
3344**                  BTM_SCO_PKT_TYPES_MASK_EV5
3345**
3346** Returns          packet types supported for the connection
3347**
3348*******************************************************************************/
3349    BTM_API extern UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx);
3350
3351
3352/*******************************************************************************
3353**
3354** Function         BTM_ReadDeviceScoPacketTypes
3355**
3356** Description      This function is read the SCO packet types that
3357**                  the device supports.
3358**
3359** Returns          packet types supported by the device.
3360**
3361*******************************************************************************/
3362    BTM_API extern UINT16 BTM_ReadDeviceScoPacketTypes (void);
3363
3364
3365/*******************************************************************************
3366**
3367** Function         BTM_ReadScoHandle
3368**
3369** Description      This function is used to read the HCI handle used for a specific
3370**                  SCO connection,
3371**
3372** Returns          handle for the connection, or 0xFFFF if invalid SCO index.
3373**
3374*******************************************************************************/
3375    BTM_API extern UINT16 BTM_ReadScoHandle (UINT16 sco_inx);
3376
3377
3378/*******************************************************************************
3379**
3380** Function         BTM_ReadScoBdAddr
3381**
3382** Description      This function is read the remote BD Address for a specific
3383**                  SCO connection,
3384**
3385** Returns          pointer to BD address or NULL if not known
3386**
3387*******************************************************************************/
3388    BTM_API extern UINT8 *BTM_ReadScoBdAddr (UINT16 sco_inx);
3389
3390
3391/*******************************************************************************
3392**
3393** Function         BTM_ReadScoDiscReason
3394**
3395** Description      This function is returns the reason why an (e)SCO connection
3396**                  has been removed. It contains the value until read, or until
3397**                  another (e)SCO connection has disconnected.
3398**
3399** Returns          HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
3400**
3401*******************************************************************************/
3402    BTM_API extern UINT16 BTM_ReadScoDiscReason (void);
3403
3404
3405/*******************************************************************************
3406**
3407** Function         BTM_SetEScoMode
3408**
3409** Description      This function sets up the negotiated parameters for SCO or
3410**                  eSCO, and sets as the default mode used for calls to
3411**                  BTM_CreateSco.  It can be called only when there are no
3412**                  active (e)SCO links.
3413**
3414** Returns          BTM_SUCCESS if the successful.
3415**                  BTM_BUSY if there are one or more active (e)SCO links.
3416**
3417*******************************************************************************/
3418    BTM_API extern tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode,
3419                                                tBTM_ESCO_PARAMS *p_parms);
3420
3421/*******************************************************************************
3422**
3423** Function         BTM_SetWBSCodec
3424**
3425** Description      This function sends command to the controller to setup
3426**                  WBS codec for the upcoming eSCO connection.
3427**
3428** Returns          BTM_SUCCESS.
3429**
3430**
3431*******************************************************************************/
3432BTM_API extern tBTM_STATUS BTM_SetWBSCodec (tBTM_SCO_CODEC_TYPE codec_type);
3433
3434/*******************************************************************************
3435**
3436** Function         BTM_RegForEScoEvts
3437**
3438** Description      This function registers a SCO event callback with the
3439**                  specified instance.  It should be used to received
3440**                  connection indication events and change of link parameter
3441**                  events.
3442**
3443** Returns          BTM_SUCCESS if the successful.
3444**                  BTM_ILLEGAL_VALUE if there is an illegal sco_inx
3445**
3446*******************************************************************************/
3447    BTM_API extern tBTM_STATUS BTM_RegForEScoEvts (UINT16 sco_inx,
3448                                                   tBTM_ESCO_CBACK *p_esco_cback);
3449
3450/*******************************************************************************
3451**
3452** Function         BTM_ReadEScoLinkParms
3453**
3454** Description      This function returns the current eSCO link parameters for
3455**                  the specified handle.  This can be called anytime a connection
3456**                  is active, but is typically called after receiving the SCO
3457**                  opened callback.
3458**
3459**                  Note: If called over a 1.1 controller, only the packet types
3460**                        field has meaning.
3461**                  Note: If the upper layer doesn't know the current sco index,
3462**                  BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first parameter to
3463**                  find the first active SCO index
3464**
3465** Returns          BTM_SUCCESS if returned data is valid connection.
3466**                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
3467**                  BTM_MODE_UNSUPPORTED if local controller does not support
3468**                      1.2 specification.
3469**
3470*******************************************************************************/
3471    BTM_API extern tBTM_STATUS BTM_ReadEScoLinkParms (UINT16 sco_inx,
3472                                                      tBTM_ESCO_DATA *p_parms);
3473
3474/*******************************************************************************
3475**
3476** Function         BTM_ChangeEScoLinkParms
3477**
3478** Description      This function requests renegotiation of the parameters on
3479**                  the current eSCO Link.  If any of the changes are accepted
3480**                  by the controllers, the BTM_ESCO_CHG_EVT event is sent in
3481**                  the tBTM_ESCO_CBACK function with the current settings of
3482**                  the link. The callback is registered through the call to
3483**                  BTM_SetEScoMode.
3484**
3485**
3486** Returns          BTM_CMD_STARTED if command is successfully initiated.
3487**                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
3488**                  BTM_NO_RESOURCES - not enough resources to initiate command.
3489**                  BTM_MODE_UNSUPPORTED if local controller does not support
3490**                      1.2 specification.
3491**
3492*******************************************************************************/
3493    BTM_API extern tBTM_STATUS BTM_ChangeEScoLinkParms (UINT16 sco_inx,
3494                                                        tBTM_CHG_ESCO_PARAMS *p_parms);
3495
3496/*******************************************************************************
3497**
3498** Function         BTM_EScoConnRsp
3499**
3500** Description      This function is called upon receipt of an (e)SCO connection
3501**                  request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
3502**                  the request. Parameters used to negotiate eSCO links.
3503**                  If p_parms is NULL, then values set through BTM_SetEScoMode
3504**                  are used.
3505**                  If the link type of the incoming request is SCO, then only
3506**                  the tx_bw, max_latency, content format, and packet_types are
3507**                  valid.  The hci_status parameter should be
3508**                  ([0x0] to accept, [0x0d..0x0f] to reject)
3509**
3510**
3511** Returns          void
3512**
3513*******************************************************************************/
3514    BTM_API extern void BTM_EScoConnRsp (UINT16 sco_inx, UINT8 hci_status,
3515                                         tBTM_ESCO_PARAMS *p_parms);
3516
3517/*******************************************************************************
3518**
3519** Function         BTM_GetNumScoLinks
3520**
3521** Description      This function returns the number of active SCO links.
3522**
3523** Returns          UINT8
3524**
3525*******************************************************************************/
3526    BTM_API extern UINT8 BTM_GetNumScoLinks (void);
3527
3528/*****************************************************************************
3529**  SECURITY MANAGEMENT FUNCTIONS
3530*****************************************************************************/
3531/*******************************************************************************
3532**
3533** Function         BTM_SecRegister
3534**
3535** Description      Application manager calls this function to register for
3536**                  security services.  There can be one and only one application
3537**                  saving link keys.  BTM allows only first registration.
3538**
3539** Returns          TRUE if registered OK, else FALSE
3540**
3541*******************************************************************************/
3542    BTM_API extern BOOLEAN BTM_SecRegister (tBTM_APPL_INFO *p_cb_info);
3543
3544
3545/*******************************************************************************
3546**
3547** Function         BTM_SecRegisterLinkKeyNotificationCallback
3548**
3549** Description      Profiles can register to be notified when a new Link Key
3550**                  is generated per connection.
3551**
3552** Returns          TRUE if registered OK, else FALSE
3553**
3554*******************************************************************************/
3555    BTM_API extern BOOLEAN BTM_SecRegisterLinkKeyNotificationCallback (
3556                                                        tBTM_LINK_KEY_CALLBACK *p_callback);
3557
3558
3559/*******************************************************************************
3560**
3561** Function         BTM_SecAddRmtNameNotifyCallback
3562**
3563** Description      Profiles can register to be notified when name of the
3564**                  remote device is resolved (up to BTM_SEC_MAX_RMT_NAME_CALLBACKS).
3565**
3566** Returns          TRUE if registered OK, else FALSE
3567**
3568*******************************************************************************/
3569    BTM_API extern BOOLEAN BTM_SecAddRmtNameNotifyCallback (
3570                                                               tBTM_RMT_NAME_CALLBACK *p_callback);
3571
3572
3573/*******************************************************************************
3574**
3575** Function         BTM_SecDeleteRmtNameNotifyCallback
3576**
3577** Description      A profile can deregister notification when a new Link Key
3578**                  is generated per connection.
3579**
3580** Returns          TRUE if OK, else FALSE
3581**
3582*******************************************************************************/
3583    BTM_API extern BOOLEAN BTM_SecDeleteRmtNameNotifyCallback (
3584                                                            tBTM_RMT_NAME_CALLBACK *p_callback);
3585
3586
3587/*******************************************************************************
3588**
3589** Function         BTM_SecSetConnectFilterCallback
3590**
3591** Description      Host can register to be asked whenever an HCI connection
3592**                  request is received.  In the registered function host
3593**                  suppose to check connectibility filters.  Yes/No result
3594**                  should be returned synchronously.
3595**
3596** Returns          void
3597**
3598*******************************************************************************/
3599    BTM_API extern void BTM_SecSetConnectFilterCallback (tBTM_FILTER_CB *p_callback);
3600
3601
3602/*******************************************************************************
3603**
3604** Function         BTM_GetSecurityMode
3605**
3606** Description      Get security mode for the device
3607**
3608** Returns          void
3609**
3610*******************************************************************************/
3611    BTM_API extern UINT8 BTM_GetSecurityMode (void);
3612
3613
3614/*******************************************************************************
3615**
3616** Function         BTM_GetSecurityFlags
3617**
3618** Description      Get security flags for the device
3619**
3620** Returns          BOOLEAN TRUE or FALSE is device found
3621**
3622*******************************************************************************/
3623    BTM_API extern BOOLEAN BTM_GetSecurityFlags (BD_ADDR bd_addr, UINT8 * p_sec_flags);
3624
3625/*******************************************************************************
3626**
3627** Function         BTM_GetSecurityFlagsByTransport
3628**
3629** Description      Get security flags for the device on a particular transport
3630**
3631** Parameters      bd_addr: BD address of remote device
3632**                  p_sec_flags : Out parameter to be filled with security flags for the connection
3633**                  transport :  Physical transport of the connection (BR/EDR or LE)
3634**
3635** Returns          BOOLEAN TRUE or FALSE is device found
3636**
3637*******************************************************************************/
3638    BTM_API extern BOOLEAN BTM_GetSecurityFlagsByTransport (BD_ADDR bd_addr,
3639                                UINT8 * p_sec_flags, tBT_TRANSPORT transport);
3640
3641/*******************************************************************************
3642**
3643** Function         BTM_ReadTrustedMask
3644**
3645** Description      Get trusted mask for the device
3646**
3647** Returns          NULL, if the device record is not found.
3648**                  otherwise, the trusted mask
3649**
3650*******************************************************************************/
3651    BTM_API extern UINT32 * BTM_ReadTrustedMask (BD_ADDR bd_addr);
3652
3653
3654/*******************************************************************************
3655**
3656** Function         BTM_SetSecurityMode
3657**
3658** Description      Set security mode for the device
3659**
3660** Returns          void
3661**
3662*******************************************************************************/
3663    BTM_API extern void BTM_SetSecurityMode (UINT8 sec_mode);
3664
3665
3666/*******************************************************************************
3667**
3668** Function         BTM_SetPinType
3669**
3670** Description      Set PIN type for the device.
3671**
3672** Returns          void
3673**
3674*******************************************************************************/
3675    BTM_API extern void BTM_SetPinType (UINT8 pin_type, PIN_CODE pin_code, UINT8 pin_code_len);
3676
3677
3678/*******************************************************************************
3679**
3680** Function         BTM_SetPairableMode
3681**
3682** Description      Enable or disable pairing
3683**
3684** Parameters       allow_pairing - (TRUE or FALSE) whether or not the device
3685**                      allows pairing.
3686**                  connect_only_paired - (TRUE or FALSE) whether or not to
3687**                      only allow paired devices to connect.
3688**
3689** Returns          void
3690**
3691*******************************************************************************/
3692    BTM_API extern void BTM_SetPairableMode (BOOLEAN allow_pairing, BOOLEAN connect_only_paired);
3693
3694/*******************************************************************************
3695**
3696** Function         BTM_SetSecurityLevel
3697**
3698** Description      Register service security level with Security Manager.  Each
3699**                  service must register its requirements regardless of the
3700**                  security level that is used.  This API is called once for originators
3701**                  nad again for acceptors of connections.
3702**
3703** Returns          TRUE if registered OK, else FALSE
3704**
3705*******************************************************************************/
3706    BTM_API extern BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name,
3707                                                 UINT8 service_id, UINT16 sec_level,
3708                                                 UINT16 psm, UINT32 mx_proto_id,
3709                                                 UINT32 mx_chan_id);
3710
3711/*******************************************************************************
3712**
3713** Function         BTM_SetUCDSecurityLevel
3714**
3715** Description      Register UCD service security level with Security Manager.  Each
3716**                  service must register its requirements regardless of the
3717**                  security level that is used.  This API is called once for originators
3718**                  and again for acceptors of connections.
3719**
3720** Returns          TRUE if registered OK, else FALSE
3721**
3722*******************************************************************************/
3723    BTM_API extern BOOLEAN BTM_SetUCDSecurityLevel (BOOLEAN is_originator, char *p_name,
3724                                                          UINT8 service_id, UINT16 sec_level,
3725                                                          UINT16 psm, UINT32 mx_proto_id,
3726                                                          UINT32 mx_chan_id);
3727
3728/*******************************************************************************
3729**
3730** Function         BTM_SetOutService
3731**
3732** Description      This function is called to set the service for
3733**                  outgoing connection.
3734**
3735** Returns          void
3736**
3737*******************************************************************************/
3738    BTM_API extern void BTM_SetOutService(BD_ADDR bd_addr, UINT8 service_id, UINT32 mx_chan_id);
3739
3740/*******************************************************************************
3741**
3742** Function         BTM_SecClrService
3743**
3744** Description      Removes specified service record(s) from the security database.
3745**                  All service records with the specified name are removed.
3746**                  Typically used only by devices with limited RAM so that it can
3747**                  reuse an old security service record.
3748**                          records (except SDP).
3749**
3750** Returns          Number of records that were freed.
3751**
3752*******************************************************************************/
3753    BTM_API extern UINT8 BTM_SecClrService (UINT8 service_id);
3754
3755/*******************************************************************************
3756**
3757** Function         BTM_SecClrUCDService
3758**
3759** Description
3760**
3761** Parameters       Service ID - Id of the service to remove. ('0' removes all service
3762**                          records.
3763**
3764** Returns          Number of records that were freed.
3765**
3766*******************************************************************************/
3767    BTM_API extern UINT8 BTM_SecClrUCDService (UINT8 service_id);
3768
3769/*******************************************************************************
3770**
3771** Function         BTM_SecAddDevice
3772**
3773** Description      Add/modify device.  This function will be normally called
3774**                  during host startup to restore all required information
3775**                  stored in the NVRAM.
3776**                  dev_class, bd_name, link_key, and features are NULL if unknown
3777**
3778** Returns          TRUE if added OK, else FALSE
3779**
3780*******************************************************************************/
3781    BTM_API extern BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class,
3782                                             BD_NAME bd_name, UINT8 *features,
3783                                             UINT32 trusted_mask[], LINK_KEY link_key,
3784                                             UINT8 key_type, tBTM_IO_CAP io_cap);
3785
3786
3787/*******************************************************************************
3788**
3789** Function         BTM_SecDeleteDevice
3790**
3791** Description      Free resources associated with the device.
3792**
3793** Returns          TRUE if rmoved OK, FALSE if not found
3794**
3795*******************************************************************************/
3796    BTM_API extern BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr);
3797
3798
3799/*******************************************************************************
3800**
3801** Function         BTM_SecUseMasterLinkKey
3802**
3803** Description      This function is called to tell master of the piconet to
3804**                  switch to master link key
3805**
3806** Returns          BTM_SUCCESS if command is successully initiated
3807**
3808*******************************************************************************/
3809    BTM_API extern tBTM_STATUS BTM_SecUseMasterLinkKey (BOOLEAN use_master_key);
3810
3811
3812/*******************************************************************************
3813**
3814** Function         BTM_SetMasterKeyCompCback
3815**
3816** Description      This function is called to register for the master key complete
3817**                  status event.
3818**
3819** Parameters:      mkey_cback - callback registered with the security manager
3820**
3821** Returns          void
3822**
3823*******************************************************************************/
3824    BTM_API extern void BTM_SetMasterKeyCompCback(tBTM_MKEY_CALLBACK *mkey_cback );
3825
3826
3827/*******************************************************************************
3828**
3829** Function         BTM_SecGetDeviceLinkKey
3830**
3831** Description      This function is called to obtain link key for the device
3832**                  it returns BTM_SUCCESS if link key is available, or
3833**                  BTM_UNKNOWN_ADDR if Security Manager does not know about
3834**                  the device or device record does not contain link key info
3835**
3836** Returns          BTM_SUCCESS if successful, otherwise error code
3837**
3838*******************************************************************************/
3839    BTM_API extern tBTM_STATUS BTM_SecGetDeviceLinkKey (BD_ADDR bd_addr,
3840                                                        LINK_KEY link_key);
3841
3842
3843/*******************************************************************************
3844**
3845** Function         BTM_PINCodeReply
3846**
3847** Description      This function is called after Security Manager submitted
3848**                  PIN code request to the UI.
3849**
3850** Parameters:      bd_addr      - Address of the device for which PIN was requested
3851**                  res          - result of the operation BTM_SUCCESS if success
3852**                  pin_len      - length in bytes of the PIN Code
3853**                  p_pin        - pointer to array with the PIN Code
3854**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3855**
3856** Returns          void
3857**
3858*******************************************************************************/
3859    BTM_API extern void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len,
3860                                          UINT8 *p_pin, UINT32 trusted_mask[]);
3861
3862
3863/*******************************************************************************
3864**
3865** Function         BTM_DeviceAuthorized
3866**
3867** Description      This function is called after Security Manager submitted
3868**                  authorization request to the UI.
3869**
3870** Parameters:      bd_addr     - Address of the device for which PIN was requested
3871**                  res         - result of the operation BTM_SUCCESS if success
3872**
3873** Returns          void
3874**
3875*******************************************************************************/
3876    BTM_API extern void BTM_DeviceAuthorized (BD_ADDR bd_addr, UINT8 res,
3877                                              UINT32 trusted_mask[]);
3878
3879
3880/*******************************************************************************
3881**
3882** Function         BTM_SecBond
3883**
3884** Description      This function is called to perform bonding with peer device.
3885**
3886** Parameters:      bd_addr      - Address of the device to bond
3887**                  pin_len      - length in bytes of the PIN Code
3888**                  p_pin        - pointer to array with the PIN Code
3889**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3890
3891** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3892**
3893*******************************************************************************/
3894    BTM_API extern tBTM_STATUS BTM_SecBond (BD_ADDR bd_addr,
3895                                            UINT8 pin_len, UINT8 *p_pin,
3896                                            UINT32 trusted_mask[]);
3897
3898/*******************************************************************************
3899**
3900** Function         BTM_SecBondByTransport
3901**
3902** Description      This function is called to perform bonding by designated transport
3903**
3904** Parameters:      bd_addr      - Address of the device to bond
3905**                  pin_len      - length in bytes of the PIN Code
3906**                  p_pin        - pointer to array with the PIN Code
3907**                  trusted_mask - bitwise OR of trusted services (array of UINT32)
3908**                  transport :  Physical transport to use for bonding (BR/EDR or LE)
3909**
3910** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3911**
3912*******************************************************************************/
3913    BTM_API extern tBTM_STATUS BTM_SecBondByTransport (BD_ADDR bd_addr,
3914                                            tBT_TRANSPORT transport,
3915                                            UINT8 pin_len, UINT8 *p_pin,
3916                                            UINT32 trusted_mask[]);
3917
3918/*******************************************************************************
3919**
3920** Function         BTM_SecBondCancel
3921**
3922** Description      This function is called to cancel ongoing bonding process
3923**                  with peer device.
3924**
3925** Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
3926**
3927*******************************************************************************/
3928    BTM_API extern tBTM_STATUS BTM_SecBondCancel (BD_ADDR bd_addr);
3929
3930/*******************************************************************************
3931**
3932** Function         BTM_SetEncryption
3933**
3934** Description      This function is called to ensure that connection is
3935**                  encrypted.  Should be called only on an open connection.
3936**                  Typically only needed for connections that first want to
3937**                  bring up unencrypted links, then later encrypt them.
3938**
3939** Parameters:      bd_addr       - Address of the peer device
3940**                  p_callback    - Pointer to callback function called if
3941**                                  this function returns PENDING after required
3942**                                  procedures are completed.  Can be set to NULL
3943**                                  if status is not desired.
3944**                  p_ref_data    - pointer to any data the caller wishes to receive
3945**                                  in the callback function upon completion.
3946*                                   can be set to NULL if not used.
3947**
3948** Returns          BTM_SUCCESS   - already encrypted
3949**                  BTM_PENDING   - command will be returned in the callback
3950**                  BTM_WRONG_MODE- connection not up.
3951**                  BTM_BUSY      - security procedures are currently active
3952**                  BTM_MODE_UNSUPPORTED - if security manager not linked in.
3953**
3954*******************************************************************************/
3955    BTM_API extern tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport,
3956                                                  tBTM_SEC_CBACK *p_callback, void *p_ref_data);
3957
3958/*******************************************************************************
3959**
3960** Function         BTM_ConfirmReqReply
3961**
3962** Description      This function is called to confirm the numeric value for
3963**                  Simple Pairing in response to BTM_SP_CFM_REQ_EVT
3964**
3965** Parameters:      res           - result of the operation BTM_SUCCESS if success
3966**                  bd_addr       - Address of the peer device
3967**
3968*******************************************************************************/
3969    BTM_API extern void BTM_ConfirmReqReply(tBTM_STATUS res, BD_ADDR bd_addr);
3970
3971/*******************************************************************************
3972**
3973** Function         BTM_PasskeyReqReply
3974**
3975** Description      This function is called to provide the passkey for
3976**                  Simple Pairing in response to BTM_SP_KEY_REQ_EVT
3977**
3978** Parameters:      res           - result of the operation BTM_SUCCESS if success
3979**                  bd_addr       - Address of the peer device
3980**                  passkey       - numeric value in the range of 0 - 999999(0xF423F).
3981**
3982*******************************************************************************/
3983    BTM_API extern void BTM_PasskeyReqReply(tBTM_STATUS res, BD_ADDR bd_addr, UINT32 passkey);
3984
3985/*******************************************************************************
3986**
3987** Function         BTM_SendKeypressNotif
3988**
3989** Description      This function is used during the passkey entry model
3990**                  by a device with KeyboardOnly IO capabilities
3991**                  (very likely to be a HID Device).
3992**                  It is called by a HID Device to inform the remote device when
3993**                  a key has been entered or erased.
3994**
3995** Parameters:      bd_addr - Address of the peer device
3996**                  type - notification type
3997**
3998*******************************************************************************/
3999    BTM_API extern void BTM_SendKeypressNotif(BD_ADDR bd_addr, tBTM_SP_KEY_TYPE type);
4000
4001/*******************************************************************************
4002**
4003** Function         BTM_IoCapRsp
4004**
4005** Description      This function is called in response to BTM_SP_IO_REQ_EVT
4006**                  When the event data io_req.oob_data is set to BTM_OOB_UNKNOWN
4007**                  by the tBTM_SP_CALLBACK implementation, this function is
4008**                  called to provide the actual response
4009**
4010** Parameters:      bd_addr - Address of the peer device
4011**                  io_cap  - The IO capability of local device.
4012**                  oob     - BTM_OOB_NONE or BTM_OOB_PRESENT.
4013**                  auth_req- MITM protection required or not.
4014**
4015*******************************************************************************/
4016    BTM_API extern void BTM_IoCapRsp(BD_ADDR bd_addr, tBTM_IO_CAP io_cap,
4017                                     tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
4018
4019/*******************************************************************************
4020**
4021** Function         BTM_ReadLocalOobData
4022**
4023** Description      This function is called to read the local OOB data from
4024**                  LM
4025**
4026*******************************************************************************/
4027    BTM_API extern tBTM_STATUS BTM_ReadLocalOobData(void);
4028
4029/*******************************************************************************
4030**
4031** Function         BTM_RemoteOobDataReply
4032**
4033** Description      This function is called to provide the remote OOB data for
4034**                  Simple Pairing in response to BTM_SP_RMT_OOB_EVT
4035**
4036** Parameters:      bd_addr     - Address of the peer device
4037**                  c           - simple pairing Hash C.
4038**                  r           - simple pairing Randomizer  C.
4039**
4040*******************************************************************************/
4041    BTM_API extern void BTM_RemoteOobDataReply(tBTM_STATUS res, BD_ADDR bd_addr,
4042                                                        BT_OCTET16 c, BT_OCTET16 r);
4043
4044/*******************************************************************************
4045**
4046** Function         BTM_BuildOobData
4047**
4048** Description      This function is called to build the OOB data payload to
4049**                  be sent over OOB (non-Bluetooth) link
4050**
4051** Parameters:      p_data  - the location for OOB data
4052**                  max_len - p_data size.
4053**                  c       - simple pairing Hash C.
4054**                  r       - simple pairing Randomizer  C.
4055**                  name_len- 0, local device name would not be included.
4056**                            otherwise, the local device name is included for
4057**                            up to this specified length
4058**
4059** Returns          Number of bytes in p_data.
4060**
4061*******************************************************************************/
4062    BTM_API extern UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
4063                                           BT_OCTET16 r, UINT8 name_len);
4064
4065/*******************************************************************************
4066**
4067** Function         BTM_ReadOobData
4068**
4069** Description      This function is called to parse the OOB data payload
4070**                  received over OOB (non-Bluetooth) link
4071**
4072** Parameters:      p_data  - the location for OOB data
4073**                  eir_tag - The associated EIR tag to read the data.
4074**                  *p_len(output) - the length of the data with the given tag.
4075**
4076** Returns          the beginning of the data with the given tag.
4077**                  NULL, if the tag is not found.
4078**
4079*******************************************************************************/
4080    BTM_API extern UINT8 * BTM_ReadOobData(UINT8 *p_data, UINT8 eir_tag, UINT8 *p_len);
4081
4082/*******************************************************************************
4083**
4084** Function         BTM_SecReadDevName
4085**
4086** Description      Looks for the device name in the security database for the
4087**                  specified BD address.
4088**
4089** Returns          Pointer to the name or NULL
4090**
4091*******************************************************************************/
4092    BTM_API extern char *BTM_SecReadDevName (BD_ADDR bd_addr);
4093
4094
4095/*****************************************************************************
4096**  POWER MANAGEMENT FUNCTIONS
4097*****************************************************************************/
4098/*******************************************************************************
4099**
4100** Function         BTM_PmRegister
4101**
4102** Description      register or deregister with power manager
4103**
4104** Returns          BTM_SUCCESS if successful,
4105**                  BTM_NO_RESOURCES if no room to hold registration
4106**                  BTM_ILLEGAL_VALUE
4107**
4108*******************************************************************************/
4109    BTM_API extern tBTM_STATUS BTM_PmRegister (UINT8 mask, UINT8 *p_pm_id,
4110                                               tBTM_PM_STATUS_CBACK *p_cb);
4111
4112
4113/*******************************************************************************
4114**
4115** Function         BTM_SetPowerMode
4116**
4117** Description      store the mode in control block or
4118**                  alter ACL connection behavior.
4119**
4120** Returns          BTM_SUCCESS if successful,
4121**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
4122**
4123*******************************************************************************/
4124    BTM_API extern tBTM_STATUS BTM_SetPowerMode (UINT8 pm_id, BD_ADDR remote_bda,
4125                                                 tBTM_PM_PWR_MD *p_mode);
4126
4127
4128/*******************************************************************************
4129**
4130** Function         BTM_ReadPowerMode
4131**
4132** Description      This returns the current mode for a specific
4133**                  ACL connection.
4134**
4135** Input Param      remote_bda - device address of desired ACL connection
4136**
4137** Output Param     p_mode - address where the current mode is copied into.
4138**                          BTM_ACL_MODE_NORMAL
4139**                          BTM_ACL_MODE_HOLD
4140**                          BTM_ACL_MODE_SNIFF
4141**                          BTM_ACL_MODE_PARK
4142**                          (valid only if return code is BTM_SUCCESS)
4143**
4144** Returns          BTM_SUCCESS if successful,
4145**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
4146**
4147*******************************************************************************/
4148    BTM_API extern tBTM_STATUS BTM_ReadPowerMode (BD_ADDR remote_bda,
4149                                                  tBTM_PM_MODE *p_mode);
4150
4151/*******************************************************************************
4152**
4153** Function         BTM_SetSsrParams
4154**
4155** Description      This sends the given SSR parameters for the given ACL
4156**                  connection if it is in ACTIVE mode.
4157**
4158** Input Param      remote_bda - device address of desired ACL connection
4159**                  max_lat    - maximum latency (in 0.625ms)(0-0xFFFE)
4160**                  min_rmt_to - minimum remote timeout
4161**                  min_loc_to - minimum local timeout
4162**
4163**
4164** Returns          BTM_SUCCESS if the HCI command is issued successful,
4165**                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
4166**                  BTM_CMD_STORED if the command is stored
4167**
4168*******************************************************************************/
4169    BTM_API extern tBTM_STATUS BTM_SetSsrParams (BD_ADDR remote_bda, UINT16 max_lat,
4170                                                 UINT16 min_rmt_to, UINT16 min_loc_to);
4171
4172/*******************************************************************************
4173**
4174** Function         BTM_IsPowerManagerOn
4175**
4176** Description      This function is called to check if power manager is included.
4177**                  in the BTE version.
4178**
4179** Returns          TRUE if power manager is compiled in, otherwise FALSE.
4180**
4181*******************************************************************************/
4182    BTM_API extern BOOLEAN BTM_IsPowerManagerOn (void);
4183
4184
4185/*******************************************************************************
4186**
4187** Function         BTM_GetHCIConnHandle
4188**
4189** Description      This function is called to get the handle for an ACL connection
4190**                  to a specific remote BD Address.
4191**
4192** Returns          the handle of the connection, or 0xFFFF if none.
4193**
4194*******************************************************************************/
4195    BTM_API extern UINT16 BTM_GetHCIConnHandle (BD_ADDR remote_bda, tBT_TRANSPORT transport);
4196
4197
4198/*******************************************************************************
4199**
4200** Function         BTM_ReadStoredLinkKey
4201**
4202** Description      This function is called to obtain link key for the specified
4203**                  device from the NVRAM storage attached to the Bluetooth
4204**                  controller.
4205**
4206** Parameters:      bd_addr      - Address of the device
4207**                  p_cb         - Call back function to be called to return
4208**                                 the results
4209**
4210*******************************************************************************/
4211    BTM_API extern tBTM_STATUS BTM_ReadStoredLinkKey (BD_ADDR bd_addr,  tBTM_CMPL_CB *p_cb);
4212
4213
4214/*******************************************************************************
4215**
4216** Function         BTM_WriteStoredLinkKey
4217**
4218** Description      This function is called to write link keys for the specified
4219**                  device addresses to the NVRAM storage attached to the Bluetooth
4220**                  controller.
4221**
4222** Parameters:      num_keys     - Number of link keys
4223**                  bd_addr      - Addresses of the devices
4224**                  link_key     - Link Keys to be stored
4225**                  p_cb         - Call back function to be called to return
4226**                                 the results
4227**
4228*******************************************************************************/
4229    BTM_API extern tBTM_STATUS BTM_WriteStoredLinkKey (UINT8 num_keys,
4230                                                       BD_ADDR *bd_addr,
4231                                                       LINK_KEY *link_key,
4232                                                       tBTM_CMPL_CB *p_cb);
4233
4234
4235/*******************************************************************************
4236**
4237** Function         BTM_DeleteStoredLinkKey
4238**
4239** Description      This function is called to delete link key for the specified
4240**                  device addresses from the NVRAM storage attached to the Bluetooth
4241**                  controller.
4242**
4243** Parameters:      bd_addr      - Addresses of the devices
4244**                  p_cb         - Call back function to be called to return
4245**                                 the results
4246**
4247*******************************************************************************/
4248    BTM_API extern tBTM_STATUS BTM_DeleteStoredLinkKey(BD_ADDR bd_addr, tBTM_CMPL_CB *p_cb);
4249
4250/*******************************************************************************
4251**
4252** Function         BTM_WriteEIR
4253**
4254** Description      This function is called to write EIR data to controller.
4255**
4256** Parameters       p_buff - allocated HCI command buffer including extended
4257**                           inquriry response
4258**
4259** Returns          BTM_SUCCESS  - if successful
4260**                  BTM_MODE_UNSUPPORTED - if local device cannot support it
4261**
4262*******************************************************************************/
4263    BTM_API extern tBTM_STATUS BTM_WriteEIR( BT_HDR * p_buff );
4264
4265/*******************************************************************************
4266**
4267** Function         BTM_CheckEirData
4268**
4269** Description      This function is called to get EIR data from significant part.
4270**
4271** Parameters       p_eir - pointer of EIR significant part
4272**                  type   - finding EIR data type
4273**                  p_length - return the length of EIR data
4274**
4275** Returns          pointer of EIR data
4276**
4277*******************************************************************************/
4278    BTM_API extern UINT8 *BTM_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length );
4279
4280/*******************************************************************************
4281**
4282** Function         BTM_HasEirService
4283**
4284** Description      This function is called to know if UUID in bit map of UUID.
4285**
4286** Parameters       p_eir_uuid - bit map of UUID list
4287**                  uuid16 - UUID 16-bit
4288**
4289** Returns          TRUE - if found
4290**                  FALSE - if not found
4291**
4292*******************************************************************************/
4293    BTM_API extern BOOLEAN BTM_HasEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
4294
4295/*******************************************************************************
4296**
4297** Function         BTM_HasInquiryEirService
4298**
4299** Description      This function is called to know if UUID in bit map of UUID list.
4300**
4301** Parameters       p_results - inquiry results
4302**                  uuid16 - UUID 16-bit
4303**
4304** Returns          BTM_EIR_FOUND - if found
4305**                  BTM_EIR_NOT_FOUND - if not found and it is complete list
4306**                  BTM_EIR_UNKNOWN - if not found and it is not complete list
4307**
4308*******************************************************************************/
4309    BTM_API extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( tBTM_INQ_RESULTS *p_results,
4310                                                                    UINT16 uuid16 );
4311
4312/*******************************************************************************
4313**
4314** Function         BTM_AddEirService
4315**
4316** Description      This function is called to add a service in bit map of UUID list.
4317**
4318** Parameters       p_eir_uuid - bit mask of UUID list for EIR
4319**                  uuid16 - UUID 16-bit
4320**
4321** Returns          None
4322**
4323*******************************************************************************/
4324    BTM_API extern void BTM_AddEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
4325
4326/*******************************************************************************
4327**
4328** Function         BTM_RemoveEirService
4329**
4330** Description      This function is called to remove a service in bit map of UUID list.
4331**
4332** Parameters       p_eir_uuid - bit mask of UUID list for EIR
4333**                  uuid16 - UUID 16-bit
4334**
4335** Returns          None
4336**
4337*******************************************************************************/
4338    BTM_API extern void BTM_RemoveEirService( UINT32 *p_eir_uuid, UINT16 uuid16 );
4339
4340/*******************************************************************************
4341**
4342** Function         BTM_GetEirSupportedServices
4343**
4344** Description      This function is called to get UUID list from bit map of UUID list.
4345**
4346** Parameters       p_eir_uuid - bit mask of UUID list for EIR
4347**                  p - reference of current pointer of EIR
4348**                  max_num_uuid16 - max number of UUID can be written in EIR
4349**                  num_uuid16 - number of UUID have been written in EIR
4350**
4351** Returns          BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
4352**                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
4353**
4354*******************************************************************************/
4355    BTM_API extern UINT8 BTM_GetEirSupportedServices( UINT32 *p_eir_uuid,    UINT8 **p,
4356                                                      UINT8  max_num_uuid16, UINT8 *p_num_uuid16);
4357
4358/*******************************************************************************
4359**
4360** Function         BTM_GetEirUuidList
4361**
4362** Description      This function parses EIR and returns UUID list.
4363**
4364** Parameters       p_eir - EIR
4365**                  uuid_size - LEN_UUID_16, LEN_UUID_32, LEN_UUID_128
4366**                  p_num_uuid - return number of UUID in found list
4367**                  p_uuid_list - return UUID 16-bit list
4368**                  max_num_uuid - maximum number of UUID to be returned
4369**
4370** Returns          0 - if not found
4371**                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE
4372**                  BTM_EIR_MORE_16BITS_UUID_TYPE
4373**                  BTM_EIR_COMPLETE_32BITS_UUID_TYPE
4374**                  BTM_EIR_MORE_32BITS_UUID_TYPE
4375**                  BTM_EIR_COMPLETE_128BITS_UUID_TYPE
4376**                  BTM_EIR_MORE_128BITS_UUID_TYPE
4377**
4378*******************************************************************************/
4379    BTM_API extern UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid,
4380                                             UINT8 *p_uuid_list, UINT8 max_num_uuid);
4381
4382/*****************************************************************************
4383**  SCO OVER HCI
4384*****************************************************************************/
4385/*******************************************************************************
4386**
4387** Function         BTM_ConfigScoPath
4388**
4389** Description      This function enable/disable SCO over HCI and registers SCO
4390**                  data callback if SCO over HCI is enabled.
4391**
4392** Parameter        path: SCO or HCI
4393**                  p_sco_data_cb: callback function or SCO data if path is set
4394**                                 to transport.
4395**                  p_pcm_param: pointer to the PCM interface parameter. If a NULL
4396**                               pointer is used, PCM parameter maintained in
4397**                               the control block will be used; otherwise update
4398**                               control block value.
4399**                  err_data_rpt: Lisbon feature to enable the erronous data report
4400**                                or not.
4401**
4402** Returns          BTM_SUCCESS if the successful.
4403**                  BTM_NO_RESOURCES: no rsource to start the command.
4404**                  BTM_ILLEGAL_VALUE: invalid callback function pointer.
4405**                  BTM_CMD_STARTED :Command sent. Waiting for command cmpl event.
4406**
4407**
4408*******************************************************************************/
4409    BTM_API extern tBTM_STATUS BTM_ConfigScoPath (tBTM_SCO_ROUTE_TYPE path,
4410                                                  tBTM_SCO_DATA_CB *p_sco_data_cb,
4411                                                  tBTM_SCO_PCM_PARAM *p_pcm_param,
4412                                                  BOOLEAN err_data_rpt);
4413
4414/*******************************************************************************
4415**
4416** Function         BTM_WriteScoData
4417**
4418** Description      This function write SCO data to a specified instance. The data
4419**                  to be written p_buf needs to carry an offset of
4420**                  HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
4421**                  exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is set
4422**                  to 60 and is configurable. Data longer than the maximum bytes
4423**                  will be truncated.
4424**
4425** Returns          BTM_SUCCESS: data write is successful
4426**                  BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
4427**                  BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO packet
4428**                                      size.
4429**                  BTM_NO_RESOURCES: no resources.
4430**                  BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is not
4431**                                    routed via HCI.
4432**
4433**
4434*******************************************************************************/
4435    BTM_API extern tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf);
4436
4437/*******************************************************************************
4438**
4439** Function         BTM_SetARCMode
4440**
4441** Description      Send Audio Routing Control command.
4442**
4443** Returns          void
4444**
4445*******************************************************************************/
4446BTM_API extern void BTM_SetARCMode (UINT8 iface, UINT8 arc_mode, tBTM_VSC_CMPL_CB *p_arc_cb);
4447
4448
4449/*******************************************************************************
4450**
4451** Function         BTM_PCM2Setup_Write
4452**
4453** Description      Send PCM2_Setup write command.
4454**
4455** Returns          void
4456**
4457*******************************************************************************/
4458BTM_API extern void BTM_PCM2Setup_Write (BOOLEAN clk_master, tBTM_VSC_CMPL_CB *p_arc_cb);
4459
4460
4461/*******************************************************************************
4462**
4463** Function         BTM_PM_ReadControllerState
4464**
4465** Description      This function is called to obtain the controller state
4466**
4467** Returns          Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and BTM_CONTRL_IDLE)
4468**
4469*******************************************************************************/
4470BTM_API extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
4471
4472#ifdef __cplusplus
4473}
4474#endif
4475
4476#endif /* BTM_API_H */
4477