-
Notifications
You must be signed in to change notification settings - Fork 455
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
Read RSSI from a connected BLE device #1
Conversation
- Implement all required logic to iOS and Android native code - Update protos for required data structures - Update example app to periodically show RSSI of connected device - Copy regenerate.md from flutter_blue and do flutter_blue_plus related changes
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.
Hi, I really like this pull request, as I've missed this functionality lately.
But I'm curious, if it is possible to implement this in "reactive" style. I mean that instead of calling readRssi
method, there would be Stream<int> rssi
field, which would emit a new event every time the rssi changes.
I see that the last changed lines from example/lib/main.dart
try to imitate that, by just getting the value periodically. But I mean something more like, being notified about rssi change by the android SDK instead of polling.
I'm asking, because I don't have much experience in that topic, but the rssi
field would match better the rest of the library (like state
fields in FlutterBluePlus
/BluetoothDevice
or isScanning
etc.) and I think it would be better to implement it like that if it's possible.
The functionality was added as closely as possible to how it works on the native side. This gives the app the highest flexibility how it wants to use the functionality (e.g. if it needs the value once to be able to warn in case of weak signal before doing some BLE communication, or if it needs it regularly e.g. to display the signal strength in the UI). Providing a stream of rssi values by the plugin would mean, that several assumptions have to be made. E.g. the frequency of reading the rssi, post-processing (e.g. low-pass filtering as the value fluctuates strongly for single measurements), decision when a new rssi is different enough (e.g. the app might want to know only if the value is within a certain range) are different depending on the use-case. Of course, it could be made configurable with many parameters, but in my opinion, it is simpler to do such logic in the app directly. |
If there is no similar API to the Stream based one (and after my small search through the docs there isn't) I totally agree with you that this API is much better. Thank you for explaining it. |
Rebased and ready for review again |
@boskokg: Is there any chance you will merge this PR to the base branch? Do you need more info? |
Any word on this? I'd really like to see this integrated as well. |
@sophisticode can you please check the comment I put on your merge request? |
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.
check
@boskokg: Sorry, but I cannot see your comment. |
@boskokg: |
Thanks @sophisticode |
This change adds functionality to read RSSI from a connected device. All required logic to iOS and Android native code is implemented and protos have been updated and regenerated for the required data structures
The example app was also updated to periodically show the RSSI of a connected device.
Furthermore, the regenerate.md file from flutter_blue was copied and flutter_blue_plus related changes were done to help anyone when doing future changes to protos.