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/24 00:53:25 UTC

[11/50] [abbrv] incubator-mynewt-core git commit: BLE Host - Update conns' pref. MTU

BLE Host - Update conns' pref. MTU

Prior to this commit, setting the preferred MTU only affected future
connections.

Now, an existing connection is updated if we haven't transmitted our
preferred MTU over it yet.


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

Branch: refs/heads/master
Commit: 30d5d15550c0c464a7a185a554794730d498dd7e
Parents: 567c9c1
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Aug 12 17:44:19 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Aug 12 18:16:35 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_att.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/30d5d155/net/nimble/host/src/ble_att.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_att.c b/net/nimble/host/src/ble_att.c
index 608904a..a6d39b8 100644
--- a/net/nimble/host/src/ble_att.c
+++ b/net/nimble/host/src/ble_att.c
@@ -496,6 +496,10 @@ ble_att_preferred_mtu(void)
 int
 ble_att_set_preferred_mtu(uint16_t mtu)
 {
+    struct ble_l2cap_chan *chan;
+    struct ble_hs_conn *conn;
+    int i;
+
     if (mtu < BLE_ATT_MTU_DFLT) {
         return BLE_HS_EINVAL;
     }
@@ -505,7 +509,22 @@ ble_att_set_preferred_mtu(uint16_t mtu)
 
     ble_att_preferred_mtu_val = mtu;
 
-    /* XXX: Set my_mtu for established connections that haven't exchanged. */
+    /* Set my_mtu for established connections that haven't exchanged. */
+    ble_hs_lock();
+
+    i = 0;
+    while ((conn = ble_hs_conn_find_by_idx(i)) != NULL) {
+        chan = ble_hs_conn_chan_find(conn, BLE_L2CAP_CID_ATT);
+        BLE_HS_DBG_ASSERT(chan != NULL);
+
+        if (!(chan->blc_flags & BLE_L2CAP_CHAN_F_TXED_MTU)) {
+            chan->blc_my_mtu = mtu;
+        }
+
+        i++;
+    }
+
+    ble_hs_unlock();
 
     return 0;
 }