component/bt: add clear white list API

This commit is contained in:
zhiweijian 2020-05-21 11:33:51 +08:00 committed by xiewenxiang
parent a887f8df83
commit ae06bdadaf
12 changed files with 79 additions and 0 deletions

View File

@ -324,6 +324,21 @@ esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_clear_whitelist(void)
{
btc_msg_t msg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_CLEAR_WHITE_LIST;
return (btc_transfer_context(&msg, NULL, 0, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_get_whitelist_size(uint16_t *length)
{
if (length == NULL) {

View File

@ -968,6 +968,16 @@ esp_err_t esp_ble_gap_config_local_icon (uint16_t icon);
*/
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda, esp_ble_wl_addr_type_t wl_addr_type);
/**
* @brief Clear all white list
*
* @return
* - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_clear_whitelist(void);
/**
* @brief Get the whitelist size in the controller
*

View File

@ -715,6 +715,13 @@ void bta_dm_update_white_list(tBTA_DM_MSG *p_data)
#endif ///BLE_INCLUDED == TRUE
}
void bta_dm_clear_white_list(tBTA_DM_MSG *p_data)
{
#if (BLE_INCLUDED == TRUE)
BTM_BleClearWhitelist();
#endif
}
void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data)
{
#if (BLE_INCLUDED == TRUE)

View File

@ -240,6 +240,17 @@ void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_T
}
}
void BTA_DmClearWhiteList(void)
{
tBTA_DM_API_ENABLE *p_msg;
if ((p_msg = (tBTA_DM_API_ENABLE *)osi_malloc(sizeof(tBTA_DM_API_ENABLE))) != NULL) {
p_msg->hdr.event = BTA_DM_API_CLEAR_WHITE_LIST_EVT;
p_msg->p_sec_cback = NULL;
bta_sys_sendmsg(p_msg);
}
}
void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
{
tBTA_DM_API_READ_ADV_TX_POWER *p_msg;

View File

@ -163,6 +163,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */
bta_dm_clear_white_list, /* BTA_DM_API_CLEAR_WHITE_LIST_EVT */
bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */
bta_dm_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */
#if BLE_INCLUDED == TRUE

View File

@ -159,6 +159,7 @@ enum {
BTA_DM_API_REMOVE_ALL_ACL_EVT,
BTA_DM_API_REMOVE_DEVICE_EVT,
BTA_DM_API_UPDATE_WHITE_LIST_EVT,
BTA_DM_API_CLEAR_WHITE_LIST_EVT,
BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT,
BTA_DM_API_READ_RSSI_EVT,
#if BLE_INCLUDED == TRUE
@ -1285,6 +1286,7 @@ extern void bta_dm_disable (tBTA_DM_MSG *p_data);
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
extern void bta_dm_config_eir (tBTA_DM_MSG *p_data);
extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data);
extern void bta_dm_clear_white_list(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data);
extern void bta_dm_read_rssi(tBTA_DM_MSG *p_data);
extern void bta_dm_set_visibility (tBTA_DM_MSG *p_data);

View File

@ -1492,6 +1492,8 @@ void BTA_DmSetQos(BD_ADDR bd_addr, UINT32 t_poll, tBTM_CMPL_CB *p_cb);
#if (BLE_INCLUDED == TRUE)
extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_ADD_WHITELIST_CBACK *add_wl_cb);
extern void BTA_DmClearWhiteList(void);
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
#endif ///BLE_INCLUDED == TRUE

View File

@ -1142,6 +1142,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST:
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, arg->update_white_list.wl_addr_type, btc_add_whitelist_complete_callback);
break;
case BTC_GAP_BLE_ACT_CLEAR_WHITE_LIST:
BTA_DmClearWhiteList();
break;
case BTC_GAP_BLE_ACT_READ_RSSI:
BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
break;

View File

@ -42,6 +42,7 @@ typedef enum {
BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON,
BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST,
BTC_GAP_BLE_ACT_CLEAR_WHITE_LIST,
BTC_GAP_BLE_ACT_SET_CONN_PARAMS,
BTC_GAP_BLE_ACT_SET_DEV_NAME,
BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,

View File

@ -396,6 +396,8 @@ void btm_ble_clear_white_list_complete(UINT8 *p_data, UINT16 evt_len)
if (status == HCI_SUCCESS) {
p_cb->white_list_avail_size = controller_get_interface()->get_ble_white_list_size();
} else {
BTM_TRACE_ERROR ("%s failed, status 0x%x\n", __func__, status);
}
}

View File

@ -310,6 +310,20 @@ BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR remote_bda, tBLE_A
return btm_update_dev_to_white_list(add_remove, remote_bda, addr_type, add_wl_cb);
}
/*******************************************************************************
**
** Function BTM_BleUpdateAdvWhitelist
**
** Description Add or remove device from advertising white list
**
** Returns void
**
*******************************************************************************/
void BTM_BleClearWhitelist(void)
{
btm_ble_clear_white_list();
}
/*******************************************************************************
**
** Function BTM_BleUpdateAdvFilterPolicy

View File

@ -1804,6 +1804,17 @@ void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr,
//extern
BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type, tBTM_ADD_WHITELIST_CBACK *add_wl_cb);
/*******************************************************************************
**
** Function BTM_BleClearWhitelist
**
** Description Clear all white list
**
** Returns void
**
*******************************************************************************/
void BTM_BleClearWhitelist(void);
/*******************************************************************************
**
** Function BTM_BleUpdateAdvFilterPolicy