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:57 UTC

[05/50] incubator-mynewt-core git commit: nimble/att: Don't pass Writes Response as packed structure

nimble/att: Don't pass Writes Response as packed structure

Use packed structure only for mapping it onto received mbuf. Data is
passed to upper layers in native form. This allows compiler to generate
more effective code with regards to unaligned access.


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/a63f7d30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a63f7d30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a63f7d30

Branch: refs/heads/master
Commit: a63f7d30ca2f0128973b258d6592d49775f2fbd5
Parents: 4e0f1b9
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Mar 24 15:39:11 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   |  3 ++-
 net/nimble/host/src/ble_gatt_priv.h |  2 +-
 net/nimble/host/src/ble_gattc.c     | 25 +++++++++++++------------
 3 files changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a63f7d30/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 d34c096..cbd41c9 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -884,7 +884,8 @@ ble_att_clt_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom)
 
 done:
     /* Notify GATT client that the full response has been parsed. */
-    ble_gattc_rx_prep_write_rsp(conn_handle, rc, &rsp, rxom);
+    ble_gattc_rx_prep_write_rsp(conn_handle, rc, rsp.bapc_handle,
+                                rsp.bapc_offset, rxom);
     return rc;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a63f7d30/net/nimble/host/src/ble_gatt_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gatt_priv.h b/net/nimble/host/src/ble_gatt_priv.h
index ea06b33..2ed8170 100644
--- a/net/nimble/host/src/ble_gatt_priv.h
+++ b/net/nimble/host/src/ble_gatt_priv.h
@@ -126,7 +126,7 @@ void ble_gattc_rx_find_type_value_hinfo(
 void ble_gattc_rx_find_type_value_complete(uint16_t conn_handle, int status);
 void ble_gattc_rx_write_rsp(uint16_t conn_handle);
 void ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
-                                 struct ble_att_prep_write_cmd *rsp,
+                                 uint16_t handle, uint16_t offset,
                                  struct os_mbuf **rxom);
 void ble_gattc_rx_exec_write_rsp(uint16_t conn_handle, int status);
 void ble_gattc_rx_indicate_rsp(uint16_t conn_handle);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a63f7d30/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index ca5d541..66344d8 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -335,7 +335,7 @@ typedef int ble_gattc_rx_adata_fn(struct ble_gattc_proc *proc,
                                   struct ble_att_read_type_adata *adata);
 
 typedef int ble_gattc_rx_prep_fn(struct ble_gattc_proc *proc, int status,
-                                 struct ble_att_prep_write_cmd *rsp,
+                                 uint16_t handle, uint16_t offset,
                                  struct os_mbuf **om);
 
 typedef int ble_gattc_rx_attr_fn(struct ble_gattc_proc *proc, int status,
@@ -3917,7 +3917,8 @@ ble_gattc_write_long_err(struct ble_gattc_proc *proc, int status,
  */
 static int
 ble_gattc_write_long_rx_prep(struct ble_gattc_proc *proc,
-                             int status, struct ble_att_prep_write_cmd *rsp,
+                             int status,
+                             uint16_t handle, uint16_t offset,
                              struct os_mbuf **rxom)
 {
     struct os_mbuf *om;
@@ -3943,15 +3944,15 @@ ble_gattc_write_long_rx_prep(struct ble_gattc_proc *proc,
         rc = BLE_HS_EBADDATA;
         goto err;
     }
-    if (rsp->bapc_handle != proc->write_long.attr.handle) {
+    if (handle != proc->write_long.attr.handle) {
         rc = BLE_HS_EBADDATA;
         goto err;
     }
-    if (rsp->bapc_offset != proc->write_long.attr.offset) {
+    if (offset != proc->write_long.attr.offset) {
         rc = BLE_HS_EBADDATA;
         goto err;
     }
-    if (rsp->bapc_offset + OS_MBUF_PKTLEN(om) >
+    if (offset + OS_MBUF_PKTLEN(om) >
         OS_MBUF_PKTLEN(proc->write_long.attr.om)) {
 
         rc = BLE_HS_EBADDATA;
@@ -3962,7 +3963,7 @@ ble_gattc_write_long_rx_prep(struct ble_gattc_proc *proc,
         goto err;
     }
     if (os_mbuf_cmpm(om, 0,
-                     proc->write_long.attr.om, rsp->bapc_offset,
+                     proc->write_long.attr.om, offset,
                      proc->write_long.length) != 0) {
 
         rc = BLE_HS_EBADDATA;
@@ -4225,7 +4226,7 @@ ble_gattc_write_reliable_err(struct ble_gattc_proc *proc, int status,
 static int
 ble_gattc_write_reliable_rx_prep(struct ble_gattc_proc *proc,
                                  int status,
-                                 struct ble_att_prep_write_cmd *rsp,
+                                 uint16_t handle, uint16_t offset,
                                  struct os_mbuf **rxom)
 {
     struct ble_gatt_attr *attr;
@@ -4252,15 +4253,15 @@ ble_gattc_write_reliable_rx_prep(struct ble_gattc_proc *proc,
     attr = proc->write_reliable.attrs + proc->write_reliable.cur_attr;
 
     /* Verify the response. */
-    if (rsp->bapc_handle != attr->handle) {
+    if (handle != attr->handle) {
         rc = BLE_HS_EBADDATA;
         goto err;
     }
-    if (rsp->bapc_offset != attr->offset) {
+    if (offset != attr->offset) {
         rc = BLE_HS_EBADDATA;
         goto err;
     }
-    if (os_mbuf_cmpm(attr->om, rsp->bapc_offset, om, 0,
+    if (os_mbuf_cmpm(attr->om, offset, om, 0,
                      proc->write_reliable.length) != 0) {
 
         rc = BLE_HS_EBADDATA;
@@ -4958,7 +4959,7 @@ ble_gattc_rx_write_rsp(uint16_t conn_handle)
  */
 void
 ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
-                            struct ble_att_prep_write_cmd *rsp,
+                            uint16_t handle, uint16_t offset,
                             struct os_mbuf **om)
 {
 #if !NIMBLE_BLE_ATT_CLT_PREP_WRITE
@@ -4973,7 +4974,7 @@ ble_gattc_rx_prep_write_rsp(uint16_t conn_handle, int status,
                                          ble_gattc_rx_prep_entries,
                                          &rx_entry);
     if (proc != NULL) {
-        rc = rx_entry->cb(proc, status, rsp, om);
+        rc = rx_entry->cb(proc, status, handle, offset, om);
         ble_gattc_process_status(proc, rc);
     }
 }