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:47:04 UTC

[12/50] incubator-mynewt-core git commit: nimble/att: Use new helpers for sending Find Information Request

nimble/att: Use new helpers for sending Find Information Request

This constructs response directly on mbuf reducing number of memcopies.


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

Branch: refs/heads/master
Commit: 5e82b3f7c0daf08547b51ec47907891e4cbb1b38
Parents: 1c08e62
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Mar 24 15:32:18 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           | 25 ++++++++++--------------
 net/nimble/host/src/ble_att_priv.h          |  4 ++--
 net/nimble/host/src/ble_gattc.c             |  8 +++-----
 net/nimble/host/test/src/ble_att_clt_test.c | 17 ++++------------
 4 files changed, 19 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5e82b3f7/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 c35ad89..f72b209 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -209,37 +209,32 @@ ble_att_clt_rx_mtu(uint16_t conn_handle, struct os_mbuf **rxom)
  *****************************************************************************/
 
 int
-ble_att_clt_tx_find_info(uint16_t conn_handle,
-                         const struct ble_att_find_info_req *req)
+ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle,
+                         uint16_t end_handle)
 {
 #if !NIMBLE_BLE_ATT_CLT_FIND_INFO
     return BLE_HS_ENOTSUP;
 #endif
 
+    struct ble_att_find_info_req *req;
     struct os_mbuf *txom;
-    int rc;
-
-    if (req->bafq_start_handle == 0 ||
-        req->bafq_start_handle > req->bafq_end_handle) {
 
+    if (start_handle == 0 || start_handle > end_handle) {
         return BLE_HS_EINVAL;
     }
 
-    rc = ble_att_clt_init_req(BLE_ATT_FIND_INFO_REQ_SZ, &txom);
-    if (rc != 0) {
-        return rc;
+    req = ble_att_cmd_get(BLE_ATT_OP_FIND_INFO_REQ, sizeof(*req), &txom);
+    if (req == NULL) {
+        return BLE_HS_ENOMEM;
     }
-    ble_att_find_info_req_write(txom->om_data, txom->om_len, req);
 
-    rc = ble_att_clt_tx_req(conn_handle, txom);
-    if (rc != 0) {
-        return rc;
-    }
+    req->bafq_start_handle = htole16(start_handle);
+    req->bafq_end_handle = htole16(end_handle);
 
     BLE_ATT_LOG_CMD(1, "find info req", conn_handle,
                     ble_att_find_info_req_log, req);
 
-    return 0;
+    return ble_att_tx(conn_handle, txom);
 }
 
 static int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5e82b3f7/net/nimble/host/src/ble_att_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_priv.h b/net/nimble/host/src/ble_att_priv.h
index 08185bc..86a7b76 100644
--- a/net/nimble/host/src/ble_att_priv.h
+++ b/net/nimble/host/src/ble_att_priv.h
@@ -268,8 +268,8 @@ int ble_att_clt_tx_read_group_type(uint16_t conn_handle,
                                    const ble_uuid_t *uuid128);
 int ble_att_clt_rx_read_group_type(uint16_t conn_handle,
                                    struct os_mbuf **rxom);
-int ble_att_clt_tx_find_info(uint16_t conn_handle,
-                             const struct ble_att_find_info_req *req);
+int ble_att_clt_tx_find_info(uint16_t conn_handle, uint16_t start_handle,
+                             uint16_t end_handle);
 int ble_att_clt_rx_find_info(uint16_t conn_handle, struct os_mbuf **rxom);
 int ble_att_clt_tx_find_type_value(
     uint16_t conn_handle, const struct ble_att_find_type_value_req *req,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5e82b3f7/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 84491dc..99d2e83 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -2679,15 +2679,13 @@ ble_gattc_disc_all_dscs_tmo(struct ble_gattc_proc *proc)
 static int
 ble_gattc_disc_all_dscs_tx(struct ble_gattc_proc *proc)
 {
-    struct ble_att_find_info_req req;
     int rc;
 
     ble_gattc_dbg_assert_proc_not_inserted(proc);
 
-    req.bafq_start_handle = proc->disc_all_dscs.prev_handle + 1;
-    req.bafq_end_handle = proc->disc_all_dscs.end_handle;
-
-    rc = ble_att_clt_tx_find_info(proc->conn_handle, &req);
+    rc = ble_att_clt_tx_find_info(proc->conn_handle,
+                                  proc->disc_all_dscs.prev_handle + 1,
+                                  proc->disc_all_dscs.end_handle);
     if (rc != 0) {
         return rc;
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5e82b3f7/net/nimble/host/test/src/ble_att_clt_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/test/src/ble_att_clt_test.c b/net/nimble/host/test/src/ble_att_clt_test.c
index afd7c41..dec4695 100644
--- a/net/nimble/host/test/src/ble_att_clt_test.c
+++ b/net/nimble/host/test/src/ble_att_clt_test.c
@@ -77,34 +77,25 @@ ble_att_clt_test_tx_write_req_or_cmd(uint16_t conn_handle,
 
 TEST_CASE(ble_att_clt_test_tx_find_info)
 {
-    struct ble_att_find_info_req req;
     uint16_t conn_handle;
     int rc;
 
     conn_handle = ble_att_clt_test_misc_init();
 
     /*** Success. */
-    req.bafq_start_handle = 1;
-    req.bafq_end_handle = 0xffff;
-    rc = ble_att_clt_tx_find_info(conn_handle, &req);
+    rc = ble_att_clt_tx_find_info(conn_handle, 1, 0xffff);
     TEST_ASSERT(rc == 0);
 
     /*** Error: start handle of 0. */
-    req.bafq_start_handle = 0;
-    req.bafq_end_handle = 0xffff;
-    rc = ble_att_clt_tx_find_info(conn_handle, &req);
+    rc = ble_att_clt_tx_find_info(conn_handle, 0, 0xffff);
     TEST_ASSERT(rc == BLE_HS_EINVAL);
 
     /*** Error: start handle greater than end handle. */
-    req.bafq_start_handle = 500;
-    req.bafq_end_handle = 499;
-    rc = ble_att_clt_tx_find_info(conn_handle, &req);
+    rc = ble_att_clt_tx_find_info(conn_handle, 500, 499);
     TEST_ASSERT(rc == BLE_HS_EINVAL);
 
     /*** Success; start and end handles equal. */
-    req.bafq_start_handle = 500;
-    req.bafq_end_handle = 500;
-    rc = ble_att_clt_tx_find_info(conn_handle, &req);
+    rc = ble_att_clt_tx_find_info(conn_handle, 500, 500);
     TEST_ASSERT(rc == 0);
 }