]> granicus.if.org Git - esp-idf/commitdiff
component/bt: Change the gattc prepare write callback params.
authorYulong <huangyulong@espressif.com>
Tue, 14 Nov 2017 12:00:45 +0000 (07:00 -0500)
committerYulong <huangyulong@espressif.com>
Tue, 14 Nov 2017 12:00:45 +0000 (07:00 -0500)
components/bt/bluedroid/api/include/esp_gattc_api.h
components/bt/bluedroid/bta/gatt/bta_gattc_utils.c
components/bt/bluedroid/bta/include/bta_gatt_api.h
components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c

index 1bf9d3b9f4f5e8b84382b6002834ab645774d29f..adf3dbda375f7d7ae27521eb96448ef4cfd5c854 100644 (file)
@@ -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 */
 
     /**
index 620d08e83075a05383a76a1eb7423ee749460465..b5409b40b3bc5a5bec07be994735b43d756f27db 100644 (file)
@@ -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);
index b7dfa855a69732eb87475d34a839a3a9be176eb2..95f681521646916a3593fed65a8a4437328d32b1 100644 (file)
@@ -299,6 +299,7 @@ typedef struct {
     UINT16              conn_id;
     tBTA_GATT_STATUS    status;
     UINT16              handle;
+    UINT16              offset;
 }tBTA_GATTC_WRITE;
 
 typedef struct {
index a1a1c88541710979337ec60a153ff1bd7d00c616..a49f3ed1b76938889097cccefcb2ecda8ac0d3e2 100644 (file)
@@ -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, &param);
         break;
     }