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