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 "common/bt_defs.h" 29 #include "stack/btm_api.h" 30 #include "common/bt_common_types.h" 31 32 #define CHANNEL_MAP_LEN 5 33 typedef UINT8 tBTM_BLE_CHNL_MAP[CHANNEL_MAP_LEN]; 34 35 /* 0x00-0x04 only used for set advertising parameter command */ 36 #define BTM_BLE_CONNECT_EVT 0x00 /* 0x00-0x04 only used for set advertising 37 parameter command */ 38 #define BTM_BLE_CONNECT_DIR_EVT 0x01 /* Connectable directed advertising */ 39 #define BTM_BLE_DISCOVER_EVT 0x02 /* Scannable undirected advertising */ 40 #define BTM_BLE_NON_CONNECT_EVT 0x03 /* Non connectable undirected advertising */ 41 #define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04 /* Connectable low duty 42 cycle directed advertising */ 43 /* 0x00 - 0x05 can be received on adv event type */ 44 #define BTM_BLE_SCAN_RSP_EVT 0x04 45 #define BTM_BLE_SCAN_REQ_EVT 0x05 46 #define BTM_BLE_UNKNOWN_EVT 0xff 47 48 #define BTM_BLE_UNKNOWN_EVT 0xff 49 50 typedef UINT8 tBTM_BLE_EVT; 51 typedef UINT8 tBTM_BLE_CONN_MODE; 52 53 typedef UINT32 tBTM_BLE_REF_VALUE; 54 55 #define BTM_BLE_SCAN_MODE_PASS 0 56 #define BTM_BLE_SCAN_MODE_ACTI 1 57 #define BTM_BLE_SCAN_MODE_NONE 0xff 58 typedef UINT8 tBLE_SCAN_MODE; 59 60 #define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0 61 #define BTM_BLE_BATCH_SCAN_MODE_PASS 1 62 #define BTM_BLE_BATCH_SCAN_MODE_ACTI 2 63 #define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3 64 65 typedef UINT8 tBTM_BLE_BATCH_SCAN_MODE; 66 67 /* advertising channel map */ 68 #define BTM_BLE_ADV_CHNL_37 (0x01 << 0) 69 #define BTM_BLE_ADV_CHNL_38 (0x01 << 1) 70 #define BTM_BLE_ADV_CHNL_39 (0x01 << 2) 71 typedef UINT8 tBTM_BLE_ADV_CHNL_MAP; 72 73 /*d efault advertising channel map */ 74 #ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP 75 #define BTM_BLE_DEFAULT_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37| BTM_BLE_ADV_CHNL_38| BTM_BLE_ADV_CHNL_39) 76 #endif 77 78 /* advertising filter policy */ 79 #define AP_SCAN_CONN_ALL 0x00 /* default */ 80 #define AP_SCAN_WL_CONN_ALL 0x01 81 #define AP_SCAN_ALL_CONN_WL 0x02 82 #define AP_SCAN_CONN_WL 0x03 83 #define AP_SCAN_CONN_POLICY_MAX 0x04 84 typedef UINT8 tBTM_BLE_AFP; 85 86 /* default advertising filter policy */ 87 #ifndef BTM_BLE_DEFAULT_AFP 88 #define BTM_BLE_DEFAULT_AFP AP_SCAN_CONN_ALL 89 #endif 90 91 /* scanning filter policy */ 92 #define SP_ADV_ALL 0x00 /* 0: accept adv packet from all, directed adv pkt not directed */ 93 /* to local device is ignored */ 94 #define SP_ADV_WL 0x01 /* 1: accept adv packet from device in white list, directed adv */ 95 /* packet not directed to local device is ignored */ 96 #define SP_ADV_ALL_RPA_DIR_ADV 0x02 /* 2: accept adv packet from all, directed adv pkt */ 97 /* not directed to me is ignored except direct adv with RPA */ 98 #define SP_ADV_WL_RPA_DIR_ADV 0x03 /* 3: accept adv packet from device in white list, directed */ 99 /* adv pkt not directed to me is ignored except direct adv */ 100 /* with RPA */ 101 typedef UINT8 tBTM_BLE_SFP; 102 103 #ifndef BTM_BLE_DEFAULT_SFP 104 #define BTM_BLE_DEFAULT_SFP SP_ADV_ALL 105 #endif 106 107 /* adv parameter boundary values */ 108 #if BLE_HIGH_DUTY_ADV_INTERVAL 109 #define BTM_BLE_ADV_INT_MIN 0x0008 /* 5ms */ 110 #else 111 #define BTM_BLE_ADV_INT_MIN 0x0020 /* 20ms */ 112 #endif 113 #define BTM_BLE_ADV_INT_MAX 0x4000 /* 10240ms */ 114 115 /* Full scan boundary values */ 116 #define BTM_BLE_ADV_SCAN_FULL_MIN 0x00 117 #define BTM_BLE_ADV_SCAN_FULL_MAX 0x64 118 119 /* Partial scan boundary values */ 120 #define BTM_BLE_ADV_SCAN_TRUNC_MIN BTM_BLE_ADV_SCAN_FULL_MIN 121 #define BTM_BLE_ADV_SCAN_TRUNC_MAX BTM_BLE_ADV_SCAN_FULL_MAX 122 123 /* Threshold values */ 124 #define BTM_BLE_ADV_SCAN_THR_MIN BTM_BLE_ADV_SCAN_FULL_MIN 125 #define BTM_BLE_ADV_SCAN_THR_MAX BTM_BLE_ADV_SCAN_FULL_MAX 126 127 /* connection parameter boundary values */ 128 #define BTM_BLE_SCAN_INT_MIN 0x0004 129 #define BTM_BLE_SCAN_INT_MAX 0x4000 130 #define BTM_BLE_SCAN_WIN_MIN 0x0004 131 #define BTM_BLE_SCAN_WIN_MAX 0x4000 132 #define BTM_BLE_EXT_SCAN_INT_MAX 0x00FFFFFF 133 #define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF 134 #define BTM_BLE_CONN_INT_MIN 0x0006 135 #define BTM_BLE_CONN_INT_MAX 0x0C80 136 #define BTM_BLE_CONN_LATENCY_MAX 499 137 #define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A 138 #define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80 139 #define BTM_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ 140 #define BTM_BLE_SCAN_PARAM_UNDEF 0xffffffff 141 142 /* default connection parameters if not configured, use GAP recommend value for auto/selective connection */ 143 /* default scan interval */ 144 #ifndef BTM_BLE_SCAN_FAST_INT 145 #define BTM_BLE_SCAN_FAST_INT 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */ 146 #endif 147 /* default scan window for background connection, applicable for auto connection or selective connection */ 148 #ifndef BTM_BLE_SCAN_FAST_WIN 149 #define BTM_BLE_SCAN_FAST_WIN 48 /* 30 ms = 48 *0.625 */ 150 #endif 151 152 /* default scan parameter used in reduced power cycle (background scanning) */ 153 #ifndef BTM_BLE_SCAN_SLOW_INT_1 154 #define BTM_BLE_SCAN_SLOW_INT_1 2048 /* 1.28 s = 2048 *0.625 */ 155 #endif 156 #ifndef BTM_BLE_SCAN_SLOW_WIN_1 157 #define BTM_BLE_SCAN_SLOW_WIN_1 48 /* 30 ms = 48 *0.625 */ 158 #endif 159 160 /* default scan parameter used in reduced power cycle (background scanning) */ 161 #ifndef BTM_BLE_SCAN_SLOW_INT_2 162 #define BTM_BLE_SCAN_SLOW_INT_2 4096 /* 2.56 s = 4096 *0.625 */ 163 #endif 164 #ifndef BTM_BLE_SCAN_SLOW_WIN_2 165 #define BTM_BLE_SCAN_SLOW_WIN_2 36 /* 22.5 ms = 36 *0.625 */ 166 #endif 167 168 /* default connection interval min */ 169 #ifndef BTM_BLE_CONN_INT_MIN_DEF 170 #define BTM_BLE_CONN_INT_MIN_DEF 10 /* recommended min: 12.5 ms = 10 * 1.25 */ 171 #endif 172 173 /* default connection interval max */ 174 #ifndef BTM_BLE_CONN_INT_MAX_DEF 175 #if CONFIG_IDF_TARGET_ESP32 176 #define BTM_BLE_CONN_INT_MAX_DEF 12 /* recommended max: 15 ms = 12 * 1.25 */ 177 #else 178 #define BTM_BLE_CONN_INT_MAX_DEF (((MAX_ACL_CONNECTIONS + 1) * 4) > 12 ? ((MAX_ACL_CONNECTIONS + 1) * 4) : 12) /* recommended max: BTM_BLE_CONN_INT_MAX_DEF * 1.25 ms*/ 179 #endif 180 #endif 181 182 /* default slave latency */ 183 #ifndef BTM_BLE_CONN_SLAVE_LATENCY_DEF 184 #define BTM_BLE_CONN_SLAVE_LATENCY_DEF 0 /* 0 */ 185 #endif 186 187 /* default supervision timeout */ 188 #ifndef BTM_BLE_CONN_TIMEOUT_DEF 189 #define BTM_BLE_CONN_TIMEOUT_DEF 600 190 #endif 191 192 /* minimum acceptable connection interval */ 193 #ifndef BTM_BLE_CONN_INT_MIN_LIMIT 194 #define BTM_BLE_CONN_INT_MIN_LIMIT 0x0009 195 #endif 196 197 #define BTM_BLE_DIR_CONN_FALLBACK_UNDIR 1 198 #define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV 2 199 200 #ifndef BTM_BLE_DIR_CONN_FALLBACK 201 #define BTM_BLE_DIR_CONN_FALLBACK BTM_BLE_DIR_CONN_FALLBACK_UNDIR 202 #endif 203 204 #define BTM_CMAC_TLEN_SIZE 8 /* 64 bits */ 205 #define BTM_BLE_AUTH_SIGN_LEN 12 /* BLE data signature length 8 Bytes + 4 bytes counter*/ 206 typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */ 207 208 #ifndef BTM_BLE_HOST_SUPPORT 209 #define BTM_BLE_HOST_SUPPORT 0x01 210 #endif 211 212 #ifndef BTM_BLE_SIMULTANEOUS_HOST 213 #define BTM_BLE_SIMULTANEOUS_HOST 0x01 214 #endif 215 216 /* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */ 217 #define BTM_BLE_APPEARANCE_UNKNOWN 0x0000 218 #define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040 219 #define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080 220 #define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0 221 #define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1 222 #define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100 223 #define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140 224 #define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180 225 #define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0 226 #define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200 227 #define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240 228 #define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280 229 #define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0 230 #define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300 231 #define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301 232 #define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340 233 #define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341 234 #define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380 235 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381 236 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382 237 #define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0 238 #define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1 239 #define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2 240 #define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3 241 #define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4 242 #define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5 243 #define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6 244 #define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7 245 #define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8 246 #define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400 247 #define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440 248 #define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441 249 #define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442 250 #define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443 251 #define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480 252 #define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481 253 #define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482 254 #define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 255 #define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484 256 #define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 257 #define BTM_BLE_APPEARANCE_STANDALONE_SPEAKER 0x0841 258 #define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 259 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 260 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 261 #define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80 262 #define BTM_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE 0x0CC0 263 #define BTM_BLE_APPEARANCE_POWERED_WHEELCHAIR 0x0CC1 264 #define BTM_BLE_APPEARANCE_MOBILITY_SCOOTER 0x0CC2 265 #define BTM_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR 0x0D00 266 #define BTM_BLE_APPEARANCE_GENERIC_INSULIN_PUMP 0x0D40 267 #define BTM_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP 0x0D41 268 #define BTM_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP 0x0D44 269 #define BTM_BLE_APPEARANCE_INSULIN_PEN 0x0D48 270 #define BTM_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY 0x0D80 271 #define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440 272 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441 273 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442 274 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443 275 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444 276 277 278 /* Structure returned with Rand/Encrypt complete callback */ 279 typedef struct { 280 UINT8 status; 281 UINT8 param_len; 282 UINT16 opcode; 283 UINT8 param_buf[BT_OCTET16_LEN]; 284 } tBTM_RAND_ENC; 285 286 /* General callback function for notifying an application that a synchronous 287 ** BTM function is complete. The pointer contains the address of any returned data. 288 */ 289 typedef void (tBTM_RAND_ENC_CB) (tBTM_RAND_ENC *p1); 290 291 #define BTM_BLE_FILTER_TARGET_SCANNER 0x01 292 #define BTM_BLE_FILTER_TARGET_ADVR 0x00 293 294 #define BTM_BLE_POLICY_BLACK_ALL 0x00 /* relevant to both */ 295 #define BTM_BLE_POLICY_ALLOW_SCAN 0x01 /* relevant to advertiser */ 296 #define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */ 297 #define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */ 298 299 /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */ 300 #define BTM_BLE_LIMIT_DISC_FLAG (0x01 << 0) 301 #define BTM_BLE_GEN_DISC_FLAG (0x01 << 1) 302 #define BTM_BLE_BREDR_NOT_SPT (0x01 << 2) 303 /* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */ 304 #define BTM_BLE_DMT_CONTROLLER_SPT (0x01 << 3) 305 #define BTM_BLE_DMT_HOST_SPT (0x01 << 4) 306 #define BTM_BLE_NON_LIMIT_DISC_FLAG (0x00 ) /* lowest bit unset */ 307 #define BTM_BLE_ADV_FLAG_MASK (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG) 308 #define BTM_BLE_LIMIT_DISC_MASK (BTM_BLE_LIMIT_DISC_FLAG ) 309 310 #define BTM_BLE_AD_BIT_DEV_NAME (0x00000001 << 0) 311 #define BTM_BLE_AD_BIT_FLAGS (0x00000001 << 1) 312 #define BTM_BLE_AD_BIT_MANU (0x00000001 << 2) 313 #define BTM_BLE_AD_BIT_TX_PWR (0x00000001 << 3) 314 #define BTM_BLE_AD_BIT_INT_RANGE (0x00000001 << 5) 315 #define BTM_BLE_AD_BIT_SERVICE (0x00000001 << 6) 316 #define BTM_BLE_AD_BIT_SERVICE_SOL (0x00000001 << 7) 317 #define BTM_BLE_AD_BIT_SERVICE_DATA (0x00000001 << 8) 318 #define BTM_BLE_AD_BIT_SIGN_DATA (0x00000001 << 9) 319 #define BTM_BLE_AD_BIT_SERVICE_128SOL (0x00000001 << 10) 320 #define BTM_BLE_AD_BIT_APPEARANCE (0x00000001 << 11) 321 #define BTM_BLE_AD_BIT_PUBLIC_ADDR (0x00000001 << 12) 322 #define BTM_BLE_AD_BIT_RANDOM_ADDR (0x00000001 << 13) 323 #define BTM_BLE_AD_BIT_SERVICE_32 (0x00000001 << 4) 324 #define BTM_BLE_AD_BIT_SERVICE_32SOL (0x00000001 << 14) 325 #define BTM_BLE_AD_BIT_PROPRIETARY (0x00000001 << 15) 326 #define BTM_BLE_AD_BIT_SERVICE_128 (0x00000001 << 16) /*128-bit Service UUIDs*/ 327 328 typedef UINT32 tBTM_BLE_AD_MASK; 329 330 /* relate to ESP_BLE_AD_TYPE_xxx in esp_gap_ble_api.h */ 331 #define BTM_BLE_AD_TYPE_FLAG HCI_EIR_FLAGS_TYPE /* 0x01 */ 332 #define BTM_BLE_AD_TYPE_16SRV_PART HCI_EIR_MORE_16BITS_UUID_TYPE /* 0x02 */ 333 #define BTM_BLE_AD_TYPE_16SRV_CMPL HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 */ 334 #define BTM_BLE_AD_TYPE_32SRV_PART HCI_EIR_MORE_32BITS_UUID_TYPE /* 0x04 */ 335 #define BTM_BLE_AD_TYPE_32SRV_CMPL HCI_EIR_COMPLETE_32BITS_UUID_TYPE /* 0x05 */ 336 #define BTM_BLE_AD_TYPE_128SRV_PART HCI_EIR_MORE_128BITS_UUID_TYPE /* 0x06 */ 337 #define BTM_BLE_AD_TYPE_128SRV_CMPL HCI_EIR_COMPLETE_128BITS_UUID_TYPE /* 0x07 */ 338 #define BTM_BLE_AD_TYPE_NAME_SHORT HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 */ 339 #define BTM_BLE_AD_TYPE_NAME_CMPL HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */ 340 #define BTM_BLE_AD_TYPE_TX_PWR HCI_EIR_TX_POWER_LEVEL_TYPE /* 0x0A */ 341 #define BTM_BLE_AD_TYPE_DEV_CLASS 0x0D 342 #define BTM_BLE_AD_TYPE_SM_TK 0x10 343 #define BTM_BLE_AD_TYPE_SM_OOB_FLAG 0x11 344 #define BTM_BLE_AD_TYPE_INT_RANGE 0x12 345 #define BTM_BLE_AD_TYPE_SOL_SRV_UUID 0x14 346 #define BTM_BLE_AD_TYPE_128SOL_SRV_UUID 0x15 347 #define BTM_BLE_AD_TYPE_SERVICE_DATA 0x16 348 #define BTM_BLE_AD_TYPE_PUBLIC_TARGET 0x17 349 #define BTM_BLE_AD_TYPE_RANDOM_TARGET 0x18 350 #define BTM_BLE_AD_TYPE_APPEARANCE 0x19 351 #define BTM_BLE_AD_TYPE_ADV_INT 0x1a 352 #define BTM_BLE_AD_TYPE_LE_DEV_ADDR 0x1b 353 #define BTM_BLE_AD_TYPE_LE_ROLE 0x1c 354 #define BTM_BLE_AD_TYPE_SPAIR_C256 0x1d 355 #define BTM_BLE_AD_TYPE_SPAIR_R256 0x1e 356 #define BTM_BLE_AD_TYPE_32SOL_SRV_UUID 0x1f 357 #define BTM_BLE_AD_TYPE_32SERVICE_DATA 0x20 358 #define BTM_BLE_AD_TYPE_128SERVICE_DATA 0x21 359 #define BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM 0x22 360 #define BTM_BLE_AD_TYPE_LE_SECURE_RANDOM 0x23 361 #define BTM_BLE_AD_TYPE_URI 0x24 362 #define BTM_BLE_AD_TYPE_INDOOR_POSITION 0x25 363 #define BTM_BLE_AD_TYPE_TRANS_DISC_DATA 0x26 364 #define BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE 0x27 365 #define BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE 0x28 366 367 #define BTM_BLE_AD_TYPE_MANU HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xff */ 368 typedef UINT8 tBTM_BLE_AD_TYPE; 369 370 #define BTM_BLE_LONG_ADV_MAX_LEN 249 371 372 /* Security settings used with L2CAP LE COC */ 373 #define BTM_SEC_LE_LINK_ENCRYPTED 0x01 374 #define BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM 0x02 375 #define BTM_SEC_LE_LINK_PAIRED_WITH_MITM 0x04 376 377 /* Min/max Preferred number of payload octets that the local Controller 378 should include in a single Link Layer Data Channel PDU. */ 379 #define BTM_BLE_DATA_SIZE_MAX 0x00fb 380 #define BTM_BLE_DATA_SIZE_MIN 0x001b 381 382 /* Preferred maximum number of microseconds that the local Controller 383 should use to transmit a single Link Layer Data Channel PDU. */ 384 #define BTM_BLE_DATA_TX_TIME_MIN 0x0148 385 #if (BLE_50_FEATURE_SUPPORT == TRUE) 386 #define BTM_BLE_DATA_TX_TIME_MAX 0x04290 // define by spec v5.0 387 #else 388 #define BTM_BLE_DATA_TX_TIME_MAX 0x0848 389 #endif 390 391 /* adv tx power level */ 392 #define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */ 393 #define BTM_BLE_ADV_TX_POWER_MAX BTM_TX_POWER_LEVEL_MAX /* maximum tx power */ 394 typedef UINT8 tBTM_BLE_ADV_TX_POWER; 395 396 /* adv tx power in dBm */ 397 typedef struct { 398 UINT8 adv_inst_max; /* max adv instance supported in controller */ 399 UINT8 rpa_offloading; 400 UINT16 tot_scan_results_strg; 401 UINT8 max_irk_list_sz; 402 UINT8 filter_support; 403 UINT8 max_filter; 404 UINT8 energy_support; 405 BOOLEAN values_read; 406 UINT16 version_supported; 407 UINT16 total_trackable_advertisers; 408 UINT8 extended_scan_support; 409 UINT8 debug_logging_supported; 410 } tBTM_BLE_VSC_CB; 411 412 /* slave preferred connection interval range */ 413 typedef struct { 414 UINT16 low; 415 UINT16 hi; 416 417 } tBTM_BLE_INT_RANGE; 418 419 /* Service tag supported in the device */ 420 typedef struct { 421 UINT8 num_service; 422 BOOLEAN list_cmpl; 423 UINT16 *p_uuid; 424 } tBTM_BLE_SERVICE; 425 426 /* 32 bits Service supported in the device */ 427 typedef struct { 428 UINT8 num_service; 429 BOOLEAN list_cmpl; 430 UINT32 *p_uuid; 431 } tBTM_BLE_32SERVICE; 432 433 /* 128 bits Service supported in the device */ 434 typedef struct { 435 BOOLEAN list_cmpl; 436 UINT8 uuid128[MAX_UUID_SIZE]; 437 } tBTM_BLE_128SERVICE; 438 439 typedef struct { 440 UINT8 len; 441 UINT8 *p_val; 442 } tBTM_BLE_MANU; 443 444 445 typedef struct { 446 tBT_UUID service_uuid; 447 UINT8 len; 448 UINT8 *p_val; 449 } tBTM_BLE_SERVICE_DATA; 450 451 typedef struct { 452 UINT8 adv_type; 453 UINT8 len; 454 UINT8 *p_val; /* number of len byte */ 455 } tBTM_BLE_PROP_ELEM; 456 457 typedef struct { 458 UINT8 num_elem; 459 tBTM_BLE_PROP_ELEM *p_elem; 460 } tBTM_BLE_PROPRIETARY; 461 462 typedef struct { 463 tBTM_BLE_INT_RANGE int_range; /* slave preferred conn interval range */ 464 tBTM_BLE_MANU *p_manu; /* manufacturer data */ 465 tBTM_BLE_SERVICE *p_services; /* services */ 466 tBTM_BLE_128SERVICE *p_services_128b; /* 128 bits service */ 467 tBTM_BLE_32SERVICE *p_service_32b; /* 32 bits Service UUID */ 468 tBTM_BLE_SERVICE *p_sol_services; /* 16 bits services Solicitation UUIDs */ 469 tBTM_BLE_32SERVICE *p_sol_service_32b; /* List of 32 bit Service Solicitation UUIDs */ 470 tBTM_BLE_128SERVICE *p_sol_service_128b; /* List of 128 bit Service Solicitation UUIDs */ 471 tBTM_BLE_PROPRIETARY *p_proprietary; 472 tBTM_BLE_SERVICE_DATA *p_service_data; /* service data */ 473 UINT16 appearance; 474 UINT8 flag; 475 UINT8 tx_power; 476 } tBTM_BLE_ADV_DATA; 477 478 #ifndef BTM_BLE_MULTI_ADV_MAX 479 #define BTM_BLE_MULTI_ADV_MAX 16 /* controller returned adv_inst_max should be less 480 than this number */ 481 #endif 482 483 #define BTM_BLE_MULTI_ADV_INVALID 0 484 485 #define BTM_BLE_MULTI_ADV_ENB_EVT 1 486 #define BTM_BLE_MULTI_ADV_DISABLE_EVT 2 487 #define BTM_BLE_MULTI_ADV_PARAM_EVT 3 488 #define BTM_BLE_MULTI_ADV_DATA_EVT 4 489 typedef UINT8 tBTM_BLE_MULTI_ADV_EVT; 490 491 #define BTM_BLE_MULTI_ADV_DEFAULT_STD 0 492 493 typedef struct { 494 UINT16 adv_int_min; 495 UINT16 adv_int_max; 496 UINT8 adv_type; 497 tBTM_BLE_ADV_CHNL_MAP channel_map; 498 tBTM_BLE_AFP adv_filter_policy; 499 tBTM_BLE_ADV_TX_POWER tx_power; 500 } tBTM_BLE_ADV_PARAMS; 501 502 typedef struct { 503 UINT8 *p_sub_code; /* dynamic array to store sub code */ 504 UINT8 *p_inst_id; /* dynamic array to store instance id */ 505 UINT8 pending_idx; 506 UINT8 next_idx; 507 } tBTM_BLE_MULTI_ADV_OPQ; 508 509 typedef void (tBTM_BLE_MULTI_ADV_CBACK)(tBTM_BLE_MULTI_ADV_EVT evt, UINT8 inst_id, 510 void *p_ref, tBTM_STATUS status); 511 512 typedef struct { 513 UINT8 inst_id; 514 BOOLEAN in_use; 515 UINT8 adv_evt; 516 BD_ADDR rpa; 517 TIMER_LIST_ENT raddr_timer_ent; 518 tBTM_BLE_MULTI_ADV_CBACK *p_cback; 519 void *p_ref; 520 UINT8 index; 521 } tBTM_BLE_MULTI_ADV_INST; 522 523 typedef struct { 524 UINT8 inst_index_queue[BTM_BLE_MULTI_ADV_MAX]; 525 int front; 526 int rear; 527 } tBTM_BLE_MULTI_ADV_INST_IDX_Q; 528 529 typedef struct { 530 tBTM_BLE_MULTI_ADV_INST *p_adv_inst; /* dynamic array to store adv instance */ 531 tBTM_BLE_MULTI_ADV_OPQ op_q; 532 } tBTM_BLE_MULTI_ADV_CB; 533 534 typedef UINT8 tGATT_IF; 535 536 typedef void (tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value); 537 typedef void (tBTM_BLE_SCAN_REP_CBACK)(tBTM_BLE_REF_VALUE ref_value, UINT8 report_format, 538 UINT8 num_records, UINT16 total_len, 539 UINT8 *p_rep_data, UINT8 status); 540 typedef void (tBTM_BLE_SCAN_SETUP_CBACK)(UINT8 evt, tBTM_BLE_REF_VALUE ref_value, UINT8 status); 541 542 #ifndef BTM_BLE_BATCH_SCAN_MAX 543 #define BTM_BLE_BATCH_SCAN_MAX 5 544 #endif 545 546 #ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE 547 #define BTM_BLE_BATCH_REP_MAIN_Q_SIZE 2 548 #endif 549 550 typedef enum { 551 BTM_BLE_SCAN_INVALID_STATE = 0, 552 BTM_BLE_SCAN_ENABLE_CALLED = 1, 553 BTM_BLE_SCAN_ENABLED_STATE = 2, 554 BTM_BLE_SCAN_DISABLE_CALLED = 3, 555 BTM_BLE_SCAN_DISABLED_STATE = 4 556 } tBTM_BLE_BATCH_SCAN_STATE; 557 558 enum { 559 BTM_BLE_DISCARD_OLD_ITEMS, 560 BTM_BLE_DISCARD_LOWER_RSSI_ITEMS 561 }; 562 typedef UINT8 tBTM_BLE_DISCARD_RULE; 563 564 typedef struct { 565 UINT8 sub_code[BTM_BLE_BATCH_SCAN_MAX]; 566 tBTM_BLE_BATCH_SCAN_STATE cur_state[BTM_BLE_BATCH_SCAN_MAX]; 567 tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_SCAN_MAX]; 568 UINT8 pending_idx; 569 UINT8 next_idx; 570 } tBTM_BLE_BATCH_SCAN_OPQ; 571 572 typedef struct { 573 UINT8 rep_mode[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 574 tBTM_BLE_REF_VALUE ref_value[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 575 UINT8 num_records[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 576 UINT16 data_len[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 577 UINT8 *p_data[BTM_BLE_BATCH_REP_MAIN_Q_SIZE]; 578 UINT8 pending_idx; 579 UINT8 next_idx; 580 } tBTM_BLE_BATCH_SCAN_REP_Q; 581 582 typedef struct { 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 /// Ble scan duplicate type 598 enum { 599 BTM_BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */ 600 BTM_BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */ 601 BTM_BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */ 602 }; 603 /* filter selection bit index */ 604 #define BTM_BLE_PF_ADDR_FILTER 0 605 #define BTM_BLE_PF_SRVC_DATA 1 606 #define BTM_BLE_PF_SRVC_UUID 2 607 #define BTM_BLE_PF_SRVC_SOL_UUID 3 608 #define BTM_BLE_PF_LOCAL_NAME 4 609 #define BTM_BLE_PF_MANU_DATA 5 610 #define BTM_BLE_PF_SRVC_DATA_PATTERN 6 611 #define BTM_BLE_PF_TYPE_ALL 7 /* when passed in payload filter type all, only clear action is applicable */ 612 #define BTM_BLE_PF_TYPE_MAX 8 613 614 /* max number of filter spot for different filter type */ 615 #ifndef BTM_BLE_MAX_UUID_FILTER 616 #define BTM_BLE_MAX_UUID_FILTER 8 617 #endif 618 #ifndef BTM_BLE_MAX_ADDR_FILTER 619 #define BTM_BLE_MAX_ADDR_FILTER 8 620 #endif 621 #ifndef BTM_BLE_PF_STR_COND_MAX 622 #define BTM_BLE_PF_STR_COND_MAX 4 /* apply to manu data , or local name */ 623 #endif 624 #ifndef BTM_BLE_PF_STR_LEN_MAX 625 #define BTM_BLE_PF_STR_LEN_MAX 29 /* match for first 29 bytes */ 626 #endif 627 628 typedef UINT8 tBTM_BLE_PF_COND_TYPE; 629 630 #define BTM_BLE_PF_LOGIC_OR 0 631 #define BTM_BLE_PF_LOGIC_AND 1 632 typedef UINT8 tBTM_BLE_PF_LOGIC_TYPE; 633 634 #define BTM_BLE_PF_ENABLE 1 635 #define BTM_BLE_PF_CONFIG 2 636 typedef UINT8 tBTM_BLE_PF_ACTION; 637 638 typedef UINT8 tBTM_BLE_PF_FILT_INDEX; 639 640 typedef UINT8 tBTM_BLE_PF_AVBL_SPACE; 641 642 #define BTM_BLE_PF_BRDCAST_ADDR_FILT 1 643 #define BTM_BLE_PF_SERV_DATA_CHG_FILT 2 644 #define BTM_BLE_PF_SERV_UUID 4 645 #define BTM_BLE_PF_SERV_SOLC_UUID 8 646 #define BTM_BLE_PF_LOC_NAME_CHECK 16 647 #define BTM_BLE_PF_MANUF_NAME_CHECK 32 648 #define BTM_BLE_PF_SERV_DATA_CHECK 64 649 typedef UINT16 tBTM_BLE_PF_FEAT_SEL; 650 651 #define BTM_BLE_PF_LIST_LOGIC_OR 1 652 #define BTM_BLE_PF_LIST_LOGIC_AND 2 653 typedef UINT16 tBTM_BLE_PF_LIST_LOGIC_TYPE; 654 655 #define BTM_BLE_PF_FILT_LOGIC_OR 0 656 #define BTM_BLE_PF_FILT_LOGIC_AND 1 657 typedef UINT16 tBTM_BLE_PF_FILT_LOGIC_TYPE; 658 659 typedef UINT8 tBTM_BLE_PF_RSSI_THRESHOLD; 660 typedef UINT8 tBTM_BLE_PF_DELIVERY_MODE; 661 typedef UINT16 tBTM_BLE_PF_TIMEOUT; 662 typedef UINT8 tBTM_BLE_PF_TIMEOUT_CNT; 663 typedef UINT16 tBTM_BLE_PF_ADV_TRACK_ENTRIES; 664 665 typedef struct { 666 tBTM_BLE_PF_FEAT_SEL feat_seln; 667 tBTM_BLE_PF_LIST_LOGIC_TYPE logic_type; 668 tBTM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type; 669 tBTM_BLE_PF_RSSI_THRESHOLD rssi_high_thres; 670 tBTM_BLE_PF_RSSI_THRESHOLD rssi_low_thres; 671 tBTM_BLE_PF_DELIVERY_MODE dely_mode; 672 tBTM_BLE_PF_TIMEOUT found_timeout; 673 tBTM_BLE_PF_TIMEOUT lost_timeout; 674 tBTM_BLE_PF_TIMEOUT_CNT found_timeout_cnt; 675 tBTM_BLE_PF_ADV_TRACK_ENTRIES num_of_tracking_entries; 676 } tBTM_BLE_PF_FILT_PARAMS; 677 678 enum { 679 BTM_BLE_SCAN_COND_ADD, 680 BTM_BLE_SCAN_COND_DELETE, 681 BTM_BLE_SCAN_COND_CLEAR = 2 682 }; 683 typedef UINT8 tBTM_BLE_SCAN_COND_OP; 684 685 enum { 686 BTM_BLE_FILT_ENABLE_DISABLE = 1, 687 BTM_BLE_FILT_CFG = 2, 688 BTM_BLE_FILT_ADV_PARAM = 3 689 }; 690 691 typedef UINT8 tBTM_BLE_FILT_CB_EVT; 692 693 /* BLE adv payload filtering config complete callback */ 694 typedef void (tBTM_BLE_PF_CFG_CBACK)(tBTM_BLE_PF_ACTION action, tBTM_BLE_SCAN_COND_OP cfg_op, 695 tBTM_BLE_PF_AVBL_SPACE avbl_space, tBTM_STATUS status, 696 tBTM_BLE_REF_VALUE ref_value); 697 698 typedef void (tBTM_BLE_PF_CMPL_CBACK) (tBTM_BLE_PF_CFG_CBACK); 699 700 /* BLE adv payload filtering status setup complete callback */ 701 typedef void (tBTM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTM_STATUS status, 702 tBTM_BLE_REF_VALUE ref_value); 703 704 /* BLE adv payload filtering param setup complete callback */ 705 typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type, 706 tBTM_BLE_PF_AVBL_SPACE avbl_space, 707 tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status); 708 #if (BLE_50_FEATURE_SUPPORT == TRUE) 709 #define MAX_BLE_ADV_INSTANCE 10 710 #define MIN_BLE_PERIODIC_ADV_REPORT_LEN 7 711 typedef struct { 712 UINT8 inst_id; 713 BOOLEAN configured; 714 BOOLEAN legacy_pdu; 715 716 717 BOOLEAN directed; 718 BOOLEAN scannable; 719 BOOLEAN connetable; 720 } tBTM_BLE_EXTENDED_INST; 721 722 typedef struct { 723 tBTM_BLE_EXTENDED_INST inst[MAX_BLE_ADV_INSTANCE]; /* dynamic array to store adv instance */ 724 UINT8 scan_duplicate; 725 } tBTM_BLE_EXTENDED_CB; 726 727 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE (1 << 0) 728 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE (1 << 1) 729 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED (1 << 2) 730 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED (1 << 3) 731 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY (1 << 4) 732 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV (1 << 5) 733 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR (1 << 6) 734 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_MASK (0x7F) 735 736 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 737 ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ 738 ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE) 739 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 740 ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ 741 ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED) 742 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 743 ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\ 744 ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED) 745 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\ 746 ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE) 747 #define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY) 748 typedef UINT16 tBTM_BLE_EXT_ADV_TYPE_MASK; 749 750 #define BTM_BLE_GAP_PHY_1M 1 751 #define BTM_BLE_GAP_PHY_2M 2 752 #define BTM_BLE_GAP_PHY_CODED 3 753 typedef UINT8 tBTM_BLE_GAP_PHY; 754 755 #define BTM_BLE_GAP_PHY_NO_TX_PREF_MASK (0x01) 756 #define BTM_BLE_GAP_PHY_NO_RX_PREF_MASK (0x02) 757 #define BTM_BLE_GAP_PHY_1M_PREF_MASK (0x03) 758 #define BTM_BLE_GAP_PHY_2M_PREF_MASK (0x04) 759 #define BTM_BLE_GAP_PHY_CODED_PREF_MASK (0x05) 760 typedef UINT8 tBTM_BLE_GAP_PHY_MASK; 761 762 #define BTM_BLE_GAP_EXT_SCAN_UNCODE_MASK 0x01 763 #define BTM_BLE_GAP_EXT_SCAN_CODE_MASK 0x02 764 typedef UINT8 tBTM_BLE_EXT_SCAN_CFG_MASK; 765 766 typedef struct { 767 tBTM_BLE_EXT_ADV_TYPE_MASK type; 768 UINT32 interval_min; 769 UINT32 interval_max; 770 tBTM_BLE_ADV_CHNL_MAP channel_map; 771 tBLE_ADDR_TYPE own_addr_type; 772 tBLE_ADDR_TYPE peer_addr_type; 773 BD_ADDR peer_addr; 774 tBTM_BLE_AFP filter_policy; 775 INT8 tx_power; 776 tBTM_BLE_GAP_PHY primary_phy; 777 UINT8 max_skip; 778 tBTM_BLE_GAP_PHY secondary_phy; 779 UINT8 sid; 780 BOOLEAN scan_req_notif; 781 } tBTM_BLE_GAP_EXT_ADV_PARAMS; 782 783 typedef struct { 784 UINT8 instance; 785 int duration; 786 int max_events; 787 } tBTM_BLE_EXT_ADV; 788 789 790 typedef struct { 791 tBLE_SCAN_MODE scan_type; 792 UINT16 scan_interval; 793 UINT16 scan_window; 794 } tBTM_BLE_EXT_SCAN_CFG; 795 796 typedef struct { 797 tBLE_ADDR_TYPE own_addr_type; 798 UINT8 filter_policy; 799 UINT8 scan_duplicate; 800 tBTM_BLE_EXT_SCAN_CFG_MASK cfg_mask; 801 tBTM_BLE_EXT_SCAN_CFG uncoded_cfg; 802 tBTM_BLE_EXT_SCAN_CFG coded_cfg; 803 } tBTM_BLE_EXT_SCAN_PARAMS; 804 805 typedef struct { 806 UINT16 interval_min; 807 UINT16 interval_max; 808 UINT8 properties; 809 } tBTM_BLE_Periodic_Adv_Params; 810 811 typedef struct { 812 UINT8 filter_policy; 813 #if (CONFIG_BT_BLE_FEAT_CREATE_SYNC_ENH) 814 UINT8 reports_disabled; 815 UINT8 filter_duplicates; 816 #endif 817 UINT8 sid; 818 tBLE_ADDR_TYPE addr_type; 819 BD_ADDR addr; 820 UINT16 skip; 821 UINT16 sync_timeout; 822 } tBTM_BLE_Periodic_Sync_Params; 823 824 typedef struct { 825 uint8_t status; 826 uint16_t conn_idx; 827 uint8_t tx_phy; 828 uint8_t rx_phy; 829 } tBTM_BLE_UPDATE_PHY; 830 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) 831 typedef union { 832 UINT16 uuid16_mask; 833 UINT32 uuid32_mask; 834 UINT8 uuid128_mask[LEN_UUID_128]; 835 } tBTM_BLE_PF_COND_MASK; 836 837 typedef struct { 838 tBLE_BD_ADDR *p_target_addr; /* target address, if NULL, generic UUID filter */ 839 tBT_UUID uuid; /* UUID condition */ 840 tBTM_BLE_PF_LOGIC_TYPE cond_logic; /* AND/OR */ 841 tBTM_BLE_PF_COND_MASK *p_uuid_mask; /* UUID mask */ 842 } tBTM_BLE_PF_UUID_COND; 843 844 typedef struct { 845 UINT8 data_len; /* <= 20 bytes */ 846 UINT8 *p_data; 847 } tBTM_BLE_PF_LOCAL_NAME_COND; 848 849 typedef struct { 850 UINT16 company_id; /* company ID */ 851 UINT8 data_len; /* <= 20 bytes */ 852 UINT8 *p_pattern; 853 UINT16 company_id_mask; /* UUID value mask */ 854 UINT8 *p_pattern_mask; /* Manufacturer data matching mask, 855 same length as data pattern, 856 set to all 0xff, match exact data */ 857 } tBTM_BLE_PF_MANU_COND; 858 859 typedef struct { 860 UINT16 uuid; /* service ID */ 861 UINT8 data_len; /* <= 20 bytes */ 862 UINT8 *p_pattern; 863 UINT8 *p_pattern_mask; /* Service data matching mask, same length as data pattern, 864 set to all 0xff, match exact data */ 865 } tBTM_BLE_PF_SRVC_PATTERN_COND; 866 867 868 typedef union { 869 tBLE_BD_ADDR target_addr; 870 tBTM_BLE_PF_LOCAL_NAME_COND local_name; /* local name filtering */ 871 tBTM_BLE_PF_MANU_COND manu_data; /* manufacturer data filtering */ 872 tBTM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */ 873 tBTM_BLE_PF_UUID_COND solicitate_uuid; /* solicited service UUID filtering */ 874 tBTM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */ 875 } tBTM_BLE_PF_COND_PARAM; 876 877 typedef struct { 878 UINT8 action_ocf[BTM_BLE_PF_TYPE_MAX]; 879 tBTM_BLE_REF_VALUE ref_value[BTM_BLE_PF_TYPE_MAX]; 880 tBTM_BLE_PF_PARAM_CBACK *p_filt_param_cback[BTM_BLE_PF_TYPE_MAX]; 881 tBTM_BLE_PF_CFG_CBACK *p_scan_cfg_cback[BTM_BLE_PF_TYPE_MAX]; 882 UINT8 cb_evt[BTM_BLE_PF_TYPE_MAX]; 883 UINT8 pending_idx; 884 UINT8 next_idx; 885 } tBTM_BLE_ADV_FILTER_ADV_OPQ; 886 887 #define BTM_BLE_MAX_FILTER_COUNTER (BTM_BLE_MAX_ADDR_FILTER + 1) /* per device filter + one generic filter indexed by 0 */ 888 889 #ifndef BTM_CS_IRK_LIST_MAX 890 #define BTM_CS_IRK_LIST_MAX 0x20 891 #endif 892 893 typedef struct { 894 BOOLEAN in_use; 895 BD_ADDR bd_addr; 896 UINT8 pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by tBTM_BLE_PF_COND_TYPE */ 897 } tBTM_BLE_PF_COUNT; 898 899 typedef struct { 900 BOOLEAN enable; 901 UINT8 op_type; 902 tBTM_BLE_PF_COUNT *p_addr_filter_count; /* per BDA filter array */ 903 tBLE_BD_ADDR cur_filter_target; 904 tBTM_BLE_PF_STATUS_CBACK *p_filt_stat_cback; 905 tBTM_BLE_ADV_FILTER_ADV_OPQ op_q; 906 } tBTM_BLE_ADV_FILTER_CB; 907 908 /* Sub codes */ 909 #define BTM_BLE_META_PF_ENABLE 0x00 910 #define BTM_BLE_META_PF_FEAT_SEL 0x01 911 #define BTM_BLE_META_PF_ADDR 0x02 912 #define BTM_BLE_META_PF_UUID 0x03 913 #define BTM_BLE_META_PF_SOL_UUID 0x04 914 #define BTM_BLE_META_PF_LOCAL_NAME 0x05 915 #define BTM_BLE_META_PF_MANU_DATA 0x06 916 #define BTM_BLE_META_PF_SRVC_DATA 0x07 917 #define BTM_BLE_META_PF_ALL 0x08 918 919 typedef UINT8 BTM_BLE_ADV_STATE; 920 typedef UINT8 BTM_BLE_ADV_INFO_PRESENT; 921 typedef UINT8 BTM_BLE_RSSI_VALUE; 922 typedef UINT16 BTM_BLE_ADV_INFO_TIMESTAMP; 923 924 /* These are the fields returned in each device adv packet. It 925 ** is returned in the results callback if registered. 926 */ 927 typedef struct { 928 UINT8 conn_mode; 929 tBTM_BLE_AD_MASK ad_mask; /* mask of the valid adv data field */ 930 UINT8 flag; 931 UINT8 tx_power_level; 932 UINT8 remote_name_len; 933 UINT8 *p_remote_name; 934 tBTM_BLE_SERVICE service; 935 } tBTM_BLE_INQ_DATA; 936 937 enum { 938 BTM_BLE_CONN_NONE, 939 BTM_BLE_CONN_AUTO, 940 BTM_BLE_CONN_SELECTIVE 941 }; 942 typedef UINT8 tBTM_BLE_CONN_TYPE; 943 944 #define ADV_INFO_PRESENT 0x00 945 #define NO_ADV_INFO_PRESENT 0x01 946 947 typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA; 948 949 typedef void (tBTM_BLE_TRACK_ADV_CBACK)(tBTM_BLE_TRACK_ADV_DATA *p_track_adv_data); 950 951 typedef UINT8 tBTM_BLE_TRACK_ADV_EVT; 952 953 typedef struct { 954 tBTM_BLE_REF_VALUE ref_value; 955 tBTM_BLE_TRACK_ADV_CBACK *p_track_cback; 956 } tBTM_BLE_ADV_TRACK_CB; 957 958 enum { 959 BTM_BLE_TRACK_ADV_ADD, 960 BTM_BLE_TRACK_ADV_REMOVE 961 }; 962 963 typedef UINT8 tBTM_BLE_TRACK_ADV_ACTION; 964 965 #define BTM_BLE_MULTI_ADV_INVALID 0 966 967 #define BTM_BLE_BATCH_SCAN_ENABLE_EVT 1 968 #define BTM_BLE_BATCH_SCAN_CFG_STRG_EVT 2 969 #define BTM_BLE_BATCH_SCAN_READ_REPTS_EVT 3 970 #define BTM_BLE_BATCH_SCAN_THR_EVT 4 971 #define BTM_BLE_BATCH_SCAN_PARAM_EVT 5 972 #define BTM_BLE_BATCH_SCAN_DISABLE_EVT 6 973 974 typedef UINT8 tBTM_BLE_BATCH_SCAN_EVT; 975 976 typedef UINT32 tBTM_BLE_TX_TIME_MS; 977 typedef UINT32 tBTM_BLE_RX_TIME_MS; 978 typedef UINT32 tBTM_BLE_IDLE_TIME_MS; 979 typedef UINT32 tBTM_BLE_ENERGY_USED; 980 981 typedef void (tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, tBTM_BLE_RX_TIME_MS rx_time, 982 tBTM_BLE_IDLE_TIME_MS idle_time, 983 tBTM_BLE_ENERGY_USED energy_used, 984 tBTM_STATUS status); 985 986 typedef struct { 987 tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback; 988 } tBTM_BLE_ENERGY_INFO_CB; 989 990 typedef BOOLEAN (tBTM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name); 991 typedef void (tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status); 992 993 /* callback function for SMP signing algorithm, signed data in little endian order with tlen bits long */ 994 typedef void (tBTM_BLE_SIGN_CBACK)(void *p_ref_data, UINT8 *p_signing_data); 995 typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match); 996 /* random address set complete callback */ 997 typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda); 998 999 typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt); 1000 typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status); 1001 1002 tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb; 1003 1004 typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status); 1005 typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status); 1006 1007 typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info); 1008 typedef void (tBTM_CLEAR_ADV_CMPL_CBACK) (UINT8 status); 1009 typedef void (tBTM_SET_PRIVACY_MODE_CMPL_CBACK) (tBTM_STATUS status); 1010 typedef void (tBTM_SET_CSA_SUPPORT_CMPL_CBACK) (tBTM_STATUS status); 1011 1012 #if (BLE_50_FEATURE_SUPPORT == TRUE) 1013 #define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1 1014 #define BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT 2 1015 #define BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT 3 1016 #define BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT 4 1017 #define BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT 5 1018 #define BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT 6 1019 #define BTM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT 7 1020 #define BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT 8 1021 #define BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT 9 1022 #define BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT 10 1023 #define BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT 11 1024 #define BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT 12 1025 #define BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT 13 1026 #define BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT 14 1027 #define BTM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT 15 1028 #define BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT 16 1029 #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT 17 1030 #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT 18 1031 #define BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT 19 1032 #define BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT 20 1033 #define BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT 21 1034 #define BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT 22 1035 #define BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT 23 1036 #define BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT 24 1037 #define BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT 25 1038 #define BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT 26 1039 #define BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT 27 1040 #define BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT 28 1041 #define BTM_BLE_5_GAP_ADV_TERMINATED_EVT 29 1042 #define BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT 30 1043 #define BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT 31 1044 #define BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT 32 1045 #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT 33 1046 #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT 34 1047 #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 1048 #define BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT 35 1049 #define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT 36 1050 #define BTM_BLE_GAP_PERIODIC_ADV_SET_INFO_TRANS_COMPLETE_EVT 37 1051 #define BTM_BLE_GAP_SET_PAST_PARAMS_COMPLETE_EVT 38 1052 #define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_RECV_EVT 39 1053 #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 1054 #define BTM_BLE_GAP_SET_PRIVACY_MODE_COMPLETE_EVT 40 1055 #define BTM_BLE_5_GAP_UNKNOWN_EVT 41 1056 typedef UINT8 tBTM_BLE_5_GAP_EVENT; 1057 1058 #define BTM_BLE_EXT_ADV_DATA_COMPLETE 0x00 1059 #define BTM_BLE_EXT_ADV_DATA_INCOMPLETE 0x01 1060 #define BTM_BLE_EXT_ADV_DATA_TRUNCATED 0x02 1061 typedef UINT8 tBTM_BLE_EXT_ADV_DATA_STATUS; 1062 1063 #define BTM_BLE_ADV_DATA_COMPLETE_MASK (0x0000) 1064 #define BTM_BLE_ADV_DATA_INCOMPLETE_MASK (0x0020) 1065 #define BTM_BLE_ADV_DATA_TRUNCATED_MASK (0x0040) 1066 #define BTM_BLE_ADV_DATA_STATUS_MASK (0x0060) 1067 1068 1069 //#define BTM_BLE_ADV_CONN_MASK (0x0001) 1070 //#define BTM_BLE_ADV_SCAN_MASK (0x0002) 1071 //#define BTM_BLE_ADV_DIRECT_MASK (0x0004) 1072 //#define BTM_BLE_SCAN_RSP_MASK (0x0008) 1073 #define BTM_BLE_ADV_LEGACY_MASK (0x0010) 1074 typedef UINT8 tBTM_BLE_ADV_MASK; 1075 1076 // /* Advertising report */ 1077 // #define BTM_BLE_ADV_REPORT_ADV_IND (0) 1078 // #define BTM_BLE_ADV_REPORT_DIR_IND (1) 1079 // #define BTM_BLE_ADV_REPORT_SCAN_IND (2) 1080 // #define BTM_BLE_ADV_REPORT_NONCONN_IND (3) 1081 // #define BTM_BLE_ADV_REPORT_SCAN_RSP (4) 1082 1083 // /* Bluetooth 5.0, Vol 2, Part E, 7.7.65.13 */ 1084 // #define BTM_BLE_LEGACY_ADV_TYPE_IND (0x13) 1085 // #define BTM_BLE_LEGACY_ADV_TYPE_DIRECT_IND (0x15) 1086 // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_IND (0x12) 1087 // #define BTM_BLE_LEGACY_ADV_TYPE_NONCON_IND (0x10) 1088 // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_IND (0x1b) 1089 // #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_SCAN_IND (0x1a) 1090 1091 typedef struct { 1092 UINT8 status; 1093 BD_ADDR addr; 1094 UINT8 tx_phy; 1095 UINT8 rx_phy; 1096 } tBTM_BLE_READ_PHY_CMPL; 1097 1098 typedef struct { 1099 UINT8 status; 1100 } tBTM_BLE_SET_PREF_DEF_PHY_CMPL; 1101 1102 typedef struct { 1103 UINT8 status; 1104 UINT8 instance; 1105 } tBTM_BLE_SET_PERF_PHY_CMPL; 1106 1107 typedef struct { 1108 UINT8 status; 1109 UINT8 instance; 1110 } tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL; 1111 1112 typedef struct { 1113 UINT8 status; 1114 UINT8 instance; 1115 } tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL; 1116 1117 typedef struct { 1118 UINT8 status; 1119 UINT8 instance; 1120 } tBTM_BLE_EXT_ADV_DATA_SET_CMPL; 1121 1122 typedef struct { 1123 UINT8 status; 1124 UINT8 instance; 1125 } tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL; 1126 1127 typedef struct { 1128 UINT8 status; 1129 UINT8 instance_num; 1130 UINT8 instance[10]; 1131 } tBTM_BLE_EXT_ADV_START_CMPL; 1132 1133 typedef struct { 1134 UINT8 status; 1135 UINT8 instance; 1136 } tBTM_BLE_EXT_ADV_STOP_CMPL; 1137 1138 typedef struct { 1139 UINT8 status; 1140 UINT8 instance; 1141 } tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL; 1142 1143 typedef struct { 1144 UINT8 status; 1145 UINT8 instance; 1146 } tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL; 1147 1148 typedef struct { 1149 UINT8 status; 1150 UINT8 instance; 1151 } tBTM_BLE_PERIOD_ADV_START_CMPL; 1152 1153 typedef struct { 1154 UINT8 status; 1155 UINT8 instance; 1156 } tBTM_BLE_PERIOD_ADV_STOP_CMPL; 1157 1158 typedef struct { 1159 UINT8 status; 1160 } tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL; 1161 1162 typedef struct { 1163 UINT8 status; 1164 } tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL; 1165 1166 typedef struct { 1167 UINT8 status; 1168 } tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL; 1169 1170 typedef struct { 1171 UINT8 status; 1172 } tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL; 1173 1174 typedef struct { 1175 UINT8 status; 1176 } tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL; 1177 1178 typedef struct { 1179 UINT8 status; 1180 } tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL; 1181 1182 typedef struct { 1183 UINT8 status; 1184 } tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL; 1185 1186 typedef struct { 1187 UINT8 status; 1188 } tBTM_BLE_EXT_SCAN_START_CMPL; 1189 1190 typedef struct { 1191 UINT8 status; 1192 } tBTM_BLE_EXT_SCAN_STOP_CMPL; 1193 1194 typedef struct { 1195 UINT8 status; 1196 } tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL; 1197 1198 typedef struct { 1199 uint8_t status; 1200 BD_ADDR addr; 1201 uint8_t tx_phy; 1202 uint8_t rx_phy; 1203 } tBTM_BLE_PHY_UPDATE_CMPL; 1204 1205 typedef struct { 1206 // UINT8 props; 1207 // UINT8 legacy_event_type; 1208 UINT8 event_type; 1209 tBLE_ADDR_TYPE addr_type; 1210 BD_ADDR addr; 1211 UINT8 primary_phy; 1212 UINT8 secondry_phy; 1213 UINT8 sid; 1214 UINT8 tx_power; 1215 UINT8 rssi; 1216 UINT16 per_adv_interval; 1217 tBLE_ADDR_TYPE dir_addr_type; 1218 BD_ADDR dir_addr; 1219 tBTM_BLE_EXT_ADV_DATA_STATUS data_status; 1220 UINT8 adv_data_len; 1221 UINT8 *adv_data; 1222 } tBTM_BLE_EXT_ADV_REPORT; 1223 1224 typedef struct { 1225 UINT8 status; 1226 UINT8 adv_handle; 1227 UINT16 conn_handle; 1228 UINT8 completed_event; 1229 } tBTM_BLE_ADV_TERMINAT; 1230 1231 typedef struct { 1232 UINT8 adv_handle; 1233 tBLE_ADDR_TYPE scan_addr_type; 1234 BD_ADDR scan_addr; 1235 } tBTM_BLE_SCAN_REQ_RECEIVED; 1236 1237 typedef struct { 1238 UINT16 conn_handle; 1239 UINT8 channel_sel_alg; 1240 } tBTM_BLE_CHANNEL_SEL_ALG; 1241 1242 typedef struct { 1243 UINT16 sync_handle; 1244 UINT8 tx_power; 1245 INT8 rssi; 1246 tBTM_BLE_EXT_ADV_DATA_STATUS data_status; 1247 UINT8 data_length; 1248 UINT8 *data; 1249 } tBTM_PERIOD_ADV_REPORT; 1250 1251 typedef struct { 1252 UINT16 sync_handle; 1253 } tBTM_BLE_PERIOD_ADV_SYNC_LOST; 1254 1255 typedef struct { 1256 UINT8 status; 1257 UINT16 sync_handle; 1258 UINT8 sid; 1259 tBLE_ADDR_TYPE adv_addr_type; 1260 BD_ADDR adv_addr; 1261 UINT8 adv_phy; 1262 UINT16 period_adv_interval; 1263 UINT8 adv_clk_accuracy; 1264 } tBTM_BLE_PERIOD_ADV_SYNC_ESTAB; 1265 1266 typedef struct { 1267 UINT16 scan_interval; 1268 UINT16 scan_window; 1269 UINT16 interval_min; 1270 UINT16 interval_max; 1271 UINT16 latency; 1272 UINT16 supervision_timeout; 1273 UINT16 min_ce_len; 1274 UINT16 max_ce_len; 1275 } tBTM_BLE_CONN_PARAMS; 1276 1277 #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 1278 typedef struct { 1279 UINT8 status; 1280 } tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL; 1281 1282 typedef struct { 1283 UINT8 status; 1284 BD_ADDR addr; 1285 } tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL; 1286 1287 typedef struct { 1288 UINT8 status; 1289 BD_ADDR addr; 1290 } tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL; 1291 1292 typedef struct { 1293 UINT8 status; 1294 BD_ADDR addr; 1295 } tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL; 1296 1297 typedef struct { 1298 UINT8 status; 1299 BD_ADDR addr; 1300 UINT16 service_data; 1301 UINT16 sync_handle; 1302 UINT8 adv_sid; 1303 UINT8 adv_addr_type; 1304 BD_ADDR adv_addr; 1305 UINT8 adv_phy; 1306 UINT16 adv_interval; 1307 UINT8 adv_clk_accuracy; 1308 } tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV; 1309 #endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 1310 1311 typedef union { 1312 UINT8 status; 1313 tBTM_BLE_READ_PHY_CMPL read_phy; 1314 tBTM_BLE_SET_PREF_DEF_PHY_CMPL set_perf_def_phy; 1315 tBTM_BLE_SET_PERF_PHY_CMPL set_perf_phy; 1316 tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL set_ext_rand_addr; 1317 tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL set_params; 1318 tBTM_BLE_EXT_ADV_DATA_SET_CMPL adv_data_set; 1319 tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL scan_rsp_data_set; 1320 tBTM_BLE_EXT_ADV_START_CMPL adv_start; 1321 tBTM_BLE_EXT_ADV_STOP_CMPL adv_stop; 1322 tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL per_adv_set_params; 1323 tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL per_adv_data_set; 1324 tBTM_BLE_PERIOD_ADV_START_CMPL per_adv_start; 1325 tBTM_BLE_PERIOD_ADV_STOP_CMPL per_adv_stop; 1326 tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL per_adv_sync_create; 1327 tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL per_adv_sync_cancel; 1328 tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL per_adv_sync_term; 1329 tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL per_adv_add_dev; 1330 tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL per_adv_remove_dev; 1331 tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL per_adv_clear_dev; 1332 tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL ext_scan; 1333 tBTM_BLE_EXT_SCAN_START_CMPL scan_start; 1334 tBTM_BLE_EXT_SCAN_STOP_CMPL scan_stop; 1335 tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL ext_conn_set_params; 1336 tBTM_BLE_PHY_UPDATE_CMPL phy_update; 1337 tBTM_BLE_EXT_ADV_REPORT ext_adv_report; 1338 tBTM_BLE_ADV_TERMINAT adv_term; 1339 tBTM_BLE_SCAN_REQ_RECEIVED scan_req; 1340 tBTM_BLE_CHANNEL_SEL_ALG channel_sel; 1341 tBTM_PERIOD_ADV_REPORT period_adv_report; 1342 tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost; 1343 tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab; 1344 #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 1345 tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL per_adv_recv_enable; 1346 tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL per_adv_sync_trans; 1347 tBTM_BLE_PERIOD_ADV_SET_INFO_TRANS_CMPL per_adv_set_info_trans; 1348 tBTM_BLE_SET_PERIOD_ADV_SYNC_TRANS_PARAMS_CMPL set_past_params; 1349 tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV past_recv; 1350 #endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 1351 } tBTM_BLE_5_GAP_CB_PARAMS; 1352 1353 typedef struct { 1354 UINT8 phy_mask; 1355 tBTM_BLE_CONN_PARAMS phy_1m_conn_params; 1356 tBTM_BLE_CONN_PARAMS phy_2m_conn_params; 1357 tBTM_BLE_CONN_PARAMS phy_coded_conn_params; 1358 } tBTM_EXT_CONN_PARAMS; 1359 1360 typedef void (*tBTM_BLE_5_HCI_CBACK)(tBTM_BLE_5_GAP_EVENT event, tBTM_BLE_5_GAP_CB_PARAMS *params); 1361 1362 #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) 1363 1364 /***************************************************************************** 1365 ** EXTERNAL FUNCTION DECLARATIONS 1366 *****************************************************************************/ 1367 /* 1368 #ifdef __cplusplus 1369 extern "C" { 1370 #endif 1371 */ 1372 1373 /******************************************************************************* 1374 ** 1375 ** Function BTM_BleRegiseterConnParamCallback 1376 ** 1377 ** Description register connection parameters update callback func 1378 ** 1379 ** Parameters: update_conn_param_cb 1380 ** 1381 ** Returns void 1382 ** 1383 *******************************************************************************/ 1384 void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb); 1385 void BTM_BleRegiseterPktLengthChangeCallback(tBTM_SET_PKT_DATA_LENGTH_CBACK *ptk_len_chane_cb); 1386 1387 /******************************************************************************* 1388 ** 1389 ** Function BTM_SecAddBleDevice 1390 ** 1391 ** Description Add/modify device. This function will be normally called 1392 ** during host startup to restore all required information 1393 ** for a LE device stored in the NVRAM. 1394 ** 1395 ** Parameters: bd_addr - BD address of the peer 1396 ** bd_name - Name of the peer device. NULL if unknown. 1397 ** dev_type - Remote device's device type. 1398 ** addr_type - LE device address type. 1399 ** auth_mode - auth mode 1400 ** 1401 ** Returns TRUE if added OK, else FALSE 1402 ** 1403 *******************************************************************************/ 1404 //extern 1405 BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, 1406 tBT_DEVICE_TYPE dev_type, tBLE_ADDR_TYPE addr_type, UINT32 auth_mode); 1407 1408 /******************************************************************************* 1409 ** 1410 ** Function BTM_SecAddBleKey 1411 ** 1412 ** Description Add/modify LE device information. This function will be 1413 ** normally called during host startup to restore all required 1414 ** information stored in the NVRAM. 1415 ** 1416 ** Parameters: bd_addr - BD address of the peer 1417 ** p_le_key - LE key values. 1418 ** key_type - LE SMP key type. 1419 * 1420 ** Returns TRUE if added OK, else FALSE 1421 ** 1422 *******************************************************************************/ 1423 //extern 1424 BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, 1425 tBTM_LE_KEY_TYPE key_type); 1426 1427 /******************************************************************************* 1428 ** 1429 ** Function BTM_BleSetAdvParams 1430 ** 1431 ** Description This function is called to set advertising parameters. 1432 ** 1433 ** Parameters: None. 1434 ** 1435 ** Returns void 1436 ** 1437 *******************************************************************************/ 1438 //extern 1439 tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, 1440 tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map); 1441 1442 1443 1444 /******************************************************************************* 1445 ** 1446 ** Function BTM_BleSetAdvParamsAll 1447 ** 1448 ** Description This function is called to set all of the advertising parameters. 1449 ** 1450 ** Parameters: None. 1451 ** 1452 ** Returns void 1453 ** 1454 *******************************************************************************/ 1455 tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type, 1456 tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda, 1457 tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb); 1458 1459 /******************************************************************************* 1460 ** 1461 ** Function BTM_BleStartAdv 1462 ** 1463 ** Description This function is called to start adv. 1464 ** 1465 ** Parameters: None. 1466 ** 1467 ** Returns status 1468 ** 1469 *******************************************************************************/ 1470 tBTM_STATUS BTM_BleStartAdv(void); 1471 1472 1473 /******************************************************************************* 1474 ** 1475 ** Function BTM_BleWriteAdvData 1476 ** 1477 ** Description This function is called to write advertising data. 1478 ** 1479 ** Parameters: None. 1480 ** 1481 ** Returns void 1482 ** 1483 *******************************************************************************/ 1484 //extern 1485 tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, 1486 tBTM_BLE_ADV_DATA *p_data); 1487 1488 /******************************************************************************* 1489 ** 1490 ** Function BTM_BleWriteLongAdvData 1491 ** 1492 ** Description This function is called to write long advertising data. 1493 ** 1494 ** Parameters: adv_data: long advertising data 1495 ** adv_data_len: the length of long advertising data 1496 ** 1497 ** Returns void 1498 ** 1499 *******************************************************************************/ 1500 tBTM_STATUS BTM_BleWriteLongAdvData(uint8_t *adv_data, uint8_t adv_data_len); 1501 1502 /******************************************************************************* 1503 ** 1504 ** Function BTM_BleWriteAdvDataRaw 1505 ** 1506 ** Description This function is called to write raw advertising data. 1507 ** 1508 ** Parameters: p_raw_adv : point to raw advertising data 1509 ** raw_adv_len : raw advertising data 1510 ** 1511 ** Returns BTM_SUCCESS means success. 1512 ** 1513 *******************************************************************************/ 1514 //extern 1515 tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len); 1516 1517 1518 tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr); 1519 1520 void BTM_BleClearRandAddress(void); 1521 1522 1523 /******************************************************************************* 1524 ** 1525 ** Function BTM_BleSetAdvParams 1526 ** 1527 ** Description This function is called to set advertising parameters. 1528 ** 1529 ** Parameters adv_int_min: minimum advertising interval 1530 ** adv_int_max: maximum advertising interval 1531 ** p_dir_bda: connectable direct initiator's LE device address 1532 ** chnl_map: advertising channel map. 1533 ** 1534 ** Returns void 1535 ** 1536 *******************************************************************************/ 1537 //extern 1538 void BTM_BleReadAdvParams (UINT16 *adv_int_min, UINT16 *adv_int_max, 1539 tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP *p_chnl_map); 1540 1541 /******************************************************************************* 1542 ** 1543 ** Function BTM_BleObtainVendorCapabilities 1544 ** 1545 ** Description This function is called to obtain vendor capabilities 1546 ** 1547 ** Parameters p_cmn_vsc_cb - Returns the vendor capabilities 1548 ** 1549 ** Returns void 1550 ** 1551 *******************************************************************************/ 1552 //extern 1553 void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); 1554 1555 /******************************************************************************* 1556 ** 1557 ** Function BTM_BleSetScanParams 1558 ** 1559 ** Description This function is called to set Scan parameters. 1560 ** 1561 ** Parameters client_if - Client IF value 1562 ** scan_interval - Scan interval 1563 ** scan_window - Scan window 1564 ** scan_type - Scan type 1565 ** scan_setup_status_cback - Scan setup status callback 1566 ** 1567 ** Returns void 1568 ** 1569 *******************************************************************************/ 1570 //extern 1571 void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval, 1572 UINT32 scan_window, tBLE_SCAN_MODE scan_type, 1573 tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback); 1574 1575 1576 1577 /******************************************************************************* 1578 ** 1579 ** Function BTM_BleSetScanFilterParams 1580 ** 1581 ** Description This function is called to set Scan Filter & parameters. 1582 ** 1583 ** Parameters client_if - Client IF value 1584 ** scan_interval - Scan interval 1585 ** scan_window - Scan window 1586 ** scan_type - Scan type 1587 ** addr_type_own - owner address type 1588 ** scan_duplicate_filter - scan duplicate filter 1589 ** scan_filter_policy - scan filter policy 1590 ** scan_setup_status_cback - Scan setup status callback 1591 ** 1592 ** Returns void 1593 ** 1594 *******************************************************************************/ 1595 tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window, 1596 tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBTM_BLE_SFP scan_filter_policy, 1597 tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback); 1598 1599 1600 /******************************************************************************* 1601 ** 1602 ** Function BTM_BleGetVendorCapabilities 1603 ** 1604 ** Description This function reads local LE features 1605 ** 1606 ** Parameters p_cmn_vsc_cb : Locala LE capability structure 1607 ** 1608 ** Returns void 1609 ** 1610 *******************************************************************************/ 1611 //extern 1612 void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB *p_cmn_vsc_cb); 1613 /******************************************************************************* 1614 ** 1615 ** Function BTM_BleSetStorageConfig 1616 ** 1617 ** Description This function is called to setup storage configuration and setup callbacks. 1618 ** 1619 ** Parameters UINT8 batch_scan_full_max -Batch scan full maximum 1620 UINT8 batch_scan_trunc_max - Batch scan truncated value maximum 1621 UINT8 batch_scan_notify_threshold - Threshold value 1622 tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback - Setup callback 1623 tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback 1624 void *p_ref - Reference value 1625 ** 1626 ** Returns tBTM_STATUS 1627 ** 1628 *******************************************************************************/ 1629 //extern 1630 tBTM_STATUS BTM_BleSetStorageConfig(UINT8 batch_scan_full_max, 1631 UINT8 batch_scan_trunc_max, 1632 UINT8 batch_scan_notify_threshold, 1633 tBTM_BLE_SCAN_SETUP_CBACK *p_setup_cback, 1634 tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback, 1635 tBTM_BLE_SCAN_REP_CBACK *p_cback, 1636 tBTM_BLE_REF_VALUE ref_value); 1637 1638 /******************************************************************************* 1639 ** 1640 ** Function BTM_BleEnableBatchScan 1641 ** 1642 ** Description This function is called to enable batch scan 1643 ** 1644 ** Parameters tBTM_BLE_BATCH_SCAN_MODE scan_mode - Batch scan mode 1645 UINT32 scan_interval -Scan interval 1646 UINT32 scan_window - Scan window value 1647 tBLE_ADDR_TYPE addr_type - Address type 1648 tBTM_BLE_DISCARD_RULE discard_rule - Data discard rules 1649 ** 1650 ** Returns tBTM_STATUS 1651 ** 1652 *******************************************************************************/ 1653 //extern 1654 tBTM_STATUS BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode, 1655 UINT32 scan_interval, UINT32 scan_window, 1656 tBTM_BLE_DISCARD_RULE discard_rule, 1657 tBLE_ADDR_TYPE addr_type, 1658 tBTM_BLE_REF_VALUE ref_value); 1659 1660 /******************************************************************************* 1661 ** 1662 ** Function BTM_BleDisableBatchScan 1663 ** 1664 ** Description This function is called to disable batch scanning 1665 ** 1666 ** Parameters void 1667 ** 1668 ** Returns void 1669 ** 1670 *******************************************************************************/ 1671 //extern 1672 tBTM_STATUS BTM_BleDisableBatchScan(tBTM_BLE_REF_VALUE ref_value); 1673 1674 /******************************************************************************* 1675 ** 1676 ** Function BTM_BleReadScanReports 1677 ** 1678 ** Description This function is called to read batch scan reports 1679 ** 1680 ** Parameters tBLE_SCAN_MODE scan_mode - Scan mode report to be read out 1681 tBTM_BLE_SCAN_REP_CBACK* p_cback - Reports callback 1682 ** 1683 ** Returns tBTM_STATUS 1684 ** 1685 *******************************************************************************/ 1686 //extern 1687 tBTM_STATUS BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode, 1688 tBTM_BLE_REF_VALUE ref_value); 1689 1690 /******************************************************************************* 1691 ** 1692 ** Function BTM_BleTrackAdvertiser 1693 ** 1694 ** Description This function is called to read batch scan reports 1695 ** 1696 ** Parameters p_track_cback - Tracking callback 1697 ** ref_value - Reference value 1698 ** 1699 ** Returns tBTM_STATUS 1700 ** 1701 *******************************************************************************/ 1702 //extern 1703 tBTM_STATUS BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK *p_track_cback, 1704 tBTM_BLE_REF_VALUE ref_value); 1705 1706 /******************************************************************************* 1707 ** 1708 ** Function BTM_BleWriteScanRsp 1709 ** 1710 ** Description This function is called to write LE scan response. 1711 ** 1712 ** Parameters: p_scan_rsp: scan response. 1713 ** 1714 ** Returns status 1715 ** 1716 *******************************************************************************/ 1717 //extern 1718 tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask, 1719 tBTM_BLE_ADV_DATA *p_data); 1720 1721 /******************************************************************************* 1722 ** 1723 ** Function BTM_BleWriteScanRspRaw 1724 ** 1725 ** Description This function is called to write raw scan response data 1726 ** 1727 ** Parameters: None. 1728 ** 1729 ** Returns void 1730 ** 1731 *******************************************************************************/ 1732 //extern 1733 tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len); 1734 1735 /******************************************************************************* 1736 ** 1737 ** Function BTM_BleObserve 1738 ** 1739 ** Description This procedure keep the device listening for advertising 1740 ** events from a broadcast device. 1741 ** 1742 ** Parameters start: start or stop observe. 1743 ** 1744 ** Returns void 1745 ** 1746 *******************************************************************************/ 1747 //extern 1748 tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration, 1749 tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb); 1750 1751 /******************************************************************************* 1752 ** 1753 ** Function BTM_BleScan 1754 ** 1755 ** Description This procedure keep the device listening for advertising 1756 ** events from a broadcast device. 1757 ** 1758 ** Parameters start: start or stop scan. 1759 ** 1760 ** Returns void 1761 ** 1762 *******************************************************************************/ 1763 //extern 1764 tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration, 1765 tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb); 1766 1767 1768 /******************************************************************************* 1769 ** 1770 ** Function BTM_GetDeviceIDRoot 1771 ** 1772 ** Description This function is called to read the local device identity 1773 ** root. 1774 ** 1775 ** Returns void 1776 ** the local device ER is copied into er 1777 ** 1778 *******************************************************************************/ 1779 //extern 1780 void BTM_GetDeviceIDRoot (BT_OCTET16 ir); 1781 1782 /******************************************************************************* 1783 ** 1784 ** Function BTM_GetDeviceEncRoot 1785 ** 1786 ** Description This function is called to read the local device encryption 1787 ** root. 1788 ** 1789 ** Returns void 1790 ** the local device ER is copied into er 1791 ** 1792 *******************************************************************************/ 1793 //extern 1794 void BTM_GetDeviceEncRoot (BT_OCTET16 er); 1795 1796 /******************************************************************************* 1797 ** 1798 ** Function BTM_GetDeviceDHK 1799 ** 1800 ** Description This function is called to read the local device DHK. 1801 ** 1802 ** Returns void 1803 ** the local device DHK is copied into dhk 1804 ** 1805 *******************************************************************************/ 1806 //extern 1807 void BTM_GetDeviceDHK (BT_OCTET16 dhk); 1808 1809 /******************************************************************************* 1810 ** 1811 ** Function BTM_SecurityGrant 1812 ** 1813 ** Description This function is called to grant security process. 1814 ** 1815 ** Parameters bd_addr - peer device bd address. 1816 ** res - result of the operation BTM_SUCCESS if success. 1817 ** Otherwise, BTM_REPEATED_ATTEMPTS is too many attempts. 1818 ** 1819 ** Returns None 1820 ** 1821 *******************************************************************************/ 1822 //extern 1823 void BTM_SecurityGrant(BD_ADDR bd_addr, UINT8 res); 1824 1825 /******************************************************************************* 1826 ** 1827 ** Function BTM_BlePasskeyReply 1828 ** 1829 ** Description This function is called after Security Manager submitted 1830 ** passkey request to the application. 1831 ** 1832 ** Parameters: bd_addr - Address of the device for which passkey was requested 1833 ** res - result of the operation SMP_SUCCESS if success 1834 ** passkey - numeric value in the range of 1835 ** BTM_MIN_PASSKEY_VAL(0) - BTM_MAX_PASSKEY_VAL(999999(0xF423F)). 1836 ** 1837 *******************************************************************************/ 1838 //extern 1839 void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey); 1840 1841 /******************************************************************************* 1842 ** 1843 ** Function BTM_BleSetStaticPasskey 1844 ** 1845 ** Description This function is called to set static passkey 1846 ** 1847 ** 1848 ** Parameters: add - set static passkey when add is TRUE 1849 ** clear static passkey when add is FALSE 1850 ** passkey - static passkey 1851 ** 1852 ** 1853 *******************************************************************************/ 1854 void BTM_BleSetStaticPasskey(BOOLEAN add, UINT32 passkey); 1855 1856 /******************************************************************************* 1857 ** 1858 ** Function BTM_BleConfirmReply 1859 ** 1860 ** Description This function is called after Security Manager submitted 1861 ** numeric comparison request to the application. 1862 ** 1863 ** Parameters: bd_addr - Address of the device with which numeric 1864 ** comparison was requested 1865 ** res - comparison result BTM_SUCCESS if success 1866 ** 1867 *******************************************************************************/ 1868 //extern 1869 void BTM_BleConfirmReply (BD_ADDR bd_addr, UINT8 res); 1870 1871 /******************************************************************************* 1872 ** 1873 ** Function BTM_LeOobDataReply 1874 ** 1875 ** Description This function is called to provide the OOB data for 1876 ** SMP in response to BTM_LE_OOB_REQ_EVT 1877 ** 1878 ** Parameters: bd_addr - Address of the peer device 1879 ** res - result of the operation SMP_SUCCESS if success 1880 ** p_data - simple pairing Randomizer C. 1881 ** 1882 *******************************************************************************/ 1883 //extern 1884 void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data); 1885 1886 /******************************************************************************* 1887 ** 1888 ** Function BTM_BleSecureConnectionOobDataReply 1889 ** 1890 ** Description This function is called to provide the OOB data for 1891 ** SMP in response to BTM_LE_SC_OOB_REQ_EVT when secure connection 1892 ** 1893 ** Parameters: bd_addr - Address of the peer device 1894 ** p_c - pointer to Confirmation 1895 ** p_r - pointer to Randomizer 1896 ** 1897 *******************************************************************************/ 1898 void BTM_BleSecureConnectionOobDataReply(BD_ADDR bd_addr, UINT8 *p_c, UINT8 *p_r); 1899 1900 /******************************************************************************* 1901 ** 1902 ** Function BTM_BleSecureConnectionCreateOobData 1903 ** 1904 ** Description This function is called to create the OOB data for 1905 ** SMP when secure connection 1906 ** 1907 *******************************************************************************/ 1908 void BTM_BleSecureConnectionCreateOobData(void); 1909 1910 /******************************************************************************* 1911 ** 1912 ** Function BTM_BleDataSignature 1913 ** 1914 ** Description This function is called to sign the data using AES128 CMAC 1915 ** algorithm. 1916 ** 1917 ** Parameter bd_addr: target device the data to be signed for. 1918 ** p_text: singing data 1919 ** len: length of the signing data 1920 ** signature: output parameter where data signature is going to 1921 ** be stored. 1922 ** 1923 ** Returns TRUE if signing successful, otherwise FALSE. 1924 ** 1925 *******************************************************************************/ 1926 //extern 1927 BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, 1928 BLE_SIGNATURE signature); 1929 1930 /******************************************************************************* 1931 ** 1932 ** Function BTM_BleVerifySignature 1933 ** 1934 ** Description This function is called to verify the data signature 1935 ** 1936 ** Parameter bd_addr: target device the data to be signed for. 1937 ** p_orig: original data before signature. 1938 ** len: length of the signing data 1939 ** counter: counter used when doing data signing 1940 ** p_comp: signature to be compared against. 1941 1942 ** Returns TRUE if signature verified correctly; otherwise FALSE. 1943 ** 1944 *******************************************************************************/ 1945 //extern 1946 BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, 1947 UINT16 len, UINT32 counter, 1948 UINT8 *p_comp); 1949 1950 /******************************************************************************* 1951 ** 1952 ** Function BTM_ReadConnectionAddr 1953 ** 1954 ** Description This function is called to set the local device random address 1955 ** . 1956 ** 1957 ** Returns void 1958 ** 1959 *******************************************************************************/ 1960 //extern 1961 void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr, 1962 tBLE_ADDR_TYPE *p_addr_type); 1963 1964 1965 1966 /******************************************************************************* 1967 ** 1968 ** Function BTM_ReadRemoteConnectionAddr 1969 ** 1970 ** Description This function is read the remote device address currently used 1971 ** . 1972 ** 1973 ** Returns void 1974 ** 1975 *******************************************************************************/ 1976 //extern 1977 BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr, 1978 BD_ADDR conn_addr, 1979 tBLE_ADDR_TYPE *p_addr_type); 1980 1981 /******************************************************************************* 1982 ** 1983 ** Function BTM_BleLoadLocalKeys 1984 ** 1985 ** Description Local local identity key, encryption root or sign counter. 1986 ** 1987 ** Parameters: key_type: type of key, can be BTM_BLE_KEY_TYPE_ID, BTM_BLE_KEY_TYPE_ER 1988 ** or BTM_BLE_KEY_TYPE_COUNTER. 1989 ** p_key: pointer to the key. 1990 * 1991 ** Returns non2. 1992 ** 1993 *******************************************************************************/ 1994 //extern 1995 void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key); 1996 1997 1998 /******************************************************************************* 1999 ** 2000 ** Function BTM_BleSetBgConnType 2001 ** 2002 ** Description This function is called to set BLE background connection 2003 ** procedure type. It can be auto connection, or selective connection. 2004 ** 2005 ** Parameters conn_type: it can be auto connection, or selective connection. 2006 ** p_select_cback: callback function when selective connection procedure 2007 ** is being used. 2008 ** 2009 ** Returns void 2010 ** 2011 *******************************************************************************/ 2012 //extern 2013 BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE conn_type, 2014 tBTM_BLE_SEL_CBACK *p_select_cback); 2015 2016 /******************************************************************************* 2017 ** 2018 ** Function BTM_BleUpdateBgConnDev 2019 ** 2020 ** Description This function is called to add or remove a device into/from 2021 ** background connection procedure. The background connection 2022 * procedure is decided by the background connection type, it can be 2023 * auto connection, or selective connection. 2024 ** 2025 ** Parameters add_remove: TRUE to add; FALSE to remove. 2026 ** remote_bda: device address to add/remove. 2027 ** 2028 ** Returns void 2029 ** 2030 *******************************************************************************/ 2031 //extern 2032 BOOLEAN BTM_BleUpdateBgConnDev(BOOLEAN add_remove, BD_ADDR remote_bda); 2033 2034 /******************************************************************************* 2035 ** 2036 ** Function BTM_BleClearBgConnDev 2037 ** 2038 ** Description This function is called to clear the whitelist, 2039 ** end any pending whitelist connections, 2040 * and reset the local bg device list. 2041 ** 2042 ** Parameters void 2043 ** 2044 ** Returns void 2045 ** 2046 *******************************************************************************/ 2047 //extern 2048 void BTM_BleClearBgConnDev(void); 2049 2050 /******************************************************** 2051 ** 2052 ** Function BTM_BleSetPrefConnParams 2053 ** 2054 ** Description Set a peripheral's preferred connection parameters. When 2055 ** any of the value does not want to be updated while others 2056 ** do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to 2057 ** leave untouched. 2058 ** 2059 ** Parameters: bd_addr - BD address of the peripheral 2060 ** min_conn_int - minimum preferred connection interval 2061 ** max_conn_int - maximum preferred connection interval 2062 ** slave_latency - preferred slave latency 2063 ** supervision_tout - preferred supervision timeout 2064 ** 2065 ** Returns void 2066 ** 2067 *******************************************************************************/ 2068 //extern 2069 void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, 2070 UINT16 min_conn_int, UINT16 max_conn_int, 2071 UINT16 slave_latency, UINT16 supervision_tout); 2072 2073 /****************************************************************************** 2074 ** 2075 ** Function BTM_BleSetConnScanParams 2076 ** 2077 ** Description Set scan parameters used in BLE connection request 2078 ** 2079 ** Parameters: scan_interval - scan interval 2080 ** scan_window - scan window 2081 ** 2082 ** Returns void 2083 ** 2084 *******************************************************************************/ 2085 //extern 2086 void BTM_BleSetConnScanParams (UINT32 scan_interval, UINT32 scan_window); 2087 2088 /****************************************************************************** 2089 ** 2090 ** Function BTM_BleReadControllerFeatures 2091 ** 2092 ** Description Reads BLE specific controller features 2093 ** 2094 ** Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when features are read 2095 ** 2096 ** Returns void 2097 ** 2098 *******************************************************************************/ 2099 //extern 2100 void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback); 2101 2102 /******************************************************************************* 2103 ** 2104 ** Function BTM_CheckAdvData 2105 ** 2106 ** Description This function is called to get ADV data for a specific type. 2107 ** 2108 ** Parameters p_adv - pointer of ADV data 2109 ** type - finding ADV data type 2110 ** p_length - return the length of ADV data not including type 2111 ** 2112 ** Returns pointer of ADV data 2113 ** 2114 *******************************************************************************/ 2115 //extern 2116 UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT16 adv_data_len, UINT8 type, UINT8 *p_length); 2117 2118 /******************************************************************************* 2119 ** 2120 ** Function BTM_BleGetCurrentAddress 2121 ** 2122 ** Description This function is called to get local used BLE address. 2123 ** 2124 ** Parameters: None. 2125 ** 2126 ** Returns success or fail 2127 ** 2128 *******************************************************************************/ 2129 BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type); 2130 2131 /******************************************************************************* 2132 ** 2133 ** Function BTM__BLEReadDiscoverability 2134 ** 2135 ** Description This function is called to read the current LE discoverability 2136 ** mode of the device. 2137 ** 2138 ** Returns BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or 2139 ** BTM_BLE_GENRAL_DISCOVERABLE 2140 ** 2141 *******************************************************************************/ 2142 UINT16 BTM_BleReadDiscoverability(void); 2143 2144 /******************************************************************************* 2145 ** 2146 ** Function BTM__BLEReadConnectability 2147 ** 2148 ** Description This function is called to read the current LE connectibility 2149 ** mode of the device. 2150 ** 2151 ** Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE 2152 ** 2153 *******************************************************************************/ 2154 //extern 2155 UINT16 BTM_BleReadConnectability (void); 2156 2157 void BTM_Recovery_Pre_State(void); 2158 2159 /******************************************************************************* 2160 ** 2161 ** Function BTM_ReadDevInfo 2162 ** 2163 ** Description This function is called to read the device/address type 2164 ** of BD address. 2165 ** 2166 ** Parameter remote_bda: remote device address 2167 ** p_dev_type: output parameter to read the device type. 2168 ** p_addr_type: output parameter to read the address type. 2169 ** 2170 *******************************************************************************/ 2171 //extern 2172 void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, 2173 tBLE_ADDR_TYPE *p_addr_type); 2174 2175 2176 /******************************************************************************* 2177 ** 2178 ** Function BTM_ReadConnectedTransportAddress 2179 ** 2180 ** Description This function is called to read the paired device/address type of other device paired 2181 ** corresponding to the BD_address 2182 ** 2183 ** Parameter remote_bda: remote device address, carry out the transport address 2184 ** transport: active transport 2185 ** 2186 ** Return TRUE if an active link is identified; FALSE otherwise 2187 ** 2188 *******************************************************************************/ 2189 //extern 2190 BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda, 2191 tBT_TRANSPORT transport); 2192 2193 /******************************************************************************* 2194 ** 2195 ** Function BTM_BleBroadcast 2196 ** 2197 ** Description This function is to start or stop broadcasting. 2198 ** 2199 ** Parameters start: start or stop broadcasting. 2200 ** 2201 ** Returns status. 2202 ** 2203 *******************************************************************************/ 2204 //extern 2205 tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback); 2206 2207 /******************************************************************************* 2208 ** 2209 ** Function BTM_BleConfigPrivacy 2210 ** 2211 ** Description This function is called to enable or disable the privacy in 2212 ** the local device. 2213 ** 2214 ** Parameters enable: TRUE to enable it; FALSE to disable it. 2215 ** 2216 ** Returns BOOLEAN privacy mode set success; otherwise failed. 2217 ** 2218 *******************************************************************************/ 2219 //extern 2220 BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck); 2221 2222 /******************************************************************************* 2223 ** 2224 ** Function BTM_BleConfigLocalIcon 2225 ** 2226 ** Description This function is called to set local icon 2227 ** 2228 ** Parameters icon: appearance value. 2229 ** 2230 ** 2231 *******************************************************************************/ 2232 void BTM_BleConfigLocalIcon(uint16_t icon); 2233 2234 /******************************************************************************* 2235 ** 2236 ** Function BTM_BleConfigConnParams 2237 ** 2238 ** Description This function is called to set the connection parameters 2239 ** 2240 ** Parameters int_min: minimum connection interval 2241 ** int_max: maximum connection interval 2242 ** latency: slave latency 2243 ** timeout: supervision timeout 2244 ** 2245 *******************************************************************************/ 2246 void BTM_BleConfigConnParams(uint16_t int_min, uint16_t int_max, uint16_t latency, uint16_t timeout); 2247 2248 /******************************************************************************* 2249 ** 2250 ** Function BTM_BleLocalPrivacyEnabled 2251 ** 2252 ** Description Checks if local device supports private address 2253 ** 2254 ** Returns Return TRUE if local privacy is enabled else FALSE 2255 ** 2256 *******************************************************************************/ 2257 //extern 2258 BOOLEAN BTM_BleLocalPrivacyEnabled(void); 2259 2260 /******************************************************************************* 2261 ** 2262 ** Function BTM_BleEnableMixedPrivacyMode 2263 ** 2264 ** Description This function is called to enabled Mixed mode if privacy 1.2 2265 ** is applicable in controller. 2266 ** 2267 ** Parameters mixed_on: mixed mode to be used or not. 2268 ** 2269 ** Returns void 2270 ** 2271 *******************************************************************************/ 2272 //extern 2273 void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on); 2274 2275 /******************************************************************************* 2276 ** 2277 ** Function BTM_BleMaxMultiAdvInstanceCount 2278 ** 2279 ** Description Returns max number of multi adv instances supported by controller 2280 ** 2281 ** Returns Max multi adv instance count 2282 ** 2283 *******************************************************************************/ 2284 //extern 2285 UINT8 BTM_BleMaxMultiAdvInstanceCount(void); 2286 2287 /******************************************************************************* 2288 ** 2289 ** Function BTM_BleSetConnectableMode 2290 ** 2291 ** Description This function is called to set BLE connectable mode for a 2292 ** peripheral device. 2293 ** 2294 ** Parameters connectable_mode: directed connectable mode, or non-directed.It can 2295 ** be BTM_BLE_CONNECT_EVT, BTM_BLE_CONNECT_DIR_EVT or 2296 ** BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 2297 ** 2298 ** Returns BTM_ILLEGAL_VALUE if controller does not support BLE. 2299 ** BTM_SUCCESS is status set successfully; otherwise failure. 2300 ** 2301 *******************************************************************************/ 2302 //extern 2303 tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode); 2304 2305 /******************************************************************************* 2306 ** 2307 ** Function BTM_BleTurnOnPrivacyOnRemote 2308 ** 2309 ** Description This function is called to enable or disable the privacy on the 2310 ** remote device. 2311 ** 2312 ** Parameters bd_addr: remote device address. 2313 ** privacy_on: TRUE to enable it; FALSE to disable it. 2314 ** 2315 ** Returns void 2316 ** 2317 *******************************************************************************/ 2318 //extern 2319 void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr, 2320 BOOLEAN privacy_on); 2321 2322 /******************************************************************************* 2323 ** 2324 ** Function BTM_BleUpdateAdvWhitelist 2325 ** 2326 ** Description Add or remove device from advertising white list 2327 ** 2328 ** Returns void 2329 ** 2330 *******************************************************************************/ 2331 //extern 2332 BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb); 2333 2334 /******************************************************************************* 2335 ** 2336 ** Function BTM_BleClearWhitelist 2337 ** 2338 ** Description Clear all white list 2339 ** 2340 ** Returns void 2341 ** 2342 *******************************************************************************/ 2343 void BTM_BleClearWhitelist(tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb); 2344 2345 /******************************************************************************* 2346 ** 2347 ** Function BTM_BleUpdateAdvFilterPolicy 2348 ** 2349 ** Description This function update the filter policy of advertiser. 2350 ** 2351 ** Parameter adv_policy: advertising filter policy 2352 ** 2353 ** Return void 2354 *******************************************************************************/ 2355 //extern 2356 void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy); 2357 2358 /******************************************************************************* 2359 ** 2360 ** Function BTM_BleReceiverTest 2361 ** 2362 ** Description This function is called to start the LE Receiver test 2363 ** 2364 ** Parameter rx_freq - Frequency Range 2365 ** p_cmd_cmpl_cback - Command Complete callback 2366 ** 2367 *******************************************************************************/ 2368 void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback); 2369 2370 2371 /******************************************************************************* 2372 ** 2373 ** Function BTM_BleTransmitterTest 2374 ** 2375 ** Description This function is called to start the LE Transmitter test 2376 ** 2377 ** Parameter tx_freq - Frequency Range 2378 ** test_data_len - Length in bytes of payload data in each packet 2379 ** packet_payload - Pattern to use in the payload 2380 ** p_cmd_cmpl_cback - Command Complete callback 2381 ** 2382 *******************************************************************************/ 2383 void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, 2384 UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback); 2385 2386 /******************************************************************************* 2387 ** 2388 ** Function BTM_BleTestEnd 2389 ** 2390 ** Description This function is called to stop the in-progress TX or RX test 2391 ** 2392 ** Parameter p_cmd_cmpl_cback - Command complete callback 2393 ** 2394 *******************************************************************************/ 2395 void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback); 2396 2397 /******************************************************************************* 2398 ** 2399 ** Function BTM_UseLeLink 2400 ** 2401 ** Description This function is to select the underneath physical link to use. 2402 ** 2403 ** Returns TRUE to use LE, FALSE use BR/EDR. 2404 ** 2405 *******************************************************************************/ 2406 //extern 2407 BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr); 2408 2409 /******************************************************************************* 2410 ** 2411 ** Function BTM_BleStackEnable 2412 ** 2413 ** Description Enable/Disable BLE functionality on stack regardless controller 2414 ** capability. 2415 ** 2416 ** Parameters: enable: TRUE to enable, FALSE to disable. 2417 ** 2418 ** Returns TRUE if added OK, else FALSE 2419 ** 2420 *******************************************************************************/ 2421 //extern 2422 tBTM_STATUS BTM_BleStackEnable (BOOLEAN enable); 2423 2424 /******************************************************************************* 2425 ** 2426 ** Function BTM_GetLeSecurityState 2427 ** 2428 ** Description This function is called to get security mode 1 flags and 2429 ** encryption key size for LE peer. 2430 ** 2431 ** Returns BOOLEAN TRUE if LE device is found, FALSE otherwise. 2432 ** 2433 *******************************************************************************/ 2434 //extern 2435 BOOLEAN BTM_GetLeSecurityState (BD_ADDR bd_addr, 2436 UINT8 *p_le_dev_sec_flags, 2437 UINT8 *p_le_key_size); 2438 2439 /******************************************************************************* 2440 ** 2441 ** Function BTM_BleSecurityProcedureIsRunning 2442 ** 2443 ** Description This function indicates if LE security procedure is 2444 ** currently running with the peer. 2445 ** 2446 ** Returns BOOLEAN TRUE if security procedure is running, FALSE otherwise. 2447 ** 2448 *******************************************************************************/ 2449 //extern 2450 BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr); 2451 2452 /******************************************************************************* 2453 ** 2454 ** Function BTM_BleGetSupportedKeySize 2455 ** 2456 ** Description This function gets the maximum encryption key size in bytes 2457 ** the local device can support. 2458 ** record. 2459 ** 2460 ** Returns the key size or 0 if the size can't be retrieved. 2461 ** 2462 *******************************************************************************/ 2463 //extern 2464 UINT8 BTM_BleGetSupportedKeySize (BD_ADDR bd_addr); 2465 2466 /*******************************************************************************/ 2467 /* Multi ADV API */ 2468 /******************************************************************************* 2469 ** 2470 ** Function BTM_BleEnableAdvInstance 2471 ** 2472 ** Description This function enable a Multi-ADV instance with the specified 2473 ** adv parameters 2474 ** 2475 ** Parameters p_params: pointer to the adv parameter structure, set as default 2476 ** adv parameter when the instance is enabled. 2477 ** p_cback: callback function for the adv instance. 2478 ** p_ref: reference data attach to the adv instance to be enabled. 2479 ** 2480 ** Returns status 2481 ** 2482 *******************************************************************************/ 2483 //extern 2484 tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params, 2485 tBTM_BLE_MULTI_ADV_CBACK *p_cback, 2486 void *p_ref); 2487 2488 /******************************************************************************* 2489 ** 2490 ** Function BTM_BleUpdateAdvInstParam 2491 ** 2492 ** Description This function update a Multi-ADV instance with the specified 2493 ** adv parameters. 2494 ** 2495 ** Parameters inst_id: adv instance ID 2496 ** p_params: pointer to the adv parameter structure. 2497 ** 2498 ** Returns status 2499 ** 2500 *******************************************************************************/ 2501 //extern 2502 tBTM_STATUS BTM_BleUpdateAdvInstParam (UINT8 inst_id, tBTM_BLE_ADV_PARAMS *p_params); 2503 2504 /******************************************************************************* 2505 ** 2506 ** Function BTM_BleCfgAdvInstData 2507 ** 2508 ** Description This function configure a Multi-ADV instance with the specified 2509 ** adv data or scan response data. 2510 ** 2511 ** Parameters inst_id: adv instance ID 2512 ** is_scan_rsp: is this scacn response, if no set as adv data. 2513 ** data_mask: adv data mask. 2514 ** p_data: pointer to the adv data structure. 2515 ** 2516 ** Returns status 2517 ** 2518 *******************************************************************************/ 2519 //extern 2520 tBTM_STATUS BTM_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp, 2521 tBTM_BLE_AD_MASK data_mask, 2522 tBTM_BLE_ADV_DATA *p_data); 2523 2524 /******************************************************************************* 2525 ** 2526 ** Function BTM_BleDisableAdvInstance 2527 ** 2528 ** Description This function disable a Multi-ADV instance. 2529 ** 2530 ** Parameters inst_id: adv instance ID 2531 ** 2532 ** Returns status 2533 ** 2534 *******************************************************************************/ 2535 //extern 2536 tBTM_STATUS BTM_BleDisableAdvInstance (UINT8 inst_id); 2537 2538 /******************************************************************************* 2539 ** 2540 ** Function BTM_BleAdvFilterParamSetup 2541 ** 2542 ** Description This function is called to setup the adv data payload filter 2543 ** condition. 2544 ** 2545 ** Parameters p_target: enabble the filter condition on a target device; if NULL 2546 ** enable the generic scan condition. 2547 ** enable: enable or disable the filter condition 2548 ** 2549 ** Returns void 2550 ** 2551 *******************************************************************************/ 2552 //extern 2553 tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, 2554 tBTM_BLE_PF_FILT_INDEX filt_index, 2555 tBTM_BLE_PF_FILT_PARAMS *p_filt_params, 2556 tBLE_BD_ADDR *p_target, tBTM_BLE_PF_PARAM_CBACK *p_cmpl_cback, 2557 tBTM_BLE_REF_VALUE ref_value); 2558 2559 /******************************************************************************* 2560 ** 2561 ** Function BTM_BleCfgFilterCondition 2562 ** 2563 ** Description This function is called to configure the adv data payload filter 2564 ** condition. 2565 ** 2566 ** Parameters action: to read/write/clear 2567 ** cond_type: filter condition type. 2568 ** p_cond: filter condition parameter 2569 ** 2570 ** Returns tBTM_STATUS 2571 ** 2572 *******************************************************************************/ 2573 //extern 2574 tBTM_STATUS BTM_BleCfgFilterCondition(tBTM_BLE_SCAN_COND_OP action, 2575 tBTM_BLE_PF_COND_TYPE cond_type, 2576 tBTM_BLE_PF_FILT_INDEX filt_index, 2577 tBTM_BLE_PF_COND_PARAM *p_cond, 2578 tBTM_BLE_PF_CFG_CBACK *p_cmpl_cback, 2579 tBTM_BLE_REF_VALUE ref_value); 2580 2581 /******************************************************************************* 2582 ** 2583 ** Function BTM_BleEnableDisableFilterFeature 2584 ** 2585 ** Description This function is called to enable or disable the APCF feature 2586 ** 2587 ** Parameters enable - TRUE - enables the APCF, FALSE - disables the APCF 2588 ** ref_value - Ref value 2589 ** 2590 ** Returns tBTM_STATUS 2591 ** 2592 *******************************************************************************/ 2593 //extern 2594 tBTM_STATUS BTM_BleEnableDisableFilterFeature(UINT8 enable, 2595 tBTM_BLE_PF_STATUS_CBACK *p_stat_cback, 2596 tBTM_BLE_REF_VALUE ref_value); 2597 2598 /******************************************************************************* 2599 ** 2600 ** Function BTM_BleGetEnergyInfo 2601 ** 2602 ** Description This function obtains the energy info 2603 ** 2604 ** Parameters p_ener_cback - Callback pointer 2605 ** 2606 ** Returns status 2607 ** 2608 *******************************************************************************/ 2609 //extern 2610 tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK *p_ener_cback); 2611 2612 /******************************************************************************* 2613 ** 2614 ** Function BTM_SetBleDataLength 2615 ** 2616 ** Description This function is called to set maximum BLE transmission packet size 2617 ** 2618 ** Returns BTM_SUCCESS if success; otherwise failed. 2619 ** 2620 *******************************************************************************/ 2621 //extern 2622 tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length); 2623 2624 /******************************************************************************* 2625 ** 2626 ** Function BTM_UpdateBleDuplicateExceptionalList 2627 ** 2628 ** Description This function is called to update duplicate scan exceptional list. 2629 ** 2630 ** Parameters: subcode: add, remove or clean duplicate scan exceptional list. 2631 ** type: device info type 2632 ** device_info: device information 2633 ** update_exceptional_list_cmp_cb: complete callback 2634 ** 2635 ** Returns status 2636 ** 2637 *******************************************************************************/ 2638 2639 tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info, tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb); 2640 2641 /******************************************************************************* 2642 ** 2643 ** Function BTM_GetCurrentConnParams 2644 ** 2645 ** Description This function is called to read the current connection parameters 2646 ** of the device 2647 ** 2648 ** Returns TRUE or FALSE 2649 ** 2650 *******************************************************************************/ 2651 2652 BOOLEAN BTM_GetCurrentConnParams(BD_ADDR bda, uint16_t *interval, uint16_t *latency, uint16_t *timeout); 2653 2654 /******************************************************************************* 2655 ** 2656 ** Function BTM_Ble_Authorization 2657 ** 2658 ** Description This function is used to authorize a specified device 2659 ** 2660 ** Returns TRUE or FALSE 2661 ** 2662 *******************************************************************************/ 2663 BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize); 2664 2665 /******************************************************************************* 2666 ** 2667 ** Function BTM_BleClearAdv 2668 ** 2669 ** Description This function is called to clear legacy advertising 2670 ** 2671 ** Parameter p_clear_adv_cback - Command complete callback 2672 ** 2673 *******************************************************************************/ 2674 BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback); 2675 2676 /******************************************************************************* 2677 ** 2678 ** Function BTM_BleSetRpaTimeout 2679 ** 2680 ** Description This function is called to set the Resolvable Private Address 2681 ** (RPA) timeout. 2682 ** 2683 ** Parameter rpa_timeout - The timeout value for RPA, typically in seconds. 2684 ** 2685 *******************************************************************************/ 2686 BOOLEAN BTM_BleSetRpaTimeout(uint16_t rpa_timeout, tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback); 2687 2688 /******************************************************************************* 2689 ** 2690 ** Function BTM_BleAddDevToResolvingList 2691 ** 2692 ** Description This function is called to add a device to the resolving list 2693 ** used to generate and resolve Resolvable Private Addresses (RPAs) 2694 ** in the Bluetooth Controller. 2695 ** 2696 ** Parameters addr - The address of the device to be added to the resolving list. 2697 ** addr_type - The address type of the device (public or random). 2698 ** irk - The Identity Resolving Key (IRK) of the device. 2699 ** p_add_dev_to_resolving_list_callback - Callback function to be called when the operation is completed. 2700 ** 2701 ** Returns TRUE if the operation was successful, otherwise FALSE. 2702 ** 2703 *******************************************************************************/ 2704 BOOLEAN BTM_BleAddDevToResolvingList(BD_ADDR addr, 2705 uint8_t addr_type, 2706 uint8_t irk[], 2707 tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_add_dev_to_resolving_list_callback); 2708 2709 /******************************************************************************* 2710 ** 2711 ** Function BTM_BleSetPrivacyMode 2712 ** 2713 ** Description This function is called to set the privacy mode of device in resolving list 2714 ** 2715 ** Parameters addr_type - The address type of the device in resolving list (public or random). 2716 ** addr - The address of the device in resolving list. 2717 ** privacy_mode - The privacy mode (network or device) of the device. 2718 ** p_callback - Callback function to be called when the operation is completed. 2719 ** 2720 ** Returns TRUE if the operation was successful, otherwise FALSE. 2721 ** 2722 *******************************************************************************/ 2723 BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type, 2724 BD_ADDR bd_addr, 2725 UINT8 privacy_mode, 2726 tBTM_SET_PRIVACY_MODE_CMPL_CBACK *p_callback); 2727 2728 /******************************************************************************* 2729 ** 2730 ** Function BTM_BleSetCsaSupport 2731 ** 2732 ** Description This function is called to set the ChSel field of Advertising or Initiating PDUs 2733 ** 2734 ** Parameters csa_select - Select LE Channel Selection Algorithm. 2735 ** p_callback - Callback function to be called when the operation is completed. 2736 ** 2737 ** Returns TRUE if the operation was successful, otherwise FALSE. 2738 ** 2739 *******************************************************************************/ 2740 BOOLEAN BTM_BleSetCsaSupport (UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback); 2741 2742 /* 2743 #ifdef __cplusplus 2744 } 2745 #endif 2746 */ 2747 #if (BLE_50_FEATURE_SUPPORT == TRUE) 2748 void BTM_BleGapRegisterCallback(tBTM_BLE_5_HCI_CBACK cb); 2749 2750 tBTM_STATUS BTM_BleReadPhy(BD_ADDR bd_addr, UINT8 *tx_phy, UINT8 *rx_phy); 2751 2752 tBTM_STATUS BTM_BleSetPreferDefaultPhy(UINT8 tx_phy_mask, UINT8 rx_phy_mask); 2753 2754 tBTM_STATUS BTM_BleSetPreferPhy(BD_ADDR bd_addr, UINT8 all_phys, UINT8 tx_phy_mask, 2755 UINT8 rx_phy_mask, UINT16 phy_options); 2756 2757 tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr); 2758 2759 tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PARAMS *params); 2760 2761 tBTM_STATUS BTM_BleConfigExtendedAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 len, UINT8 *data); 2762 2763 tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_adv); 2764 2765 tBTM_STATUS BTM_BleExtAdvSetRemove(UINT8 instance); 2766 2767 tBTM_STATUS BTM_BleExtAdvSetClear(void); 2768 2769 tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Params *params); 2770 2771 tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data, BOOLEAN only_update_did); 2772 2773 tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, UINT8 enable); 2774 2775 tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params); 2776 2777 tBTM_STATUS BTM_BlePeriodicAdvSyncCancel(void); 2778 2779 tBTM_STATUS BTM_BlePeriodicAdvSyncTerm(UINT16 sync_handle); 2780 2781 tBTM_STATUS BTM_BlePeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid); 2782 2783 tBTM_STATUS BTM_BlePeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid); 2784 2785 tBTM_STATUS BTM_BlePeriodicAdvClearDev(void); 2786 2787 tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params); 2788 2789 tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period); 2790 2791 void BTM_BleSetPreferExtenedConnParams(BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params); 2792 2793 void BTM_BleEnhancedReceiverTest(UINT8 rx_freq, UINT8 phy, UINT8 modulation_index, tBTM_CMPL_CB *p_cmd_cmpl_cback); 2794 2795 void BTM_BleEnhancedTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, UINT8 packet_payload, UINT8 phy, tBTM_CMPL_CB *p_cmd_cmpl_cback); 2796 2797 #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) 2798 2799 #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 2800 void BTM_BlePeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable); 2801 2802 void BTM_BlePeriodicAdvSyncTrans(BD_ADDR bd_addr, UINT16 service_data, UINT16 sync_handle); 2803 2804 void BTM_BlePeriodicAdvSetInfoTrans(BD_ADDR bd_addr, UINT16 service_data, UINT8 adv_handle); 2805 2806 void BTM_BleSetPeriodicAdvSyncTransParams(BD_ADDR bd_addr, UINT8 mode, UINT16 skip, UINT16 sync_timeout, UINT8 cte_type); 2807 #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) 2808 2809 #endif 2810