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

[13/50] incubator-mynewt-core git commit: nimble/att: Use new helpers for sending Read By Group Type Request

nimble/att: Use new helpers for sending Read By Group Type 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/1c08e62b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1c08e62b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1c08e62b

Branch: refs/heads/master
Commit: 1c08e62b42bed9fe0ba83d564548b388c55ebc45
Parents: 3f4cac3
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Mar 24 15:31:52 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      | 40 +++++++++--------------------
 net/nimble/host/src/ble_att_cmd_priv.h |  1 +
 net/nimble/host/src/ble_att_priv.h     |  6 ++---
 net/nimble/host/src/ble_gattc.c        |  7 +++--
 4 files changed, 19 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1c08e62b/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 96a04e2..c35ad89 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -707,50 +707,34 @@ ble_att_clt_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom)
 
 int
 ble_att_clt_tx_read_group_type(uint16_t conn_handle,
-                               const struct ble_att_read_group_type_req *req,
+                               uint16_t start_handle, uint16_t end_handle,
                                const ble_uuid_t *uuid)
 {
 #if !NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE
     return BLE_HS_ENOTSUP;
 #endif
 
+    struct ble_att_read_group_type_req *req;
     struct os_mbuf *txom;
-    int rc;
-
-    txom = NULL;
-
-    if (req->bagq_start_handle == 0 ||
-        req->bagq_start_handle > req->bagq_end_handle) {
-
-        rc = BLE_HS_EINVAL;
-        goto err;
-    }
 
-    rc = ble_att_clt_init_req(BLE_ATT_READ_GROUP_TYPE_REQ_BASE_SZ, &txom);
-    if (rc != 0) {
-        goto err;
+    if (start_handle == 0 || start_handle > end_handle) {
+        return BLE_HS_EINVAL;
     }
-    ble_att_read_group_type_req_write(txom->om_data, txom->om_len, req);
 
-    rc = ble_uuid_to_mbuf(uuid, txom);
-    if (rc != 0) {
-        goto err;
+    req = ble_att_cmd_get(BLE_ATT_OP_READ_GROUP_TYPE_REQ,
+                          sizeof(*req) + ble_uuid_length(uuid), &txom);
+    if (req == NULL) {
+        return BLE_HS_ENOMEM;
     }
 
-    rc = ble_att_clt_tx_req(conn_handle, txom);
-    txom = NULL;
-    if (rc != 0) {
-        goto err;
-    }
+    req->bagq_start_handle = htole16(start_handle);
+    req->bagq_end_handle = htole16(end_handle);
+    ble_uuid_flat(uuid, req->uuid);
 
     BLE_ATT_LOG_CMD(1, "read group type req", conn_handle,
                     ble_att_read_group_type_req_log, req);
 
-    return 0;
-
-err:
-    os_mbuf_free_chain(txom);
-    return rc;
+    return ble_att_tx(conn_handle, txom);
 }
 
 static int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1c08e62b/net/nimble/host/src/ble_att_cmd_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_cmd_priv.h b/net/nimble/host/src/ble_att_cmd_priv.h
index be7fda3..d1c7d33 100644
--- a/net/nimble/host/src/ble_att_cmd_priv.h
+++ b/net/nimble/host/src/ble_att_cmd_priv.h
@@ -222,6 +222,7 @@ struct ble_att_read_mult_req {
 struct ble_att_read_group_type_req {
     uint16_t bagq_start_handle;
     uint16_t bagq_end_handle;
+    uint8_t uuid[0];
 } __attribute__((packed));
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1c08e62b/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 19f84a4..08185bc 100644
--- a/net/nimble/host/src/ble_att_priv.h
+++ b/net/nimble/host/src/ble_att_priv.h
@@ -263,9 +263,9 @@ int ble_att_clt_rx_read_mult(uint16_t conn_handle, struct os_mbuf **rxom);
 int ble_att_clt_tx_read_type(uint16_t conn_handle, uint16_t start_handle,
                              uint16_t end_handle, const ble_uuid_t *uuid);
 int ble_att_clt_rx_read_type(uint16_t conn_handle, struct os_mbuf **rxom);
-int ble_att_clt_tx_read_group_type(
-    uint16_t conn_handle, const struct ble_att_read_group_type_req *req,
-    const ble_uuid_t *uuid128);
+int ble_att_clt_tx_read_group_type(uint16_t conn_handle,
+                                   uint16_t start_handle, uint16_t end_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,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1c08e62b/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 2e04e54..84491dc 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -1385,15 +1385,14 @@ ble_gattc_disc_all_svcs_tmo(struct ble_gattc_proc *proc)
 static int
 ble_gattc_disc_all_svcs_tx(struct ble_gattc_proc *proc)
 {
-    struct ble_att_read_group_type_req req;
     ble_uuid16_t uuid = BLE_UUID16_INIT(BLE_ATT_UUID_PRIMARY_SERVICE);
     int rc;
 
     ble_gattc_dbg_assert_proc_not_inserted(proc);
 
-    req.bagq_start_handle = proc->disc_all_svcs.prev_handle + 1;
-    req.bagq_end_handle = 0xffff;
-    rc = ble_att_clt_tx_read_group_type(proc->conn_handle, &req, &uuid.u);
+    rc = ble_att_clt_tx_read_group_type(proc->conn_handle,
+                                        proc->disc_all_svcs.prev_handle + 1,
+                                        0xffff, &uuid.u);
     if (rc != 0) {
         return rc;
     }