Skip to content

Commit a4c20a0

Browse files
aykevldeadprogram
authored andcommitted
sd: respect connection parameter update request from peripheral
I've found at least one device that will disconnect after about 40s if this connection parameter update request is not honored.
1 parent a34a646 commit a4c20a0

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

adapter_nrf528xx-full.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,16 @@ func handleEvent() {
100100
// report has been processed.
101101
gotScanReport.Set(1)
102102
case C.BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
103-
// Respond with the default PPCP connection parameters by passing
104-
// nil:
105-
// > If NULL is provided on a peripheral role, the parameters in the
106-
// > PPCP characteristic of the GAP service will be used instead. If
107-
// > NULL is provided on a central role and in response to a
108-
// > BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request
109-
// > will be rejected
110-
C.sd_ble_gap_conn_param_update(gapEvent.conn_handle, nil)
103+
request := gapEvent.params.unionfield_conn_param_update_request()
104+
if debug {
105+
interval_min_ms := request.conn_params.min_conn_interval * 125 / 100
106+
interval_max_ms := request.conn_params.max_conn_interval * 125 / 100
107+
timeout_ms := request.conn_params.conn_sup_timeout * 10
108+
print("evt: gap connection param update request min=", interval_min_ms, "ms max=", interval_max_ms, "ms latency=", request.conn_params.slave_latency, " timeout=", timeout_ms, "ms\r\n")
109+
}
110+
// Accept the requested connection parameter update (some
111+
// peripherals don't like it when their requests get rejected).
112+
C.sd_ble_gap_conn_param_update(gapEvent.conn_handle, &request.conn_params)
111113
case C.BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
112114
if debug {
113115
println("evt: gap data length update request")

0 commit comments

Comments
 (0)