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