-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BLE: allow client to override write with/without response #159
BLE: allow client to override write with/without response #159
Conversation
LGTM. |
@@ -338,7 +338,7 @@ private async Task<JToken> Write(JObject parameters) | |||
{ | |||
var buffer = EncodingHelpers.DecodeBuffer(parameters); | |||
var endpoint = await GetEndpoint("write request", parameters, GattHelpers.BlockListStatus.ExcludeWrites); | |||
var withResponse = (parameters["withResponse"]?.ToObject<bool>() ?? false) || | |||
var withResponse = parameters["withResponse"]?.ToObject<bool>() ?? | |||
!endpoint.CharacteristicProperties.HasFlag(GattCharacteristicProperties.WriteWithoutResponse); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set to a variable "the characteristic thinks we MUST write WITH response"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to say that we explicitly expect an error if the gatt characteristic does not have property write with response (because then we're trying to write and we're not allowed to write at all)
@@ -297,7 +297,10 @@ class BLESession: Session, SwiftCBCentralManagerDelegate, SwiftCBPeripheralDeleg | |||
return | |||
} | |||
|
|||
let writeType = (withResponse || !endpoint.properties.contains(.writeWithoutResponse)) ? | |||
// If the client specified a write type, honor that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this comment to c# as well
// If the client specified a write type, honor that. | ||
// Otherwise, if the characteristic claims to support writing without response, do that. | ||
// Otherwise, write with response. | ||
let writeType = (withResponse ?? !endpoint.properties.contains(.writeWithoutResponse)) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withResponse = withResponse ?? !endpoint.properties.contains(.writeWithoutResponse));
let writeType = withResponse ? x : y
might be more clear?
I'm going to merge this as-is for now but I've filed #161 to follow up on the review comments later. |
Resolves
Resolves #150
Closes #154
Proposed Changes
In #154, @terado0618 implemented a fix for #150 on Windows. This PR includes #154 along with a similar change for macOS and documentation of the new behavior.
Reason for Changes
This offers a significant performance boost on Windows: see this comment. Performance on macOS seems to be acceptable without this change, but I think it's important for the hardware communication to be similar on both platforms so that extensions don't need to worry about platform differences.
This PR should be merged with scratchfoundation/scratch-vm#2298.
@terado0618, please let me know if you have concerns about this PR. Thanks!