1 /****************************************************************************** 2 * 3 * Copyright 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 #ifndef BTM_BLE_API_TYPES_H 20 #define BTM_BLE_API_TYPES_H 21 22 #include <base/callback_forward.h> 23 #include <hardware/bt_common_types.h> 24 #include <vector> 25 26 #define CHNL_MAP_LEN 5 27 typedef uint8_t tBTM_BLE_CHNL_MAP[CHNL_MAP_LEN]; 28 29 /* 0x00-0x04 only used for set advertising parameter command */ 30 #define BTM_BLE_CONNECT_EVT 0x00 31 /* Connectable directed advertising */ 32 #define BTM_BLE_CONNECT_DIR_EVT 0x01 33 /* Scannable undirected advertising */ 34 #define BTM_BLE_DISCOVER_EVT 0x02 35 /* Non connectable undirected advertising */ 36 #define BTM_BLE_NON_CONNECT_EVT 0x03 37 /* Connectable low duty cycle directed advertising */ 38 #define BTM_BLE_CONNECT_LO_DUTY_DIR_EVT 0x04 39 /* 0x00 - 0x04 can be received on adv event type */ 40 #define BTM_BLE_ADV_IND_EVT 0x00 41 #define BTM_BLE_ADV_DIRECT_IND_EVT 0x01 42 #define BTM_BLE_ADV_SCAN_IND_EVT 0x02 43 #define BTM_BLE_ADV_NONCONN_IND_EVT 0x03 44 #define BTM_BLE_SCAN_RSP_EVT 0x04 45 46 #define BTM_BLE_UNKNOWN_EVT 0xff 47 48 typedef uint8_t tBTM_BLE_EVT; 49 typedef uint8_t tBTM_BLE_CONN_MODE; 50 51 typedef uint32_t tBTM_BLE_REF_VALUE; 52 53 #define BTM_BLE_SCAN_MODE_PASS 0 54 #define BTM_BLE_SCAN_MODE_ACTI 1 55 #define BTM_BLE_SCAN_MODE_NONE 0xff 56 typedef uint8_t tBLE_SCAN_MODE; 57 58 #define BTM_BLE_BATCH_SCAN_MODE_DISABLE 0 59 #define BTM_BLE_BATCH_SCAN_MODE_PASS 1 60 #define BTM_BLE_BATCH_SCAN_MODE_ACTI 2 61 #define BTM_BLE_BATCH_SCAN_MODE_PASS_ACTI 3 62 63 typedef uint8_t tBTM_BLE_BATCH_SCAN_MODE; 64 65 /* advertising channel map */ 66 #define BTM_BLE_ADV_CHNL_37 (0x01 << 0) 67 #define BTM_BLE_ADV_CHNL_38 (0x01 << 1) 68 #define BTM_BLE_ADV_CHNL_39 (0x01 << 2) 69 typedef uint8_t tBTM_BLE_ADV_CHNL_MAP; 70 71 /*d efault advertising channel map */ 72 #ifndef BTM_BLE_DEFAULT_ADV_CHNL_MAP 73 #define BTM_BLE_DEFAULT_ADV_CHNL_MAP \ 74 (BTM_BLE_ADV_CHNL_37 | BTM_BLE_ADV_CHNL_38 | BTM_BLE_ADV_CHNL_39) 75 #endif 76 77 /* advertising filter policy */ 78 #define AP_SCAN_CONN_ALL 0x00 /* default */ 79 #define AP_SCAN_WL_CONN_ALL 0x01 80 #define AP_SCAN_ALL_CONN_WL 0x02 81 #define AP_SCAN_CONN_WL 0x03 82 #define AP_SCAN_CONN_POLICY_MAX 0x04 83 typedef uint8_t tBTM_BLE_AFP; 84 85 /* default advertising filter policy */ 86 #ifndef BTM_BLE_DEFAULT_AFP 87 #define BTM_BLE_DEFAULT_AFP AP_SCAN_CONN_ALL 88 #endif 89 90 /* scanning filter policy */ 91 /* 0: accept adv packet from all, directed adv pkt not directed */ 92 /* to local device is ignored */ 93 #define SP_ADV_ALL 0x00 94 /* 1: accept adv packet from device in white list, directed adv */ 95 /* packet not directed to local device is ignored */ 96 #define SP_ADV_WL 0x01 97 /* 2: accept adv packet from all, directed adv pkt */ 98 /* not directed to me is ignored except direct adv with RPA */ 99 #define SP_ADV_ALL_RPA_DIR_ADV 0x02 100 /* 3: accept adv packet from device in white list, directed */ 101 /* adv pkt not directed to me is ignored except direct adv with RPA */ 102 #define SP_ADV_WL_RPA_DIR_ADV 0x03 103 104 typedef uint8_t tBTM_BLE_SFP; 105 106 #ifndef BTM_BLE_DEFAULT_SFP 107 #define BTM_BLE_DEFAULT_SFP SP_ADV_ALL 108 #endif 109 110 /* adv parameter boundary values */ 111 #define BTM_BLE_ADV_INT_MIN 0x0020 112 #define BTM_BLE_ADV_INT_MAX 0x4000 113 114 /* Full scan boundary values */ 115 #define BTM_BLE_ADV_SCAN_FULL_MIN 0x00 116 #define BTM_BLE_ADV_SCAN_FULL_MAX 0x64 117 118 /* Partial scan boundary values */ 119 #define BTM_BLE_ADV_SCAN_TRUNC_MIN BTM_BLE_ADV_SCAN_FULL_MIN 120 #define BTM_BLE_ADV_SCAN_TRUNC_MAX BTM_BLE_ADV_SCAN_FULL_MAX 121 122 /* Threshold values */ 123 #define BTM_BLE_ADV_SCAN_THR_MIN BTM_BLE_ADV_SCAN_FULL_MIN 124 #define BTM_BLE_ADV_SCAN_THR_MAX BTM_BLE_ADV_SCAN_FULL_MAX 125 126 /* connection parameter boundary values */ 127 #define BTM_BLE_SCAN_INT_MIN 0x0004 128 #define BTM_BLE_SCAN_INT_MAX 0x4000 129 #define BTM_BLE_SCAN_WIN_MIN 0x0004 130 #define BTM_BLE_SCAN_WIN_MAX 0x4000 131 #define BTM_BLE_EXT_SCAN_INT_MAX 0x00FFFFFF 132 #define BTM_BLE_EXT_SCAN_WIN_MAX 0xFFFF 133 #define BTM_BLE_CONN_INT_MIN 0x0006 134 #define BTM_BLE_CONN_INT_MAX 0x0C80 135 #define BTM_BLE_CONN_LATENCY_MAX 500 136 #define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A 137 #define BTM_BLE_CONN_SUP_TOUT_MAX 0x0C80 138 /* use this value when a specific value not to be overwritten */ 139 #define BTM_BLE_CONN_PARAM_UNDEF 0xffff 140 #define BTM_BLE_SCAN_PARAM_UNDEF 0xffff 141 142 /* default connection parameters if not configured, use GAP recommended value 143 * for auto/selective connection */ 144 /* default scan interval */ 145 #ifndef BTM_BLE_SCAN_FAST_INT 146 #define BTM_BLE_SCAN_FAST_INT 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */ 147 #endif 148 /* default scan window for background connection, applicable for auto connection 149 * or selective connection */ 150 #ifndef BTM_BLE_SCAN_FAST_WIN 151 #define BTM_BLE_SCAN_FAST_WIN 48 /* 30 ms = 48 *0.625 */ 152 #endif 153 154 /* default scan paramter used in reduced power cycle (background scanning) */ 155 #ifndef BTM_BLE_SCAN_SLOW_INT_1 156 #define BTM_BLE_SCAN_SLOW_INT_1 2048 /* 1.28 s = 2048 *0.625 */ 157 #endif 158 #ifndef BTM_BLE_SCAN_SLOW_WIN_1 159 #define BTM_BLE_SCAN_SLOW_WIN_1 48 /* 30 ms = 48 *0.625 */ 160 #endif 161 162 /* default scan paramter used in reduced power cycle (background scanning) */ 163 #ifndef BTM_BLE_SCAN_SLOW_INT_2 164 #define BTM_BLE_SCAN_SLOW_INT_2 4096 /* 2.56 s = 4096 *0.625 */ 165 #endif 166 #ifndef BTM_BLE_SCAN_SLOW_WIN_2 167 #define BTM_BLE_SCAN_SLOW_WIN_2 36 /* 22.5 ms = 36 *0.625 */ 168 #endif 169 170 /* default connection interval min */ 171 #ifndef BTM_BLE_CONN_INT_MIN_DEF 172 /* recommended min: 30ms = 24 * 1.25 */ 173 #define BTM_BLE_CONN_INT_MIN_DEF 24 174 #endif 175 176 /* default connectino interval max */ 177 #ifndef BTM_BLE_CONN_INT_MAX_DEF 178 /* recommended max: 50 ms = 56 * 1.25 */ 179 #define BTM_BLE_CONN_INT_MAX_DEF 40 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 500 190 #endif 191 192 /* minimum supervision timeout */ 193 #ifndef BTM_BLE_CONN_TIMEOUT_MIN_DEF 194 #define BTM_BLE_CONN_TIMEOUT_MIN_DEF 100 195 #endif 196 197 /* minimum acceptable connection interval */ 198 #ifndef BTM_BLE_CONN_INT_MIN_LIMIT 199 #define BTM_BLE_CONN_INT_MIN_LIMIT 0x0009 200 #endif 201 202 /* minimum acceptable connection interval when there is bonded Hearing Aid 203 * device */ 204 #ifndef BTM_BLE_CONN_INT_MIN_HEARINGAID 205 #define BTM_BLE_CONN_INT_MIN_HEARINGAID 0x0010 206 #endif 207 208 #define BTM_CMAC_TLEN_SIZE 8 /* 64 bits */ 209 #define BTM_BLE_AUTH_SIGN_LEN \ 210 12 /* BLE data signature length 8 Bytes + 4 bytes counter*/ 211 typedef uint8_t BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */ 212 213 #ifndef BTM_BLE_HOST_SUPPORT 214 #define BTM_BLE_HOST_SUPPORT 0x01 215 #endif 216 217 #ifndef BTM_BLE_SIMULTANEOUS_HOST 218 #define BTM_BLE_SIMULTANEOUS_HOST 0x01 219 #endif 220 221 /* Appearance Values Reported with BTM_BLE_AD_TYPE_APPEARANCE */ 222 #define BTM_BLE_APPEARANCE_UKNOWN 0x0000 223 #define BTM_BLE_APPEARANCE_GENERIC_PHONE 0x0040 224 #define BTM_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080 225 #define BTM_BLE_APPEARANCE_GENERIC_WATCH 0x00C0 226 #define BTM_BLE_APPEARANCE_SPORTS_WATCH 0x00C1 227 #define BTM_BLE_APPEARANCE_GENERIC_CLOCK 0x0100 228 #define BTM_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140 229 #define BTM_BLE_APPEARANCE_GENERIC_REMOTE 0x0180 230 #define BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0 231 #define BTM_BLE_APPEARANCE_GENERIC_TAG 0x0200 232 #define BTM_BLE_APPEARANCE_GENERIC_KEYRING 0x0240 233 #define BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280 234 #define BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0 235 #define BTM_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300 236 #define BTM_BLE_APPEARANCE_THERMOMETER_EAR 0x0301 237 #define BTM_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340 238 #define BTM_BLE_APPEARANCE_HEART_RATE_BELT 0x0341 239 #define BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380 240 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381 241 #define BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382 242 #define BTM_BLE_APPEARANCE_GENERIC_HID 0x03C0 243 #define BTM_BLE_APPEARANCE_HID_KEYBOARD 0x03C1 244 #define BTM_BLE_APPEARANCE_HID_MOUSE 0x03C2 245 #define BTM_BLE_APPEARANCE_HID_JOYSTICK 0x03C3 246 #define BTM_BLE_APPEARANCE_HID_GAMEPAD 0x03C4 247 #define BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5 248 #define BTM_BLE_APPEARANCE_HID_CARD_READER 0x03C6 249 #define BTM_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7 250 #define BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8 251 #define BTM_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400 252 #define BTM_BLE_APPEARANCE_GENERIC_WALKING 0x0440 253 #define BTM_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441 254 #define BTM_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442 255 #define BTM_BLE_APPEARANCE_WALKING_ON_HIP 0x0443 256 #define BTM_BLE_APPEARANCE_GENERIC_CYCLING 0x0480 257 #define BTM_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481 258 #define BTM_BLE_APPEARANCE_CYCLING_SPEED 0x0482 259 #define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 260 #define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484 261 #define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 262 #define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 263 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 264 #define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 265 #define BTM_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80 266 #define BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440 267 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441 268 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442 269 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443 270 #define BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444 271 272 /* Structure returned with Rand/Encrypt complete callback */ 273 typedef struct { 274 uint8_t status; 275 uint8_t param_len; 276 uint16_t opcode; 277 uint8_t param_buf[OCTET16_LEN]; 278 } tBTM_RAND_ENC; 279 280 /* General callback function for notifying an application that a synchronous 281 * BTM function is complete. The pointer contains the address of any returned 282 * data. 283 */ 284 typedef void(tBTM_RAND_ENC_CB)(tBTM_RAND_ENC* p1); 285 286 #define BTM_BLE_FILTER_TARGET_SCANNER 0x01 287 #define BTM_BLE_FILTER_TARGET_ADVR 0x00 288 289 #define BTM_BLE_POLICY_BLACK_ALL 0x00 /* relevant to both */ 290 #define BTM_BLE_POLICY_ALLOW_SCAN 0x01 /* relevant to advertiser */ 291 #define BTM_BLE_POLICY_ALLOW_CONN 0x02 /* relevant to advertiser */ 292 #define BTM_BLE_POLICY_WHITE_ALL 0x03 /* relevant to both */ 293 294 /* ADV data flag bit definition used for BTM_BLE_AD_TYPE_FLAG */ 295 #define BTM_BLE_LIMIT_DISC_FLAG (0x01 << 0) 296 #define BTM_BLE_GEN_DISC_FLAG (0x01 << 1) 297 #define BTM_BLE_BREDR_NOT_SPT (0x01 << 2) 298 /* 4.1 spec adv flag for simultaneous BR/EDR+LE connection support */ 299 #define BTM_BLE_DMT_CONTROLLER_SPT (0x01 << 3) 300 #define BTM_BLE_DMT_HOST_SPT (0x01 << 4) 301 #define BTM_BLE_NON_LIMIT_DISC_FLAG (0x00) /* lowest bit unset */ 302 #define BTM_BLE_ADV_FLAG_MASK \ 303 (BTM_BLE_LIMIT_DISC_FLAG | BTM_BLE_BREDR_NOT_SPT | BTM_BLE_GEN_DISC_FLAG) 304 #define BTM_BLE_LIMIT_DISC_MASK (BTM_BLE_LIMIT_DISC_FLAG) 305 306 // TODO(jpawlowski): this should be removed with code that depend on it. 307 #define BTM_BLE_AD_BIT_FLAGS (0x00000001 << 1) 308 309 #define BTM_BLE_AD_TYPE_FLAG HCI_EIR_FLAGS_TYPE /* 0x01 */ 310 #define BTM_BLE_AD_TYPE_16SRV_CMPL \ 311 HCI_EIR_COMPLETE_16BITS_UUID_TYPE /* 0x03 \ 312 */ 313 #define BTM_BLE_AD_TYPE_NAME_SHORT \ 314 HCI_EIR_SHORTENED_LOCAL_NAME_TYPE /* 0x08 \ 315 */ 316 #define BTM_BLE_AD_TYPE_NAME_CMPL HCI_EIR_COMPLETE_LOCAL_NAME_TYPE /* 0x09 */ 317 318 #define BTM_BLE_AD_TYPE_APPEARANCE 0x19 319 320 /* Security settings used with L2CAP LE COC */ 321 #define BTM_SEC_LE_LINK_ENCRYPTED 0x01 322 #define BTM_SEC_LE_LINK_PAIRED_WITHOUT_MITM 0x02 323 #define BTM_SEC_LE_LINK_PAIRED_WITH_MITM 0x04 324 325 /* Min/max Preferred number of payload octets that the local Controller 326 should include in a single Link Layer Data Channel PDU. */ 327 #define BTM_BLE_DATA_SIZE_MAX 0x00fb 328 #define BTM_BLE_DATA_SIZE_MIN 0x001b 329 330 /* Preferred maximum number of microseconds that the local Controller 331 should use to transmit a single Link Layer Data Channel PDU. */ 332 #define BTM_BLE_DATA_TX_TIME_MIN 0x0148 333 #define BTM_BLE_DATA_TX_TIME_MAX_LEGACY 0x0848 334 #define BTM_BLE_DATA_TX_TIME_MAX 0x4290 335 336 /* adv tx power in dBm */ 337 typedef struct { 338 uint8_t adv_inst_max; /* max adv instance supported in controller */ 339 uint8_t rpa_offloading; 340 uint16_t tot_scan_results_strg; 341 uint8_t max_irk_list_sz; 342 uint8_t filter_support; 343 uint8_t max_filter; 344 uint8_t energy_support; 345 bool values_read; 346 uint16_t version_supported; 347 uint16_t total_trackable_advertisers; 348 uint8_t extended_scan_support; 349 uint8_t debug_logging_supported; 350 } tBTM_BLE_VSC_CB; 351 352 typedef void(tBTM_BLE_ADV_DATA_CMPL_CBACK)(tBTM_STATUS status); 353 354 #ifndef BTM_BLE_MULTI_ADV_MAX 355 #define BTM_BLE_MULTI_ADV_MAX \ 356 16 /* controller returned adv_inst_max should be less \ 357 than this number */ 358 #endif 359 360 typedef uint8_t tGATT_IF; 361 362 typedef void(tBTM_BLE_SCAN_THRESHOLD_CBACK)(tBTM_BLE_REF_VALUE ref_value); 363 using tBTM_BLE_SCAN_REP_CBACK = 364 base::Callback<void(uint8_t /* status */, uint8_t /* report_format */, 365 uint8_t /* num_reports */, std::vector<uint8_t>)>; 366 367 #ifndef BTM_BLE_BATCH_SCAN_MAX 368 #define BTM_BLE_BATCH_SCAN_MAX 5 369 #endif 370 371 #ifndef BTM_BLE_BATCH_REP_MAIN_Q_SIZE 372 #define BTM_BLE_BATCH_REP_MAIN_Q_SIZE 2 373 #endif 374 375 typedef enum { 376 BTM_BLE_SCAN_INVALID_STATE = 0, 377 BTM_BLE_SCAN_ENABLE_CALLED = 1, 378 BTM_BLE_SCAN_ENABLED_STATE = 2, 379 BTM_BLE_SCAN_DISABLE_CALLED = 3, 380 BTM_BLE_SCAN_DISABLED_STATE = 4 381 } tBTM_BLE_BATCH_SCAN_STATE; 382 383 enum { BTM_BLE_DISCARD_OLD_ITEMS, BTM_BLE_DISCARD_LOWER_RSSI_ITEMS }; 384 typedef uint8_t tBTM_BLE_DISCARD_RULE; 385 386 typedef struct { 387 tBTM_BLE_BATCH_SCAN_STATE cur_state; 388 tBTM_BLE_BATCH_SCAN_MODE scan_mode; 389 uint32_t scan_interval; 390 uint32_t scan_window; 391 tBLE_ADDR_TYPE addr_type; 392 tBTM_BLE_DISCARD_RULE discard_rule; 393 tBTM_BLE_SCAN_THRESHOLD_CBACK* p_thres_cback; 394 tBTM_BLE_REF_VALUE ref_value; 395 } tBTM_BLE_BATCH_SCAN_CB; 396 397 /* filter selection bit index */ 398 #define BTM_BLE_PF_ADDR_FILTER 0 399 #define BTM_BLE_PF_SRVC_DATA 1 400 #define BTM_BLE_PF_SRVC_UUID 2 401 #define BTM_BLE_PF_SRVC_SOL_UUID 3 402 #define BTM_BLE_PF_LOCAL_NAME 4 403 #define BTM_BLE_PF_MANU_DATA 5 404 #define BTM_BLE_PF_SRVC_DATA_PATTERN 6 405 /* when passed in payload filter type all, only clear action is applicable */ 406 #define BTM_BLE_PF_TYPE_ALL 7 407 #define BTM_BLE_PF_TYPE_MAX 8 408 409 /* max number of filter spot for different filter type */ 410 #ifndef BTM_BLE_MAX_UUID_FILTER 411 #define BTM_BLE_MAX_UUID_FILTER 8 412 #endif 413 #ifndef BTM_BLE_MAX_ADDR_FILTER 414 #define BTM_BLE_MAX_ADDR_FILTER 8 415 #endif 416 #ifndef BTM_BLE_PF_STR_COND_MAX 417 #define BTM_BLE_PF_STR_COND_MAX 4 /* apply to manu data , or local name */ 418 #endif 419 #ifndef BTM_BLE_PF_STR_LEN_MAX 420 #define BTM_BLE_PF_STR_LEN_MAX 29 /* match for first 29 bytes */ 421 #endif 422 423 typedef uint8_t tBTM_BLE_PF_COND_TYPE; 424 425 #define BTM_BLE_PF_LOGIC_OR 0 426 #define BTM_BLE_PF_LOGIC_AND 1 427 typedef uint8_t tBTM_BLE_PF_LOGIC_TYPE; 428 429 #define BTM_BLE_PF_ENABLE 1 430 #define BTM_BLE_PF_CONFIG 2 431 typedef uint8_t tBTM_BLE_PF_ACTION; 432 433 typedef uint8_t tBTM_BLE_PF_FILT_INDEX; 434 435 typedef uint8_t tBTM_BLE_PF_AVBL_SPACE; 436 437 enum { 438 BTM_BLE_SCAN_COND_ADD, 439 BTM_BLE_SCAN_COND_DELETE, 440 BTM_BLE_SCAN_COND_CLEAR = 2 441 }; 442 typedef uint8_t tBTM_BLE_SCAN_COND_OP; 443 444 /* BLE adv payload filtering config complete callback */ 445 using tBTM_BLE_PF_CFG_CBACK = base::Callback<void( 446 uint8_t /* avbl_space */, uint8_t /* action */, uint8_t /* status */)>; 447 448 /* BLE adv payload filtering status setup complete callback */ 449 using tBTM_BLE_PF_STATUS_CBACK = 450 base::Callback<void(uint8_t /*action*/, tBTM_STATUS /* status */)>; 451 452 /* BLE adv payload filtering param setup complete callback */ 453 using tBTM_BLE_PF_PARAM_CB = base::Callback<void( 454 uint8_t /* avbl_space */, uint8_t /* action */, uint8_t /* status */)>; 455 456 /* per device filter + one generic filter indexed by 0 */ 457 #define BTM_BLE_MAX_FILTER_COUNTER (BTM_BLE_MAX_ADDR_FILTER + 1) 458 459 #ifndef BTM_CS_IRK_LIST_MAX 460 #define BTM_CS_IRK_LIST_MAX 0x20 461 #endif 462 463 typedef struct { 464 bool in_use; 465 RawAddress bd_addr; 466 uint8_t pf_counter[BTM_BLE_PF_TYPE_MAX]; /* number of filter indexed by 467 tBTM_BLE_PF_COND_TYPE */ 468 } tBTM_BLE_PF_COUNT; 469 470 typedef struct { 471 bool enable; 472 uint8_t op_type; 473 tBTM_BLE_PF_COUNT* p_addr_filter_count; /* per BDA filter array */ 474 tBLE_BD_ADDR cur_filter_target; 475 } tBTM_BLE_ADV_FILTER_CB; 476 477 /* Sub codes */ 478 #define BTM_BLE_META_PF_ENABLE 0x00 479 #define BTM_BLE_META_PF_FEAT_SEL 0x01 480 #define BTM_BLE_META_PF_ADDR 0x02 481 #define BTM_BLE_META_PF_UUID 0x03 482 #define BTM_BLE_META_PF_SOL_UUID 0x04 483 #define BTM_BLE_META_PF_LOCAL_NAME 0x05 484 #define BTM_BLE_META_PF_MANU_DATA 0x06 485 #define BTM_BLE_META_PF_SRVC_DATA 0x07 486 #define BTM_BLE_META_PF_ALL 0x08 487 488 typedef uint8_t BTM_BLE_ADV_STATE; 489 typedef uint8_t BTM_BLE_ADV_INFO_PRESENT; 490 typedef uint8_t BTM_BLE_RSSI_VALUE; 491 typedef uint16_t BTM_BLE_ADV_INFO_TIMESTAMP; 492 493 #define ADV_INFO_PRESENT 0x00 494 #define NO_ADV_INFO_PRESENT 0x01 495 496 typedef btgatt_track_adv_info_t tBTM_BLE_TRACK_ADV_DATA; 497 498 typedef void(tBTM_BLE_TRACK_ADV_CBACK)( 499 tBTM_BLE_TRACK_ADV_DATA* p_track_adv_data); 500 501 typedef uint8_t tBTM_BLE_TRACK_ADV_EVT; 502 503 typedef struct { 504 tBTM_BLE_REF_VALUE ref_value; 505 tBTM_BLE_TRACK_ADV_CBACK* p_track_cback; 506 } tBTM_BLE_ADV_TRACK_CB; 507 508 enum { BTM_BLE_TRACK_ADV_ADD, BTM_BLE_TRACK_ADV_REMOVE }; 509 510 typedef uint8_t tBTM_BLE_TRACK_ADV_ACTION; 511 512 typedef uint8_t tBTM_BLE_BATCH_SCAN_EVT; 513 514 typedef uint32_t tBTM_BLE_TX_TIME_MS; 515 typedef uint32_t tBTM_BLE_RX_TIME_MS; 516 typedef uint32_t tBTM_BLE_IDLE_TIME_MS; 517 typedef uint32_t tBTM_BLE_ENERGY_USED; 518 519 typedef void(tBTM_BLE_ENERGY_INFO_CBACK)(tBTM_BLE_TX_TIME_MS tx_time, 520 tBTM_BLE_RX_TIME_MS rx_time, 521 tBTM_BLE_IDLE_TIME_MS idle_time, 522 tBTM_BLE_ENERGY_USED energy_used, 523 tBTM_STATUS status); 524 525 typedef struct { 526 tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback; 527 } tBTM_BLE_ENERGY_INFO_CB; 528 529 typedef void(tBTM_BLE_CTRL_FEATURES_CBACK)(tBTM_STATUS status); 530 531 typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, 532 tBTM_STATUS status); 533 534 #endif // BTM_BLE_API_TYPES_H 535