feat(softdevice): use ConnectionPriority, and add PeripheralLatency - #474
Draft
acouvreur wants to merge 1 commit into
Draft
feat(softdevice): use ConnectionPriority, and add PeripheralLatency#474acouvreur wants to merge 1 commit into
acouvreur wants to merge 1 commit into
Conversation
acouvreur
marked this pull request as draft
September 2, 2026 19:02
acouvreur
force-pushed
the
feat/connection-priority
branch
from
September 2, 2026 19:10
7d5e8ad to
ed29352
Compare
acouvreur
force-pushed
the
feat/connection-priority-nordic
branch
from
September 2, 2026 19:10
a246688 to
a900a98
Compare
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
force-pushed
the
feat/connection-priority
branch
from
September 2, 2026 19:15
ed29352 to
826dd9a
Compare
acouvreur
force-pushed
the
feat/connection-priority-nordic
branch
from
September 2, 2026 19:15
a900a98 to
c984fbc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fromConnectionParams.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.Resolvedshows the two together.The table is in gap.go
ConnectionPriority.Paramsgives the parameters for each priority.ThroughputBalancedPowerSavingThe table is in
gap.goand 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.(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
PowerSavingare an estimate of a good compromise.PeripheralLatency
The table needs a field that
ConnectionParamsdid not have. The difference between power saving and balanced is the number of connection events that the peripheral can skip. The value ofble_gap_conn_params_t.slave_latencywas always0, thus the user could not set it.ConnectionParams.PeripheralLatencynow sets it. This is also a correction on its own.This is also why the enumeration in #422 could not operate. Without this field,
ConnectionLatencyHighhad no equivalent on the backends that can use it.Tests
go build,go vetandgo testare satisfactory on the host. golangci-lint finds no new problems. TinyGo buildspca10056-s140v7andpca10040-s132v6. The second target usesexamples/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
PowerSavingrequest gives the correct interval and latency in a connection parameters update event.