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