diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index cc00fd66fe..954272be12 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -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) { diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index 61ba0a8ba8..fbb399dde8 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -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 * diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index a84c30ae8d..da29114cef 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -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) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 0319694898..10d3c5abd7 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -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; diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 63926825f4..d489d56d7e 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -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 diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index 08fcb93274..2d28e0f62b 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -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); diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index 5b174bb1d1..c9a9443432 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -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 diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 599b60fe58..0feb497428 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -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; diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index 3af1559ff8..5effd0a97b 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -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, diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c index f218bdf299..618f75d865 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -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); } } diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 81684f875b..e201bdfd99 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -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 diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index 0886b5b789..363a9ddde7 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -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