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