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