Merge branch 'bugfix/btdm_gattc_mutiple_read_bug' into 'master'

component/bt: Fixed the bug of mutiple read can not callback.

See merge request !1286
This commit is contained in:
Jiang Jiang Jian 2017-09-30 15:45:56 +08:00
commit a8dab7680a
6 changed files with 33 additions and 16 deletions

View file

@ -63,6 +63,7 @@ typedef enum {
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
ESP_GATTC_READ_MUTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor mutiple complete, the event comes */
} esp_gattc_cb_event_t;

View file

@ -83,7 +83,8 @@ static UINT16 bta_gattc_opcode_to_int_evt[] = {
BTA_GATTC_API_READ_EVT,
BTA_GATTC_API_WRITE_EVT,
BTA_GATTC_API_EXEC_EVT,
BTA_GATTC_API_CFG_MTU_EVT
BTA_GATTC_API_CFG_MTU_EVT,
BTA_GATTC_API_READ_MULTI_EVT
};
#if (BT_TRACE_VERBOSE == TRUE)
@ -1225,8 +1226,12 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
} else {
cb_data.read.handle = p_clcb->p_q_cmd->api_read.handle;
}
event = p_clcb->p_q_cmd->api_read.cmpl_evt;
if (p_clcb->p_q_cmd->hdr.event != BTA_GATTC_API_READ_MULTI_EVT) {
event = p_clcb->p_q_cmd->api_read.cmpl_evt;
} else {
event = p_clcb->p_q_cmd->api_read_multi.cmpl_evt;
}
cb_data.read.conn_id = p_clcb->bta_conn_id;
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
@ -1348,20 +1353,22 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
return;
}
if (p_clcb->p_q_cmd->hdr.event != bta_gattc_opcode_to_int_evt[op - GATTC_OPTYPE_READ]) {
mapped_op = p_clcb->p_q_cmd->hdr.event - BTA_GATTC_API_READ_EVT + GATTC_OPTYPE_READ;
if ( mapped_op > GATTC_OPTYPE_INDICATION) {
mapped_op = 0;
}
if (p_clcb->p_q_cmd->hdr.event != BTA_GATTC_API_READ_MULTI_EVT) {
mapped_op = p_clcb->p_q_cmd->hdr.event - BTA_GATTC_API_READ_EVT + GATTC_OPTYPE_READ;
if ( mapped_op > GATTC_OPTYPE_INDICATION) {
mapped_op = 0;
}
#if (BT_TRACE_VERBOSE == TRUE)
APPL_TRACE_ERROR("expect op:(%s :0x%04x), receive unexpected operation (%s).",
bta_gattc_op_code_name[mapped_op] , p_clcb->p_q_cmd->hdr.event,
bta_gattc_op_code_name[op]);
APPL_TRACE_ERROR("expect op:(%s :0x%04x), receive unexpected operation (%s).",
bta_gattc_op_code_name[mapped_op] , p_clcb->p_q_cmd->hdr.event,
bta_gattc_op_code_name[op]);
#else
APPL_TRACE_ERROR("expect op:(%u :0x%04x), receive unexpected operation (%u).",
mapped_op , p_clcb->p_q_cmd->hdr.event, op);
APPL_TRACE_ERROR("expect op:(%u :0x%04x), receive unexpected operation (%u).",
mapped_op , p_clcb->p_q_cmd->hdr.event, op);
#endif
return;
return;
}
}
/* discard responses if service change indication is received before operation completed */

View file

@ -545,7 +545,7 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
p_buf->hdr.layer_specific = conn_id;
p_buf->auth_req = auth_req;
p_buf->num_attr = p_read_multi->num_attr;
p_buf->cmpl_evt = BTA_GATTC_READ_MUTIPLE_EVT;
if (p_buf->num_attr > 0) {
memcpy(p_buf->handles, p_read_multi->handles, sizeof(UINT16) * p_read_multi->num_attr);
}

View file

@ -181,6 +181,7 @@ typedef UINT8 tBTA_GATT_STATUS;
#define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */
#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
#define BTA_GATTC_READ_MUTIPLE_EVT 37 /* GATTC Read mutiple event */
typedef UINT8 tBTA_GATTC_EVT;

View file

@ -165,6 +165,7 @@ typedef struct {
tBTA_GATT_AUTH_REQ auth_req;
UINT8 num_attr;
UINT16 handles[GATT_MAX_READ_MULTI_HANDLES];
tBTA_GATTC_EVT cmpl_evt;
}tBTA_GATTC_API_READ_MULTI;
typedef struct {

View file

@ -128,7 +128,8 @@ static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
// Allocate buffer for request data if necessary
switch (msg->act) {
case BTA_GATTC_READ_DESCR_EVT:
case BTA_GATTC_READ_CHAR_EVT: {
case BTA_GATTC_READ_CHAR_EVT:
case BTA_GATTC_READ_MUTIPLE_EVT: {
if (p_src_data->read.p_value && p_src_data->read.p_value->p_value) {
p_dest_data->read.p_value = (tBTA_GATT_UNFMT *)osi_malloc(sizeof(tBTA_GATT_UNFMT) + p_src_data->read.p_value->len);
p_dest_data->read.p_value->p_value = (uint8_t *)(p_dest_data->read.p_value + 1);
@ -151,7 +152,8 @@ static void btc_gattc_free_req_data(btc_msg_t *msg)
tBTA_GATTC *arg = (tBTA_GATTC *)(msg->arg);
switch (msg->act) {
case BTA_GATTC_READ_DESCR_EVT:
case BTA_GATTC_READ_CHAR_EVT: {
case BTA_GATTC_READ_CHAR_EVT:
case BTA_GATTC_READ_MUTIPLE_EVT: {
if (arg->read.p_value) {
osi_free(arg->read.p_value);
}
@ -807,6 +809,11 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
btc_gattc_cb_to_app(ESP_GATTC_READ_DESCR_EVT, gattc_if, &param);
break;
}
case BTA_GATTC_READ_MUTIPLE_EVT: {
set_read_value(&gattc_if, &param, &arg->read);
btc_gattc_cb_to_app(ESP_GATTC_READ_MUTIPLE_EVT, gattc_if, &param);
break;
}
case BTA_GATTC_WRITE_DESCR_EVT: {
tBTA_GATTC_WRITE *write = &arg->write;