Skip to content

Commit ef0f7f6

Browse files
committed
Merge branch 'bugfix/fix_ble_resolve_adv_data_v5.0' into 'release/v5.0'
fix(ble/bluedroid): Fixed memory out-of-bounds issue when parsing adv data (v5.0) See merge request espressif/esp-idf!33026
2 parents fd859c6 + ae186b8 commit ef0f7f6

File tree

17 files changed

+151
-43
lines changed

17 files changed

+151
-43
lines changed

components/bt/controller/esp32/bt.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ do{\
9292
#define OSI_VERSION 0x00010005
9393
#define OSI_MAGIC_VALUE 0xFADEBEAD
9494

95+
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL)
9596
/* Types definition
9697
************************************************************************
9798
*/
@@ -909,7 +910,21 @@ static int IRAM_ATTR cause_sw_intr_to_core_wrapper(int core_id, int intr_no)
909910

910911
static void *malloc_internal_wrapper(size_t size)
911912
{
912-
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
913+
return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
914+
}
915+
916+
void *malloc_ble_controller_mem(size_t size)
917+
{
918+
void *p = heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
919+
if(p == NULL) {
920+
ESP_LOGE(BTDM_LOG_TAG, "Malloc failed");
921+
}
922+
return p;
923+
}
924+
925+
uint32_t get_ble_controller_free_heap_size(void)
926+
{
927+
return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS);
913928
}
914929

915930
static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6])

components/bt/controller/esp32c3/bt.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ do{\
117117

118118
#define BLE_PWR_HDL_INVL 0xFFFF
119119

120+
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA)
120121
/* Types definition
121122
************************************************************************
122123
*/
@@ -715,13 +716,27 @@ static bool IRAM_ATTR is_in_isr_wrapper(void)
715716

716717
static void *malloc_internal_wrapper(size_t size)
717718
{
718-
void *p = heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);
719+
void *p = heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
719720
if(p == NULL) {
720721
ESP_LOGE(BT_LOG_TAG, "Malloc failed");
721722
}
722723
return p;
723724
}
724725

726+
void *malloc_ble_controller_mem(size_t size)
727+
{
728+
void *p = heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
729+
if(p == NULL) {
730+
ESP_LOGE(BT_LOG_TAG, "Malloc failed");
731+
}
732+
return p;
733+
}
734+
735+
uint32_t get_ble_controller_free_heap_size(void)
736+
{
737+
return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS);
738+
}
739+
725740
static int IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
726741
{
727742
int ret = esp_read_mac(mac, ESP_MAC_BT);

components/bt/host/bluedroid/api/esp_gap_ble_api.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,21 +488,33 @@ esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t
488488
return ESP_OK;
489489
}
490490

491-
uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length)
491+
uint8_t *esp_ble_resolve_adv_data_by_type( uint8_t *adv_data, uint16_t adv_data_len, esp_ble_adv_data_type type, uint8_t *length)
492492
{
493+
if (length == NULL) {
494+
return NULL;
495+
}
496+
493497
if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) &&
494498
(type != ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE)) {
495499
LOG_ERROR("the eir type not define, type = %x\n", type);
500+
*length = 0;
496501
return NULL;
497502
}
498503

499-
if (adv_data == NULL) {
500-
LOG_ERROR("Invalid p_eir data.\n");
504+
if (adv_data == NULL || adv_data_len == 0) {
505+
LOG_ERROR("Invalid advertising data.\n");
506+
*length = 0;
501507
return NULL;
502508
}
503509

504-
return (BTM_CheckAdvData( adv_data, type, length));
510+
return (BTM_CheckAdvData( adv_data, adv_data_len, type, length));
505511
}
512+
513+
uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length)
514+
{
515+
return esp_ble_resolve_adv_data_by_type( adv_data, ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX, (esp_ble_adv_data_type) type, length);
516+
}
517+
506518
#if (BLE_42_FEATURE_SUPPORT == TRUE)
507519
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
508520
{

components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,17 +1903,41 @@ esp_err_t esp_ble_gap_get_device_name(void);
19031903
*
19041904
*/
19051905
esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t * addr_type);
1906+
19061907
/**
19071908
* @brief This function is called to get ADV data for a specific type.
19081909
*
1909-
* @param[in] adv_data - pointer of ADV data which to be resolved
1910-
* @param[in] type - finding ADV data type
1911-
* @param[out] length - return the length of ADV data not including type
1910+
* @note This is the recommended function to use for resolving ADV data by type.
1911+
* It improves upon the deprecated `esp_ble_resolve_adv_data` function by
1912+
* including an additional parameter to specify the length of the ADV data,
1913+
* thereby offering better safety and reliability.
1914+
*
1915+
* @param[in] adv_data - pointer of ADV data which to be resolved
1916+
* @param[in] adv_data_len - the length of ADV data which to be resolved.
1917+
* @param[in] type - finding ADV data type
1918+
* @param[out] length - return the length of ADV data not including type
19121919
*
1913-
* @return pointer of ADV data
1920+
* @return pointer of ADV data
1921+
*
1922+
*/
1923+
uint8_t *esp_ble_resolve_adv_data_by_type( uint8_t *adv_data, uint16_t adv_data_len, esp_ble_adv_data_type type, uint8_t *length);
1924+
1925+
/**
1926+
* @brief This function is called to get ADV data for a specific type.
1927+
*
1928+
* @note This function has been deprecated and will be removed in a future release.
1929+
* Please use `esp_ble_resolve_adv_data_by_type` instead, which provides
1930+
* better parameter validation and supports more accurate data resolution.
1931+
*
1932+
* @param[in] adv_data - pointer of ADV data which to be resolved
1933+
* @param[in] type - finding ADV data type
1934+
* @param[out] length - return the length of ADV data not including type
1935+
*
1936+
* @return pointer of ADV data
19141937
*
19151938
*/
19161939
uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length);
1940+
19171941
#if (BLE_42_FEATURE_SUPPORT == TRUE)
19181942
/**
19191943
* @brief This function is called to set raw advertising data. User need to fill

components/bt/host/bluedroid/stack/btm/btm_ble_gap.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,7 +2101,7 @@ BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type)
21012101
** Returns pointer of ADV data
21022102
**
21032103
*******************************************************************************/
2104-
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length)
2104+
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT16 adv_data_len, UINT8 type, UINT8 *p_length)
21052105
{
21062106
UINT8 *p = p_adv;
21072107
UINT8 length;
@@ -2110,7 +2110,7 @@ UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length)
21102110

21112111
STREAM_TO_UINT8(length, p);
21122112

2113-
while ( length && (p - p_adv < BTM_BLE_CACHE_ADV_DATA_MAX)) {
2113+
while ( length && (p - p_adv < adv_data_len)) {
21142114
STREAM_TO_UINT8(adv_type, p);
21152115

21162116
if ( adv_type == type ) {
@@ -2123,7 +2123,7 @@ UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length)
21232123

21242124
/* Break loop if advertising data is in an incorrect format,
21252125
as it may lead to memory overflow */
2126-
if (p >= p_adv + BTM_BLE_CACHE_ADV_DATA_MAX) {
2126+
if (p >= p_adv + adv_data_len) {
21272127
break;
21282128
}
21292129

@@ -3176,7 +3176,7 @@ UINT8 btm_ble_is_discoverable(BD_ADDR bda, UINT8 evt_type, UINT8 *p)
31763176
}
31773177

31783178
if (p_le_inq_cb->adv_len != 0) {
3179-
if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache,
3179+
if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len,
31803180
BTM_BLE_AD_TYPE_FLAG, &data_len)) != NULL) {
31813181
flag = * p_flag;
31823182

@@ -3392,7 +3392,7 @@ BOOLEAN btm_ble_update_inq_result(BD_ADDR bda, tINQ_DB_ENT *p_i, UINT8 addr_type
33923392
p_i->inq_count = p_inq->inq_counter; /* Mark entry for current inquiry */
33933393

33943394
if (p_le_inq_cb->adv_len != 0) {
3395-
if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, BTM_BLE_AD_TYPE_FLAG, &len)) != NULL) {
3395+
if ((p_flag = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len, BTM_BLE_AD_TYPE_FLAG, &len)) != NULL) {
33963396
p_cur->flag = * p_flag;
33973397
}
33983398
}
@@ -3402,11 +3402,11 @@ BOOLEAN btm_ble_update_inq_result(BD_ADDR bda, tINQ_DB_ENT *p_i, UINT8 addr_type
34023402
* then try to convert the appearance value to a class of device value Bluedroid can use.
34033403
* Otherwise fall back to trying to infer if it is a HID device based on the service class.
34043404
*/
3405-
p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, BTM_BLE_AD_TYPE_APPEARANCE, &len);
3405+
p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len, BTM_BLE_AD_TYPE_APPEARANCE, &len);
34063406
if (p_uuid16 && len == 2) {
34073407
btm_ble_appearance_to_cod((UINT16)p_uuid16[0] | (p_uuid16[1] << 8), p_cur->dev_class);
34083408
} else {
3409-
if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache,
3409+
if ((p_uuid16 = BTM_CheckAdvData(p_le_inq_cb->adv_data_cache, p_le_inq_cb->adv_len,
34103410
BTM_BLE_AD_TYPE_16SRV_CMPL, &len)) != NULL) {
34113411
UINT8 i;
34123412
for (i = 0; i + 2 <= len; i = i + 2) {
@@ -3493,10 +3493,10 @@ void btm_send_sel_conn_callback(BD_ADDR remote_bda, UINT8 evt_type, UINT8 *p_dat
34933493

34943494
/* get the device name if exist in ADV data */
34953495
if (data_len != 0) {
3496-
p_dev_name = BTM_CheckAdvData(p_data, BTM_BLE_AD_TYPE_NAME_CMPL, &len);
3496+
p_dev_name = BTM_CheckAdvData(p_data, data_len, BTM_BLE_AD_TYPE_NAME_CMPL, &len);
34973497

34983498
if (p_dev_name == NULL) {
3499-
p_dev_name = BTM_CheckAdvData(p_data, BTM_BLE_AD_TYPE_NAME_SHORT, &len);
3499+
p_dev_name = BTM_CheckAdvData(p_data, data_len, BTM_BLE_AD_TYPE_NAME_SHORT, &len);
35003500
}
35013501

35023502
if (p_dev_name) {

components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_cback);
21122112
**
21132113
*******************************************************************************/
21142114
//extern
2115-
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length);
2115+
UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT16 adv_data_len, UINT8 type, UINT8 *p_length);
21162116

21172117
/*******************************************************************************
21182118
**

examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
247247
case ESP_GAP_SEARCH_INQ_RES_EVT:
248248
esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6);
249249
ESP_LOGI(GATTC_TAG, "Searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len);
250-
adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv, ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
250+
adv_name = esp_ble_resolve_adv_data_by_type(scan_result->scan_rst.ble_adv,
251+
scan_result->scan_rst.adv_data_len + scan_result->scan_rst.scan_rsp_len,
252+
ESP_BLE_AD_TYPE_NAME_CMPL,
253+
&adv_name_len);
251254
ESP_LOGI(GATTC_TAG, "Searched Device Name Len %d", adv_name_len);
252255
esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len);
253256
ESP_LOGI(GATTC_TAG, "\n");

examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,10 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
388388
case ESP_GAP_SEARCH_INQ_RES_EVT:
389389
esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6);
390390
ESP_LOGI(GATTC_TAG, "searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len);
391-
adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,
392-
ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
391+
adv_name = esp_ble_resolve_adv_data_by_type(scan_result->scan_rst.ble_adv,
392+
scan_result->scan_rst.adv_data_len + scan_result->scan_rst.scan_rsp_len,
393+
ESP_BLE_AD_TYPE_NAME_CMPL,
394+
&adv_name_len);
393395
ESP_LOGI(GATTC_TAG, "searched Device Name Len %d", adv_name_len);
394396
esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len);
395397
ESP_LOGI(GATTC_TAG, "\n");

examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,10 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
339339
case ESP_GAP_SEARCH_INQ_RES_EVT:
340340
esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6);
341341
ESP_LOGI(GATTC_TAG, "searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len);
342-
adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,
343-
ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
342+
adv_name = esp_ble_resolve_adv_data_by_type(scan_result->scan_rst.ble_adv,
343+
scan_result->scan_rst.adv_data_len + scan_result->scan_rst.scan_rsp_len,
344+
ESP_BLE_AD_TYPE_NAME_CMPL,
345+
&adv_name_len);
344346
ESP_LOGI(GATTC_TAG, "searched Device Name Len %d", adv_name_len);
345347
esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len);
346348

examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,10 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
439439
case ESP_GAP_SEARCH_INQ_RES_EVT:
440440
esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6);
441441
ESP_LOGI(GATTC_TAG, "Searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len);
442-
adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,
443-
ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
442+
adv_name = esp_ble_resolve_adv_data_by_type(scan_result->scan_rst.ble_adv,
443+
scan_result->scan_rst.adv_data_len + scan_result->scan_rst.scan_rsp_len,
444+
ESP_BLE_AD_TYPE_NAME_CMPL,
445+
&adv_name_len);
444446
ESP_LOGI(GATTC_TAG, "Searched Device Name Len %d", adv_name_len);
445447
esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len);
446448
ESP_LOGI(GATTC_TAG, "\n");

examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,10 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
769769
case ESP_GAP_SEARCH_INQ_RES_EVT:
770770
esp_log_buffer_hex(GATTC_TAG, scan_result->scan_rst.bda, 6);
771771
ESP_LOGI(GATTC_TAG, "Searched Adv Data Len %d, Scan Response Len %d", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len);
772-
adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,
773-
ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
772+
adv_name = esp_ble_resolve_adv_data_by_type(scan_result->scan_rst.ble_adv,
773+
scan_result->scan_rst.adv_data_len + scan_result->scan_rst.scan_rsp_len,
774+
ESP_BLE_AD_TYPE_NAME_CMPL,
775+
&adv_name_len);
774776
ESP_LOGI(GATTC_TAG, "Searched Device Name Len %d", adv_name_len);
775777
esp_log_buffer_char(GATTC_TAG, adv_name, adv_name_len);
776778
ESP_LOGI(GATTC_TAG, "\n");

examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,10 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
484484
} else {
485485
ESP_LOGI(GATTC_TAG, "extend adv, adv type 0x%x data len %d", param->ext_adv_report.params.event_type, param->ext_adv_report.params.adv_data_len);
486486
}
487-
adv_name = esp_ble_resolve_adv_data(param->ext_adv_report.params.adv_data,
488-
ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
487+
adv_name = esp_ble_resolve_adv_data_by_type(param->ext_adv_report.params.adv_data,
488+
param->ext_adv_report.params.adv_data_len,
489+
ESP_BLE_AD_TYPE_NAME_CMPL,
490+
&adv_name_len);
489491
if (!connect && strlen(remote_device_name) == adv_name_len && strncmp((char *)adv_name, remote_device_name, adv_name_len) == 0) {
490492
connect = true;
491493
esp_ble_gap_stop_ext_scan();

examples/bluetooth/bluedroid/ble_50/peroidic_sync/main/periodic_sync_demo.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
108108
case ESP_GAP_BLE_EXT_ADV_REPORT_EVT: {
109109
uint8_t *adv_name = NULL;
110110
uint8_t adv_name_len = 0;
111-
adv_name = esp_ble_resolve_adv_data(param->ext_adv_report.params.adv_data, ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
111+
adv_name = esp_ble_resolve_adv_data_by_type(param->ext_adv_report.params.adv_data,
112+
param->ext_adv_report.params.adv_data_len,
113+
ESP_BLE_AD_TYPE_NAME_CMPL,
114+
&adv_name_len);
112115
if ((adv_name != NULL) && (memcmp(adv_name, "ESP_MULTI_ADV_80MS", adv_name_len) == 0) && !periodic_sync) {
113116
periodic_sync = true;
114117
char adv_temp_name[30] = {'0'};

examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,10 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
293293
esp_ble_gap_cb_param_t *scan_result = (esp_ble_gap_cb_param_t *)param;
294294
switch (scan_result->scan_rst.search_evt) {
295295
case ESP_GAP_SEARCH_INQ_RES_EVT:
296-
adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv,
297-
ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);
296+
adv_name = esp_ble_resolve_adv_data_by_type(scan_result->scan_rst.ble_adv,
297+
scan_result->scan_rst.adv_data_len + scan_result->scan_rst.scan_rsp_len,
298+
ESP_BLE_AD_TYPE_NAME_CMPL,
299+
&adv_name_len);
298300
if (adv_name != NULL) {
299301
if (strlen(remote_device_name) == adv_name_len && strncmp((char *)adv_name, remote_device_name, adv_name_len) == 0) {
300302
if (connect == false) {

examples/bluetooth/blufi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To test this demo, you need to prepare a mobile phone with blufi application ins
2020
Blufi is completely open source, here is the download link:
2121

2222
* [Blufi source code](https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/blufi)
23-
* [BluFi protocol](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/blufi.html?highlight=blufi#the-frame-formats-defined-in-blufi)
23+
* [BluFi protocol](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/ble/blufi.html)
2424
* [iOS source code](https://github.com/EspressifApp/EspBlufiForiOS)
2525
* [Android source code](https://github.com/EspressifApp/EspBlufi)
2626
* [Bluetooth Network User Guide CN](https://www.espressif.com/sites/default/files/documentation/esp32_bluetooth_networking_user_guide_cn.pdf)

0 commit comments

Comments
 (0)