You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/08/13 01:18:39 UTC

[6/7] incubator-mynewt-core git commit: BLE Host - Only log ATT cmd after tx succeeds.

BLE Host - Only log ATT cmd after tx succeeds.

Before, we were logging each ATT transmission as soon as a higher layer
requested the send.

Now:

* For client requests, don't log until after transmit succeeds.

* For server responses, don't log until we are sure we will attempt a
transmission.  Unfortunately, due to the way the server code is
structures, we don't have the necessary information for logging after
the transmit occurs.  This is still an improvement, as it prevents
spurious logging when there are invalid arguments or insufficient
resources.


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

Branch: refs/heads/develop
Commit: 032d0a791af19899312dd9fe8a1053a81b69cf92
Parents: e3750fe
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Aug 12 18:10:39 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Aug 12 18:16:35 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_att_clt.c | 76 +++++++++++++++++++---------------
 net/nimble/host/src/ble_att_svr.c | 10 +++--
 2 files changed, 48 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/032d0a79/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 735e819..2e7352b 100644
--- a/net/nimble/host/src/ble_att_clt.c
+++ b/net/nimble/host/src/ble_att_clt.c
@@ -118,8 +118,6 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, const struct ble_att_mtu_cmd *req)
     struct os_mbuf *txom;
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "mtu req", conn_handle, ble_att_mtu_cmd_log, req);
-
     if (req->bamc_mtu < BLE_ATT_MTU_DFLT) {
         return BLE_HS_EINVAL;
     }
@@ -151,6 +149,8 @@ ble_att_clt_tx_mtu(uint16_t conn_handle, const struct ble_att_mtu_cmd *req)
         return rc;
     }
 
+    BLE_ATT_LOG_CMD(1, "mtu req", conn_handle, ble_att_mtu_cmd_log, req);
+
     ble_hs_lock();
 
     ble_att_conn_chan_find(conn_handle, &conn, &chan);
@@ -206,9 +206,6 @@ ble_att_clt_tx_find_info(uint16_t conn_handle,
     struct os_mbuf *txom;
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "find info req", conn_handle,
-                    ble_att_find_info_req_log, req);
-
     if (req->bafq_start_handle == 0 ||
         req->bafq_start_handle > req->bafq_end_handle) {
 
@@ -226,6 +223,9 @@ ble_att_clt_tx_find_info(uint16_t conn_handle,
         return rc;
     }
 
+    BLE_ATT_LOG_CMD(1, "find info req", conn_handle,
+                    ble_att_find_info_req_log, req);
+
     return 0;
 }
 
@@ -336,9 +336,6 @@ ble_att_clt_tx_find_type_value(uint16_t conn_handle,
     return BLE_HS_ENOTSUP;
 #endif
 
-    BLE_ATT_LOG_CMD(1, "find type value req", conn_handle,
-                    ble_att_find_type_value_req_log, req);
-
     struct os_mbuf *txom;
     int rc;
 
@@ -369,6 +366,9 @@ ble_att_clt_tx_find_type_value(uint16_t conn_handle,
         goto err;
     }
 
+    BLE_ATT_LOG_CMD(1, "find type value req", conn_handle,
+                    ble_att_find_type_value_req_log, req);
+
     return 0;
 
 err:
@@ -447,9 +447,6 @@ ble_att_clt_tx_read_type(uint16_t conn_handle,
 
     txom = NULL;
 
-    BLE_ATT_LOG_CMD(1, "read type req", conn_handle,
-                    ble_att_read_type_req_log, req);
-
     if (req->batq_start_handle == 0 ||
         req->batq_start_handle > req->batq_end_handle) {
 
@@ -475,6 +472,9 @@ ble_att_clt_tx_read_type(uint16_t conn_handle,
         goto err;
     }
 
+    BLE_ATT_LOG_CMD(1, "read type req", conn_handle,
+                    ble_att_read_type_req_log, req);
+
     return 0;
 
 err:
@@ -555,8 +555,6 @@ ble_att_clt_tx_read(uint16_t conn_handle, const struct ble_att_read_req *req)
     struct os_mbuf *txom;
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "read req", conn_handle, ble_att_read_req_log, req);
-
     if (req->barq_handle == 0) {
         return BLE_HS_EINVAL;
     }
@@ -572,6 +570,8 @@ ble_att_clt_tx_read(uint16_t conn_handle, const struct ble_att_read_req *req)
         return rc;
     }
 
+    BLE_ATT_LOG_CMD(1, "read req", conn_handle, ble_att_read_req_log, req);
+
     return 0;
 }
 
@@ -609,9 +609,6 @@ ble_att_clt_tx_read_blob(uint16_t conn_handle,
     struct os_mbuf *txom;
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "read blob req", conn_handle,
-                    ble_att_read_blob_req_log, req);
-
     if (req->babq_handle == 0) {
         return BLE_HS_EINVAL;
     }
@@ -627,6 +624,9 @@ ble_att_clt_tx_read_blob(uint16_t conn_handle,
         return rc;
     }
 
+    BLE_ATT_LOG_CMD(1, "read blob req", conn_handle,
+                    ble_att_read_blob_req_log, req);
+
     return 0;
 }
 
@@ -756,9 +756,6 @@ ble_att_clt_tx_read_group_type(uint16_t conn_handle,
 
     txom = NULL;
 
-    BLE_ATT_LOG_CMD(1, "read group type req", conn_handle,
-                    ble_att_read_group_type_req_log, req);
-
     if (req->bagq_start_handle == 0 ||
         req->bagq_start_handle > req->bagq_end_handle) {
 
@@ -783,6 +780,9 @@ ble_att_clt_tx_read_group_type(uint16_t conn_handle,
         goto err;
     }
 
+    BLE_ATT_LOG_CMD(1, "read group type req", conn_handle,
+                    ble_att_read_group_type_req_log, req);
+
     return 0;
 
 err:
@@ -896,10 +896,14 @@ ble_att_clt_tx_write_req(uint16_t conn_handle,
 
     int rc;
 
+    rc = ble_att_clt_tx_write_req_or_cmd(conn_handle, req, txom, 1);
+    if (rc != 0) {
+        return rc;
+    }
+
     BLE_ATT_LOG_CMD(1, "write req", conn_handle, ble_att_write_cmd_log, req);
 
-    rc = ble_att_clt_tx_write_req_or_cmd(conn_handle, req, txom, 1);
-    return rc;
+    return 0;
 }
 
 int
@@ -913,10 +917,14 @@ ble_att_clt_tx_write_cmd(uint16_t conn_handle,
 
     int rc;
 
+    rc = ble_att_clt_tx_write_req_or_cmd(conn_handle, req, txom, 0);
+    if (rc != 0) {
+        return rc;
+    }
+
     BLE_ATT_LOG_CMD(1, "write cmd", conn_handle, ble_att_write_cmd_log, req);
 
-    rc = ble_att_clt_tx_write_req_or_cmd(conn_handle, req, txom, 0);
-    return rc;
+    return 0;
 }
 
 int
@@ -948,9 +956,6 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle,
 
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "prep write req", conn_handle,
-                    ble_att_prep_write_cmd_log, req);
-
     if (req->bapc_handle == 0) {
         rc = BLE_HS_EINVAL;
         goto err;
@@ -983,6 +988,9 @@ ble_att_clt_tx_prep_write(uint16_t conn_handle,
         goto err;
     }
 
+    BLE_ATT_LOG_CMD(1, "prep write req", conn_handle,
+                    ble_att_prep_write_cmd_log, req);
+
     return 0;
 
 err:
@@ -1036,9 +1044,6 @@ ble_att_clt_tx_exec_write(uint16_t conn_handle,
     struct os_mbuf *txom;
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "exec write req", conn_handle,
-                    ble_att_exec_write_req_log, req);
-
     if ((req->baeq_flags & BLE_ATT_EXEC_WRITE_F_RESERVED) != 0) {
         return BLE_HS_EINVAL;
     }
@@ -1054,6 +1059,9 @@ ble_att_clt_tx_exec_write(uint16_t conn_handle,
         return rc;
     }
 
+    BLE_ATT_LOG_CMD(1, "exec write req", conn_handle,
+                    ble_att_exec_write_req_log, req);
+
     return 0;
 }
 
@@ -1092,8 +1100,6 @@ ble_att_clt_tx_notify(uint16_t conn_handle,
 
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "notify req", conn_handle, ble_att_notify_req_log, req);
-
     if (req->banq_handle == 0) {
         rc = BLE_HS_EINVAL;
         goto err;
@@ -1112,6 +1118,8 @@ ble_att_clt_tx_notify(uint16_t conn_handle,
         goto err;
     }
 
+    BLE_ATT_LOG_CMD(1, "notify req", conn_handle, ble_att_notify_req_log, req);
+
     return 0;
 
 err:
@@ -1134,9 +1142,6 @@ ble_att_clt_tx_indicate(uint16_t conn_handle,
 
     int rc;
 
-    BLE_ATT_LOG_CMD(1, "indicate req", conn_handle, ble_att_indicate_req_log,
-                    req);
-
     if (req->baiq_handle == 0) {
         rc = BLE_HS_EINVAL;
         goto err;
@@ -1157,6 +1162,9 @@ ble_att_clt_tx_indicate(uint16_t conn_handle,
         goto err;
     }
 
+    BLE_ATT_LOG_CMD(1, "indicate req", conn_handle, ble_att_indicate_req_log,
+                    req);
+
     return 0;
 
 err:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/032d0a79/net/nimble/host/src/ble_att_svr.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c
index 710db20..5d64c25 100644
--- a/net/nimble/host/src/ble_att_svr.c
+++ b/net/nimble/host/src/ble_att_svr.c
@@ -510,8 +510,6 @@ ble_att_svr_tx_error_rsp(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
     rsp.baep_error_code = error_code;
 
     ble_att_error_rsp_write(dst, BLE_ATT_ERROR_RSP_SZ, &rsp);
-    BLE_ATT_LOG_CMD(1, "error rsp", conn->bhc_handle,
-                    ble_att_error_rsp_log, &rsp);
 
     rc = ble_l2cap_tx(conn, chan, txom);
     txom = NULL;
@@ -519,6 +517,9 @@ ble_att_svr_tx_error_rsp(struct ble_hs_conn *conn, struct ble_l2cap_chan *chan,
         goto err;
     }
 
+    BLE_ATT_LOG_CMD(1, "error rsp", conn->bhc_handle,
+                    ble_att_error_rsp_log, &rsp);
+
     return 0;
 
 err:
@@ -829,8 +830,6 @@ ble_att_svr_build_find_info_rsp(uint16_t conn_handle,
     }
 
     ble_att_find_info_rsp_write(buf, BLE_ATT_FIND_INFO_RSP_BASE_SZ, &rsp);
-    BLE_ATT_LOG_CMD(1, "find info rsp", conn_handle, ble_att_find_info_rsp_log,
-                    &rsp);
 
     /* Write the variable length Information Data field, populating the format
      * field as appropriate.
@@ -842,6 +841,9 @@ ble_att_svr_build_find_info_rsp(uint16_t conn_handle,
         goto done;
     }
 
+    BLE_ATT_LOG_CMD(1, "find info rsp", conn_handle, ble_att_find_info_rsp_log,
+                    &rsp);
+
     rc = 0;
 
 done: