-
-
Notifications
You must be signed in to change notification settings - Fork 187
Description
Describe the bug
Once a device is discovered, it is always returned in the list of devices from available_ble_devices even when it is powered off.
To Reproduce
Steps to reproduce:
- Power on a meshtastic device
- Run
available_ble_devicesin example or own app and print out the list of devices, in a loop - Power off the device
Expected behavior
The device will cease to be reported as one of the available btle devices.
Additional context
Macos Tahoe 26.2
If you stop the app/loop, and restart it. The powered off device will not be discovered, as you would expect.
This, together with the no-MAC-on-macos issue have given me a lot of issues and debugging.
Not sure where the core issue lies, in this crate or btleplug?
This is the code I have used to debug this:
// loop scanning for devices
loop {
// start scanning for MeshTastic radios
// TODO report an error if cannot scan
let _ = central
.start_scan(ScanFilter {
services: vec![MSH_SERVICE],
})
.await;
tokio::time::sleep(Duration::from_secs(4)).await;
match central.peripherals().await {
Ok(peripherals) => {
let mut ble_devices_now: HashSet<String> = HashSet::new();
for peripheral in peripherals {
ble_devices_now.insert(
peripheral
.properties()
.await
.unwrap()
.unwrap()
.local_name
.unwrap(),
);
}
println!("Found: {:?}", ble_devices_now);
.....
I start the app running that code and it discovers my two devices and prints:
Found : {"Meshtastic_5171", "Meshtastic_47fd"}
I power off both devices, and it continues to report the same list of devices.
If I restart the app (with the devices powered off) they are not discovered.