You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ko...@apache.org on 2024/02/13 07:43:41 UTC

(mynewt-nimble) branch master updated: nimble/ll: Fix channel map update instant calculation

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4340db0c5 nimble/ll: Fix channel map update instant calculation
4340db0c5 is described below

commit 4340db0c5c5a8293c4d9774b9585d7309505426d
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Fri Dec 22 14:10:53 2023 +0100

    nimble/ll: Fix channel map update instant calculation
    
    The instant for channel map update was calculated at the time PDU was
    enqueued in connsm. This caused new map to be always applied at instant
    regardless if PDU was even dequeued for tx, e.g. in case there
    encryption procedure pending. This could result in connection being
    dropped.
    
    Currently we calculate instant when PDU is dequeued to make sure this is
    the next PDU to be sent and thus instant is valid.
---
 nimble/host/include/host/ble_gatt.h          | 20 --------------------
 nimble/host/services/gatt/src/ble_svc_gatt.c |  5 ++++-
 nimble/host/src/ble_gatt_priv.h              |  2 ++
 3 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/nimble/host/include/host/ble_gatt.h b/nimble/host/include/host/ble_gatt.h
index 0f811e733..b82ab2f40 100644
--- a/nimble/host/include/host/ble_gatt.h
+++ b/nimble/host/include/host/ble_gatt.h
@@ -1076,26 +1076,6 @@ int ble_gatts_reset(void);
  */
 int ble_gatts_start(void);
 
-/**
- * Saves Client Supported Features for specified connection.
- *
- * @param conn_handle           Connection handle identifying connection for
- *                              which Client Supported Features should be saved
- * @param om                    The mbuf chain to set value from.
- *
- * @return                      0 on success;
- *                              BLE_HS_ENOTCONN if no matching connection
- *                              was found
- *                              BLE_HS_EINVAL if supplied buffer is empty or
- *                              if any Client Supported Feature was
- *                              attempted to be disabled.
- *                              A BLE host core return code on unexpected
- *                              error.
- *
- */
-int ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle,
-                                      struct os_mbuf *om);
-
 /**
  * Gets Client Supported Features for specified connection.
  *
diff --git a/nimble/host/services/gatt/src/ble_svc_gatt.c b/nimble/host/services/gatt/src/ble_svc_gatt.c
index d3262e17b..91abf9ad6 100644
--- a/nimble/host/services/gatt/src/ble_svc_gatt.c
+++ b/nimble/host/services/gatt/src/ble_svc_gatt.c
@@ -22,6 +22,7 @@
 #include "sysinit/sysinit.h"
 #include "host/ble_hs.h"
 #include "services/gatt/ble_svc_gatt.h"
+#include "../src/ble_gatt_priv.h"
 
 static uint16_t ble_svc_gatt_changed_val_handle;
 static uint16_t ble_svc_gatt_start_handle;
@@ -112,7 +113,9 @@ ble_svc_gatt_cl_sup_feat_access(uint16_t conn_handle, uint16_t attr_handle,
         return 0;
     }
     if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
-        return ble_gatts_peer_cl_sup_feat_update(conn_handle, ctxt->om);
+        if (ble_gatts_peer_cl_sup_feat_update(conn_handle, ctxt->om)) {
+            return BLE_ATT_ERR_UNLIKELY;
+        }
     }
 
     return 0;
diff --git a/nimble/host/src/ble_gatt_priv.h b/nimble/host/src/ble_gatt_priv.h
index eb778293c..50e0a75b9 100644
--- a/nimble/host/src/ble_gatt_priv.h
+++ b/nimble/host/src/ble_gatt_priv.h
@@ -201,6 +201,8 @@ int ble_gatts_clt_cfg_access(uint16_t conn_handle, uint16_t attr_handle,
                              uint8_t op, uint16_t offset, struct os_mbuf **om,
                              void *arg);
 
+int ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle,
+                                      struct os_mbuf *om);
 /*** @misc. */
 int ble_gatts_conn_can_alloc(void);
 int ble_gatts_conn_init(struct ble_gatts_conn *gatts_conn);