Add available_ble_devices() method#68
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.
@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.
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.
sounds good to me
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Since this PR was auto-closed, I've created #72 with the BleDevice struct instead of the tuple.
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. |
|
It was auto-closed and I probably can't reopen the PR. There might have to be a new PR. |
|
New PR, as this one was auto-closed: #72 Now with BleDevice struct instead of the tuple. |
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