-
-
Couldn't load subscription status.
- Fork 35
Add available_ble_devices() method #68
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
base: bump-msrv
Are you sure you want to change the base?
Conversation
| #[cfg(feature = "bluetooth-le")] | ||
| pub async fn available_ble_devices( | ||
| scan_duration: Duration, | ||
| ) -> Result<Vec<(Option<String>, BDAddr)>, Error> { |
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.
@andrewdavidmackenzie @matthewCmatt please test this new API.
- name doesn't have to be always available, so we return
Option<String> - you can do
let ble_id = BleId::from(mac_addr);wheremac_addrisBDaddr. And then useble_idinbuild_ble_stream.
I decided to keep btleplug::BDaddr as part of the API but I've also considered using a different type. String is the next obvious choice but it would have to only have try_from() instead of from(), which is not so convenient . The other choice is implementing own MAC address type, which I find too tedious.
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.
Note that it would be nicer to have a struct with two fields instead of (Option<String>, BDaddr) and I intend to do that. Please confirm first that this approach works for you.
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.
sounds good to me
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'd prefer the struct, and if possible that it implements PartialEq, Eq - so that I can have a Vec of them, and use contains() to determine if an instance is in the Vec.
Also refactored BleHandler: * added available_peripherals method, factoring out logic out of BleHandler::find_ble_radio. * added comments
|
Trying to update... I have a direct dependency on possible to update to a newer version of toml? |
This is a consequence of #69 I think the best way forward would be bumping MSRV to 1.84 and then dropping indexmap dependency, because this is getting annoying. I'll get to it soon. |
|
The MSRV fix is in #70 and this branch contains the fix too. |
|
Confirmed that fixes the conflict. But I will wait for the struct before changing my code. |
Summary
The
available_ble_devices()is requested by many users to detect BLE devices running Meshtastic.Also refactored
BleHandler:BleHandler::find_ble_radio.Related Issues
#32
Checklist