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 2017/03/03 17:36:24 UTC

[09/26] incubator-mynewt-core git commit: nibmle/l2cap: Clear LE CoC channel on ACL drop

nibmle/l2cap: Clear LE CoC channel on ACL drop

When ACL is disconnected before L2CAP is disconnected we need to
make sure proper cleaning is done and application is notified
about channel disconnection.

Therefore with this patch sending DISCONNECTED EVENT is moved to
function doing free of COC specific data in the channel


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

Branch: refs/heads/develop
Commit: e488b9df404e1dc45ce6494d66fbe965d66a1758
Parents: 93ac0df
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Sun Feb 12 21:45:29 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Fri Mar 3 12:40:42 2017 +0100

----------------------------------------------------------------------
 net/nimble/host/src/ble_l2cap_coc.c | 14 ++++++++++++++
 net/nimble/host/src/ble_l2cap_sig.c | 16 ----------------
 2 files changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e488b9df/net/nimble/host/src/ble_l2cap_coc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_coc.c b/net/nimble/host/src/ble_l2cap_coc.c
index 12d79d6..ec01fec 100644
--- a/net/nimble/host/src/ble_l2cap_coc.c
+++ b/net/nimble/host/src/ble_l2cap_coc.c
@@ -276,6 +276,18 @@ ble_l2cap_coc_create_srv_chan(uint16_t conn_handle, uint16_t psm,
     return 0;
 }
 
+static void
+ble_l2cap_event_coc_disconnected(struct ble_l2cap_chan *chan)
+{
+    struct ble_l2cap_event event = { };
+
+    event.type = BLE_L2CAP_EVENT_COC_DISCONNECTED;
+    event.disconnect.conn_handle = chan->conn_handle;
+    event.disconnect.chan = chan;
+
+    chan->cb(&event, chan->cb_arg);
+}
+
 void
 ble_l2cap_coc_cleanup_chan(struct ble_l2cap_chan *chan)
 {
@@ -284,6 +296,8 @@ ble_l2cap_coc_cleanup_chan(struct ble_l2cap_chan *chan)
             return;
     }
 
+    ble_l2cap_event_coc_disconnected(chan);
+
     os_mbuf_free_chain(chan->coc_rx.sdu);
     os_mbuf_free_chain(chan->coc_tx.sdu);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e488b9df/net/nimble/host/src/ble_l2cap_sig.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_l2cap_sig.c b/net/nimble/host/src/ble_l2cap_sig.c
index 8da2dad..b77fa3b 100644
--- a/net/nimble/host/src/ble_l2cap_sig.c
+++ b/net/nimble/host/src/ble_l2cap_sig.c
@@ -585,18 +585,6 @@ ble_l2cap_event_coc_connected(struct ble_l2cap_chan *chan, uint16_t status)
     chan->cb(&event, chan->cb_arg);
 }
 
-static void
-ble_l2cap_event_coc_disconnected(struct ble_l2cap_chan *chan)
-{
-    struct ble_l2cap_event event = { };
-
-    event.type = BLE_L2CAP_EVENT_COC_DISCONNECTED;
-    event.disconnect.conn_handle = chan->conn_handle;
-    event.disconnect.chan = chan;
-
-    chan->cb(&event, chan->cb_arg);
-}
-
 static int
 ble_l2cap_event_coc_accept(struct ble_l2cap_chan *chan, uint16_t peer_sdu_size)
 {
@@ -891,8 +879,6 @@ ble_l2cap_sig_disc_req_rx(uint16_t conn_handle, struct ble_l2cap_sig_hdr *hdr,
     rsp->dcid = htole16(chan->scid);
     rsp->scid = htole16(chan->dcid);
 
-    ble_l2cap_event_coc_disconnected(chan);
-
     ble_hs_conn_delete_chan(conn, chan);
     ble_hs_unlock();
 
@@ -922,8 +908,6 @@ ble_l2cap_sig_coc_disconnect_cb(struct ble_l2cap_sig_proc *proc, int status)
         goto done;
     }
 
-    ble_l2cap_event_coc_disconnected(chan);
-
 done:
     ble_hs_lock();
     conn = ble_hs_conn_find(chan->conn_handle);