From b07a5f03cfc13b6c3b9a4376736bc88869f64ae8 Mon Sep 17 00:00:00 2001 From: Yulong Date: Tue, 14 Nov 2017 07:00:45 -0500 Subject: [PATCH] component/bt: Change the gattc prepare write callback params. --- components/bt/bluedroid/api/include/esp_gattc_api.h | 1 + components/bt/bluedroid/bta/gatt/bta_gattc_utils.c | 11 +++++++---- components/bt/bluedroid/bta/include/bta_gatt_api.h | 1 + .../bt/bluedroid/btc/profile/std/gatt/btc_gattc.c | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/components/bt/bluedroid/api/include/esp_gattc_api.h b/components/bt/bluedroid/api/include/esp_gattc_api.h index 1bf9d3b9f4..adf3dbda37 100644 --- a/components/bt/bluedroid/api/include/esp_gattc_api.h +++ b/components/bt/bluedroid/api/include/esp_gattc_api.h @@ -146,6 +146,7 @@ typedef union { esp_gatt_status_t status; /*!< Operation status */ uint16_t conn_id; /*!< Connection id */ uint16_t handle; /*!< The Characteristic or descriptor handle */ + uint16_t offset; /*!< The prepare write offset, this value is valid only when prepare write */ } write; /*!< Gatt client callback param of ESP_GATTC_WRITE_DESCR_EVT */ /** diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c b/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c index 620d08e830..b5409b40b3 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_utils.c @@ -460,13 +460,16 @@ BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) if (p_clcb->p_q_cmd == NULL) { p_clcb->p_q_cmd = p_data; return TRUE; - } else if (p_data->hdr.event == BTA_GATTC_API_WRITE_EVT && - p_data->api_write.write_type == BTA_GATTC_WRITE_PREPARE && - p_data->api_write.handle == p_clcb->p_q_cmd->api_write.handle && - bta_gattc_has_prepare_command_in_queue(p_clcb)) { + } else if ((p_data->hdr.event == BTA_GATTC_API_WRITE_EVT && + p_data->api_write.write_type == BTA_GATTC_WRITE_PREPARE) && + ((p_clcb->p_q_cmd->hdr.event == BTA_GATTC_API_WRITE_EVT && + p_clcb->p_q_cmd->api_write.write_type == BTA_GATTC_WRITE_PREPARE) || + bta_gattc_has_prepare_command_in_queue(p_clcb))) { + APPL_TRACE_DEBUG("%s(), prepare offset = %d", __func__, p_data->api_write.offset); cb_data.write.status = BTA_GATT_CONGESTED; cb_data.write.handle = p_data->api_write.handle; cb_data.write.conn_id = p_clcb->bta_conn_id; + cb_data.write.offset = p_data->api_write.offset; /* write complete, callback */ if (p_clcb->p_rcb->p_cback != NULL) { ( *p_clcb->p_rcb->p_cback)(BTA_GATTC_PREP_WRITE_EVT, (tBTA_GATTC *)&cb_data); diff --git a/components/bt/bluedroid/bta/include/bta_gatt_api.h b/components/bt/bluedroid/bta/include/bta_gatt_api.h index b7dfa855a6..95f6815216 100644 --- a/components/bt/bluedroid/bta/include/bta_gatt_api.h +++ b/components/bt/bluedroid/bta/include/bta_gatt_api.h @@ -299,6 +299,7 @@ typedef struct { UINT16 conn_id; tBTA_GATT_STATUS status; UINT16 handle; + UINT16 offset; }tBTA_GATTC_WRITE; typedef struct { diff --git a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c index a1a1c88541..a49f3ed1b7 100644 --- a/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c +++ b/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c @@ -770,6 +770,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg) param.write.conn_id = BTC_GATT_GET_CONN_ID(write->conn_id); param.write.status = write->status; param.write.handle = write->handle; + param.write.offset = write->offset; btc_gattc_cb_to_app(ret_evt, gattc_if, ¶m); break; } -- 2.40.0