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_BLE_API_H 26 #define BTM_BLE_API_H 27 28 #include "btm_api.h" 29 #include "bt_common.h" 30 #include "osi/include/alarm.h" 31 #include <hardware/bt_common_types.h> 32 33 #define CHNL_MAP_LEN 5 34 typedef UINT8 tBTM_BLE_CHNL_MAP[CHNL_MAP_LEN]; 35 36 /* 0x00-0x04 only used for set advertising parameter command */ 37 #define BTM_BLE_CONNECT_EVT 0x00 /* 0x00-0x04 only used for set advertising 38 parameter command */ 39 #define BTM_BLE_CONNECT_DIR_EVT 0x01 /* Connectable directed advertising */ 40 #define BTM_BLE_DISCOVER_EVT 0x02 /* Scannable undirected advertising */ 41 #define BTM_BLE_NON_CONNECT_EVT 0x03 /* Non connectable undirected advertising */ 42 #define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04 /* Connectable low duty 43 cycle directed advertising */ 44 /* 0x00 - 0x05 can be received on adv event type */ 45 #define BTM_BLE_SCAN_RSP_EVT 0x04 46 #define BTM_BLE_SCAN_REQ_EVT 0x05 47 #define BTM_BLE_UNKNOWN_EVT 0xff 48 49 #define BTM_BLE_UNKNOWN_EVT 0xff 50 51 typedef UINT8 tBTM_BLE_EVT; 52 typedef UINT8 tBTM_BLE_CONN_MODE; 53 54 typedef UINT32 tBTM_BLE_REF_VALUE; 55 56 #define BTM_BLE_SCAN_MODE_PASS 0 57 #define BTM_BLE_SCAN_MODE_ACTI 1 58 #define BTM_BLE_SCAN_MODE_NONE 0xff 59 typedef UINT8 tBLE_SCAN_MODE; 60 61 #define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0 62 #define BTM_BLE_BATCH_SCAN_MODE_PASS 1 63 #define BTM_BLE_BATCH_SCAN_MODE_ACTI 2 64 #define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3 65 66 typedef UINT8 tBTM_BLE_BATCH_SCAN_MODE; 67 68 /* advertising channel map */ 69 #define BTM_BLE_ADV_CHNL_37 (0x01 << 0) 70 #define BTM_BLE_ADV_CHNL_38 (0x01 << 1) 71 #define BTM_BLE_ADV_CHNL_39 (0x01 << 2) 72 typedef UINT8 tBTM_BLE_ADV_CHNL_MAP; 73 74 /*d efault advertising channel map */ 75 #ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP 76 #define BTM_BLE_DEFAULT_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37| BTM_BLE_ADV_CHNL_38| BTM_BLE_ADV_CHNL_39) 77 #endif 78 79 /* advertising filter policy */ 80 #define AP_SCAN_CONN_ALL 0x00 /* default */ 81 #define AP_SCAN_WL_CONN_ALL 0x01 82 #define AP_SCAN_ALL_CONN_WL 0x02 83 #define AP_SCAN_CONN_WL 0x03 84 #define AP_SCAN_CONN_POLICY_MAX 0x04 85 typedef UINT8 tBTM_BLE_AFP; 86 87 /* default advertising filter policy */ 88 #ifndef BTM_BLE_DEFAULT_AFP 89 #define BTM_BLE_DEFAULT_AFP AP_SCAN_CONN_ALL 90 #endif 91 92 /* scanning filter policy */ 93 #define SP_ADV_ALL 0x00 /* 0: accept adv packet from all, directed adv pkt not directed */ 94 /* to local device is ignored */ 95 #define SP_ADV_WL 0x01 /* 1: accept adv packet from device in white list, directed adv */ 96 /* packet not directed to local device is ignored */ 97 #define SP_ADV_ALL_RPA_DIR_ADV 0x02 /* 2: accept adv packet from all, directed adv pkt */ 98 /* not directed to me is ignored except direct adv with RPA */ 99 #define SP_ADV_WL_RPA_DIR_ADV 0x03 /* 3: accept adv packet from device in white list, directed */ 100 /* adv pkt not directed to me is ignored except direct adv */ 101 /* with RPA */ 102 typedef UINT8 tBTM_BLE_SFP; 103 104 #ifndef BTM_BLE_DEFAULT_SFP 105 #define BTM_BLE_DEFAULT_SFP SP_ADV_ALL 106 #endif 107 108 /* adv parameter boundary values */ 109 #define BTM_BLE_ADV_INT_MIN 0x0020 110 #define BTM_BLE_ADV_INT_MAX 0x4000 111 112 /* Full scan boundary values */ 113 #define BTM_BLE_ADV_SCAN_FULL_MIN 0x00 114 #define BTM_BLE_ADV_SCAN_FULL_MAX 0x64 115 116 /* Partial scan boundary values */ 117 #define BTM_BLE_ADV_SCAN_TRUNC_MIN BTM_BLE_ADV_SCAN_FULL_MIN 118 #define BTM_BLE_ADV_SCAN_TRUNC_MAX BTM_BLE_ADV_SCAN_FULL_MAX 119 120 /* Threshold values */ 121 #define BTM_BLE_ADV_SCAN_THR_MIN BTM_BLE_ADV_SCAN_FULL_MIN 122 #define BTM_BLE_ADV_SCAN_THR_MAX BTM_BLE_ADV_SCAN_FULL_MAX 123 124 /* connection parameter boundary values */ 125 #define BTM_BLE_SCAN_INT_MIN 0x0004 126 #define BTM_BLE_SCAN_INT_MAX 0x4000 127 #define BTM_BLE_SCAN_WIN_MIN 0x0004 128 #define BTM_BLE_SCAN_WIN_MAX 0x4000 129 #define BTM_BLE_EXT_SCAN_INT_MAX 0x00FFFFFF 130 #define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF 131 #define BTM_BLE_CONN_INT_MIN 0x0006 132 #define BTM_BLE_CONN_INT_MAX 0x0C80 133 #define BTM_BLE_CONN_LATENCY_MAX 500 134 #define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A 135 #define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80 136 #define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ 137 #define BTM_BLE_SCAN_PARAM_UNDEF 0xffffffff 138 139 /* default connection parameters if not configured, use GAP recommend value for auto/selective connection */ 140 /* default scan interval */ 141 #ifndef BTM_BLE_SCAN_FAST_INT 142 #define BTM_BLE_SCAN_FAST_INT 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */ 143 #endif 144 /* default scan window for background connection, applicable for auto connection or selective conenction */ 145 #ifndef BTM_BLE_SCAN_FAST_WIN 146 #define BTM_BLE_SCAN_FAST_WIN 48 /* 30 ms = 48 *0.625 */ 147 #endif 148 149 /* default scan paramter used in reduced power cycle (background scanning) */ 150 #ifndef BTM_BLE_SCAN_SLOW_INT_1 151 #define BTM_BLE_SCAN_SLOW_INT_1 2048 /* 1.28 s = 2048 *0.625 */ 152 #endif 153 #ifndef BTM_BLE_SCAN_SLOW_WIN_1 154 #define BTM_BLE_SCAN_SLOW_WIN_1 48 /* 30 ms = 48 *0.625 */ 155 #endif 156 157 /* default scan paramter used in reduced power cycle (background scanning) */ 158 #ifndef BTM_BLE_SCAN_SLOW_INT_2 159 #define BTM_BLE_SCAN_SLOW_INT_2 4096 /* 2.56 s = 4096 *0.625 */ 160 #endif 161 #ifndef BTM_BLE_SCAN_SLOW_WIN_2 162 #define BTM_BLE_SCAN_SLOW_WIN_2 36 /* 22.5 ms = 36 *0.625 */ 163 #endif 164 165 /* default connection interval min */ 166 #ifndef BTM_BLE_CONN_INT_MIN_DEF 167 #define BTM_BLE_CONN_INT_MIN_DEF 24 /* recommended min: 30ms = 24 * 1.25 */ 168 #endif 169 170 /* default connectino interval max */ 171 #ifndef BTM_BLE_CONN_INT_MAX_DEF 172 #define BTM_BLE_CONN_INT_MAX_DEF 40 /* recommended max: 50 ms = 56 * 1.25 */ 173 #endif 174 175 /* default slave latency */ 176 #ifndef BTM_BLE_CONN_SLAVE_LATENCY_DEF 177 #define BTM_BLE_CONN_SLAVE_LATENCY_DEF 0 /* 0 */ 178 #endif 179 180 /* default supervision timeout */ 181 #ifndef BTM_BLE_CONN_TIMEOUT_DEF 182 #define BTM_BLE_CONN_TIMEOUT_DEF 2000 183 #endif 184 185 /* minimum supervision timeout */ 186 #ifndef BTM_BLE_CONN_TIMEOUT_MIN_DEF 187 #define BTM_BLE_CONN_TIMEOUT_MIN_DEF 100 188 #endif 189 190 /* minimum acceptable connection interval */ 191 #ifndef BTM_BLE_CONN_INT_MIN_LIMIT 192 #define BTM_BLE_CONN_INT_MIN_LIMIT 0x0009 193 #endif 194 195 #define BTM_BLE_DIR_CONN_FALLBACK_UNDIR 1 196 #define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV 2 197 198 #ifndef BTM_BLE_DIR_CONN_FALLBACK 199 #define BTM_BLE_DIR_CONN_FALLBACK BTM_BLE_DIR_CONN_FALLBACK_UNDIR 200 #endif 201 202 #define BTM_CMAC_TLEN_SIZE 8 /* 64 bits */ 203 #define BTM_BLE_AUTH_SIGN_LEN 12 /* BLE data signature length 8 Bytes + 4 bytes counter*/ 204 typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */ 205 206 #ifndef BTM_BLE_HOST_SUPPORT 207 #define BTM_BLE_HOST_SUPPORT 0x01 208 #endif 209 210 #ifndef BTM_BLE_SIMULTANEOUS_HOST 211 #define BTM_BLE_SIMULTANEOUS_HOST 0x01 212 #endif 213 214 /* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */ 215 #define BTM_BLE_APPEARANCE_UKNOWN 0x0000 216 #define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040 217 #define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080 218 #define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0 219 #define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1 220 #define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100 221 #define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140 222 #define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180 223 #define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0 224 #define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200 225 #define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240 226 #define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280 227 #define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0 228 #define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300 229 #define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301 230 #define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340 231 #define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341 232 #define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380 233 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381 234 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382 235 #define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0 236 #define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1 237 #define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2 238 #define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3 239 #define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4 240 #define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5 241 #define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6 242 #define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7 243 #define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8 244 #define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400 245 #define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440 246 #define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441 247 #define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442 248 #define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443 249 #define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480 250 #define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481 251 #define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482 252 #define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 253 #define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484 254 #define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 255 #define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 256 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 257 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 258 #define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80 259 #define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440 260 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441 261 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442 262 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443 263 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444 264 265 266 /* Structure returned with Rand/Encrypt complete callback */ 267 typedef struct 268 { 269 UINT8 status; 270 UINT8 param_len; 271 UINT16 opcode; 272 UINT8 param_buf[BT_OCTET16_LEN]; 273 } tBTM_RAND_ENC; 274 275 /* General callback function for notifying an application that a synchronous 276 ** BTM function is complete. The pointer contains the address of any returned data. 277 */ 278 typedef void (tBTM_RAND_ENC_CB) (tBTM_RAND_ENC *p1); 279 280 #define BTM_BLE_FILTER_TARGET_SCANNER 0x01 281 #define BTM_BLE_FILTER_TARGET_ADVR 0x00 282 283 #define BTM_BLE_POLICY_BLACK_ALL 0x00 /* relevant to both */ 284 #define BTM_BLE_POLICY_ALLOW_SCAN 0x01 /* relevant to advertiser */ 285 #define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */ 286 #define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */ 287 288 /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */ 289 #define BTM_BLE_LIMIT_DISC_FLAG (0x01 << 0) 290 #define BTM_BLE_GEN_DISC_FLAG (0x01 << 1) 291 #define BTM_BLE_BREDR_NOT_SPT (0x01 << 2) 292 /* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */ 293 #define BTM_BLE_DMT_CONTROLLER_SPT (0x01 << 3) 294 #define BTM_BLE_DMT_HOST_SPT (0x01 << 4) 295 #define BTM_BLE_NON_LIMIT_DISC_FLAG (0x00 ) /* lowest bit unset */ 296 #define BTM_BLE_ADV_FLAG_MASK (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG) 297 #define BTM_BLE_LIMIT_DISC_MASK (BTM_BLE_LIMIT_DISC_FLAG ) 298 299 #define BTM_BLE_AD_BIT_DEV_NAME (0x00000001 << 0) 300 #define BTM_BLE_AD_BIT_FLAGS (0x00000001 << 1) 301 #define BTM_BLE_AD_BIT_MANU (0x00000001 << 2) 302 #define BTM_BLE_AD_BIT_TX_PWR (0x00000001 << 3) 303 #define BTM_BLE_AD_BIT_INT_RANGE (0x00000001 << 5) 304 #define BTM_BLE_AD_BIT_SERVICE (0x00000001 << 6) 305 #define BTM_BLE_AD_BIT_SERVICE_SOL (0x00000001 << 7) 306 #define BTM_BLE_AD_BIT_SERVICE_DATA (0x00000001 << 8) 307 #define BTM_BLE_AD_BIT_SIGN_DATA (0x00000001 << 9) 308 #define BTM_BLE_AD_BIT_SERVICE_128SOL (0x00000001 << 10) 309 #define BTM_BLE_AD_BIT_APPEARANCE (0x00000001 << 11) 310 #define BTM_BLE_AD_BIT_PUBLIC_ADDR (0x00000001 << 12) 311 #define BTM_BLE_AD_BIT_RANDOM_ADDR (0x00000001 << 13) 312 #define BTM_BLE_AD_BIT_SERVICE_32 (0x00000001 << 4) 313 #define BTM_BLE_AD_BIT_SERVICE_32SOL (0x00000001 << 14) 314 #define BTM_BLE_AD_BIT_PROPRIETARY (0x00000001 << 15) 315 #define BTM_BLE_AD_BIT_SERVICE_128 (0x00000001 << 16) /*128-bit Service UUIDs*/ 316 317 typedef UINT32 tBTM_BLE_AD_MASK; 318 319 #define BTM_BLE_AD_TYPE_FLAG HCI_EIR_FLAGS_TYPE /* 0x01 */ 320 #define BTM_BLE_AD_TYPE_16SRV_PART HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */ 321 #define BTM_BLE_AD_TYPE_16SRV_CMPL HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */ 322 #define BTM_BLE_AD_TYPE_32SRV_PART HCI_EIR_MORE_32BITS_UUID_TYPE /* 0x04 */ 323 #define BTM_BLE_AD_TYPE_32SRV_CMPL HCI_EIR_COMPLETE_32BITS_UUID_TYPE /* 0x05 */ 324 #define BTM_BLE_AD_TYPE_128SRV_PART HCI_EIR_MORE_128BITS_UUID_TYPE /* 0x06 */ 325 #define BTM_BLE_AD_TYPE_128SRV_CMPL HCI_EIR_COMPLETE_128BITS_UUID_TYPE /* 0x07 */ 326 #define BTM_BLE_AD_TYPE_NAME_SHORT HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */ 327 #define BTM_BLE_AD_TYPE_NAME_CMPL HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */ 328 #define BTM_BLE_AD_TYPE_TX_PWR HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */ 329 #define BTM_BLE_AD_TYPE_DEV_CLASS 0x0D 330 #define BTM_BLE_AD_TYPE_SM_TK 0x10 331 #define BTM_BLE_AD_TYPE_SM_OOB_FLAG 0x11 332 #define BTM_BLE_AD_TYPE_INT_RANGE 0x12 333 #define BTM_BLE_AD_TYPE_SOL_SRV_UUID 0x14 334 #define BTM_BLE_AD_TYPE_128SOL_SRV_UUID 0x15 335 #define BTM_BLE_AD_TYPE_SERVICE_DATA 0x16 336 #define BTM_BLE_AD_TYPE_PUBLIC_TARGET 0x17 337 #define BTM_BLE_AD_TYPE_RANDOM_TARGET 0x18 338 #define BTM_BLE_AD_TYPE_APPEARANCE 0x19 339 #define BTM_BLE_AD_TYPE_ADV_INT 0x1a 340 #define BTM_BLE_AD_TYPE_32SOL_SRV_UUID 0x1b 341 #define BTM_BLE_AD_TYPE_32SERVICE_DATA 0x1c 342 #define BTM_BLE_AD_TYPE_128SERVICE_DATA 0x1d 343 344 #define BTM_BLE_AD_TYPE_MANU HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xff */ 345 typedef UINT8 tBTM_BLE_AD_TYPE; 346 347 /* Security settings used with L2CAP LE COC */ 348 #define BTM_SEC_LE_LINK_ENCRYPTED 0x01 349 #define BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM 0x02 350 #define BTM_SEC_LE_LINK_PAIRED_WITH_MITM 0x04 351 352 /* Min/max Preferred number of payload octets that the local Controller 353 should include in a single Link Layer Data Channel PDU. */ 354 #define BTM_BLE_DATA_SIZE_MAX 0x00fb 355 #define BTM_BLE_DATA_SIZE_MIN 0x001b 356 357 /* Preferred maximum number of microseconds that the local Controller 358 should use to transmit a single Link Layer Data Channel PDU. */ 359 #define BTM_BLE_DATA_TX_TIME_MIN 0x0148 360 #define BTM_BLE_DATA_TX_TIME_MAX 0x0848 361 362 /* adv tx power level */ 363 #define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */ 364 #define BTM_BLE_ADV_TX_POWER_LOW 1 /* low tx power */ 365 #define BTM_BLE_ADV_TX_POWER_MID 2 /* middle tx power */ 366 #define BTM_BLE_ADV_TX_POWER_UPPER 3 /* upper tx power */ 367 #define BTM_BLE_ADV_TX_POWER_MAX 4 /* maximum tx power */ 368 typedef UINT8 tBTM_BLE_ADV_TX_POWER; 369 370 /* adv tx power in dBm */ 371 typedef struct 372 { 373 UINT8 adv_inst_max; /* max adv instance supported in controller */ 374 UINT8 rpa_offloading; 375 UINT16 tot_scan_results_strg; 376 UINT8 max_irk_list_sz; 377 UINT8 filter_support; 378 UINT8 max_filter; 379 UINT8 energy_support; 380 BOOLEAN values_read; 381 UINT16 version_supported; 382 UINT16 total_trackable_advertisers; 383 UINT8 extended_scan_support; 384 UINT8 debug_logging_supported; 385 }tBTM_BLE_VSC_CB; 386 387 /* slave preferred connection interval range */ 388 typedef struct 389 { 390 UINT16 low; 391 UINT16 hi; 392 393 }tBTM_BLE_INT_RANGE; 394 395 /* Service tag supported in the device */ 396 #define MAX_16BIT_SERVICES 16 397 typedef struct 398 { 399 UINT8 num_service; 400 BOOLEAN list_cmpl; 401 UINT16 uuid[MAX_16BIT_SERVICES]; 402 }tBTM_BLE_SERVICE; 403 404 /* 32 bits Service supported in the device */ 405 #define MAX_32BIT_SERVICES 4 406 typedef struct 407 { 408 UINT8 num_service; 409 BOOLEAN list_cmpl; 410 UINT32 uuid[MAX_32BIT_SERVICES]; 411 }tBTM_BLE_32SERVICE; 412 413 /* 128 bits Service supported in the device */ 414 typedef struct 415 { 416 UINT8 num_service; 417 BOOLEAN list_cmpl; 418 UINT8 uuid128[MAX_UUID_SIZE]; 419 }tBTM_BLE_128SERVICE; 420 421 #define MAX_SIZE_MANUFACTURER_DATA 32 422 typedef struct 423 { 424 UINT8 len; 425 UINT8 val[MAX_SIZE_MANUFACTURER_DATA]; 426 }tBTM_BLE_MANU; 427 428 #define MAX_SIZE_SERVICE_DATA 32 429 typedef struct 430 { 431 tBT_UUID service_uuid; 432 UINT8 len; 433 UINT8 val[MAX_SIZE_SERVICE_DATA]; 434 }tBTM_BLE_SERVICE_DATA; 435 436 #define MAX_SIZE_PROPRIETARY_ELEMENT 32 437 typedef struct 438 { 439 UINT8 adv_type; 440 UINT8 len; 441 UINT8 val[MAX_SIZE_PROPRIETARY_ELEMENT]; /* number of len byte */ 442 }tBTM_BLE_PROP_ELEM; 443 444 #define MAX_PROPRIETARY_ELEMENTS 4 445 typedef struct 446 { 447 UINT8 num_elem; 448 tBTM_BLE_PROP_ELEM elem[MAX_PROPRIETARY_ELEMENTS]; 449 }tBTM_BLE_PROPRIETARY; 450 451 typedef struct 452 { 453 tBTM_BLE_INT_RANGE int_range; /* slave prefered conn interval range */ 454 tBTM_BLE_MANU manu; /* manufactuer data */ 455 tBTM_BLE_SERVICE services; /* services */ 456 tBTM_BLE_128SERVICE services_128b; /* 128 bits service */ 457 tBTM_BLE_32SERVICE service_32b; /* 32 bits Service UUID */ 458 tBTM_BLE_SERVICE sol_services; /* 16 bits services Solicitation UUIDs */ 459 tBTM_BLE_32SERVICE sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */ 460 tBTM_BLE_128SERVICE sol_service_128b; /* List of 128 bit Service Solicitation UUIDs */ 461 tBTM_BLE_PROPRIETARY proprietary; 462 tBTM_BLE_SERVICE_DATA service_data; /* service data */ 463 UINT16 appearance; 464 UINT8 flag; 465 UINT8 tx_power; 466 }tBTM_BLE_ADV_DATA; 467 468 #ifndef BTM_BLE_MULTI_ADV_MAX 469 #define BTM_BLE_MULTI_ADV_MAX 16 /* controller returned adv_inst_max should be less 470 than this number */ 471 #endif 472 473 #define BTM_BLE_MULTI_ADV_INVALID 0 474 475 #define BTM_BLE_MULTI_ADV_ENB_EVT 1 476 #define BTM_BLE_MULTI_ADV_DISABLE_EVT 2 477 #define BTM_BLE_MULTI_ADV_PARAM_EVT 3 478 #define BTM_BLE_MULTI_ADV_DATA_EVT 4 479 typedef UINT8 tBTM_BLE_MULTI_ADV_EVT; 480 481 #define BTM_BLE_MULTI_ADV_DEFAULT_STD 0 482 483 typedef struct 484 { 485 UINT16 adv_int_min; 486 UINT16 adv_int_max; 487 UINT8 adv_type; 488 tBTM_BLE_ADV_CHNL_MAP channel_map; 489 tBTM_BLE_AFP adv_filter_policy; 490 tBTM_BLE_ADV_TX_POWER tx_power; 491 }tBTM_BLE_ADV_PARAMS; 492 493 typedef struct 494 { 495 UINT8 *p_sub_code; /* dynamic array to store sub code */ 496 UINT8 *p_inst_id; /* dynamic array to store instance id */ 497 UINT8 pending_idx; 498 UINT8 next_idx; 499 }tBTM_BLE_MULTI_ADV_OPQ; 500 501 typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id, 502 void *p_ref, tBTM_STATUS status); 503 504 typedef struct 505 { 506 UINT8 inst_id; 507 BOOLEAN in_use; 508 UINT8 adv_evt; 509 BD_ADDR rpa; 510 alarm_t *adv_raddr_timer; 511 tBTM_BLE_MULTI_ADV_CBACK *p_cback; 512 void *p_ref; 513 UINT8 index; 514 }tBTM_BLE_MULTI_ADV_INST; 515 516 typedef struct 517 { 518 UINT8 inst_index_queue[BTM_BLE_MULTI_ADV_MAX]; 519 int front; 520 int rear; 521 }tBTM_BLE_MULTI_ADV_INST_IDX_Q; 522 523 typedef struct 524 { 525 tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */ 526 tBTM_BLE_MULTI_ADV_OPQ op_q; 527 }tBTM_BLE_MULTI_ADV_CB; 528 529 typedef UINT8 tGATT_IF; 530 531 typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value); 532 typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 report_format, 533 UINT8 num_records, UINT16 total_len, 534 UINT8* p_rep_data, UINT8 status); 535 typedef void (tBTM_BLE_SCAN_SETUP_CBACK)(UINT8 evt, tBTM_BLE_REF_VALUE ref_value, UINT8 status); 536 537 #ifndef BTM_BLE_BATCH_SCAN_MAX 538 #define BTM_BLE_BATCH_SCAN_MAX 5 539 #endif 540 541 #ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE 542 #define BTM_BLE_BATCH_REP_MAIN_Q_SIZE 2 543 #endif 544 545 typedef enum 546 { 547 BTM_BLE_SCAN_INVALID_STATE=0, 548 BTM_BLE_SCAN_ENABLE_CALLED=1, 549 BTM_BLE_SCAN_ENABLED_STATE=2, 550 BTM_BLE_SCAN_DISABLE_CALLED=3, 551 BTM_BLE_SCAN_DISABLED_STATE=4 552 }tBTM_BLE_BATCH_SCAN_STATE; 553 554 enum 555 { 556 BTM_BLE_DISCARD_OLD_ITEMS, 557 BTM_BLE_DISCARD_LOWER_RSSI_ITEMS 558 }; 559 typedef UINT8 tBTM_BLE_DISCARD_RULE; 560 561 typedef struct 562 { 563 UINT8 sub_code[BTM_BLE_BATCH_SCAN_MAX]; 564 tBTM_BLE_BATCH_SCAN_STATE cur_state[BTM_BLE_BATCH_SCAN_MAX]; 565 tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_SCAN_MAX]; 566 UINT8 pending_idx; 567 UINT8 next_idx; 568 }tBTM_BLE_BATCH_SCAN_OPQ; 569 570 typedef struct 571 { 572 UINT8 rep_mode[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 573 tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 574 UINT8 num_records[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 575 UINT16 data_len[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 576 UINT8 *p_data[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 577 UINT8 pending_idx; 578 UINT8 next_idx; 579 }tBTM_BLE_BATCH_SCAN_REP_Q; 580 581 typedef struct 582 { 583 tBTM_BLE_BATCH_SCAN_STATE cur_state; 584 tBTM_BLE_BATCH_SCAN_MODE scan_mode; 585 UINT32 scan_interval; 586 UINT32 scan_window; 587 tBLE_ADDR_TYPE addr_type; 588 tBTM_BLE_DISCARD_RULE discard_rule; 589 tBTM_BLE_BATCH_SCAN_OPQ op_q; 590 tBTM_BLE_BATCH_SCAN_REP_Q main_rep_q; 591 tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback; 592 tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback; 593 tBTM_BLE_SCAN_REP_CBACK *p_scan_rep_cback; 594 tBTM_BLE_REF_VALUE ref_value; 595 }tBTM_BLE_BATCH_SCAN_CB; 596 597 /* filter selection bit index */ 598 #define BTM_BLE_PF_ADDR_FILTER 0 599 #define BTM_BLE_PF_SRVC_DATA 1 600 #define BTM_BLE_PF_SRVC_UUID 2 601 #define BTM_BLE_PF_SRVC_SOL_UUID 3 602 #define BTM_BLE_PF_LOCAL_NAME 4 603 #define BTM_BLE_PF_MANU_DATA 5 604 #define BTM_BLE_PF_SRVC_DATA_PATTERN 6 605 #define BTM_BLE_PF_TYPE_ALL 7 /* when passed in payload filter type all, only clear action is applicable */ 606 #define BTM_BLE_PF_TYPE_MAX 8 607 608 /* max number of filter spot for different filter type */ 609 #ifndef BTM_BLE_MAX_UUID_FILTER 610 #define BTM_BLE_MAX_UUID_FILTER 8 611 #endif 612 #ifndef BTM_BLE_MAX_ADDR_FILTER 613 #define BTM_BLE_MAX_ADDR_FILTER 8 614 #endif 615 #ifndef BTM_BLE_PF_STR_COND_MAX 616 #define BTM_BLE_PF_STR_COND_MAX 4 /* apply to manu data , or local name */ 617 #endif 618 #ifndef BTM_BLE_PF_STR_LEN_MAX 619 #define BTM_BLE_PF_STR_LEN_MAX 29 /* match for first 29 bytes */ 620 #endif 621 622 typedef UINT8 tBTM_BLE_PF_COND_TYPE; 623 624 #define BTM_BLE_PF_LOGIC_OR 0 625 #define BTM_BLE_PF_LOGIC_AND 1 626 typedef UINT8 tBTM_BLE_PF_LOGIC_TYPE; 627 628 #define BTM_BLE_PF_ENABLE 1 629 #define BTM_BLE_PF_CONFIG 2 630 typedef UINT8 tBTM_BLE_PF_ACTION; 631 632 typedef UINT8 tBTM_BLE_PF_FILT_INDEX; 633 634 typedef UINT8 tBTM_BLE_PF_AVBL_SPACE; 635 636 #define BTM_BLE_PF_BRDCAST_ADDR_FILT 1 637 #define BTM_BLE_PF_SERV_DATA_CHG_FILT 2 638 #define BTM_BLE_PF_SERV_UUID 4 639 #define BTM_BLE_PF_SERV_SOLC_UUID 8 640 #define BTM_BLE_PF_LOC_NAME_CHECK 16 641 #define BTM_BLE_PF_MANUF_NAME_CHECK 32 642 #define BTM_BLE_PF_SERV_DATA_CHECK 64 643 typedef UINT16 tBTM_BLE_PF_FEAT_SEL; 644 645 #define BTM_BLE_PF_LIST_LOGIC_OR 1 646 #define BTM_BLE_PF_LIST_LOGIC_AND 2 647 typedef UINT16 tBTM_BLE_PF_LIST_LOGIC_TYPE; 648 649 #define BTM_BLE_PF_FILT_LOGIC_OR 0 650 #define BTM_BLE_PF_FILT_LOGIC_AND 1 651 typedef UINT16 tBTM_BLE_PF_FILT_LOGIC_TYPE; 652 653 typedef UINT8 tBTM_BLE_PF_RSSI_THRESHOLD; 654 typedef UINT8 tBTM_BLE_PF_DELIVERY_MODE; 655 typedef UINT16 tBTM_BLE_PF_TIMEOUT; 656 typedef UINT8 tBTM_BLE_PF_TIMEOUT_CNT; 657 typedef UINT16 tBTM_BLE_PF_ADV_TRACK_ENTRIES; 658 659 typedef struct 660 { 661 tBTM_BLE_PF_FEAT_SEL feat_seln; 662 tBTM_BLE_PF_LIST_LOGIC_TYPE logic_type; 663 tBTM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type; 664 tBTM_BLE_PF_RSSI_THRESHOLD rssi_high_thres; 665 tBTM_BLE_PF_RSSI_THRESHOLD rssi_low_thres; 666 tBTM_BLE_PF_DELIVERY_MODE dely_mode; 667 tBTM_BLE_PF_TIMEOUT found_timeout; 668 tBTM_BLE_PF_TIMEOUT lost_timeout; 669 tBTM_BLE_PF_TIMEOUT_CNT found_timeout_cnt; 670 tBTM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries; 671 }tBTM_BLE_PF_FILT_PARAMS; 672 673 enum 674 { 675 BTM_BLE_SCAN_COND_ADD, 676 BTM_BLE_SCAN_COND_DELETE, 677 BTM_BLE_SCAN_COND_CLEAR = 2 678 }; 679 typedef UINT8 tBTM_BLE_SCAN_COND_OP; 680 681 enum 682 { 683 BTM_BLE_FILT_ENABLE_DISABLE = 1, 684 BTM_BLE_FILT_CFG = 2, 685 BTM_BLE_FILT_ADV_PARAM = 3 686 }; 687 688 typedef UINT8 tBTM_BLE_FILT_CB_EVT; 689 690 /* BLE adv payload filtering config complete callback */ 691 typedef void (tBTM_BLE_PF_CFG_CBACK)(tBTM_BLE_PF_ACTION action, tBTM_BLE_SCAN_COND_OP cfg_op, 692 tBTM_BLE_PF_AVBL_SPACE avbl_space, tBTM_STATUS status, 693 tBTM_BLE_REF_VALUE ref_value); 694 695 typedef void (tBTM_BLE_PF_CMPL_CBACK) (tBTM_BLE_PF_CFG_CBACK); 696 697 /* BLE adv payload filtering status setup complete callback */ 698 typedef void (tBTM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTM_STATUS status, 699 tBTM_BLE_REF_VALUE ref_value); 700 701 /* BLE adv payload filtering param setup complete callback */ 702 typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type, 703 tBTM_BLE_PF_AVBL_SPACE avbl_space, 704 tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status); 705 706 typedef union 707 { 708 UINT16 uuid16_mask; 709 UINT32 uuid32_mask; 710 UINT8 uuid128_mask[LEN_UUID_128]; 711 }tBTM_BLE_PF_COND_MASK; 712 713 typedef struct 714 { 715 tBLE_BD_ADDR *p_target_addr; /* target address, if NULL, generic UUID filter */ 716 tBT_UUID uuid; /* UUID condition */ 717 tBTM_BLE_PF_LOGIC_TYPE cond_logic; /* AND/OR */ 718 tBTM_BLE_PF_COND_MASK *p_uuid_mask; /* UUID mask */ 719 }tBTM_BLE_PF_UUID_COND; 720 721 typedef struct 722 { 723 UINT8 data_len; /* <= 20 bytes */ 724 UINT8 *p_data; 725 }tBTM_BLE_PF_LOCAL_NAME_COND; 726 727 typedef struct 728 { 729 UINT16 company_id; /* company ID */ 730 UINT8 data_len; /* <= 20 bytes */ 731 UINT8 *p_pattern; 732 UINT16 company_id_mask; /* UUID value mask */ 733 UINT8 *p_pattern_mask; /* Manufacturer data matching mask, 734 same length as data pattern, 735 set to all 0xff, match exact data */ 736 }tBTM_BLE_PF_MANU_COND; 737 738 typedef struct 739 { 740 UINT16 uuid; /* service ID */ 741 UINT8 data_len; /* <= 20 bytes */ 742 UINT8 *p_pattern; 743 UINT8 *p_pattern_mask; /* Service data matching mask, same length as data pattern, 744 set to all 0xff, match exact data */ 745 }tBTM_BLE_PF_SRVC_PATTERN_COND; 746 747 748 typedef union 749 { 750 tBLE_BD_ADDR target_addr; 751 tBTM_BLE_PF_LOCAL_NAME_COND local_name; /* lcoal name filtering */ 752 tBTM_BLE_PF_MANU_COND manu_data; /* manufactuer data filtering */ 753 tBTM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */ 754 tBTM_BLE_PF_UUID_COND solicitate_uuid; /* solicitated service UUID filtering */ 755 tBTM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */ 756 }tBTM_BLE_PF_COND_PARAM; 757 758 typedef struct 759 { 760 UINT8 action_ocf[BTM_BLE_PF_TYPE_MAX]; 761 tBTM_BLE_REF_VALUE ref_value[BTM_BLE_PF_TYPE_MAX]; 762 tBTM_BLE_PF_PARAM_CBACK *p_filt_param_cback[BTM_BLE_PF_TYPE_MAX]; 763 tBTM_BLE_PF_CFG_CBACK *p_scan_cfg_cback[BTM_BLE_PF_TYPE_MAX]; 764 UINT8 cb_evt[BTM_BLE_PF_TYPE_MAX]; 765 UINT8 pending_idx; 766 UINT8 next_idx; 767 }tBTM_BLE_ADV_FILTER_ADV_OPQ; 768 769 #define BTM_BLE_MAX_FILTER_COUNTER (BTM_BLE_MAX_ADDR_FILTER + 1) /* per device filter + one generic filter indexed by 0 */ 770 771 #ifndef BTM_CS_IRK_LIST_MAX 772 #define BTM_CS_IRK_LIST_MAX 0x20 773 #endif 774 775 typedef struct 776 { 777 BOOLEAN in_use; 778 BD_ADDR bd_addr; 779 UINT8 pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by tBTM_BLE_PF_COND_TYPE */ 780 }tBTM_BLE_PF_COUNT; 781 782 typedef struct 783 { 784 BOOLEAN enable; 785 UINT8 op_type; 786 tBTM_BLE_PF_COUNT *p_addr_filter_count; /* per BDA filter array */ 787 tBLE_BD_ADDR cur_filter_target; 788 tBTM_BLE_PF_STATUS_CBACK *p_filt_stat_cback; 789 tBTM_BLE_ADV_FILTER_ADV_OPQ op_q; 790 }tBTM_BLE_ADV_FILTER_CB; 791 792 /* Sub codes */ 793 #define BTM_BLE_META_PF_ENABLE 0x00 794 #define BTM_BLE_META_PF_FEAT_SEL 0x01 795 #define BTM_BLE_META_PF_ADDR 0x02 796 #define BTM_BLE_META_PF_UUID 0x03 797 #define BTM_BLE_META_PF_SOL_UUID 0x04 798 #define BTM_BLE_META_PF_LOCAL_NAME 0x05 799 #define BTM_BLE_META_PF_MANU_DATA 0x06 800 #define BTM_BLE_META_PF_SRVC_DATA 0x07 801 #define BTM_BLE_META_PF_ALL 0x08 802 803 typedef UINT8 BTM_BLE_ADV_STATE; 804 typedef UINT8 BTM_BLE_ADV_INFO_PRESENT; 805 typedef UINT8 BTM_BLE_RSSI_VALUE; 806 typedef UINT16 BTM_BLE_ADV_INFO_TIMESTAMP; 807 808 /* These are the fields returned in each device adv packet. It 809 ** is returned in the results callback if registered. 810 */ 811 typedef struct 812 { 813 UINT8 conn_mode; 814 tBTM_BLE_AD_MASK ad_mask; /* mask of the valid adv data field */ 815 UINT8 flag; 816 UINT8 tx_power_level; 817 UINT8 remote_name_len; 818 UINT8 *p_remote_name; 819 tBTM_BLE_SERVICE service; 820 } tBTM_BLE_INQ_DATA; 821 822 enum 823 { 824 BTM_BLE_CONN_NONE, 825 BTM_BLE_CONN_AUTO, 826 BTM_BLE_CONN_SELECTIVE 827 }; 828 typedef UINT8 tBTM_BLE_CONN_TYPE; 829 830 #define ADV_INFO_PRESENT 0x00 831 #define NO_ADV_INFO_PRESENT 0x01 832 833 typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA; 834 835 typedef void (tBTM_BLE_TRACK_ADV_CBACK)(tBTM_BLE_TRACK_ADV_DATA *p_track_adv_data); 836 837 typedef UINT8 tBTM_BLE_TRACK_ADV_EVT; 838 839 typedef struct 840 { 841 tBTM_BLE_REF_VALUE ref_value; 842 tBTM_BLE_TRACK_ADV_CBACK *p_track_cback; 843 }tBTM_BLE_ADV_TRACK_CB; 844 845 enum 846 { 847 BTM_BLE_TRACK_ADV_ADD, 848 BTM_BLE_TRACK_ADV_REMOVE 849 }; 850 851 typedef UINT8 tBTM_BLE_TRACK_ADV_ACTION; 852 853 #define BTM_BLE_MULTI_ADV_INVALID 0 854 855 #define BTM_BLE_BATCH_SCAN_ENABLE_EVT 1 856 #define BTM_BLE_BATCH_SCAN_CFG_STRG_EVT 2 857 #define BTM_BLE_BATCH_SCAN_READ_REPTS_EVT 3 858 #define BTM_BLE_BATCH_SCAN_THR_EVT 4 859 #define BTM_BLE_BATCH_SCAN_PARAM_EVT 5 860 #define BTM_BLE_BATCH_SCAN_DISABLE_EVT 6 861 862 typedef UINT8 tBTM_BLE_BATCH_SCAN_EVT; 863 864 typedef UINT32 tBTM_BLE_TX_TIME_MS; 865 typedef UINT32 tBTM_BLE_RX_TIME_MS; 866 typedef UINT32 tBTM_BLE_IDLE_TIME_MS; 867 typedef UINT32 tBTM_BLE_ENERGY_USED; 868 869 typedef void (tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time, 870 tBTM_BLE_IDLE_TIME_MS idle_time, 871 tBTM_BLE_ENERGY_USED energy_used, 872 tBTM_STATUS status); 873 874 typedef struct 875 { 876 tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback; 877 }tBTM_BLE_ENERGY_INFO_CB; 878 879 typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name); 880 typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status); 881 882 /* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */ 883 typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data); 884 typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match); 885 /* random address set complete callback */ 886 typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda); 887 888 typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt); 889 typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status); 890 891 tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb; 892 893 /***************************************************************************** 894 ** EXTERNAL FUNCTION DECLARATIONS 895 *****************************************************************************/ 896 #ifdef __cplusplus 897 extern "C" { 898 #endif 899 /******************************************************************************* 900 ** 901 ** Function BTM_SecAddBleDevice 902 ** 903 ** Description Add/modify device. This function will be normally called 904 ** during host startup to restore all required information 905 ** for a LE device stored in the NVRAM. 906 ** 907 ** Parameters: bd_addr - BD address of the peer 908 ** bd_name - Name of the peer device. NULL if unknown. 909 ** dev_type - Remote device's device type. 910 ** addr_type - LE device address type. 911 ** 912 ** Returns TRUE if added OK, else FALSE 913 ** 914 *******************************************************************************/ 915 extern BOOLEAN BTM_SecAddBleDevice (const BD_ADDR bd_addr, BD_NAME bd_name, 916 tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type); 917 918 /******************************************************************************* 919 ** 920 ** Function BTM_SecAddBleKey 921 ** 922 ** Description Add/modify LE device information. This function will be 923 ** normally called during host startup to restore all required 924 ** information stored in the NVRAM. 925 ** 926 ** Parameters: bd_addr - BD address of the peer 927 ** p_le_key - LE key values. 928 ** key_type - LE SMP key type. 929 * 930 ** Returns TRUE if added OK, else FALSE 931 ** 932 *******************************************************************************/ 933 extern BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, 934 tBTM_LE_KEY_TYPE key_type); 935 936 /******************************************************************************* 937 ** 938 ** Function BTM_BleSetAdvParams 939 ** 940 ** Description This function is called to set advertising parameters. 941 ** 942 ** Parameters: None. 943 ** 944 ** Returns void 945 ** 946 *******************************************************************************/ 947 extern tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, 948 tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map); 949 950 /******************************************************************************* 951 ** 952 ** Function BTM_BleWriteAdvData 953 ** 954 ** Description This function is called to write advertising data. 955 ** 956 ** Parameters: None. 957 ** 958 ** Returns void 959 ** 960 *******************************************************************************/ 961 extern tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, 962 tBTM_BLE_ADV_DATA *p_data); 963 964 /******************************************************************************* 965 ** 966 ** Function BTM_BleSetAdvParams 967 ** 968 ** Description This function is called to set advertising parameters. 969 ** 970 ** Parameters adv_int_min: minimum advertising interval 971 ** adv_int_max: maximum advertising interval 972 ** p_dir_bda: connectable direct initiator's LE device address 973 ** chnl_map: advertising channel map. 974 ** 975 ** Returns void 976 ** 977 *******************************************************************************/ 978 extern void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max, 979 tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map); 980 981 /******************************************************************************* 982 ** 983 ** Function BTM_BleObtainVendorCapabilities 984 ** 985 ** Description This function is called to obatin vendor capabilties 986 ** 987 ** Parameters p_cmn_vsc_cb - Returns the vednor capabilities 988 ** 989 ** Returns void 990 ** 991 *******************************************************************************/ 992 extern void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); 993 994 /******************************************************************************* 995 ** 996 ** Function BTM_BleSetScanParams 997 ** 998 ** Description This function is called to set Scan parameters. 999 ** 1000 ** Parameters client_if - Client IF value 1001 ** scan_interval - Scan interval 1002 ** scan_window - Scan window 1003 ** scan_type - Scan type 1004 ** scan_setup_status_cback - Scan setup status callback 1005 ** 1006 ** Returns void 1007 ** 1008 *******************************************************************************/ 1009 extern void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval, 1010 UINT32 scan_window, tBLE_SCAN_MODE scan_type, 1011 tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback); 1012 1013 /******************************************************************************* 1014 ** 1015 ** Function BTM_BleGetVendorCapabilities 1016 ** 1017 ** Description This function reads local LE features 1018 ** 1019 ** Parameters p_cmn_vsc_cb : Locala LE capability structure 1020 ** 1021 ** Returns void 1022 ** 1023 *******************************************************************************/ 1024 extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); 1025 /******************************************************************************* 1026 ** 1027 ** Function BTM_BleSetStorageConfig 1028 ** 1029 ** Description This function is called to setup storage configuration and setup callbacks. 1030 ** 1031 ** Parameters UINT8 batch_scan_full_max -Batch scan full maximum 1032 UINT8 batch_scan_trunc_max - Batch scan truncated value maximum 1033 UINT8 batch_scan_notify_threshold - Threshold value 1034 tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback - Setup callback 1035 tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback 1036 void *p_ref - Reference value 1037 ** 1038 ** Returns tBTM_STATUS 1039 ** 1040 *******************************************************************************/ 1041 extern tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max, 1042 UINT8 batch_scan_trunc_max, 1043 UINT8 batch_scan_notify_threshold, 1044 tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback, 1045 tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback, 1046 tBTM_BLE_SCAN_REP_CBACK* p_cback, 1047 tBTM_BLE_REF_VALUE ref_value); 1048 1049 /******************************************************************************* 1050 ** 1051 ** Function BTM_BleEnableBatchScan 1052 ** 1053 ** Description This function is called to enable batch scan 1054 ** 1055 ** Parameters tBTM_BLE_BATCH_SCAN_MODE scan_mode - Batch scan mode 1056 UINT32 scan_interval -Scan interval 1057 UINT32 scan_window - Scan window value 1058 tBLE_ADDR_TYPE addr_type - Address type 1059 tBTM_BLE_DISCARD_RULE discard_rule - Data discard rules 1060 ** 1061 ** Returns tBTM_STATUS 1062 ** 1063 *******************************************************************************/ 1064 extern tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode, 1065 UINT32 scan_interval, UINT32 scan_window, 1066 tBTM_BLE_DISCARD_RULE discard_rule, 1067 tBLE_ADDR_TYPE addr_type, 1068 tBTM_BLE_REF_VALUE ref_value); 1069 1070 /******************************************************************************* 1071 ** 1072 ** Function BTM_BleDisableBatchScan 1073 ** 1074 ** Description This function is called to disable batch scanning 1075 ** 1076 ** Parameters void 1077 ** 1078 ** Returns void 1079 ** 1080 *******************************************************************************/ 1081 extern tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value); 1082 1083 /******************************************************************************* 1084 ** 1085 ** Function BTM_BleReadScanReports 1086 ** 1087 ** Description This function is called to read batch scan reports 1088 ** 1089 ** Parameters tBLE_SCAN_MODE scan_mode - Scan mode report to be read out 1090 tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback 1091 ** 1092 ** Returns tBTM_STATUS 1093 ** 1094 *******************************************************************************/ 1095 extern tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode, 1096 tBTM_BLE_REF_VALUE ref_value); 1097 1098 /******************************************************************************* 1099 ** 1100 ** Function BTM_BleTrackAdvertiser 1101 ** 1102 ** Description This function is called to read batch scan reports 1103 ** 1104 ** Parameters p_track_cback - Tracking callback 1105 ** ref_value - Reference value 1106 ** 1107 ** Returns tBTM_STATUS 1108 ** 1109 *******************************************************************************/ 1110 extern tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback, 1111 tBTM_BLE_REF_VALUE ref_value); 1112 1113 /******************************************************************************* 1114 ** 1115 ** Function BTM_BleWriteScanRsp 1116 ** 1117 ** Description This function is called to write LE scan response. 1118 ** 1119 ** Parameters: p_scan_rsp: scan response. 1120 ** 1121 ** Returns status 1122 ** 1123 *******************************************************************************/ 1124 extern tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, 1125 tBTM_BLE_ADV_DATA *p_data); 1126 1127 /******************************************************************************* 1128 ** 1129 ** Function BTM_BleObserve 1130 ** 1131 ** Description This procedure keep the device listening for advertising 1132 ** events from a broadcast device. 1133 ** 1134 ** Parameters start: start or stop observe. 1135 ** 1136 ** Returns void 1137 ** 1138 *******************************************************************************/ 1139 extern tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT8 duration, 1140 tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb); 1141 1142 1143 /******************************************************************************* 1144 ** 1145 ** Function BTM_GetDeviceIDRoot 1146 ** 1147 ** Description This function is called to read the local device identity 1148 ** root. 1149 ** 1150 ** Returns void 1151 ** the local device ER is copied into er 1152 ** 1153 *******************************************************************************/ 1154 extern void BTM_GetDeviceIDRoot (BT_OCTET16 ir); 1155 1156 /******************************************************************************* 1157 ** 1158 ** Function BTM_GetDeviceEncRoot 1159 ** 1160 ** Description This function is called to read the local device encryption 1161 ** root. 1162 ** 1163 ** Returns void 1164 ** the local device ER is copied into er 1165 ** 1166 *******************************************************************************/ 1167 extern void BTM_GetDeviceEncRoot (BT_OCTET16 er); 1168 1169 /******************************************************************************* 1170 ** 1171 ** Function BTM_GetDeviceDHK 1172 ** 1173 ** Description This function is called to read the local device DHK. 1174 ** 1175 ** Returns void 1176 ** the local device DHK is copied into dhk 1177 ** 1178 *******************************************************************************/ 1179 extern void BTM_GetDeviceDHK (BT_OCTET16 dhk); 1180 1181 /******************************************************************************* 1182 ** 1183 ** Function BTM_SecurityGrant 1184 ** 1185 ** Description This function is called to grant security process. 1186 ** 1187 ** Parameters bd_addr - peer device bd address. 1188 ** res - result of the operation BTM_SUCCESS if success. 1189 ** Otherwise, BTM_REPEATED_ATTEMPTS is too many attempts. 1190 ** 1191 ** Returns None 1192 ** 1193 *******************************************************************************/ 1194 extern void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res); 1195 1196 /******************************************************************************* 1197 ** 1198 ** Function BTM_BlePasskeyReply 1199 ** 1200 ** Description This function is called after Security Manager submitted 1201 ** passkey request to the application. 1202 ** 1203 ** Parameters: bd_addr - Address of the device for which passkey was requested 1204 ** res - result of the operation SMP_SUCCESS if success 1205 ** passkey - numeric value in the range of 1206 ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)). 1207 ** 1208 *******************************************************************************/ 1209 extern void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey); 1210 1211 /******************************************************************************* 1212 ** 1213 ** Function BTM_BleConfirmReply 1214 ** 1215 ** Description This function is called after Security Manager submitted 1216 ** numeric comparison request to the application. 1217 ** 1218 ** Parameters: bd_addr - Address of the device with which numeric 1219 ** comparison was requested 1220 ** res - comparison result BTM_SUCCESS if success 1221 ** 1222 *******************************************************************************/ 1223 extern void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res); 1224 1225 /******************************************************************************* 1226 ** 1227 ** Function BTM_LeOobDataReply 1228 ** 1229 ** Description This function is called to provide the OOB data for 1230 ** SMP in response to BTM_LE_OOB_REQ_EVT 1231 ** 1232 ** Parameters: bd_addr - Address of the peer device 1233 ** res - result of the operation SMP_SUCCESS if success 1234 ** p_data - simple pairing Randomizer C. 1235 ** 1236 *******************************************************************************/ 1237 extern void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data); 1238 1239 /******************************************************************************* 1240 ** 1241 ** Function BTM_BleSecureConnectionOobDataReply 1242 ** 1243 ** Description This function is called to provide the OOB data for 1244 ** SMP in response to BTM_LE_OOB_REQ_EVT when secure connection 1245 ** data is available 1246 ** 1247 ** Parameters: bd_addr - Address of the peer device 1248 ** p_c - pointer to Confirmation 1249 ** p_r - pointer to Randomizer. 1250 ** 1251 *******************************************************************************/ 1252 extern void BTM_BleSecureConnectionOobDataReply(BD_ADDR bd_addr, 1253 uint8_t *p_c, uint8_t *p_r); 1254 1255 1256 /******************************************************************************* 1257 ** 1258 ** Function BTM_BleDataSignature 1259 ** 1260 ** Description This function is called to sign the data using AES128 CMAC 1261 ** algorith. 1262 ** 1263 ** Parameter bd_addr: target device the data to be signed for. 1264 ** p_text: singing data 1265 ** len: length of the signing data 1266 ** signature: output parameter where data signature is going to 1267 ** be stored. 1268 ** 1269 ** Returns TRUE if signing sucessul, otherwise FALSE. 1270 ** 1271 *******************************************************************************/ 1272 extern BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, 1273 BLE_SIGNATURE signature); 1274 1275 /******************************************************************************* 1276 ** 1277 ** Function BTM_BleVerifySignature 1278 ** 1279 ** Description This function is called to verify the data signature 1280 ** 1281 ** Parameter bd_addr: target device the data to be signed for. 1282 ** p_orig: original data before signature. 1283 ** len: length of the signing data 1284 ** counter: counter used when doing data signing 1285 ** p_comp: signature to be compared against. 1286 1287 ** Returns TRUE if signature verified correctly; otherwise FALSE. 1288 ** 1289 *******************************************************************************/ 1290 extern BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, 1291 UINT16 len, UINT32 counter, 1292 UINT8 *p_comp); 1293 1294 /******************************************************************************* 1295 ** 1296 ** Function BTM_ReadConnectionAddr 1297 ** 1298 ** Description This function is called to set the local device random address 1299 ** . 1300 ** 1301 ** Returns void 1302 ** 1303 *******************************************************************************/ 1304 extern void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr, 1305 tBLE_ADDR_TYPE *p_addr_type); 1306 1307 1308 1309 /******************************************************************************* 1310 ** 1311 ** Function BTM_ReadRemoteConnectionAddr 1312 ** 1313 ** Description This function is read the remote device address currently used 1314 ** . 1315 ** 1316 ** Returns void 1317 ** 1318 *******************************************************************************/ 1319 extern BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr, 1320 BD_ADDR conn_addr, 1321 tBLE_ADDR_TYPE *p_addr_type); 1322 1323 /******************************************************************************* 1324 ** 1325 ** Function BTM_BleLoadLocalKeys 1326 ** 1327 ** Description Local local identity key, encryption root or sign counter. 1328 ** 1329 ** Parameters: key_type: type of key, can be BTM_BLE_KEY_TYPE_ID, BTM_BLE_KEY_TYPE_ER 1330 ** or BTM_BLE_KEY_TYPE_COUNTER. 1331 ** p_key: pointer to the key. 1332 * 1333 ** Returns non2. 1334 ** 1335 *******************************************************************************/ 1336 extern void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key); 1337 1338 1339 /******************************************************************************* 1340 ** 1341 ** Function BTM_BleSetBgConnType 1342 ** 1343 ** Description This function is called to set BLE background connection 1344 ** procedure type. It can be auto connection, or selective connection. 1345 ** 1346 ** Parameters conn_type: it can be auto connection, or selective connection. 1347 ** p_select_cback: callback function when selective connection procedure 1348 ** is being used. 1349 ** 1350 ** Returns void 1351 ** 1352 *******************************************************************************/ 1353 extern BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type, 1354 tBTM_BLE_SEL_CBACK *p_select_cback); 1355 1356 /******************************************************************************* 1357 ** 1358 ** Function BTM_BleUpdateBgConnDev 1359 ** 1360 ** Description This function is called to add or remove a device into/from 1361 ** background connection procedure. The background connection 1362 * procedure is decided by the background connection type, it can be 1363 * auto connection, or selective connection. 1364 ** 1365 ** Parameters add_remove: TRUE to add; FALSE to remove. 1366 ** remote_bda: device address to add/remove. 1367 ** 1368 ** Returns void 1369 ** 1370 *******************************************************************************/ 1371 extern BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda); 1372 1373 /******************************************************************************* 1374 ** 1375 ** Function BTM_BleClearBgConnDev 1376 ** 1377 ** Description This function is called to clear the whitelist, 1378 ** end any pending whitelist connections, 1379 * and reset the local bg device list. 1380 ** 1381 ** Parameters void 1382 ** 1383 ** Returns void 1384 ** 1385 *******************************************************************************/ 1386 extern void BTM_BleClearBgConnDev(void); 1387 1388 /******************************************************** 1389 ** 1390 ** Function BTM_BleSetPrefConnParams 1391 ** 1392 ** Description Set a peripheral's preferred connection parameters. When 1393 ** any of the value does not want to be updated while others 1394 ** do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to 1395 ** leave untouched. 1396 ** 1397 ** Parameters: bd_addr - BD address of the peripheral 1398 ** min_conn_int - minimum preferred connection interval 1399 ** max_conn_int - maximum preferred connection interval 1400 ** slave_latency - preferred slave latency 1401 ** supervision_tout - preferred supervision timeout 1402 ** 1403 ** Returns void 1404 ** 1405 *******************************************************************************/ 1406 extern void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, 1407 UINT16 min_conn_int, UINT16 max_conn_int, 1408 UINT16 slave_latency, UINT16 supervision_tout); 1409 1410 /****************************************************************************** 1411 ** 1412 ** Function BTM_BleSetConnScanParams 1413 ** 1414 ** Description Set scan parameters used in BLE connection request 1415 ** 1416 ** Parameters: scan_interval - scan interval 1417 ** scan_window - scan window 1418 ** 1419 ** Returns void 1420 ** 1421 *******************************************************************************/ 1422 extern void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window); 1423 1424 /****************************************************************************** 1425 ** 1426 ** Function BTM_BleReadControllerFeatures 1427 ** 1428 ** Description Reads BLE specific controller features 1429 ** 1430 ** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read 1431 ** 1432 ** Returns void 1433 ** 1434 *******************************************************************************/ 1435 extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback); 1436 1437 /******************************************************************************* 1438 ** 1439 ** Function BTM_CheckAdvData 1440 ** 1441 ** Description This function is called to get ADV data for a specific type. 1442 ** 1443 ** Parameters p_adv - pointer of ADV data 1444 ** type - finding ADV data type 1445 ** p_length - return the length of ADV data not including type 1446 ** 1447 ** Returns pointer of ADV data 1448 ** 1449 *******************************************************************************/ 1450 extern UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length); 1451 1452 /******************************************************************************* 1453 ** 1454 ** Function BTM__BLEReadDiscoverability 1455 ** 1456 ** Description This function is called to read the current LE discoverability 1457 ** mode of the device. 1458 ** 1459 ** Returns BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or 1460 ** BTM_BLE_GENRAL_DISCOVERABLE 1461 ** 1462 *******************************************************************************/ 1463 UINT16 BTM_BleReadDiscoverability(); 1464 1465 /******************************************************************************* 1466 ** 1467 ** Function BTM__BLEReadConnectability 1468 ** 1469 ** Description This function is called to read the current LE connectibility 1470 ** mode of the device. 1471 ** 1472 ** Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE 1473 ** 1474 *******************************************************************************/ 1475 extern UINT16 BTM_BleReadConnectability (); 1476 1477 /******************************************************************************* 1478 ** 1479 ** Function BTM_ReadDevInfo 1480 ** 1481 ** Description This function is called to read the device/address type 1482 ** of BD address. 1483 ** 1484 ** Parameter remote_bda: remote device address 1485 ** p_dev_type: output parameter to read the device type. 1486 ** p_addr_type: output parameter to read the address type. 1487 ** 1488 *******************************************************************************/ 1489 extern void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, 1490 tBLE_ADDR_TYPE *p_addr_type); 1491 1492 1493 /******************************************************************************* 1494 ** 1495 ** Function BTM_ReadConnectedTransportAddress 1496 ** 1497 ** Description This function is called to read the paired device/address type of other device paired 1498 ** corresponding to the BD_address 1499 ** 1500 ** Parameter remote_bda: remote device address, carry out the transport address 1501 ** transport: active transport 1502 ** 1503 ** Return TRUE if an active link is identified; FALSE otherwise 1504 ** 1505 *******************************************************************************/ 1506 extern BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda, 1507 tBT_TRANSPORT transport); 1508 1509 /******************************************************************************* 1510 ** 1511 ** Function BTM_BleBroadcast 1512 ** 1513 ** Description This function is to start or stop broadcasting. 1514 ** 1515 ** Parameters start: start or stop broadcasting. 1516 ** 1517 ** Returns status. 1518 ** 1519 *******************************************************************************/ 1520 extern tBTM_STATUS BTM_BleBroadcast(BOOLEAN start); 1521 1522 /******************************************************************************* 1523 ** 1524 ** Function BTM_BleConfigPrivacy 1525 ** 1526 ** Description This function is called to enable or disable the privacy in 1527 ** the local device. 1528 ** 1529 ** Parameters enable: TRUE to enable it; FALSE to disable it. 1530 ** 1531 ** Returns BOOLEAN privacy mode set success; otherwise failed. 1532 ** 1533 *******************************************************************************/ 1534 extern BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable); 1535 1536 /******************************************************************************* 1537 ** 1538 ** Function BTM_BleLocalPrivacyEnabled 1539 ** 1540 ** Description Checks if local device supports private address 1541 ** 1542 ** Returns Return TRUE if local privacy is enabled else FALSE 1543 ** 1544 *******************************************************************************/ 1545 extern BOOLEAN BTM_BleLocalPrivacyEnabled(void); 1546 1547 /******************************************************************************* 1548 ** 1549 ** Function BTM_BleEnableMixedPrivacyMode 1550 ** 1551 ** Description This function is called to enabled Mixed mode if privacy 1.2 1552 ** is applicable in controller. 1553 ** 1554 ** Parameters mixed_on: mixed mode to be used or not. 1555 ** 1556 ** Returns void 1557 ** 1558 *******************************************************************************/ 1559 extern void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on); 1560 1561 /******************************************************************************* 1562 ** 1563 ** Function BTM_BleMaxMultiAdvInstanceCount 1564 ** 1565 ** Description Returns max number of multi adv instances supported by controller 1566 ** 1567 ** Returns Max multi adv instance count 1568 ** 1569 *******************************************************************************/ 1570 extern UINT8 BTM_BleMaxMultiAdvInstanceCount(); 1571 1572 /******************************************************************************* 1573 ** 1574 ** Function BTM_BleSetConnectableMode 1575 ** 1576 ** Description This function is called to set BLE connectable mode for a 1577 ** peripheral device. 1578 ** 1579 ** Parameters connectable_mode: directed connectable mode, or non-directed.It can 1580 ** be BTM_BLE_CONNECT_EVT, BTM_BLE_CONNECT_DIR_EVT or 1581 ** BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 1582 ** 1583 ** Returns BTM_ILLEGAL_VALUE if controller does not support BLE. 1584 ** BTM_SUCCESS is status set successfully; otherwise failure. 1585 ** 1586 *******************************************************************************/ 1587 extern tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode); 1588 1589 /******************************************************************************* 1590 ** 1591 ** Function BTM_BleTurnOnPrivacyOnRemote 1592 ** 1593 ** Description This function is called to enable or disable the privacy on the 1594 ** remote device. 1595 ** 1596 ** Parameters bd_addr: remote device address. 1597 ** privacy_on: TRUE to enable it; FALSE to disable it. 1598 ** 1599 ** Returns void 1600 ** 1601 *******************************************************************************/ 1602 extern void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr, 1603 BOOLEAN privacy_on); 1604 1605 /******************************************************************************* 1606 ** 1607 ** Function BTM_BleUpdateAdvWhitelist 1608 ** 1609 ** Description Add or remove device from advertising white list 1610 ** 1611 ** Returns void 1612 ** 1613 *******************************************************************************/ 1614 extern BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda); 1615 1616 /******************************************************************************* 1617 ** 1618 ** Function BTM_BleUpdateAdvFilterPolicy 1619 ** 1620 ** Description This function update the filter policy of advertiser. 1621 ** 1622 ** Parameter adv_policy: advertising filter policy 1623 ** 1624 ** Return void 1625 *******************************************************************************/ 1626 extern void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy); 1627 1628 /******************************************************************************* 1629 ** 1630 ** Function BTM_BleReceiverTest 1631 ** 1632 ** Description This function is called to start the LE Receiver test 1633 ** 1634 ** Parameter rx_freq - Frequency Range 1635 ** p_cmd_cmpl_cback - Command Complete callback 1636 ** 1637 *******************************************************************************/ 1638 void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback); 1639 1640 1641 /******************************************************************************* 1642 ** 1643 ** Function BTM_BleTransmitterTest 1644 ** 1645 ** Description This function is called to start the LE Transmitter test 1646 ** 1647 ** Parameter tx_freq - Frequency Range 1648 ** test_data_len - Length in bytes of payload data in each packet 1649 ** packet_payload - Pattern to use in the payload 1650 ** p_cmd_cmpl_cback - Command Complete callback 1651 ** 1652 *******************************************************************************/ 1653 void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, 1654 UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback); 1655 1656 /******************************************************************************* 1657 ** 1658 ** Function BTM_BleTestEnd 1659 ** 1660 ** Description This function is called to stop the in-progress TX or RX test 1661 ** 1662 ** Parameter p_cmd_cmpl_cback - Command complete callback 1663 ** 1664 *******************************************************************************/ 1665 void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback); 1666 1667 /******************************************************************************* 1668 ** 1669 ** Function BTM_UseLeLink 1670 ** 1671 ** Description This function is to select the underneath physical link to use. 1672 ** 1673 ** Returns TRUE to use LE, FALSE use BR/EDR. 1674 ** 1675 *******************************************************************************/ 1676 extern BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr); 1677 1678 /******************************************************************************* 1679 ** 1680 ** Function BTM_BleStackEnable 1681 ** 1682 ** Description Enable/Disable BLE functionality on stack regarless controller 1683 ** capability. 1684 ** 1685 ** Parameters: enable: TRUE to enable, FALSE to disable. 1686 ** 1687 ** Returns TRUE if added OK, else FALSE 1688 ** 1689 *******************************************************************************/ 1690 extern tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable); 1691 1692 /******************************************************************************* 1693 ** 1694 ** Function BTM_GetLeSecurityState 1695 ** 1696 ** Description This function is called to get security mode 1 flags and 1697 ** encryption key size for LE peer. 1698 ** 1699 ** Returns BOOLEAN TRUE if LE device is found, FALSE otherwise. 1700 ** 1701 *******************************************************************************/ 1702 extern BOOLEAN BTM_GetLeSecurityState (BD_ADDR bd_addr, 1703 UINT8 *p_le_dev_sec_flags, 1704 UINT8 *p_le_key_size); 1705 1706 /******************************************************************************* 1707 ** 1708 ** Function BTM_BleSecurityProcedureIsRunning 1709 ** 1710 ** Description This function indicates if LE security procedure is 1711 ** currently running with the peer. 1712 ** 1713 ** Returns BOOLEAN TRUE if security procedure is running, FALSE otherwise. 1714 ** 1715 *******************************************************************************/ 1716 extern BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr); 1717 1718 /******************************************************************************* 1719 ** 1720 ** Function BTM_BleGetSupportedKeySize 1721 ** 1722 ** Description This function gets the maximum encryption key size in bytes 1723 ** the local device can suport. 1724 ** record. 1725 ** 1726 ** Returns the key size or 0 if the size can't be retrieved. 1727 ** 1728 *******************************************************************************/ 1729 extern UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr); 1730 1731 /*******************************************************************************/ 1732 /* Multi ADV API */ 1733 /******************************************************************************* 1734 ** 1735 ** Function BTM_BleEnableAdvInstance 1736 ** 1737 ** Description This function enable a Multi-ADV instance with the specified 1738 ** adv parameters 1739 ** 1740 ** Parameters p_params: pointer to the adv parameter structure, set as default 1741 ** adv parameter when the instance is enabled. 1742 ** p_cback: callback function for the adv instance. 1743 ** p_ref: reference data attach to the adv instance to be enabled. 1744 ** 1745 ** Returns status 1746 ** 1747 *******************************************************************************/ 1748 extern tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params, 1749 tBTM_BLE_MULTI_ADV_CBACK *p_cback, 1750 void *p_ref); 1751 1752 /******************************************************************************* 1753 ** 1754 ** Function BTM_BleUpdateAdvInstParam 1755 ** 1756 ** Description This function update a Multi-ADV instance with the specififed 1757 ** adv parameters. 1758 ** 1759 ** Parameters inst_id: adv instance ID 1760 ** p_params: pointer to the adv parameter structure. 1761 ** 1762 ** Returns status 1763 ** 1764 *******************************************************************************/ 1765 extern tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params); 1766 1767 /******************************************************************************* 1768 ** 1769 ** Function BTM_BleCfgAdvInstData 1770 ** 1771 ** Description This function configure a Multi-ADV instance with the specified 1772 ** adv data or scan response data. 1773 ** 1774 ** Parameters inst_id: adv instance ID 1775 ** is_scan_rsp: is this scacn response, if no set as adv data. 1776 ** data_mask: adv data mask. 1777 ** p_data: pointer to the adv data structure. 1778 ** 1779 ** Returns status 1780 ** 1781 *******************************************************************************/ 1782 extern tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp, 1783 tBTM_BLE_AD_MASK data_mask, 1784 tBTM_BLE_ADV_DATA *p_data); 1785 1786 /******************************************************************************* 1787 ** 1788 ** Function BTM_BleDisableAdvInstance 1789 ** 1790 ** Description This function disable a Multi-ADV instance. 1791 ** 1792 ** Parameters inst_id: adv instance ID 1793 ** 1794 ** Returns status 1795 ** 1796 *******************************************************************************/ 1797 extern tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id); 1798 1799 /******************************************************************************* 1800 ** 1801 ** Function BTM_BleAdvFilterParamSetup 1802 ** 1803 ** Description This function is called to setup the adv data payload filter 1804 ** condition. 1805 ** 1806 ** Parameters p_target: enabble the filter condition on a target device; if NULL 1807 ** enable the generic scan condition. 1808 ** enable: enable or disable the filter condition 1809 ** 1810 ** Returns void 1811 ** 1812 *******************************************************************************/ 1813 extern tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, 1814 tBTM_BLE_PF_FILT_INDEX filt_index, 1815 tBTM_BLE_PF_FILT_PARAMS *p_filt_params, 1816 tBLE_BD_ADDR *p_target, tBTM_BLE_PF_PARAM_CBACK *p_cmpl_cback, 1817 tBTM_BLE_REF_VALUE ref_value); 1818 1819 /******************************************************************************* 1820 ** 1821 ** Function BTM_BleCfgFilterCondition 1822 ** 1823 ** Description This function is called to configure the adv data payload filter 1824 ** condition. 1825 ** 1826 ** Parameters action: to read/write/clear 1827 ** cond_type: filter condition type. 1828 ** p_cond: filter condition paramter 1829 ** 1830 ** Returns tBTM_STATUS 1831 ** 1832 *******************************************************************************/ 1833 extern tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action, 1834 tBTM_BLE_PF_COND_TYPE cond_type, 1835 tBTM_BLE_PF_FILT_INDEX filt_index, 1836 tBTM_BLE_PF_COND_PARAM *p_cond, 1837 tBTM_BLE_PF_CFG_CBACK *p_cmpl_cback, 1838 tBTM_BLE_REF_VALUE ref_value); 1839 1840 /******************************************************************************* 1841 ** 1842 ** Function BTM_BleEnableDisableFilterFeature 1843 ** 1844 ** Description This function is called to enable or disable the APCF feature 1845 ** 1846 ** Parameters enable - TRUE - enables the APCF, FALSE - disables the APCF 1847 ** ref_value - Ref value 1848 ** 1849 ** Returns tBTM_STATUS 1850 ** 1851 *******************************************************************************/ 1852 extern tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable, 1853 tBTM_BLE_PF_STATUS_CBACK *p_stat_cback, 1854 tBTM_BLE_REF_VALUE ref_value); 1855 1856 /******************************************************************************* 1857 ** 1858 ** Function BTM_BleGetEnergyInfo 1859 ** 1860 ** Description This function obtains the energy info 1861 ** 1862 ** Parameters p_ener_cback - Callback pointer 1863 ** 1864 ** Returns status 1865 ** 1866 *******************************************************************************/ 1867 extern tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback); 1868 1869 /******************************************************************************* 1870 ** 1871 ** Function BTM_SetBleDataLength 1872 ** 1873 ** Description This function is called to set maximum BLE transmission packet size 1874 ** 1875 ** Returns BTM_SUCCESS if success; otherwise failed. 1876 ** 1877 *******************************************************************************/ 1878 extern tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length); 1879 1880 #ifdef __cplusplus 1881 } 1882 #endif 1883 1884 #endif 1885