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