Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_own_addr_is_rap_random_err_v5.1' into 'relea…
Browse files Browse the repository at this point in the history
…se/v5.1'

Fixed no error report when own address type is rpa_random and no random address setting(backport v5.1)

See merge request espressif/esp-idf!23623
  • Loading branch information
wmy-espressif committed May 8, 2023
2 parents 242713c + 24cc2d7 commit 8a08cfe
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
p_data->add_result.char_uuid.uu.uuid16);
UINT16 char_uuid = p_data->add_result.char_uuid.uu.uuid16;
UINT16 service_id = p_data->add_result.service_id;
if (char_uuid == GATT_UUID_BATTERY_LEVEL) {
bas_AddCharDescr(service_id, p_data->add_result.attr_id);
}
if (char_uuid == GATT_UUID_SYSTEM_ID | GATT_UUID_MODEL_NUMBER_STR | GATT_UUID_PNP_ID |
GATT_UUID_SERIAL_NUMBER_STR | GATT_UUID_FW_VERSION_STR | GATT_UUID_HW_VERSION_STR |
GATT_UUID_SW_VERSION_STR | GATT_UUID_MANU_NAME | GATT_UUID_IEEE_DATA) {
UINT16 uuid_len = p_data->add_result.char_uuid.len;

if (uuid_len == ESP_UUID_LEN_16) {
if (char_uuid == GATT_UUID_BATTERY_LEVEL) {
bas_AddCharDescr(service_id, p_data->add_result.attr_id);
}

switch (char_uuid) {
case GATT_UUID_SYSTEM_ID:
dis_cb.dis_attr[0].handle = service_id; break;
Expand All @@ -130,6 +131,8 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
case GATT_UUID_PNP_ID:
dis_cb.dis_attr[8].handle = service_id; break;
}
default:
break;
}
}
break;
Expand Down
11 changes: 11 additions & 0 deletions components/bt/host/bluedroid/stack/btm/btm_ble_gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,18 @@ 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)
{
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) {
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;
}
}

btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = *own_bda_type;

return BTM_SUCCESS;
}
#endif
Expand Down

0 comments on commit 8a08cfe

Please sign in to comment.