You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2017/04/10 11:46:56 UTC

[04/50] incubator-mynewt-core git commit: nimble/att: Use packed struct for receiving Error Response

nimble/att: Use packed struct for receiving Error Response

Use packed structure to map it to received mbuf instead of using
dedicated parsing function. Modern compilers generate effective code
in such case anyway.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/8e602737
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8e602737
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8e602737

Branch: refs/heads/master
Commit: 8e602737948270f5d40369d354f485a41ef94caa
Parents: a63f7d3
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Mar 24 15:40:05 2017 +0100
Committer: Szymon Janc <sz...@codecoup.pl>
Committed: Mon Apr 10 11:31:31 2017 +0200

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_clt.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8e602737/net/nimble/host/src/ble_att_clt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_clt.c b/net/nimble/host/src/ble_att_clt.c
index cbd41c9..c63ec52 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -33,18 +33,25 @@
 int
 ble_att_clt_rx_error(uint16_t conn_handle, struct os_mbuf **rxom)
 {
-    struct ble_att_error_rsp rsp;
+    struct ble_att_error_rsp *rsp;
     int rc;
 
-    rc = ble_hs_mbuf_pullup_base(rxom, BLE_ATT_ERROR_RSP_SZ);
+    /* TODO move this to common part
+     * Strip L2CAP ATT header from the front of the mbuf.
+     */
+    os_mbuf_adj(*rxom, 1);
+
+    rc = ble_hs_mbuf_pullup_base(rxom, sizeof(*rsp));
     if (rc != 0) {
         return rc;
     }
 
-    ble_att_error_rsp_parse((*rxom)->om_data, (*rxom)->om_len, &rsp);
-    BLE_ATT_LOG_CMD(0, "error rsp", conn_handle, ble_att_error_rsp_log, &rsp);
+    rsp = (struct ble_att_error_rsp *)(*rxom)->om_data;
+
+    BLE_ATT_LOG_CMD(0, "error rsp", conn_handle, ble_att_error_rsp_log, rsp);
 
-    ble_gattc_rx_err(conn_handle, rsp.baep_handle, rsp.baep_error_code);
+    ble_gattc_rx_err(conn_handle, le16toh(rsp->baep_handle),
+                     le16toh(rsp->baep_error_code));
 
     return 0;
 }