-
Notifications
You must be signed in to change notification settings - Fork 17
Remove enum ambiguity from TransactionResult.responseStatus() #36
base: develop
Are you sure you want to change the base?
Conversation
Please double-check that I picked the correct enum (GattStatus vs GattDisconnectReason) for each callback's |
@@ -15,6 +15,7 @@ | |||
* Created by iowens on 8/10/17. | |||
*/ | |||
|
|||
@Deprecated |
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.
We could also just delete this enum entirely in favor of the other one.
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.
I would say yes with renaming the other one to GattFailureReason since they are not all ending in a gatt disconnect.
@@ -65,7 +65,7 @@ protected void transaction(GattTransactionCallback callback) { | |||
if(null != serviceChar) { | |||
if(doesDescriptorAlreadyExist(serviceChar, descriptor)) { | |||
TransactionResult.Builder builder = new TransactionResult.Builder().transactionName(getName()); | |||
builder.responseStatus(GattDisconnectReason.getReasonForCode(GattDisconnectReason.GATT_CONN_NO_RESOURCES.getCode()).ordinal()); | |||
builder.disconnectReason(GattDisconnectReason.GATT_CONN_NO_RESOURCES); |
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.
I feel for these cases we should maybe have it as failureReason
since this does not result in a disconnection
@@ -15,6 +15,7 @@ | |||
* Created by iowens on 8/10/17. | |||
*/ | |||
|
|||
@Deprecated |
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.
I would say yes with renaming the other one to GattFailureReason since they are not all ending in a gatt disconnect.
Fixes
description
TransactionResult.responseStatus was used to hold ordinals from both GattStatus and GattDisconnectReason enums, which created ambiguity about its meaning. Also, sometimes the "code" was passed in instead of the ordinal, creating an incorrect mapping.
Furthermore, there are 2 GattDisconnectReason enums, one of which appears to be a superset of the other.
changes
@Deprecated
status
argument in each callback. Definitely could have made a mistake here as it's not always easy to tell.how tested
No changes to bluetooth behavior, so I didn't test it.