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/61a0e851 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/61a0e851 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/61a0e851 Branch: refs/heads/1_0_0_dev Commit: 61a0e851ef6ca8aed601192a54a07668c7f42291 Parents: 5199caf Author: Åukasz Rymanowski <[email protected]> Authored: Sun Feb 12 21:45:29 2017 +0100 Committer: Marko Kiiskila <[email protected]> Committed: Mon Mar 6 15:53:01 2017 -0800 ---------------------------------------------------------------------- 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/61a0e851/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/61a0e851/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);
