From a0f864456cfed56301dd99926c4d14af3638577a Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Mon, 26 Aug 2024 19:27:36 +0800 Subject: [PATCH] fix(ble/bluedroid): Optimize BLE function 'esp_ble_resolve_adv_data_by_type' --- components/bt/host/bluedroid/api/esp_gap_ble_api.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index a359b6274e..9f70036e88 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -477,13 +477,17 @@ uint8_t *esp_ble_resolve_adv_data_by_type( uint8_t *adv_data, uint16_t adv_data_ if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) && (type != ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE)) { - LOG_ERROR("the eir type not define, type = %x\n", type); + LOG_ERROR("The advertising data type is not defined, type = %x", type); *length = 0; return NULL; } - if (adv_data == NULL || adv_data_len == 0) { - LOG_ERROR("Invalid advertising data.\n"); + if (adv_data_len == 0) { + *length = 0; + return NULL; + } + if (adv_data == NULL) { + LOG_ERROR("Invalid advertising data."); *length = 0; return NULL; }