From b041c042bb30bedf204e775ca3fa9ad7edeff7c0 Mon Sep 17 00:00:00 2001 From: baohongde Date: Thu, 10 Aug 2017 20:05:10 +0800 Subject: [PATCH 1/2] component/bt: Fix gatt read by type response bug --- components/bt/bluedroid/stack/gatt/gatt_db.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/bt/bluedroid/stack/gatt/gatt_db.c b/components/bt/bluedroid/stack/gatt/gatt_db.c index 1fe69e004..371c4c6c0 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_db.c +++ b/components/bt/bluedroid/stack/gatt/gatt_db.c @@ -334,6 +334,8 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb, #if (defined(BLE_DELAY_REQUEST_ENC) && (BLE_DELAY_REQUEST_ENC == TRUE)) UINT8 flag; #endif + BOOLEAN need_rsp; + BOOLEAN have_send_request = false; if (p_db && p_db->p_attr_list) { p_attr = (tGATT_ATTR16 *)p_db->p_attr_list; @@ -359,14 +361,21 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb, UINT16_TO_STREAM (p, p_attr->handle); status = read_attr_value ((void *)p_attr, 0, &p, FALSE, (UINT16)(*p_len - 2), &len, sec_flag, key_size); + if (status == GATT_PENDING) { - if (status == GATT_PENDING || status == GATT_STACK_RSP) { - BOOLEAN need_rsp = (status != GATT_STACK_RSP); + + need_rsp = TRUE; status = gatts_send_app_read_request(p_tcb, op_code, p_attr->handle, 0, trans_id, need_rsp); /* one callback at a time */ break; - } else if (status == GATT_SUCCESS) { + } else if (status == GATT_SUCCESS || status == GATT_STACK_RSP) { + if (status == GATT_STACK_RSP && !have_send_request){ + need_rsp = FALSE; + status = gatts_send_app_read_request(p_tcb, op_code, p_attr->handle, 0, trans_id, need_rsp); + have_send_request = true; + } + if (p_rsp->offset == 0) { p_rsp->offset = len + 2; } From 593fbe6d8d7e41b5b5a2ea8db967b9415eb279b1 Mon Sep 17 00:00:00 2001 From: baohongde Date: Tue, 22 Aug 2017 18:11:01 +0800 Subject: [PATCH 2/2] updata gatt read by type response bug --- components/bt/bluedroid/stack/gatt/gatt_db.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/bt/bluedroid/stack/gatt/gatt_db.c b/components/bt/bluedroid/stack/gatt/gatt_db.c index 371c4c6c0..0f9e37cc6 100644 --- a/components/bt/bluedroid/stack/gatt/gatt_db.c +++ b/components/bt/bluedroid/stack/gatt/gatt_db.c @@ -370,10 +370,16 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb, /* one callback at a time */ break; } else if (status == GATT_SUCCESS || status == GATT_STACK_RSP) { - if (status == GATT_STACK_RSP && !have_send_request){ + if (status == GATT_STACK_RSP){ need_rsp = FALSE; status = gatts_send_app_read_request(p_tcb, op_code, p_attr->handle, 0, trans_id, need_rsp); - have_send_request = true; + if(status == GATT_BUSY) + break; + + if (!have_send_request){ + have_send_request = true; + trans_id = p_tcb->sr_cmd.trans_id; + } } if (p_rsp->offset == 0) {