compoent bt:debug the btc_gap_ble module, fix the adv len not long fix

This commit is contained in:
Yulong 2016-11-18 05:00:47 -05:00
parent 2f7288ff03
commit 3edcd29a83
4 changed files with 21 additions and 9 deletions

View File

@ -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);

View File

@ -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;

View File

@ -14,6 +14,7 @@
#include <string.h>
#include "bt_types.h"
#include "bta_api.h"
#include "btc_task.h"
#include "btc_manage.h"
@ -456,7 +457,6 @@ 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;
@ -465,13 +465,13 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
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: {

View File

@ -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: