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

[18/50] incubator-mynewt-core git commit: nimble/att: Use new helpers for sending Notification

nimble/att: Use new helpers for sending Notification

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

Branch: refs/heads/master
Commit: 504e0e132f3462275c7aef8fd1a4cc6b3b819e16
Parents: d74cc3e
Author: Szymon Janc <sz...@codecoup.pl>
Authored: Fri Mar 24 15:35:09 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  | 21 +++++++++------------
 net/nimble/host/src/ble_att_priv.h |  3 +--
 net/nimble/host/src/ble_gattc.c    |  4 +---
 3 files changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/504e0e13/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 52c83c0..d8d5d1c 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -976,37 +976,34 @@ ble_att_clt_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom)
  *****************************************************************************/
 
 int
-ble_att_clt_tx_notify(uint16_t conn_handle,
-                      const struct ble_att_notify_req *req,
+ble_att_clt_tx_notify(uint16_t conn_handle, uint16_t handle,
                       struct os_mbuf *txom)
 {
 #if !NIMBLE_BLE_ATT_CLT_NOTIFY
     return BLE_HS_ENOTSUP;
 #endif
 
+    struct ble_att_notify_req *req;
+    struct os_mbuf *txom2;
     int rc;
 
-    if (req->banq_handle == 0) {
+    if (handle == 0) {
         rc = BLE_HS_EINVAL;
         goto err;
     }
 
-    txom = os_mbuf_prepend_pullup(txom, BLE_ATT_NOTIFY_REQ_BASE_SZ);
-    if (txom == NULL) {
+    req = ble_att_cmd_get(BLE_ATT_OP_NOTIFY_REQ, sizeof(*req), &txom2);
+    if (req == NULL) {
         rc = BLE_HS_ENOMEM;
         goto err;
     }
-    ble_att_notify_req_write(txom->om_data, BLE_ATT_NOTIFY_REQ_BASE_SZ, req);
 
-    rc = ble_att_clt_tx_req(conn_handle, txom);
-    txom = NULL;
-    if (rc != 0) {
-        goto err;
-    }
+    req->banq_handle = htole16(handle);
+    os_mbuf_concat(txom2, txom);
 
     BLE_ATT_LOG_CMD(1, "notify req", conn_handle, ble_att_notify_req_log, req);
 
-    return 0;
+    return ble_att_tx(conn_handle, txom2);
 
 err:
     os_mbuf_free_chain(txom);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/504e0e13/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 fbc81d9..8457767 100644
--- a/net/nimble/host/src/ble_att_priv.h
+++ b/net/nimble/host/src/ble_att_priv.h
@@ -286,8 +286,7 @@ int ble_att_clt_rx_prep_write(uint16_t conn_handle, struct os_mbuf **rxom);
 int ble_att_clt_tx_exec_write(uint16_t conn_handle, uint8_t flags);
 int ble_att_clt_rx_exec_write(uint16_t conn_handle, struct os_mbuf **rxom);
 int ble_att_clt_rx_write(uint16_t conn_handle, struct os_mbuf **rxom);
-int ble_att_clt_tx_notify(uint16_t conn_handle,
-                          const struct ble_att_notify_req *req,
+int ble_att_clt_tx_notify(uint16_t conn_handle, uint16_t handle,
                           struct os_mbuf *txom);
 int ble_att_clt_tx_indicate(uint16_t conn_handle,
                             const struct ble_att_indicate_req *req,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/504e0e13/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 59fbea8..85111af 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -4405,7 +4405,6 @@ ble_gattc_notify_custom(uint16_t conn_handle, uint16_t chr_val_handle,
     return BLE_HS_ENOTSUP;
 #endif
 
-    struct ble_att_notify_req req;
     int rc;
 
     STATS_INC(ble_gattc_stats, notify);
@@ -4430,8 +4429,7 @@ ble_gattc_notify_custom(uint16_t conn_handle, uint16_t chr_val_handle,
         }
     }
 
-    req.banq_handle = chr_val_handle;
-    rc = ble_att_clt_tx_notify(conn_handle, &req, txom);
+    rc = ble_att_clt_tx_notify(conn_handle, chr_val_handle, txom);
     txom = NULL;
     if (rc != 0) {
         goto err;