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