feat(gap): add ConnectionLatency in ConnectionParams#422
feat(gap): add ConnectionLatency in ConnectionParams#422acouvreur wants to merge 1 commit intotinygo-org:devfrom
Conversation
These settings are alternatives for platforms that do not support settings the MinInterval and MaxInterval directly.
| // | ||
| // Some platforms (e.g. Windows) may not support setting the connection parameters directly, | ||
| // but may support setting a latency level that corresponds to a set of connection parameters. | ||
| // In this case, the Latency field can be used to set the latency level instead of setting the connection parameters directly. |
There was a problem hiding this comment.
I just wonder about this, in part because that would probably mean we need to decide what connection params would be associated with a latency level for platforms where it does not exist.
Maybe we should go the other direction, meaning determine what latency would best match a set of connection params?
There was a problem hiding this comment.
We can create named ConnectionParams with a pre-defined set of values.
Then depending on the platform, they may use that how they want.
But what happens when using a non pre-defined for platforms that only support pre-defined set ?
Let me update the PR with the suggestions
There was a problem hiding this comment.
Mmmmh. I wanted to do something like
var lowLatencyConnectionParams = ConnectionParams{
MinInterval: NewDuration(7.5 * time.Millisecond),
MaxInterval: NewDuration(15 * time.Millisecond),
Timeout: NewDuration(4 * time.Second),
}
var mediumLatencyConnectionParams = ConnectionParams{
MinInterval: NewDuration(15 * time.Millisecond),
MaxInterval: NewDuration(30 * time.Millisecond),
Timeout: NewDuration(4 * time.Second),
}
var highLatencyConnectionParams = ConnectionParams{
MinInterval: NewDuration(30 * time.Millisecond),
MaxInterval: NewDuration(60 * time.Millisecond),
Timeout: NewDuration(4 * time.Second),
}
func ConnectionParamsLowLatency() ConnectionParams {
return lowLatencyConnectionParams
}
func ConnectionParamsMediumLatency() ConnectionParams {
return mediumLatencyConnectionParams
}
func ConnectionParamsHighLatency() ConnectionParams {
return highLatencyConnectionParams
}But I don't like it.
I wanted to be able to do some equality comparison on windows for example but it won't work as I expect.
These settings are alternatives for platforms that do not support settings the MinInterval and MaxInterval directly.
I will follow up with a pull request adding support for Windows.
Edit: here is the follow up pull request: #423
The current enumeration is heavily inspired from https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerconnectionlatency
However, we could also use the enumeration from windows:
ThroughputOptimizedBalancedPowerOptimizedWhat do you think @deadprogram ?