From 3edcd29a838aa333a4ccc72c0fb2f1ff85e74677 Mon Sep 17 00:00:00 2001 From: Yulong Date: Fri, 18 Nov 2016 05:00:47 -0500 Subject: [PATCH] compoent bt:debug the btc_gap_ble module, fix the adv len not long fix --- components/bt/bluedroid/api/esp_gap_ble_api.c | 2 +- .../bt/bluedroid/api/include/esp_gap_ble_api.h | 4 +++- .../bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c | 10 +++++----- .../app_project/Arch_SimpleClientProject.c | 14 ++++++++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/components/bt/bluedroid/api/esp_gap_ble_api.c b/components/bt/bluedroid/api/esp_gap_ble_api.c index 253545341c..a0ec1e0362 100644 --- a/components/bt/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/bluedroid/api/esp_gap_ble_api.c @@ -189,7 +189,7 @@ esp_err_t esp_ble_gap_set_device_name(char *name) *******************************************************************************/ uint8_t *esp_ble_resolve_adv_data( uint8_t *p_adv, uint8_t type, uint8_t *p_length ) { - if ((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_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); diff --git a/components/bt/bluedroid/api/include/esp_gap_ble_api.h b/components/bt/bluedroid/api/include/esp_gap_ble_api.h index 4566713c82..578ac351ae 100644 --- a/components/bt/bluedroid/api/include/esp_gap_ble_api.h +++ b/components/bt/bluedroid/api/include/esp_gap_ble_api.h @@ -12,6 +12,8 @@ #define ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 2 #define ESP_GAP_BLE_SCAN_RESULT_EVT 3 +#define ESP_BLE_ADV_DATA_LEN_MAX 31 + /****************** define the adv type macro***************************************/ #define ESP_BLE_AD_TYPE_FLAG 0x01 #define ESP_BLE_AD_TYPE_16SRV_PART 0x02 @@ -197,7 +199,7 @@ typedef union { esp_bt_dev_type_t dev_type; esp_ble_addr_type_t ble_addr_type; int rssi; - uint8_t *p_eir; /* received EIR */ + uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX]; /* received EIR */ int flag; int num_resps; } scan_rst; diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index b3b605fdb3..e6971c6c03 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -14,6 +14,7 @@ #include +#include "bt_types.h" #include "bta_api.h" #include "btc_task.h" #include "btc_manage.h" @@ -456,22 +457,21 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data { esp_ble_gap_cb_param_t param; btc_msg_t msg; - uint8_t len; - + msg.sig = BTC_SIG_API_CB; msg.pid = BTC_PID_GAP_BLE; msg.act = ESP_GAP_BLE_SCAN_RESULT_EVT; - + param.scan_rst.search_evt = event; switch (event) { case BTA_DM_INQ_RES_EVT: { - LOG_ERROR("BTA_DM_INQ_RES_EVT\n"); bdcpy(param.scan_rst.bda, p_data->inq_res.bd_addr); param.scan_rst.dev_type = p_data->inq_res.device_type; param.scan_rst.rssi = p_data->inq_res.rssi; param.scan_rst.ble_addr_type = p_data->inq_res.ble_addr_type; param.scan_rst.flag = p_data->inq_res.flag; - param.scan_rst.p_eir = p_data->inq_res.p_eir; + memcpy(param.scan_rst.ble_adv, p_data->inq_res.p_eir, + ESP_BLE_ADV_DATA_LEN_MAX); break; } case BTA_DM_INQ_CMPL_EVT: { diff --git a/examples/09_arch_client/components/bluedroid_demos/app_project/Arch_SimpleClientProject.c b/examples/09_arch_client/components/bluedroid_demos/app_project/Arch_SimpleClientProject.c index 3fb3191891..86e8e1eb4a 100644 --- a/examples/09_arch_client/components/bluedroid_demos/app_project/Arch_SimpleClientProject.c +++ b/examples/09_arch_client/components/bluedroid_demos/app_project/Arch_SimpleClientProject.c @@ -119,6 +119,8 @@ static void btif_to_bta_uuid(tBT_UUID *p_dest, bt_uuid_t *p_src) static void esp_scan_result_cb(uint32_t event, void *param) { + uint8_t *adv_name = NULL; + uint8_t adv_name_len = 0; switch(event) { case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: @@ -136,10 +138,18 @@ static void esp_scan_result_cb(uint32_t event, void *param) case ESP_GAP_SEARCH_INQ_RES_EVT: for (int i = 0; i < 6; i++) { - LOG_ERROR("%x\n", scan_result->scan_rst.bda[i]); + LOG_ERROR("%x:", scan_result->scan_rst.bda[i]); + } + LOG_ERROR("\n"); + adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv, + ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len); + LOG_ERROR("adv_name_len=%x\n",adv_name_len); + for(int j = 0; j < adv_name_len; j++) + { + LOG_ERROR("%c",adv_name[j]); } - LOG_ERROR("\n"); + //if(strcmp(scan_result->scan_rst.bda, )) break; case ESP_GAP_SEARCH_INQ_CMPL_EVT: -- 2.40.0