Merge branch 'bugfix/btdm_pair_fail_with_random_address' into 'master'
component/bt: Fix bug when pair with random address See merge request !1784
This commit is contained in:
parent
4a55009f3e
commit
df93f672e3
2 changed files with 64 additions and 2 deletions
|
@ -596,7 +596,12 @@ void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr,
|
|||
BD_ADDR dummy_bda = {0};
|
||||
|
||||
if (p != NULL) {
|
||||
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
|
||||
/*
|
||||
* Temporary solutions for pair with random address:
|
||||
* use BLE_ADDR_RANDOM when adverting with random adress or in privacy mode
|
||||
* We will do futher work here
|
||||
*/
|
||||
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE || btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) {
|
||||
p->conn_addr_type = BLE_ADDR_RANDOM;
|
||||
if (memcmp(local_rpa, dummy_bda, BD_ADDR_LEN)) {
|
||||
memcpy(p->conn_addr, local_rpa, BD_ADDR_LEN);
|
||||
|
|
|
@ -736,6 +736,22 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
|
|||
if (!controller_get_interface()->supports_ble()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporary solutions for pair with random address:
|
||||
* can't set privacy when advertising, scaning or using static random address
|
||||
* We will do futher work here
|
||||
*/
|
||||
if (p_cb->privacy_mode == BTM_PRIVACY_NONE
|
||||
&& random_cb->own_addr_type == BLE_ADDR_RANDOM) {
|
||||
BTM_TRACE_ERROR("Have set random adress, can't set privacy ");
|
||||
return FALSE;
|
||||
}
|
||||
if (!(p_cb->inq_var.state != BTM_BLE_STOP_SCAN && p_cb->inq_var.state != BTM_BLE_STOP_ADV)) {
|
||||
BTM_TRACE_ERROR("Advertising or scaning now, can't set privacy ");
|
||||
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 */
|
||||
|
@ -1165,6 +1181,16 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
|
|||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporary solutions for pair with random address:
|
||||
* can't set advertising with BLE_ADDR_PUBLIC when having set random adress or in privacy mode
|
||||
* We will do futher work here
|
||||
*/
|
||||
if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && own_bda_type == BLE_ADDR_PUBLIC) {
|
||||
BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n");
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
|
||||
!BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
|
@ -1315,6 +1341,19 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
|
|||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporary solutions for pair with random address:
|
||||
* can't set scan with BLE_ADDR_PUBLIC when having set random adress or in privacy mode
|
||||
* We will do futher work here
|
||||
*/
|
||||
if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && addr_type_own == BLE_ADDR_PUBLIC) {
|
||||
BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n");
|
||||
if (scan_setup_status_cback != NULL) {
|
||||
scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* If not supporting extended scan support, use the older range for checking */
|
||||
if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) {
|
||||
max_scan_interval = BTM_BLE_SCAN_INT_MAX;
|
||||
|
@ -1500,6 +1539,24 @@ BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr)
|
|||
if (rand_addr == NULL)
|
||||
return set_flag;
|
||||
|
||||
/*
|
||||
* Temporary solutions for pair with random address:
|
||||
* can't set rand address when advertising, scaning or in privacy mode
|
||||
* We will do futher work here
|
||||
*/
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
|
||||
BTM_TRACE_ERROR("privacy_mode is not BTM_PRIVACY_NONE ");
|
||||
return set_flag;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!(btm_cb.ble_ctr_cb.inq_var.state != BTM_BLE_STOP_SCAN && btm_cb.ble_ctr_cb.inq_var.state != BTM_BLE_STOP_ADV)) {
|
||||
BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress ");
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, rand_addr, BD_ADDR_LEN);
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
//send the set random address to the controller
|
||||
set_flag = btsnd_hcic_ble_set_random_addr(rand_addr);
|
||||
return set_flag;
|
||||
|
|
Loading…
Reference in a new issue