Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_bleqabr23_178' into 'master'
Browse files Browse the repository at this point in the history
fix(bt/bluedroid): Fix address check when using NRPA as random device address

See merge request espressif/esp-idf!25074
  • Loading branch information
esp-cjh committed Aug 7, 2023
2 parents ad149a6 + 7083222 commit f5d9986
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions components/bt/host/bluedroid/stack/btm/btm_ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,17 +1049,28 @@ uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *
#else
uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *cb)
{
tBTM_LE_RANDOM_CB *p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;

if((*own_bda_type == BLE_ADDR_RANDOM) || (*own_bda_type == BLE_ADDR_RANDOM_ID)) {
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) != BTM_BLE_GAP_ADDR_BIT_RANDOM) {
if((p_cb->exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) != BTM_BLE_GAP_ADDR_BIT_RANDOM) {
BTM_TRACE_ERROR("No random address yet, please set random address and try\n");
if(cb) {
(* cb)(HCI_ERR_ESP_VENDOR_FAIL);
}
return BTM_ILLEGAL_VALUE;
}

// If a device is using RPA, it shall also have an Identity Address
if ((*own_bda_type == BLE_ADDR_RANDOM_ID) && BTM_BLE_IS_NON_RESLVE_BDA(p_cb->static_rand_addr)) {
BTM_TRACE_ERROR("No identity address yet, please set static random address and try\n");
if (cb) {
(* cb)(HCI_ERR_ESP_VENDOR_FAIL);
}
return BTM_ILLEGAL_VALUE;
}
}

btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = *own_bda_type;
p_cb->own_addr_type = *own_bda_type;

return BTM_SUCCESS;
}
Expand Down
4 changes: 3 additions & 1 deletion components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@
typedef UINT8 tBTM_BLE_SEC_REQ_ACT;

#define BLE_STATIC_PRIVATE_MSB_MASK 0x3f
#define BLE_RESOLVE_ADDR_MSB 0x40 /* most significant bit, bit7, bit6 is 01 to be resolvable random */
#define BLE_NON_RESOLVE_ADDR_MSB 0x00 /* most significant bit, bit7, bit6 is 00 to be non-resolvable random */
#define BLE_RESOLVE_ADDR_MSB 0x40 /* most significant bit, bit7, bit6 is 01 to be resolvable random */
#define BLE_RESOLVE_ADDR_MASK 0xc0 /* bit 6, and bit7 */
#define BTM_BLE_IS_NON_RESLVE_BDA(x) ((x[0] & BLE_RESOLVE_ADDR_MASK) == BLE_NON_RESOLVE_ADDR_MSB)
#define BTM_BLE_IS_RESOLVE_BDA(x) ((x[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB)

/* LE scan activity bit mask, continue with LE inquiry bits */
Expand Down

0 comments on commit f5d9986

Please sign in to comment.