-
Notifications
You must be signed in to change notification settings - Fork 488
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
feat: uint8list instead of int list #1010
Conversation
@@ -2279,7 +2279,7 @@ public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteris | |||
LogLevel level = LogLevel.DEBUG; | |||
log(level, "onCharacteristicChanged:"); | |||
log(level, " chr: " + uuidStr(characteristic.getUuid())); | |||
onCharacteristicReceived(gatt, characteristic, value, status); | |||
onCharacteristicReceived(gatt, characteristic, value, BluetoothGatt.GATT_SUCCESS); |
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.
This is a bug, using status which is undefined.
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.
fixed
unfortunately, these are breaking changes to the API. so I wont merge. its a good idea though. I wouldnt consider this PR without perf numbers. BLE data rates are extremely slow. like 200KB/s. I think a phone can easily convert Lists at this slow speed. |
Will it be considered if I make it backward compatible? |
you would need to measure perf impact at the minimum only if it was a big impact would i consider it |
OK, I'll try it but there's still a bug anyway. |
hi, did you measure the performance impact yet? Does it make a noticeable difference? |
Still in plan😂 |
@chipweinberger
My testing device has several properties:
Here are the results (each value is in seconds):
Raw dataList of int to string:
Uint8List:
|
thanks for the numbers!! a nice little improvement! but not enough of a difference to break api. we could avoid converting to strings in the internal code, and probably get similar improvements. but i like hex, it's more useful for during application development, logs, debugging issues people file on github, etc. there are a lot more important changes we could make to improve perf, first. for example, right now we block using a mutex and don't queue up any more writes until dart knows the previous write is finished. but we could have a small queue on the native side, to avoid round tripping through Dart every time. then instead of the user calling
they would need to use:
but again, would need perf numbers. |
this is an idea i've wanted to try for awhile. it would be annoying to implement. but easy enough to test to see how much it improves things. test # 1: do lots of writes with FBP using dart and compare. |
thinking about this more, we could still log hex for verbose logs. we just need to update the logging code on the dart side to convert Uint8List to hex strings before we log.
feel free to submit a new PR. switch to Uint8List for internal comms, and just use hex when logging. youll probably still get 99% of the perf improvement you're seeing. |
I'll try, thanks. |
By the way, the result above could serve as a benchmark for future improvements, although only through the performance_screen can we compare against this benchmark. |
Purpose
Using
Uint8List
to pass the value as proposed in #954.Why?
To avoid converting between strings and byte lists. There are also several benefits shown in this video.
Tests
I've tested this on Android, and it works as expected, but I haven't tested it on iOS (I don't have a physical device).
Breaking changes
We can easily convert between
Uint8List
andList<int>
:However, this is still a breaking change. How can we make the migration painless? We could provide a value8 in the property and deprecated getter of value8, for example:
But I'm not sure whether we should offer this migration path or simply bump the major version.