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/08/29 13:03:45 UTC

[mynewt-nimble] 01/03: nimble/ll/css: Add vs event to indicate slot change

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 1a27fe6494caa299ab67cd0e9a05fa7ad439c47a
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Aug 12 13:35:14 2022 +0200

    nimble/ll/css: Add vs event to indicate slot change
    
    If hci_vs support is enabled for CSS, an event will be sent every time
    slot chanes for a connection.
---
 nimble/controller/include/controller/ble_ll_ctrl.h |  5 ++++
 nimble/controller/src/ble_ll_conn.c                |  5 ++++
 nimble/controller/src/ble_ll_hci_ev.c              | 32 ++++++++++++++++++++--
 nimble/include/nimble/hci_common.h                 | 11 ++++++--
 4 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/nimble/controller/include/controller/ble_ll_ctrl.h b/nimble/controller/include/controller/ble_ll_ctrl.h
index 379960ec..6e7ad13d 100644
--- a/nimble/controller/include/controller/ble_ll_ctrl.h
+++ b/nimble/controller/include/controller/ble_ll_ctrl.h
@@ -350,6 +350,11 @@ void ble_ll_hci_ev_sca_update(struct ble_ll_conn_sm *connsm,
 void ble_ll_hci_ev_subrate_change(struct ble_ll_conn_sm *connsm, uint8_t status);
 #endif
 
+#if MYNEWT_VAL(BLE_LL_HCI_VS_CONN_STRICT_SCHED)
+void ble_ll_hci_ev_send_vs_css_slot_changed(uint16_t conn_handle,
+                                            uint16_t slot_idx);
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index 2a8c0c05..b625a0e3 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -2496,6 +2496,11 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
                 ble_ll_sched_css_set_conn_anchor(connsm);
                 anchor_calc_for_css = 0;
             }
+
+#if MYNEWT_VAL(BLE_LL_HCI_VS_CONN_STRICT_SCHED)
+            ble_ll_hci_ev_send_vs_css_slot_changed(connsm->conn_handle,
+                                                   connsm->css_slot_idx);
+#endif
         }
 #endif
 
diff --git a/nimble/controller/src/ble_ll_hci_ev.c b/nimble/controller/src/ble_ll_hci_ev.c
index 6da2545c..b0d9fa07 100644
--- a/nimble/controller/src/ble_ll_hci_ev.c
+++ b/nimble/controller/src/ble_ll_hci_ev.c
@@ -523,10 +523,36 @@ ble_ll_hci_ev_subrate_change(struct ble_ll_conn_sm *connsm, uint8_t status)
 }
 #endif
 
+#if MYNEWT_VAL(BLE_LL_HCI_VS_CONN_STRICT_SCHED)
+void
+ble_ll_hci_ev_send_vs_css_slot_changed(uint16_t conn_handle, uint16_t slot_idx)
+{
+    struct ble_hci_ev_vs_css_slot_changed *ev;
+    struct ble_hci_ev_vs *ev_vs;
+    struct ble_hci_ev *hci_ev;
+
+    hci_ev = ble_transport_alloc_evt(0);
+    if (!hci_ev) {
+        return;
+
+    }
+
+    hci_ev->opcode = BLE_HCI_EVCODE_VS;
+    hci_ev->length = sizeof(*ev_vs) + sizeof(*ev);
+    ev_vs = (void *)hci_ev->data;
+    ev_vs->id = BLE_HCI_VS_SUBEV_ID_CSS_SLOT_CHANGED;
+    ev = (void *)ev_vs->data;
+    ev->conn_handle = htole16(conn_handle);
+    ev->slot_idx = htole16(slot_idx);
+
+    ble_ll_hci_event_send(hci_ev);
+}
+#endif
+
 void
 ble_ll_hci_ev_send_vs_assert(const char *file, uint32_t line)
 {
-    struct ble_hci_ev_vs_debug *ev;
+    struct ble_hci_ev_vs *ev;
     struct ble_hci_ev *hci_ev;
     unsigned int str_len;
     bool skip = true;
@@ -541,12 +567,12 @@ ble_ll_hci_ev_send_vs_assert(const char *file, uint32_t line)
 
     hci_ev = ble_transport_alloc_evt(0);
     if (hci_ev) {
-        hci_ev->opcode = BLE_HCI_EVCODE_VS_DEBUG;
+        hci_ev->opcode = BLE_HCI_EVCODE_VS;
         hci_ev->length = sizeof(*ev);
         ev = (void *) hci_ev->data;
 
         /* Debug id for future use */
-        ev->id = 0x00;
+        ev->id = BLE_HCI_VS_SUBEV_ID_ASSERT;
 
         /* snprintf would be nicer but this is heavy on flash
          * len = snprintf((char *) ev->data, max_len, "%s:%u", file, line);
diff --git a/nimble/include/nimble/hci_common.h b/nimble/include/nimble/hci_common.h
index 40602d7b..b690eeb2 100644
--- a/nimble/include/nimble/hci_common.h
+++ b/nimble/include/nimble/hci_common.h
@@ -1554,12 +1554,19 @@ struct ble_hci_ev_auth_pyld_tmo {
 
 #define BLE_HCI_EVCODE_SAM_STATUS_CHG       (0x58)
 
-#define BLE_HCI_EVCODE_VS_DEBUG             (0xFF)
-struct ble_hci_ev_vs_debug {
+#define BLE_HCI_EVCODE_VS                   (0xff)
+struct ble_hci_ev_vs {
     uint8_t id;
     uint8_t data[0];
 } __attribute__((packed));
 
+#define BLE_HCI_VS_SUBEV_ID_ASSERT              (0x01)
+#define BLE_HCI_VS_SUBEV_ID_CSS_SLOT_CHANGED    (0x02)
+struct ble_hci_ev_vs_css_slot_changed {
+    uint16_t conn_handle;
+    uint16_t slot_idx;
+};
+
 /* LE sub-event codes */
 #define BLE_HCI_LE_SUBEV_CONN_COMPLETE          (0x01)
 struct ble_hci_ev_le_subev_conn_complete {