fix(bt): get remote device name from eir data

This commit is contained in:
gongyantao 2024-07-31 17:24:44 +08:00
parent 9044b81452
commit 4882feaed8

View File

@ -341,6 +341,7 @@ static void handle_bt_device_result(struct disc_res_param *disc_res)
uint8_t len = 0; uint8_t len = 0;
uint8_t *data = 0; uint8_t *data = 0;
do {
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_16BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_16BITS_UUID, &len);
if (data == NULL) { if (data == NULL) {
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_16BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_INCMPL_16BITS_UUID, &len);
@ -349,7 +350,7 @@ static void handle_bt_device_result(struct disc_res_param *disc_res)
uuid.len = ESP_UUID_LEN_16; uuid.len = ESP_UUID_LEN_16;
uuid.uuid.uuid16 = data[0] + (data[1] << 8); uuid.uuid.uuid16 = data[0] + (data[1] << 8);
GAP_DBG_PRINTF(", "); print_uuid(&uuid); GAP_DBG_PRINTF(", "); print_uuid(&uuid);
continue; break;
} }
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_32BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_32BITS_UUID, &len);
@ -360,7 +361,7 @@ static void handle_bt_device_result(struct disc_res_param *disc_res)
uuid.len = len; uuid.len = len;
memcpy(&uuid.uuid.uuid32, data, sizeof(uint32_t)); memcpy(&uuid.uuid.uuid32, data, sizeof(uint32_t));
GAP_DBG_PRINTF(", "); print_uuid(&uuid); GAP_DBG_PRINTF(", "); print_uuid(&uuid);
continue; break;
} }
data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_128BITS_UUID, &len); data = esp_bt_gap_resolve_eir_data((uint8_t *)prop->val, ESP_BT_EIR_TYPE_CMPL_128BITS_UUID, &len);
@ -371,8 +372,8 @@ static void handle_bt_device_result(struct disc_res_param *disc_res)
uuid.len = len; uuid.len = len;
memcpy(uuid.uuid.uuid128, (uint8_t *)data, len); memcpy(uuid.uuid.uuid128, (uint8_t *)data, len);
GAP_DBG_PRINTF(", "); print_uuid(&uuid); GAP_DBG_PRINTF(", "); print_uuid(&uuid);
continue;
} }
} while (0);
//try to find a name //try to find a name
if (name == NULL) { if (name == NULL) {