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