Merge branch 'bugfix/fix_bleqabr23_138' into 'master'

Bluedroid: report status after clearing the BLE white list

See merge request espressif/esp-idf!23094
This commit is contained in:
Jiang Jiang Jian 2023-04-11 09:59:24 +08:00
commit 18af256a84
12 changed files with 57 additions and 45 deletions

View File

@ -502,7 +502,7 @@ int bt_le_update_white_list(struct bt_mesh_white_list *wl)
}
if (BTM_BleUpdateAdvWhitelist(wl->add_remove, wl->remote_bda,
wl->addr_type, (tBTM_ADD_WHITELIST_CBACK *)wl->update_wl_comp_cb) == false) {
wl->addr_type, (tBTM_UPDATE_WHITELIST_CBACK *)wl->update_wl_comp_cb) == false) {
return -EIO;
}

View File

@ -650,6 +650,7 @@ typedef enum {
typedef enum{
ESP_BLE_WHITELIST_REMOVE = 0X00, /*!< remove mac from whitelist */
ESP_BLE_WHITELIST_ADD = 0X01, /*!< add address to whitelist */
ESP_BLE_WHITELIST_CLEAR = 0x02, /*!< clear all device in whitelist */
} esp_ble_wl_operation_t;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
typedef enum {

View File

@ -845,14 +845,14 @@ void bta_dm_ble_set_channels (tBTA_DM_MSG *p_data)
void bta_dm_update_white_list(tBTA_DM_MSG *p_data)
{
#if (BLE_INCLUDED == TRUE)
BTM_BleUpdateAdvWhitelist(p_data->white_list.add_remove, p_data->white_list.remote_addr, p_data->white_list.addr_type, p_data->white_list.add_wl_cb);
BTM_BleUpdateAdvWhitelist(p_data->white_list.add_remove, p_data->white_list.remote_addr, p_data->white_list.addr_type, p_data->white_list.update_wl_cb);
#endif ///BLE_INCLUDED == TRUE
}
void bta_dm_clear_white_list(tBTA_DM_MSG *p_data)
{
#if (BLE_INCLUDED == TRUE)
BTM_BleClearWhitelist();
BTM_BleClearWhitelist(p_data->white_list.update_wl_cb);
#endif
}

View File

@ -324,26 +324,26 @@ void BTA_DmBleSetChannels(const uint8_t *channels, tBTA_CMPL_CB *set_channels_c
}
void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_ADD_WHITELIST_CBACK *add_wl_cb)
void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb)
{
tBTA_DM_API_UPDATE_WHITE_LIST *p_msg;
if ((p_msg = (tBTA_DM_API_UPDATE_WHITE_LIST *)osi_malloc(sizeof(tBTA_DM_API_UPDATE_WHITE_LIST))) != NULL) {
p_msg->hdr.event = BTA_DM_API_UPDATE_WHITE_LIST_EVT;
p_msg->add_remove = add_remove;
p_msg->addr_type = addr_type;
p_msg->add_wl_cb = add_wl_cb;
p_msg->update_wl_cb = update_wl_cb;
memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR));
bta_sys_sendmsg(p_msg);
}
}
void BTA_DmClearWhiteList(void)
void BTA_DmClearWhiteList(tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb)
{
tBTA_DM_API_ENABLE *p_msg;
if ((p_msg = (tBTA_DM_API_ENABLE *)osi_malloc(sizeof(tBTA_DM_API_ENABLE))) != NULL) {
tBTA_DM_API_UPDATE_WHITE_LIST *p_msg;
if ((p_msg = (tBTA_DM_API_UPDATE_WHITE_LIST *)osi_malloc(sizeof(tBTA_DM_API_UPDATE_WHITE_LIST))) != NULL) {
p_msg->hdr.event = BTA_DM_API_CLEAR_WHITE_LIST_EVT;
p_msg->p_sec_cback = NULL;
p_msg->update_wl_cb = update_wl_cb;
bta_sys_sendmsg(p_msg);
}

View File

@ -279,7 +279,7 @@ typedef struct {
BOOLEAN add_remove;
BD_ADDR remote_addr;
tBLE_ADDR_TYPE addr_type;
tBTA_ADD_WHITELIST_CBACK *add_wl_cb;
tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb;
}tBTA_DM_API_UPDATE_WHITE_LIST;
typedef struct {

View File

@ -420,7 +420,7 @@ typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK;
typedef tBTM_START_STOP_ADV_CMPL_CBACK tBTA_START_STOP_ADV_CMPL_CBACK;
typedef tBTM_ADD_WHITELIST_CBACK tBTA_ADD_WHITELIST_CBACK;
typedef tBTM_UPDATE_WHITELIST_CBACK tBTA_UPDATE_WHITELIST_CBACK;
typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
@ -1756,9 +1756,9 @@ void BTA_DmSetQos(BD_ADDR bd_addr, UINT32 t_poll, tBTM_CMPL_CB *p_cb);
*******************************************************************************/
void BTA_DmBleSetChannels(const uint8_t *channels, tBTA_CMPL_CB *set_channels_cb);
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_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBLE_ADDR_TYPE addr_type, tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb);
extern void BTA_DmClearWhiteList(void);
extern void BTA_DmClearWhiteList(tBTA_UPDATE_WHITELIST_CBACK *update_wl_cb);
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
#endif ///BLE_INCLUDED == TRUE

View File

@ -811,7 +811,7 @@ static void btc_gap_ble_set_channels_cmpl_callback(void *p_data)
}
static void btc_add_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION wl_opration)
static void btc_update_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION wl_opration)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
@ -1607,10 +1607,10 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
btc_ble_config_local_icon(arg->cfg_local_icon.icon);
break;
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);
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, arg->update_white_list.wl_addr_type, btc_update_whitelist_complete_callback);
break;
case BTC_GAP_BLE_ACT_CLEAR_WHITE_LIST:
BTA_DmClearWhiteList();
BTA_DmClearWhiteList(btc_update_whitelist_complete_callback);
break;
case BTC_GAP_BLE_ACT_READ_RSSI:
BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);

View File

@ -276,12 +276,12 @@ void btm_enq_wl_dev_operation(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE ad
** the white list.
**
*******************************************************************************/
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBTM_ADD_WHITELIST_CBACK *add_wl_cb)
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
{
if(addr_type > BLE_ADDR_RANDOM) {
BTM_TRACE_ERROR("%s address type is error, unable to add device", __func__);
if (add_wl_cb){
add_wl_cb(HCI_ERR_ILLEGAL_PARAMETER_FMT,to_add);
if (update_wl_cb){
update_wl_cb(HCI_ERR_ILLEGAL_PARAMETER_FMT,to_add);
}
return FALSE;
}
@ -313,8 +313,8 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
// do nothing
} else {
BTC_TRACE_ERROR(" controller not support resolvable address");
if (add_wl_cb){
add_wl_cb(HCI_ERR_ILLEGAL_PARAMETER_FMT,to_add);
if (update_wl_cb){
update_wl_cb(HCI_ERR_ILLEGAL_PARAMETER_FMT,to_add);
}
return FALSE;
}
@ -325,8 +325,8 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
if (to_add && p_cb->white_list_avail_size == 0) {
BTM_TRACE_ERROR("%s Whitelist full, unable to add device", __func__);
if (add_wl_cb){
add_wl_cb(HCI_ERR_MEMORY_FULL,to_add);
if (update_wl_cb){
update_wl_cb(HCI_ERR_MEMORY_FULL,to_add);
}
return FALSE;
}
@ -335,8 +335,8 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
/* added the bd_addr to the connection hash map queue */
if(!background_connection_add((bt_bdaddr_t *)bd_addr)) {
/* if the bd_addr already exist in whitelist, just callback return TRUE */
if (add_wl_cb){
add_wl_cb(HCI_SUCCESS,to_add);
if (update_wl_cb){
update_wl_cb(HCI_SUCCESS,to_add);
}
return TRUE;
}
@ -344,16 +344,16 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
/* remove the bd_addr to the connection hash map queue */
if(!background_connection_remove((bt_bdaddr_t *)bd_addr)){
/* if the bd_addr don't exist in whitelist, just callback return TRUE */
if (add_wl_cb){
add_wl_cb(HCI_SUCCESS,to_add);
if (update_wl_cb){
update_wl_cb(HCI_SUCCESS,to_add);
}
return TRUE;
}
}
if (add_wl_cb){
if (update_wl_cb){
//save add whitelist complete callback
p_cb->add_wl_cb = add_wl_cb;
p_cb->update_wl_cb = update_wl_cb;
}
/* stop the auto connect */
btm_suspend_wl_activity(p_cb->wl_state);
@ -371,11 +371,17 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
** Description This function clears the white list.
**
*******************************************************************************/
void btm_ble_clear_white_list (void)
void btm_ble_clear_white_list (tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
BTM_TRACE_EVENT ("btm_ble_clear_white_list");
btsnd_hcic_ble_clear_white_list();
background_connections_clear();
if (update_wl_cb) {
p_cb->update_wl_cb = update_wl_cb;
}
}
/*******************************************************************************
@ -399,6 +405,10 @@ void btm_ble_clear_white_list_complete(UINT8 *p_data, UINT16 evt_len)
} else {
BTM_TRACE_ERROR ("%s failed, status 0x%x\n", __func__, status);
}
if (p_cb->update_wl_cb) {
(*p_cb->update_wl_cb)(status, BTM_WHITELIST_CLEAR);
}
}
/*******************************************************************************
@ -429,9 +439,9 @@ void btm_ble_add_2_white_list_complete(UINT8 status)
--btm_cb.ble_ctr_cb.white_list_avail_size;
}
// add whitelist complete callback
if (p_cb->add_wl_cb)
if (p_cb->update_wl_cb)
{
(*p_cb->add_wl_cb)(status, BTM_WHITELIST_ADD);
(*p_cb->update_wl_cb)(status, BTM_WHITELIST_ADD);
}
}
@ -451,9 +461,9 @@ void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len)
if (*p == HCI_SUCCESS) {
++btm_cb.ble_ctr_cb.white_list_avail_size;
}
if (p_cb->add_wl_cb)
if (p_cb->update_wl_cb)
{
(*p_cb->add_wl_cb)(*p, BTM_WHITELIST_REMOVE);
(*p_cb->update_wl_cb)(*p, BTM_WHITELIST_REMOVE);
}
}

View File

@ -321,9 +321,9 @@ void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn
** Returns void
**
*******************************************************************************/
BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, tBTM_ADD_WHITELIST_CBACK *add_wl_cb)
BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
{
return btm_update_dev_to_white_list(add_remove, remote_bda, addr_type, add_wl_cb);
return btm_update_dev_to_white_list(add_remove, remote_bda, addr_type, update_wl_cb);
}
/*******************************************************************************
@ -335,9 +335,9 @@ BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR remote_bda, tBLE_A
** Returns void
**
*******************************************************************************/
void BTM_BleClearWhitelist(void)
void BTM_BleClearWhitelist(tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
{
btm_ble_clear_white_list();
btm_ble_clear_white_list(update_wl_cb);
}
/*******************************************************************************
@ -1273,7 +1273,7 @@ BOOLEAN BTM_BleSetBgConnType(tBTM_BLE_CONN_TYPE bg_conn_type,
void BTM_BleClearBgConnDev(void)
{
btm_ble_start_auto_conn(FALSE);
btm_ble_clear_white_list();
btm_ble_clear_white_list(NULL);
gatt_reset_bgdev_list();
}

View File

@ -347,7 +347,7 @@ typedef struct {
tBTM_BLE_SEL_CBACK *p_select_cback;
/* white list information */
UINT8 white_list_avail_size;
tBTM_ADD_WHITELIST_CBACK *add_wl_cb;
tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb;
tBTM_BLE_WL_STATE wl_state;
fixed_queue_t *conn_pending_q;
@ -442,10 +442,10 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size);
UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr);
/* white list function */
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBTM_ADD_WHITELIST_CBACK *add_wl_cb);
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy);
void btm_update_adv_filter_policy(tBTM_BLE_AFP adv_policy);
void btm_ble_clear_white_list (void);
void btm_ble_clear_white_list (tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len);
void btm_ble_add_2_white_list_complete(UINT8 status);
void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len);

View File

@ -152,6 +152,7 @@ typedef struct {
typedef enum{
BTM_WHITELIST_REMOVE = 0X00,
BTM_WHITELIST_ADD = 0X01,
BTM_WHITELIST_CLEAR = 0x02,
}tBTM_WL_OPERATION;
@ -190,7 +191,7 @@ typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DAT
typedef void (tBTM_SET_RAND_ADDR_CBACK) (UINT8 status);
typedef void (tBTM_ADD_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_opration);
typedef void (tBTM_UPDATE_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_opration);
typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status);

View File

@ -2270,7 +2270,7 @@ 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);
BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
/*******************************************************************************
**
@ -2281,7 +2281,7 @@ BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_AD
** Returns void
**
*******************************************************************************/
void BTM_BleClearWhitelist(void);
void BTM_BleClearWhitelist(tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
/*******************************************************************************
**