You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/06/22 13:18:21 UTC

[mynewt-nimble] 01/12: nimble/ll: Workaround for failed conn create on ext adv

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

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

commit e9f42c70711f1a8c8656f262444d17edbead8818
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Jun 9 15:54:39 2022 +0200

    nimble/ll: Workaround for failed conn create on ext adv
    
    AUX_CONNECT_RSP is sent from isr, but it's possible that LL will fail to
    create new connection for various reasons. Moreover, it's possible that
    LL will "fail" before AUX_CONNECT_RSP is actually sent over the air and
    will disable phy, so sm will be stuck waiting for tx callback.
    
    There's quite a lot of changes required to make this work properly, so
    for now let's just detect that condition and simply ignore the error,
    i.e. sm will keep advertising as if there was no AUX_CONNECT_REQ/RSP.
---
 nimble/controller/src/ble_ll_adv.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/nimble/controller/src/ble_ll_adv.c b/nimble/controller/src/ble_ll_adv.c
index 3327ba58..dad69a02 100644
--- a/nimble/controller/src/ble_ll_adv.c
+++ b/nimble/controller/src/ble_ll_adv.c
@@ -190,6 +190,7 @@ struct ble_ll_adv_sm
 #define BLE_LL_ADV_SM_FLAG_PERIODIC_DATA_INCOMPLETE 0x1000
 #define BLE_LL_ADV_SM_FLAG_PERIODIC_SYNC_SENDING    0x2000
 #define BLE_LL_ADV_SM_FLAG_PERIODIC_NEW_DATA        0x4000
+#define BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD_ERR         0x8000
 
 #define ADV_DATA_LEN(_advsm) \
                 ((_advsm->adv_data) ? OS_MBUF_PKTLEN(advsm->adv_data) : 0)
@@ -4395,6 +4396,11 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr,
             if (!(advsm->flags & BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD)) {
                 ble_ll_adv_sm_stop(advsm);
             }
+        } else if (advsm->flags & BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD) {
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
+            ble_ll_adv_flags_set(advsm, BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD_ERR);
+            valid = 1;
+#endif
         }
     }
 
@@ -4859,8 +4865,13 @@ ble_ll_adv_sec_done(struct ble_ll_adv_sm *advsm)
 
     /* Stop advertising due to transmitting connection response */
     if (advsm->flags & BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD) {
-        ble_ll_adv_sm_stop(advsm);
-        return;
+        if (!(advsm->flags & BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD_ERR)) {
+            ble_ll_adv_sm_stop(advsm);
+            return;
+        } else {
+            ble_ll_adv_flags_clear(advsm, BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD |
+                                          BLE_LL_ADV_SM_FLAG_CONN_RSP_TXD_ERR);
+        }
     }
 
     /* If we have next AUX scheduled, try to schedule another one */