component/bt : gatt client fix search service bug

1. fix search service bug
2. delete some print
This commit is contained in:
Tian Hao 2016-11-22 17:26:30 +08:00
parent 3b432735c6
commit 595bd2e3c4
7 changed files with 47 additions and 9 deletions

View file

@ -198,7 +198,12 @@ esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_u
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_SEARCH_SERVICE;
arg.conn_id = conn_id;
memcpy(&arg.uuid, filter_uuid, sizeof(esp_bt_uuid_t));
if (filter_uuid) {
arg.have_uuid = true;
memcpy(&arg.uuid, filter_uuid, sizeof(esp_bt_uuid_t));
} else {
arg.have_uuid = false;
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View file

@ -93,8 +93,14 @@ static void btc_gattc_cfg_mtu(btc_ble_gattc_args_t *arg)
static void btc_gattc_search_service(btc_ble_gattc_args_t *arg)
{
tBT_UUID *srvc_uuid = (tBT_UUID *)(&arg->uuid);
BTA_GATTC_ServiceSearchRequest(arg->conn_id, srvc_uuid);
tBT_UUID srvc_uuid;
if (arg->have_uuid) {
btc_to_bta_uuid(&srvc_uuid, &arg->uuid);
BTA_GATTC_ServiceSearchRequest(arg->conn_id, &srvc_uuid);
} else {
BTA_GATTC_ServiceSearchRequest(arg->conn_id, NULL);
}
}
static void btc_gattc_get_first_char(btc_ble_gattc_args_t *arg)
@ -488,7 +494,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
case BTA_GATTC_SEARCH_RES_EVT: {
tBTA_GATTC_SRVC_RES *srvc_res = &arg->srvc_res;
param.search_res.conn_id = srvc_res->conn_id;
memcpy(&param.search_res.service_id, &srvc_res->service_uuid, sizeof(esp_gatt_srvc_id_t));
bta_to_btc_srvc_id(&param.search_res.service_id, &srvc_res->service_uuid);
BTC_GATTC_CB_TO_APP(ESP_GATTC_SEARCH_RES_EVT, &param);
break;
}

View file

@ -39,6 +39,7 @@ typedef struct {
esp_gatt_auth_req_t auth_req;
esp_bd_addr_t remote_bda;
esp_bt_uuid_t uuid;
bool have_uuid;
uint16_t app_id;
uint16_t conn_id;
uint16_t mtu;

View file

@ -197,7 +197,7 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet) {
return;
}
if (type < DATA_TYPE_ACL || type > DATA_TYPE_EVENT) {
LOG_ERROR("%d Unknown HCI message type. Dropping this byte 0x%x,"
LOG_ERROR("%s Unknown HCI message type. Dropping this byte 0x%x,"
" min %x, max %x\n", __func__, type,
DATA_TYPE_ACL, DATA_TYPE_EVENT);
hci_hal_env.allocator->free(packet);

View file

@ -120,7 +120,8 @@ static void fragment_and_dispatch(BT_HDR *packet) {
}
static void reassemble_and_dispatch(BT_HDR *packet) {
LOG_ERROR("reassemble_and_dispatch\n");
LOG_DEBUG("reassemble_and_dispatch\n");
if ((packet->event & MSG_EVT_MASK) == MSG_HC_TO_STACK_HCI_ACL) {
uint8_t *stream = packet->data;
uint16_t handle;

View file

@ -192,7 +192,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
/* only process fixed channel data as channel open indication when link is not in disconnecting mode */
l2cble_notify_le_connection(p_lcb->remote_bd_addr);
#endif
L2CAP_TRACE_WARNING ("L2CAP - rcv_cid CID: 0x%04x\n", rcv_cid);
L2CAP_TRACE_DEBUG ("L2CAP - rcv_cid CID: 0x%04x\n", rcv_cid);
/* Find the CCB for this CID */
if (rcv_cid >= L2CAP_BASE_APPL_CID)
{

View file

@ -33,6 +33,7 @@
#include "bta_gatt_api.h"
#include "esp_gap_ble_api.h"
#include "esp_gattc_api.h"
#include "esp_gatt_defs.h"
#include "esp_bt_main.h"
@ -207,10 +208,34 @@ static void esp_gattc_result_cb(uint32_t event, void *gattc_param)
conidx = gattc_data->open.conn_id;
LOG_ERROR("conidx = %x, if = %x\n",conidx, gattc_data->open.gatt_if);
esp_ble_gattc_search_service(conidx, NULL);
LOG_ERROR("ESP_GATTC_OPEN_EVT\n");
LOG_ERROR("ESP_GATTC_OPEN_EVT status %d\n", gattc_data->open.status);
break;
case ESP_GATTC_SEARCH_RES_EVT: {
esp_gatt_srvc_id_t *srvc_id = &gattc_data->search_res.service_id;
conidx = gattc_data->open.conn_id;
LOG_ERROR("SEARCH RES: conidx = %x\n", conidx);
if (srvc_id->id.uuid.len == ESP_UUID_LEN_16) {
LOG_ERROR("UUID16: %x\n", srvc_id->id.uuid.uuid.uuid16);
} else if (srvc_id->id.uuid.len == ESP_UUID_LEN_32) {
LOG_ERROR("UUID32: %x\n", srvc_id->id.uuid.uuid.uuid32);
} else if (srvc_id->id.uuid.len == ESP_UUID_LEN_128) {
LOG_ERROR("UUID128: %x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\n", srvc_id->id.uuid.uuid.uuid128[0],
srvc_id->id.uuid.uuid.uuid128[1],srvc_id->id.uuid.uuid.uuid128[2], srvc_id->id.uuid.uuid.uuid128[3],
srvc_id->id.uuid.uuid.uuid128[4],srvc_id->id.uuid.uuid.uuid128[5],srvc_id->id.uuid.uuid.uuid128[6],
srvc_id->id.uuid.uuid.uuid128[7],srvc_id->id.uuid.uuid.uuid128[8],srvc_id->id.uuid.uuid.uuid128[9],
srvc_id->id.uuid.uuid.uuid128[10],srvc_id->id.uuid.uuid.uuid128[11],srvc_id->id.uuid.uuid.uuid128[12],
srvc_id->id.uuid.uuid.uuid128[13],srvc_id->id.uuid.uuid.uuid128[14],srvc_id->id.uuid.uuid.uuid128[15]);
} else {
LOG_ERROR("UNKNOWN LEN %d\n", srvc_id->id.uuid.len);
}
break;
}
case ESP_GATTC_SEARCH_CMPL_EVT:
conidx = gattc_data->search_cmpl.conn_id;
LOG_ERROR("SEARCH_CMPL: conidx = %x, status %d\n",conidx, gattc_data->search_cmpl.status);
break;
default:
break;
break;
}
}