From 735333aa1a379b33318aa4db8a19914491b63add Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 24 Dec 2023 19:08:52 +0100 Subject: [PATCH] softdevice: print connection parameters when debug is enabled This is very useful for debugging, though we should probably expose this in some way to users of the bluetooth package without changing a constant. --- adapter_nrf528xx-full.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adapter_nrf528xx-full.go b/adapter_nrf528xx-full.go index 6ce048b..f772863 100644 --- a/adapter_nrf528xx-full.go +++ b/adapter_nrf528xx-full.go @@ -62,6 +62,14 @@ func handleEvent() { C.sd_ble_gap_adv_start(defaultAdvertisement.handle, C.BLE_CONN_CFG_TAG_DEFAULT) } DefaultAdapter.connectHandler(Address{}, false) + case C.BLE_GAP_EVT_CONN_PARAM_UPDATE: + if debug { + // Print connection parameters for easy debugging. + params := gapEvent.params.unionfield_conn_param_update().conn_params + interval_ms := params.min_conn_interval * 125 / 100 // min and max are the same here + print("conn param update interval=", interval_ms, "ms latency=", params.slave_latency, " timeout=", params.conn_sup_timeout*10, "ms") + println() + } case C.BLE_GAP_EVT_ADV_REPORT: advReport := gapEvent.params.unionfield_adv_report() if debug && &scanReportBuffer.data[0] != (*byte)(unsafe.Pointer(advReport.data.p_data)) {