Home | History | Annotate | Download | only in btm
      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 main Bluetooth Manager (BTM) internal
     22  *  definitions.
     23  *
     24  ******************************************************************************/
     25 
     26 #ifndef BTM_BLE_INT_H
     27 #define BTM_BLE_INT_H
     28 
     29 #include "bt_target.h"
     30 #include "bt_common.h"
     31 #include "hcidefs.h"
     32 #include "btm_ble_api.h"
     33 #include "btm_int.h"
     34 
     35 #if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
     36 #include "smp_api.h"
     37 #endif
     38 
     39 
     40 /* scanning enable status */
     41 #define BTM_BLE_SCAN_ENABLE      0x01
     42 #define BTM_BLE_SCAN_DISABLE     0x00
     43 
     44 /* advertising enable status */
     45 #define BTM_BLE_ADV_ENABLE     0x01
     46 #define BTM_BLE_ADV_DISABLE    0x00
     47 
     48 /* use the high 4 bits unused by inquiry mode */
     49 #define BTM_BLE_SELECT_SCAN     0x20
     50 #define BTM_BLE_NAME_REQUEST    0x40
     51 #define BTM_BLE_OBSERVE         0x80
     52 
     53 #define BTM_BLE_MAX_WL_ENTRY        1
     54 #define BTM_BLE_AD_DATA_LEN         31
     55 
     56 #define BTM_BLE_ENC_MASK    0x03
     57 
     58 #define BTM_BLE_DUPLICATE_ENABLE        1
     59 #define BTM_BLE_DUPLICATE_DISABLE       0
     60 
     61 #define BTM_BLE_GAP_DISC_SCAN_INT      18         /* Interval(scan_int) = 11.25 ms= 0x0010 * 0.625 ms */
     62 #define BTM_BLE_GAP_DISC_SCAN_WIN      18         /* scan_window = 11.25 ms= 0x0010 * 0.625 ms */
     63 #define BTM_BLE_GAP_ADV_INT            512        /* Tgap(gen_disc) = 1.28 s= 512 * 0.625 ms */
     64 #define BTM_BLE_GAP_LIM_TIMEOUT_MS     (180 * 1000) /* Tgap(lim_timeout) = 180s max */
     65 #define BTM_BLE_LOW_LATENCY_SCAN_INT   8000       /* Interval(scan_int) = 5s= 8000 * 0.625 ms */
     66 #define BTM_BLE_LOW_LATENCY_SCAN_WIN   8000       /* scan_window = 5s= 8000 * 0.625 ms */
     67 
     68 
     69 #define BTM_BLE_GAP_ADV_FAST_INT_1         48         /* TGAP(adv_fast_interval1) = 30(used) ~ 60 ms  = 48 *0.625 */
     70 #define BTM_BLE_GAP_ADV_FAST_INT_2         160         /* TGAP(adv_fast_interval2) = 100(used) ~ 150 ms = 160 * 0.625 ms */
     71 #define BTM_BLE_GAP_ADV_SLOW_INT           2048         /* Tgap(adv_slow_interval) = 1.28 s= 512 * 0.625 ms */
     72 #define BTM_BLE_GAP_ADV_DIR_MAX_INT        800         /* Tgap(dir_conn_adv_int_max) = 500 ms = 800 * 0.625 ms */
     73 #define BTM_BLE_GAP_ADV_DIR_MIN_INT        400         /* Tgap(dir_conn_adv_int_min) = 250 ms = 400 * 0.625 ms */
     74 
     75 #define BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS    (30 * 1000)
     76 
     77 #define BTM_BLE_SEC_REQ_ACT_NONE           0
     78 #define BTM_BLE_SEC_REQ_ACT_ENCRYPT        1 /* encrypt the link using current key or key refresh */
     79 #define BTM_BLE_SEC_REQ_ACT_PAIR           2
     80 #define BTM_BLE_SEC_REQ_ACT_DISCARD        3 /* discard the sec request while encryption is started but not completed */
     81 typedef UINT8   tBTM_BLE_SEC_REQ_ACT;
     82 
     83 #define BLE_STATIC_PRIVATE_MSB_MASK          0x3f
     84 #define BLE_RESOLVE_ADDR_MSB                 0x40   /*  most significant bit, bit7, bit6 is 01 to be resolvable random */
     85 #define BLE_RESOLVE_ADDR_MASK                0xc0   /* bit 6, and bit7 */
     86 #define BTM_BLE_IS_RESOLVE_BDA(x)           ((x[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB)
     87 
     88 #define BLE_PUBLIC_ADDR_MSB_MASK            0xC0
     89 #define BLE_PUBLIC_ADDR_MSB                 0x80   /*  most significant bit, bit7, bit6 is 10 to be public address*/
     90 #define BTM_IS_PUBLIC_BDA(x)               ((x[0]  & BLE_PUBLIC_ADDR_MSB) == BLE_PUBLIC_ADDR_MSB_MASK)
     91 
     92 /* LE scan activity bit mask, continue with LE inquiry bits */
     93 #define BTM_LE_SELECT_CONN_ACTIVE      0x40     /* selection connection is in progress */
     94 #define BTM_LE_OBSERVE_ACTIVE          0x80     /* observe is in progress */
     95 
     96 /* BLE scan activity mask checking */
     97 #define BTM_BLE_IS_SCAN_ACTIVE(x)   ((x) & BTM_BLE_SCAN_ACTIVE_MASK)
     98 #define BTM_BLE_IS_INQ_ACTIVE(x)   ((x) & BTM_BLE_INQUIRY_MASK)
     99 #define BTM_BLE_IS_OBS_ACTIVE(x)   ((x) & BTM_LE_OBSERVE_ACTIVE)
    100 #define BTM_BLE_IS_SEL_CONN_ACTIVE(x)   ((x) & BTM_LE_SELECT_CONN_ACTIVE)
    101 
    102 /* BLE ADDR type ID bit */
    103 #define BLE_ADDR_TYPE_ID_BIT 0x02
    104 
    105 #define BTM_VSC_CHIP_CAPABILITY_L_VERSION 55
    106 #define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95
    107 
    108 typedef struct
    109 {
    110     UINT16              data_mask;
    111     UINT8               *p_flags;
    112     UINT8               ad_data[BTM_BLE_AD_DATA_LEN];
    113     UINT8               *p_pad;
    114 }tBTM_BLE_LOCAL_ADV_DATA;
    115 
    116 typedef struct
    117 {
    118     UINT32          inq_count;          /* Used for determining if a response has already been      */
    119                                         /* received for the current inquiry operation. (We do not   */
    120                                         /* want to flood the caller with multiple responses from    */
    121                                         /* the same device.                                         */
    122     BOOLEAN         scan_rsp;
    123     tBLE_BD_ADDR    le_bda;
    124 } tINQ_LE_BDADDR;
    125 
    126 #define BTM_BLE_ADV_DATA_LEN_MAX        31
    127 #define BTM_BLE_CACHE_ADV_DATA_MAX      62
    128 
    129 #define BTM_BLE_ISVALID_PARAM(x, min, max)  (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF))
    130 
    131 /* 15 minutes minimum for random address refreshing */
    132 #define BTM_BLE_PRIVATE_ADDR_INT_MS     (15 * 60 * 1000)
    133 
    134 typedef struct
    135 {
    136     UINT16 discoverable_mode;
    137     UINT16 connectable_mode;
    138     UINT32 scan_window;
    139     UINT32 scan_interval;
    140     UINT8 scan_type; /* current scan type: active or passive */
    141     UINT8 scan_duplicate_filter; /* duplicate filter enabled for scan */
    142     UINT16 adv_interval_min;
    143     UINT16 adv_interval_max;
    144     tBTM_BLE_AFP afp; /* advertising filter policy */
    145     tBTM_BLE_SFP sfp; /* scanning filter policy */
    146 
    147     tBLE_ADDR_TYPE adv_addr_type;
    148     UINT8 evt_type;
    149     UINT8 adv_mode;
    150     tBLE_BD_ADDR direct_bda;
    151     tBTM_BLE_EVT directed_conn;
    152     BOOLEAN fast_adv_on;
    153     alarm_t *fast_adv_timer;
    154 
    155     UINT8 adv_len;
    156     UINT8 adv_data_cache[BTM_BLE_CACHE_ADV_DATA_MAX];
    157 
    158     /* inquiry BD addr database */
    159     UINT8 num_bd_entries;
    160     UINT8 max_bd_entries;
    161     tBTM_BLE_LOCAL_ADV_DATA adv_data;
    162     tBTM_BLE_ADV_CHNL_MAP adv_chnl_map;
    163 
    164     alarm_t *inquiry_timer;
    165     BOOLEAN scan_rsp;
    166     UINT8 state; /* Current state that the inquiry process is in */
    167     INT8 tx_power;
    168 } tBTM_BLE_INQ_CB;
    169 
    170 
    171 /* random address resolving complete callback */
    172 typedef void (tBTM_BLE_RESOLVE_CBACK) (void * match_rec, void *p);
    173 
    174 typedef void (tBTM_BLE_ADDR_CBACK) (BD_ADDR_PTR static_random, void *p);
    175 
    176 /* random address management control block */
    177 typedef struct
    178 {
    179     tBLE_ADDR_TYPE              own_addr_type;         /* local device LE address type */
    180     BD_ADDR                     private_addr;
    181     BD_ADDR                     random_bda;
    182     BOOLEAN                     busy;
    183     tBTM_BLE_ADDR_CBACK         *p_generate_cback;
    184     void                        *p;
    185     alarm_t                     *refresh_raddr_timer;
    186 } tBTM_LE_RANDOM_CB;
    187 
    188 #define BTM_BLE_MAX_BG_CONN_DEV_NUM    10
    189 
    190 typedef struct
    191 {
    192     UINT16              min_conn_int;
    193     UINT16              max_conn_int;
    194     UINT16              slave_latency;
    195     UINT16              supervision_tout;
    196 
    197 }tBTM_LE_CONN_PRAMS;
    198 
    199 
    200 typedef struct
    201 {
    202     BD_ADDR     bd_addr;
    203     UINT8       attr;
    204     BOOLEAN     is_connected;
    205     BOOLEAN     in_use;
    206 }tBTM_LE_BG_CONN_DEV;
    207 
    208   /* white list using state as a bit mask */
    209 #define BTM_BLE_WL_IDLE         0
    210 #define BTM_BLE_WL_INIT         1
    211 #define BTM_BLE_WL_SCAN         2
    212 #define BTM_BLE_WL_ADV          4
    213 typedef UINT8 tBTM_BLE_WL_STATE;
    214 
    215 /* resolving list using state as a bit mask */
    216 #define BTM_BLE_RL_IDLE         0
    217 #define BTM_BLE_RL_INIT         1
    218 #define BTM_BLE_RL_SCAN         2
    219 #define BTM_BLE_RL_ADV          4
    220 typedef UINT8 tBTM_BLE_RL_STATE;
    221 
    222 /* BLE connection state */
    223 #define BLE_CONN_IDLE    0
    224 #define BLE_DIR_CONN     1
    225 #define BLE_BG_CONN      2
    226 #define BLE_CONN_CANCEL  3
    227 typedef UINT8 tBTM_BLE_CONN_ST;
    228 
    229 typedef struct
    230 {
    231     void    *p_param;
    232 }tBTM_BLE_CONN_REQ;
    233 
    234 /* LE state request */
    235 #define BTM_BLE_STATE_INVALID               0
    236 #define BTM_BLE_STATE_CONN_ADV              1
    237 #define BTM_BLE_STATE_INIT                  2
    238 #define BTM_BLE_STATE_MASTER                3
    239 #define BTM_BLE_STATE_SLAVE                 4
    240 #define BTM_BLE_STATE_LO_DUTY_DIR_ADV       5
    241 #define BTM_BLE_STATE_HI_DUTY_DIR_ADV       6
    242 #define BTM_BLE_STATE_NON_CONN_ADV          7
    243 #define BTM_BLE_STATE_PASSIVE_SCAN          8
    244 #define BTM_BLE_STATE_ACTIVE_SCAN           9
    245 #define BTM_BLE_STATE_SCAN_ADV              10
    246 #define BTM_BLE_STATE_MAX                   11
    247 typedef UINT8 tBTM_BLE_STATE;
    248 
    249 #define BTM_BLE_STATE_CONN_ADV_BIT          0x0001
    250 #define BTM_BLE_STATE_INIT_BIT              0x0002
    251 #define BTM_BLE_STATE_MASTER_BIT            0x0004
    252 #define BTM_BLE_STATE_SLAVE_BIT             0x0008
    253 #define BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT   0x0010
    254 #define BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT   0x0020
    255 #define BTM_BLE_STATE_NON_CONN_ADV_BIT      0x0040
    256 #define BTM_BLE_STATE_PASSIVE_SCAN_BIT      0x0080
    257 #define BTM_BLE_STATE_ACTIVE_SCAN_BIT       0x0100
    258 #define BTM_BLE_STATE_SCAN_ADV_BIT          0x0200
    259 typedef UINT16 tBTM_BLE_STATE_MASK;
    260 
    261 #define BTM_BLE_STATE_ALL_MASK              0x03ff
    262 #define BTM_BLE_STATE_ALL_ADV_MASK          (BTM_BLE_STATE_CONN_ADV_BIT|BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT|BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT|BTM_BLE_STATE_SCAN_ADV_BIT)
    263 #define BTM_BLE_STATE_ALL_SCAN_MASK         (BTM_BLE_STATE_PASSIVE_SCAN_BIT|BTM_BLE_STATE_ACTIVE_SCAN_BIT)
    264 #define BTM_BLE_STATE_ALL_CONN_MASK         (BTM_BLE_STATE_MASTER_BIT|BTM_BLE_STATE_SLAVE_BIT)
    265 
    266 #ifndef BTM_LE_RESOLVING_LIST_MAX
    267 #define BTM_LE_RESOLVING_LIST_MAX     0x20
    268 #endif
    269 
    270 typedef struct
    271 {
    272     BD_ADDR         *resolve_q_random_pseudo;
    273     UINT8           *resolve_q_action;
    274     UINT8           q_next;
    275     UINT8           q_pending;
    276 } tBTM_BLE_RESOLVE_Q;
    277 
    278 typedef struct
    279 {
    280     BOOLEAN     in_use;
    281     BOOLEAN     to_add;
    282     BD_ADDR     bd_addr;
    283     UINT8       attr;
    284 }tBTM_BLE_WL_OP;
    285 
    286 /* BLE privacy mode */
    287 #define BTM_PRIVACY_NONE    0              /* BLE no privacy */
    288 #define BTM_PRIVACY_1_1     1              /* BLE privacy 1.1, do not support privacy 1.0 */
    289 #define BTM_PRIVACY_1_2     2              /* BLE privacy 1.2 */
    290 #define BTM_PRIVACY_MIXED   3              /* BLE privacy mixed mode, broadcom propietary mode */
    291 typedef UINT8 tBTM_PRIVACY_MODE;
    292 
    293 /* data length change event callback */
    294 typedef void (tBTM_DATA_LENGTH_CHANGE_CBACK) (UINT16 max_tx_length, UINT16 max_rx_length);
    295 
    296 /* Define BLE Device Management control structure
    297 */
    298 typedef struct
    299 {
    300     UINT8 scan_activity;         /* LE scan activity mask */
    301 
    302     /*****************************************************
    303     **      BLE Inquiry
    304     *****************************************************/
    305     tBTM_BLE_INQ_CB inq_var;
    306 
    307     /* observer callback and timer */
    308     tBTM_INQ_RESULTS_CB *p_obs_results_cb;
    309     tBTM_CMPL_CB *p_obs_cmpl_cb;
    310     alarm_t *observer_timer;
    311 
    312     /* background connection procedure cb value */
    313     tBTM_BLE_CONN_TYPE bg_conn_type;
    314     UINT32 scan_int;
    315     UINT32 scan_win;
    316     tBTM_BLE_SEL_CBACK *p_select_cback;
    317 
    318     /* white list information */
    319     UINT8 white_list_avail_size;
    320     tBTM_BLE_WL_STATE wl_state;
    321 
    322     fixed_queue_t *conn_pending_q;
    323     tBTM_BLE_CONN_ST conn_state;
    324 
    325     /* random address management control block */
    326     tBTM_LE_RANDOM_CB addr_mgnt_cb;
    327 
    328     BOOLEAN enabled;
    329 
    330 #if BLE_PRIVACY_SPT == TRUE
    331     BOOLEAN mixed_mode; /* privacy 1.2 mixed mode is on or not */
    332     tBTM_PRIVACY_MODE privacy_mode; /* privacy mode */
    333     UINT8 resolving_list_avail_size; /* resolving list available size */
    334     tBTM_BLE_RESOLVE_Q resolving_list_pend_q; /* Resolving list queue */
    335     tBTM_BLE_RL_STATE suspended_rl_state; /* Suspended resolving list state */
    336     UINT8 *irk_list_mask; /* IRK list availability mask, up to max entry bits */
    337     tBTM_BLE_RL_STATE rl_state; /* Resolving list state */
    338 #endif
    339 
    340     tBTM_BLE_WL_OP wl_op_q[BTM_BLE_MAX_BG_CONN_DEV_NUM];
    341 
    342     /* current BLE link state */
    343     tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */
    344     UINT8 link_count[2]; /* total link count master and slave*/
    345 } tBTM_BLE_CB;
    346 
    347 #ifdef __cplusplus
    348 extern "C" {
    349 #endif
    350 
    351 extern void btm_ble_adv_raddr_timer_timeout(void *data);
    352 extern void btm_ble_refresh_raddr_timer_timeout(void *data);
    353 extern void btm_ble_process_adv_pkt (UINT8 *p);
    354 extern void btm_ble_proc_scan_rsp_rpt (UINT8 *p);
    355 extern tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, tBTM_CMPL_CB *p_cb);
    356 extern BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda);
    357 
    358 extern tBTM_STATUS btm_ble_set_discoverability(UINT16 combined_mode);
    359 extern tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode);
    360 extern tBTM_STATUS btm_ble_start_inquiry (UINT8 mode, UINT8   duration);
    361 extern void btm_ble_stop_scan(void);
    362 extern void btm_clear_all_pending_le_entry(void);
    363 
    364 extern void btm_ble_stop_scan();
    365 extern BOOLEAN btm_ble_send_extended_scan_params(UINT8 scan_type, UINT32 scan_int,
    366                                                  UINT32 scan_win, UINT8 addr_type_own,
    367                                                  UINT8 scan_filter_policy);
    368 extern void btm_ble_stop_inquiry(void);
    369 extern void btm_ble_init (void);
    370 extern void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched);
    371 extern void btm_ble_read_remote_features_complete(UINT8 *p);
    372 extern void btm_ble_write_adv_enable_complete(UINT8 * p);
    373 extern void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced);
    374 extern void btm_read_ble_local_supported_states_complete(UINT8 *p, UINT16 evt_len);
    375 extern tBTM_BLE_CONN_ST btm_ble_get_conn_st(void);
    376 extern void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st);
    377 extern UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
    378                                      tBTM_BLE_ADV_DATA *p_data);
    379 extern tBTM_STATUS btm_ble_start_adv(void);
    380 extern tBTM_STATUS btm_ble_stop_adv(void);
    381 extern tBTM_STATUS btm_ble_start_scan(void);
    382 extern void btm_ble_create_ll_conn_complete (UINT8 status);
    383 
    384 /* LE security function from btm_sec.c */
    385 #if SMP_INCLUDED == TRUE
    386 extern void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE_SEC_REQ_ACT *p_sec_req_act);
    387 extern void btm_ble_ltk_request_reply(BD_ADDR bda,  BOOLEAN use_stk, BT_OCTET16 stk);
    388 extern UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data);
    389 extern tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, tBTM_BLE_SEC_ACT sec_act, UINT8 link_role);
    390 extern void btm_ble_ltk_request(UINT16 handle, UINT8 rand[8], UINT16 ediv);
    391 extern tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk);
    392 extern void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable);
    393 #endif
    394 
    395 /* LE device management functions */
    396 extern void btm_ble_reset_id( void );
    397 
    398 /* security related functions */
    399 extern void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local );
    400 extern BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div);
    401 extern BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types);
    402 
    403 extern void btm_ble_test_command_complete(UINT8 *p);
    404 extern void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_enc_cplt_cback);
    405 
    406 extern void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY_VALUE *p_keys, BOOLEAN pass_to_application);
    407 extern void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size);
    408 extern UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr);
    409 
    410 /* white list function */
    411 extern BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr);
    412 extern void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy);
    413 extern void btm_update_adv_filter_policy(tBTM_BLE_AFP adv_policy);
    414 extern void btm_ble_clear_white_list (void);
    415 extern void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len);
    416 extern void btm_ble_add_2_white_list_complete(UINT8 status);
    417 extern void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len);
    418 extern void btm_ble_clear_white_list_complete(UINT8 *p, UINT16 evt_len);
    419 extern void btm_ble_white_list_init(UINT8 white_list_size);
    420 
    421 /* background connection function */
    422 extern BOOLEAN btm_ble_suspend_bg_conn(void);
    423 extern BOOLEAN btm_ble_resume_bg_conn(void);
    424 extern void btm_ble_initiate_select_conn(BD_ADDR bda);
    425 extern BOOLEAN btm_ble_start_auto_conn(BOOLEAN start);
    426 extern BOOLEAN btm_ble_start_select_conn(BOOLEAN start,tBTM_BLE_SEL_CBACK   *p_select_cback);
    427 extern BOOLEAN btm_ble_renew_bg_conn_params(BOOLEAN add, BD_ADDR bd_addr);
    428 extern void btm_write_dir_conn_wl(BD_ADDR target_addr);
    429 extern void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bda, UINT8 status);
    430 extern BOOLEAN btm_execute_wl_dev_operation(void);
    431 extern void btm_ble_update_link_topology_mask(UINT8 role, BOOLEAN increase);
    432 
    433 /* direct connection utility */
    434 extern BOOLEAN btm_send_pending_direct_conn(void);
    435 extern void btm_ble_enqueue_direct_conn_req(void *p_param);
    436 
    437 /* BLE address management */
    438 extern void btm_gen_resolvable_private_addr (void *p_cmd_cplt_cback);
    439 extern void btm_gen_non_resolvable_private_addr (tBTM_BLE_ADDR_CBACK *p_cback, void *p);
    440 extern void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK * p_cback, void *p);
    441 extern void btm_gen_resolve_paddr_low(tBTM_RAND_ENC *p);
    442 
    443 /*  privacy function */
    444 #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
    445 /* BLE address mapping with CS feature */
    446 extern BOOLEAN btm_identity_addr_to_random_pseudo(BD_ADDR bd_addr, UINT8 *p_addr_type, BOOLEAN refresh);
    447 extern BOOLEAN btm_random_pseudo_to_identity_addr(BD_ADDR random_pseudo, UINT8 *p_static_addr_type);
    448 extern void btm_ble_refresh_peer_resolvable_private_addr(BD_ADDR pseudo_bda, BD_ADDR rra, UINT8 rra_type);
    449 extern void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr, BD_ADDR local_rpa);
    450 extern void btm_ble_read_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len) ;
    451 extern void btm_ble_remove_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
    452 extern void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
    453 extern void btm_ble_clear_resolving_list_complete(UINT8 *p, UINT16 evt_len);
    454 extern void btm_read_ble_resolving_list_size_complete (UINT8 *p, UINT16 evt_len);
    455 extern void btm_ble_enable_resolving_list(UINT8);
    456 extern BOOLEAN btm_ble_disable_resolving_list(UINT8 rl_mask, BOOLEAN to_resume);
    457 extern void btm_ble_enable_resolving_list_for_platform (UINT8 rl_mask);
    458 extern void btm_ble_resolving_list_init(UINT8 max_irk_list_sz);
    459 extern void btm_ble_resolving_list_cleanup(void);
    460 #endif
    461 
    462 extern void btm_ble_multi_adv_configure_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst);
    463 extern void btm_ble_multi_adv_init(void);
    464 extern void* btm_ble_multi_adv_get_ref(UINT8 inst_id);
    465 extern void btm_ble_multi_adv_cleanup(void);
    466 extern void btm_ble_multi_adv_reenable(UINT8 inst_id);
    467 extern void btm_ble_multi_adv_enb_privacy(BOOLEAN enable);
    468 extern char btm_ble_map_adv_tx_power(int tx_power_index);
    469 extern void btm_ble_batchscan_init(void);
    470 extern void btm_ble_batchscan_cleanup(void);
    471 extern void btm_ble_adv_filter_init(void);
    472 extern void btm_ble_adv_filter_cleanup(void);
    473 extern BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
    474 extern BOOLEAN btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
    475 extern BOOLEAN btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
    476 
    477 #if BTM_BLE_CONFORMANCE_TESTING == TRUE
    478 extern void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc);
    479 extern void btm_ble_set_test_mac_value (BOOLEAN enable, UINT8 *p_test_mac_val);
    480 extern void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_sign_cntr);
    481 extern void btm_set_random_address(BD_ADDR random_bda);
    482 extern void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu);
    483 #endif
    484 
    485 
    486 #ifdef __cplusplus
    487 }
    488 #endif
    489 
    490 #endif
    491