mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(bt): Fix bug with address resolution enabling during non-connected activities
This commit is contained in:
parent
70951831c0
commit
9a9ce20e41
@ -869,15 +869,6 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (p_cb->inq_var.state != BTM_BLE_IDLE) {
|
||||
BTM_TRACE_ERROR("Advertising or scaning now, can't set privacy ");
|
||||
if (random_cb && random_cb->set_local_privacy_cback){
|
||||
(*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_FAIL);
|
||||
random_cb->set_local_privacy_cback = NULL;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE)
|
||||
uint8_t addr_resolution = 0;
|
||||
#endif /* defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE */
|
||||
@ -886,22 +877,12 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
|
||||
memset(p_cb->addr_mgnt_cb.resolvale_addr, 0, BD_ADDR_LEN);
|
||||
p_cb->addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
p_cb->privacy_mode = BTM_PRIVACY_NONE;
|
||||
if (random_cb && random_cb->set_local_privacy_cback){
|
||||
(*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_SUCCESS);
|
||||
random_cb->set_local_privacy_cback = NULL;
|
||||
}
|
||||
// Disable RPA function
|
||||
btsnd_hcic_ble_set_addr_resolution_enable(FALSE);
|
||||
} else { /* privacy is turned on*/
|
||||
#if (CONTROLLER_RPA_LIST_ENABLE == FALSE)
|
||||
/* always set host random address, used when privacy 1.1 or priavcy 1.2 is disabled */
|
||||
btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low);
|
||||
#else
|
||||
/* Controller generates RPA, Host don't need to set random address */
|
||||
if (random_cb && random_cb->set_local_privacy_cback){
|
||||
(*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_SUCCESS);
|
||||
random_cb->set_local_privacy_cback = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (BTM_BleMaxMultiAdvInstanceCount() > 0) {
|
||||
|
@ -377,6 +377,46 @@ void btm_ble_read_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len)
|
||||
btm_ble_refresh_peer_resolvable_private_addr(pseudo_bda, rra, rra_type);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_set_addr_resolution_enable_complete
|
||||
**
|
||||
** Description This function is called when the command to set address
|
||||
** resolution enable completes.
|
||||
**
|
||||
** Parameters p: Pointer to the command complete event data.
|
||||
** evt_len: Length of the event data.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_set_addr_resolution_enable_complete(UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
UINT8 status;
|
||||
|
||||
STREAM_TO_UINT8(status, p);
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = %d", __func__, status);
|
||||
|
||||
tBTM_LE_RANDOM_CB *random_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
|
||||
|
||||
if (!(random_cb && random_cb->set_local_privacy_cback)) {
|
||||
BTM_TRACE_ERROR("no set local privacy callback found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (status == HCI_SUCCESS) {
|
||||
random_cb->set_local_privacy_cback(BTM_SUCCESS);
|
||||
return;
|
||||
} else if (status == HCI_ERR_COMMAND_DISALLOWED) {
|
||||
BTM_TRACE_ERROR("a non-connected activity is ongoing, such as advertising and scanning");
|
||||
} else {
|
||||
BTM_TRACE_ERROR("set local privacy failed");
|
||||
}
|
||||
random_cb->set_local_privacy_cback(BTM_ILLEGAL_VALUE);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
VSC that implement controller based privacy
|
||||
********************************************************************************/
|
||||
|
@ -482,6 +482,7 @@ BOOLEAN btm_random_pseudo_to_identity_addr(BD_ADDR random_pseudo, UINT8 *p_stati
|
||||
void btm_ble_refresh_peer_resolvable_private_addr(BD_ADDR pseudo_bda, BD_ADDR rra, UINT8 rra_type);
|
||||
void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr, BD_ADDR local_rpa);
|
||||
void btm_ble_read_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len) ;
|
||||
void btm_ble_set_addr_resolution_enable_complete(UINT8 *p, UINT16 evt_len) ;
|
||||
void btm_ble_remove_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_clear_resolving_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
|
@ -1084,7 +1084,10 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
|
||||
break;
|
||||
|
||||
case HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL:
|
||||
break;
|
||||
case HCI_BLE_SET_ADDR_RESOLUTION_ENABLE:
|
||||
btm_ble_set_addr_resolution_enable_complete(p, evt_len);
|
||||
break;
|
||||
case HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT:
|
||||
break;
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
Loading…
Reference in New Issue
Block a user