]> granicus.if.org Git - esp-idf/commitdiff
component/bt: Check the value received from the peer device when sent the data used...
authorYulong <huangyulong@espressif.com>
Thu, 26 Apr 2018 13:01:53 +0000 (09:01 -0400)
committerYulong <huangyulong@espressif.com>
Fri, 27 Apr 2018 12:20:01 +0000 (08:20 -0400)
component/bt: Fix misspellings of "corret" in comments in bta_gattc_write_cmpl function.

components/bt/bluedroid/bta/gatt/bta_gattc_act.c

index c3e729f48bd87f6daf2a332daa213c25656d9ad8..455a761b21b06b9cc5fd7231e6ba75f0d45bc30e 100644 (file)
@@ -1278,11 +1278,16 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
 
     if (p_clcb->p_q_cmd->api_write.hdr.event == BTA_GATTC_API_WRITE_EVT &&
         p_clcb->p_q_cmd->api_write.write_type == BTA_GATTC_WRITE_PREPARE) {
+        // Should check the value received from the peer device is correct or not.
+        if (memcmp(p_clcb->p_q_cmd->api_write.p_value, p_data->p_cmpl->att_value.value,
+                   p_data->p_cmpl->att_value.len) != 0) {
+            cb_data.write.status = BTA_GATT_INVALID_PDU;
+        }
 
         event = BTA_GATTC_PREP_WRITE_EVT;
-               } else {
+    } else {
         event = p_clcb->p_q_cmd->api_write.cmpl_evt;
-       }
+    }
     //free the command data store in the queue.
     bta_gattc_free_command_data(p_clcb);
     bta_gattc_pop_command_to_send(p_clcb);