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 2022fb776ae63bb4302b397d25d6dc2d7fb0fc8c
Author: Szymon Czapracki <[email protected]>
AuthorDate: Mon Jul 7 17:10:51 2025 +0200

    nimble/btp: Subrate change event handling
    
    Add Subrate change event definition and handling
    in BTP layer.
---
 apps/bttester/src/btp/btp_gap.h | 11 +++++++++++
 apps/bttester/src/btp_gap.c     | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/apps/bttester/src/btp/btp_gap.h b/apps/bttester/src/btp/btp_gap.h
index ac6f26d5a..c95a0d219 100644
--- a/apps/bttester/src/btp/btp_gap.h
+++ b/apps/bttester/src/btp/btp_gap.h
@@ -455,3 +455,14 @@ struct gap_periodic_transfer_recieved_ev {
     uint8_t status;
     ble_addr_t peer_addr;
 } __packed;
+
+#define GAP_EV_SUBRATE_CHANGE 0x92
+struct gap_subrate_change_ev {
+    ble_addr_t addr;
+    uint8_t status;
+    uint16_t conn_handle;
+    uint16_t subrate_factor;
+    uint16_t periph_latency;
+    uint16_t cont_num;
+    uint16_t supervision_tmo;
+} __packed;
diff --git a/apps/bttester/src/btp_gap.c b/apps/bttester/src/btp_gap.c
index 220bbd74e..29fb50a10 100644
--- a/apps/bttester/src/btp_gap.c
+++ b/apps/bttester/src/btp_gap.c
@@ -1265,6 +1265,30 @@ periodic_transfer_received(struct ble_gap_event *event)
 }
 #endif
 
+#if MYNEWT_VAL(BLE_CONN_SUBRATING)
+static void
+subrate_change_received(struct ble_gap_event *event)
+{
+    int rc;
+    struct ble_gap_conn_desc desc;
+    struct gap_subrate_change_ev ev;
+
+    rc = ble_gap_conn_find(event->subrate_change.conn_handle, &desc);
+    assert(rc == 0);
+
+    ev.addr = desc.peer_ota_addr;
+    ev.status = event->subrate_change.status;
+    ev.conn_handle = event->subrate_change.conn_handle;
+    ev.subrate_factor = event->subrate_change.subrate_factor;
+    ev.periph_latency = event->subrate_change.periph_latency;
+    ev.cont_num = event->subrate_change.cont_num;
+    ev.supervision_tmo = event->subrate_change.supervision_tmo;
+
+    tester_event(BTP_SERVICE_ID_GAP, GAP_EV_SUBRATE_CHANGE, (uint8_t *)&ev,
+                 sizeof(ev));
+}
+#endif
+
 static void
 print_bytes(const uint8_t *bytes, int len)
 {
@@ -1563,6 +1587,19 @@ gap_event_cb(struct ble_gap_event *event, void *arg)
                        event->periodic_transfer.adv_clk_accuracy);
         periodic_transfer_received(event);
         break;
+#endif
+#if MYNEWT_VAL(BLE_CONN_SUBRATING)
+    case BLE_GAP_EVENT_SUBRATE_CHANGE:
+        console_printf(
+            "Subrate change received:"
+            "status=%d, conn_handle=%d, subrate_factor=%d, perpih_latency=%d,"
+            "cont_num=%d supervision_tmo=%d",
+            event->subrate_change.status, event->subrate_change.conn_handle,
+            event->subrate_change.subrate_factor,
+            event->subrate_change.periph_latency, 
event->subrate_change.cont_num,
+            event->subrate_change.supervision_tmo);
+        subrate_change_received(event);
+        break;
 #endif
     default:
         break;

Reply via email to