This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 96d7e8b1ae7055ac5ed71bf4df1e7bf511ec8d79
Author: Ɓukasz Rymanowski <[email protected]>
AuthorDate: Tue Jun 9 18:53:36 2020 +0200

    nimble/l2cap: Fix handling ecoc connect response
    
    When enhanced connection oriented channels are use, peer can
    accept some of the connections and refuse others.
    In such a case result will be non zero in the enh credit base connection
    response.
    
    With this patch, in such a case, we correctly connect accepted
    connections and refuse others
---
 nimble/host/src/ble_l2cap_sig.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/nimble/host/src/ble_l2cap_sig.c b/nimble/host/src/ble_l2cap_sig.c
index 58f96b0..a137afa 100644
--- a/nimble/host/src/ble_l2cap_sig.c
+++ b/nimble/host/src/ble_l2cap_sig.c
@@ -661,8 +661,8 @@ ble_l2cap_sig_coc_connect_cb(struct ble_l2cap_sig_proc 
*proc, int status)
             continue;
         }
 
-        if ((status == 0) && (chan->dcid != 0)) {
-            ble_l2cap_event_coc_connected(chan, status);
+        if (chan->dcid != 0) {
+            ble_l2cap_event_coc_connected(chan, 0);
             /* Let's forget about connected channel now.
              * Not connected will be freed later on.
              */
@@ -1066,7 +1066,15 @@ ble_l2cap_sig_credit_base_con_rsp_rx(uint16_t 
conn_handle,
 
     if (rsp->result) {
         rc = ble_l2cap_sig_coc_err2ble_hs_err(le16toh(rsp->result));
-        goto done;
+        /* Below results means that some of the channels has not been created
+         * and we have to look closer into the response.
+         * Any other results means that all the connections has been refused.
+         */
+        if ((rsp->result != BLE_L2CAP_COC_ERR_NO_RESOURCES) &&
+            (rsp->result != BLE_L2CAP_COC_ERR_INVALID_SOURCE_CID) &&
+            (rsp->result != BLE_L2CAP_COC_ERR_SOURCE_CID_ALREADY_USED)) {
+            goto done;
+        }
     }
 
     ble_hs_lock();

Reply via email to