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