Skip to content
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

Merged
merged 5 commits into from
Apr 9, 2022

Conversation

sophisticode
Copy link
Contributor

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.

- 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
Copy link

@ghost ghost left a 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.

@sophisticode
Copy link
Contributor Author

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.

@ghost
Copy link

ghost commented Feb 25, 2022

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.

@sophisticode
Copy link
Contributor Author

Rebased and ready for review again

@sophisticode
Copy link
Contributor Author

@boskokg: Is there any chance you will merge this PR to the base branch? Do you need more info?

@gregk104
Copy link

Any word on this? I'd really like to see this integrated as well.

@boskokg
Copy link
Collaborator

boskokg commented Apr 4, 2022

@sophisticode can you please check the comment I put on your merge request?

Copy link
Contributor Author

@sophisticode sophisticode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

@sophisticode
Copy link
Contributor Author

@boskokg: Sorry, but I cannot see your comment.

@boskokg
Copy link
Collaborator

boskokg commented Apr 4, 2022

@sophisticode
Screenshot 2022-04-04 at 13 43 02

@sophisticode
Copy link
Contributor Author

@boskokg:
The code in the example app was changed so that the stream stops when the device is disconnected.

@boskokg boskokg merged commit 85b66e1 into chipweinberger:master Apr 9, 2022
@boskokg
Copy link
Collaborator

boskokg commented Apr 9, 2022

Thanks @sophisticode

@jin-develop jin-develop mentioned this pull request May 22, 2023
@roger66 roger66 mentioned this pull request Feb 2, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants