Skip to content

feat(softdevice): use ConnectionPriority, and add PeripheralLatency - #474

Draft
acouvreur wants to merge 1 commit into
feat/connection-priorityfrom
feat/connection-priority-nordic
Draft

feat(softdevice): use ConnectionPriority, and add PeripheralLatency#474
acouvreur wants to merge 1 commit into
feat/connection-priorityfrom
feat/connection-priority-nordic

Conversation

@acouvreur

@acouvreur acouvreur commented Sep 2, 2026

Copy link
Copy Markdown
Member

This PR is on top of #472. The difference shows only the SoftDevice change. It is independent of #473, which does the same work for Windows.

What this does

The SoftDevice sets the connection parameters in the controller with sd_ble_gap_conn_param_update, thus it uses the explicit fields. This PR fills each field that the caller does not set from ConnectionParams.Priority. Thus code that sets only a priority also gets a result on this platform.

This makes the rule in #472 more exact. That PR says that a platform of this type ignores Priority. This is correct, but it is not sufficient, because a caller that sets only a priority then gets no result. The rule is now that explicit values stay, and that the priority fills the other fields. ConnectionParams.Resolved shows the two together.

The table is in gap.go

ConnectionPriority.Params gives the parameters for each priority.

Priority Min Max Peripheral latency Supervision timeout
Throughput 15 ms 30 ms 0 2 s
Balanced 30 ms 60 ms 0 4 s
PowerSaving 120 ms 165 ms 4 6 s

The table is in gap.go and not in each platform. Thus all backends of this type agree, and a test can make sure of the values. The test makes sure of two conditions.

  • The values obey the guidelines from Apple (section 35.6 Connection Parameters). The intervals are multiples of 15 ms, and the supervision timeouts are between 2 and 6 seconds. https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf
  • The supervision timeout is longer than (1 + peripheral latency) × max interval × 2. The SoftDevice rejects other values.

Please examine the three rows with care. They are my selection, and I did not copy them from a specification. The values for PowerSaving are an estimate of a good compromise.

PeripheralLatency

The table needs a field that ConnectionParams did not have. The difference between power saving and balanced is the number of connection events that the peripheral can skip. The value of ble_gap_conn_params_t.slave_latency was always 0, thus the user could not set it. ConnectionParams.PeripheralLatency now sets it. This is also a correction on its own.

This is also why the enumeration in #422 could not operate. Without this field, ConnectionLatencyHigh had no equivalent on the backends that can use it.

Tests

go build, go vet and go test are satisfactory on the host. golangci-lint finds no new problems. TinyGo builds pca10056-s140v7 and pca10040-s132v6. The second target uses examples/heartrate-monitor, which includes the central file that this PR changes.

I did not test this on real hardware yet. I did not make sure on a board that a PowerSaving request gives the correct interval and latency in a connection parameters update event.

@acouvreur
acouvreur marked this pull request as draft September 2, 2026 19:02
@acouvreur
acouvreur force-pushed the feat/connection-priority branch from 7d5e8ad to ed29352 Compare September 2, 2026 19:10
@acouvreur
acouvreur force-pushed the feat/connection-priority-nordic branch from a246688 to a900a98 Compare September 2, 2026 19:10
@acouvreur acouvreur changed the title feat(softdevice): honour ConnectionPriority, and add PeripheralLatency feat(softdevice): use ConnectionPriority, and add PeripheralLatency Sep 2, 2026
The SoftDevice sets the connection parameters in the controller, thus it uses
the explicit fields. Priority now fills each field that the caller does not
set. Therefore code that sets only a priority also gets a result on this
platform.

ConnectionPriority.Params gives the parameters for each priority. The values
obey the guidelines from Apple (section 35.6 Connection Parameters). A test
makes sure of this, and also that the supervision timeout is longer than the
time that the peripheral can stay silent.

https://developer.apple.com/accessories/Accessory-Design-Guidelines.pdf

The table needs a new field. The number of connection events that the
peripheral can skip was always 0 in ble_gap_conn_params_t.slave_latency.
ConnectionParams.PeripheralLatency now sets it.

Builds for pca10056-s140v7 and pca10040-s132v6.
@acouvreur
acouvreur force-pushed the feat/connection-priority branch from ed29352 to 826dd9a Compare September 2, 2026 19:15
@acouvreur
acouvreur force-pushed the feat/connection-priority-nordic branch from a900a98 to c984fbc Compare September 2, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant