feat(gap): add ConnectionPriority to ConnectionParams - #472
Open
acouvreur wants to merge 1 commit into
Open
Conversation
This was referenced Sep 2, 2026
Member
Author
|
The full set of PRs:
#473 and #474 are independent of each other. Both are on top of this PR, thus GitHub changes their target to |
acouvreur
force-pushed
the
feat/connection-priority
branch
from
September 2, 2026 19:10
7d5e8ad to
ed29352
Compare
Some platforms do not accept explicit connection parameters. Windows accepts only three presets. ConnectionPriority gives a request that these platforms can use. The names show the trade-off and not the latency. Apple and Android give opposite meanings to low and high, thus these names are not clear. The Bluetooth Core Specification also uses the term connection latency for a different parameter. https://learn.microsoft.com/en-us/uwp/api/windows.devices.bluetooth.bluetoothlepreferredconnectionparameters https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerconnectionlatency https://developer.android.com/reference/android/bluetooth/BluetoothGatt#requestConnectionPriority(int) No backend reads Priority yet. The behavior does not change.
acouvreur
force-pushed
the
feat/connection-priority
branch
from
September 2, 2026 19:15
ed29352 to
826dd9a
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 replaces #422. It divides that work into a base contract and one PR for each platform that can use it.
What this adds
ConnectionPriority, and aPriorityfield inConnectionParams. No backend reads the field yet. The behavior does not change.Why a priority is necessary
Not all platforms accept explicit connection parameters. There are three groups.
sd_ble_gap_conn_param_update. HCI can also do this, but the code does not exist yet.BluetoothLEPreferredConnectionParametershas no public constructor. It has only three static presets, and only on Windows 11 build 22000 or later.setDesiredConnectionLatencyis a method ofCBPeripheralManager, thus a central cannot use it. Web Bluetooth has no such function.A priority is a request that the second group can use. Android and CoreBluetooth divide the same range into three parts.
Why the names are not Low, Medium and High
There are two problems with these names.
The vendors do not agree on the direction. Apple
.lowand AndroidCONNECTION_PRIORITY_HIGHhave the same meaning..lowThroughputOptimizedCONNECTION_PRIORITY_HIGH.mediumBalancedCONNECTION_PRIORITY_BALANCED.highPowerOptimizedCONNECTION_PRIORITY_LOW_POWERThus many users will read
ConnectionLatencyHighin the opposite sense. Names that show the trade-off do not have this problem.The Bluetooth Core Specification uses the term connection latency for a different parameter. It is the number of connection events that the peripheral can skip. Windows uses the same name for it, in
BluetoothLEPreferredConnectionParameters.ConnectionLatency, with values from0x0000to0x01F3. This is the object that the Windows PR uses. If we keep the term free, there is no conflict when we add that field.References:
How to use the two together
A platform that accepts only presets uses
Priorityand ignores the explicit fields. A platform that sets the parameters in the controller uses the explicit fields. Set both fields to make a request that operates on all platforms.The zero value does not change the connection. This agrees with the other fields in
ConnectionParams.The PRs on top of this one
Priorityto the three WinRT presetsPriorityinto explicit parametersOne item stays open after these two PRs. Five backends return
nilfromRequestConnectionParamsbut do nothing. A subsequent PR can report the support level of each device.