You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Devices continue to be reported by Adapter::peripherals() after powering off #452
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_devices in 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.
changed the title [-]Devices continue to be reported by `central.peripherals()` after powering off[/-][+]Devices continue to be reported by `Adapter::peripherals()` after powering off[/+]on Jan 22, 2026
I'm working on this right now actually (see the ble-integration-test branch). I've spent the past couple of weeks building a hardware test platform to run library tests against, and now I'm seeing this issue in the test cases. It maybe a "this is the way the platform works" deal but I want to confirm first.
Ok, so, as of v0.12, we'll have a clear_peripherals() method that'll allow you to clear the peripheral list yourself and rescan. In lieu of building in a timeout to the library for advertisements (which I'm considering but this version is already packed), will this suffice?
One approach I guess.
I imagine when a scan is done, the lost devices don't appear. Could you
have an "unseen count" and if unseen for (say) 3 times then remove from the
list?
Activity
[-]Devices continue to be reported by `central.peripherals()` after powering off[/-][+]Devices continue to be reported by `Adapter::peripherals()` after powering off[/+]andrewdavidmackenzie commentedon Jan 30, 2026
Doing some testing on Linux I can confirm this happens on MacOS only.
In my case: Tahoe, 26.2
andrewdavidmackenzie commentedon Mar 2, 2026
Thoughts on this one?
Another "this is the way this platform works" case, and I should just look for a workaround in my app?
qdot commentedon Mar 2, 2026
I'm working on this right now actually (see the
ble-integration-testbranch). I've spent the past couple of weeks building a hardware test platform to run library tests against, and now I'm seeing this issue in the test cases. It maybe a "this is the way the platform works" deal but I want to confirm first.Can't really give an ETA, but work is happening.
andrewdavidmackenzie commentedon Mar 2, 2026
Nice! Thanks for the update.
qdot commentedon Mar 8, 2026
Ok, so, as of v0.12, we'll have a
clear_peripherals()method that'll allow you to clear the peripheral list yourself and rescan. In lieu of building in a timeout to the library for advertisements (which I'm considering but this version is already packed), will this suffice?andrewdavidmackenzie commentedon Mar 8, 2026
qdot commentedon Mar 8, 2026
"Count" and "3 times" do not mean anything in this context? Scans are not discrete.
A combination of
clear_peripherals()andconnect_with_timeout()in v0.12 should get you close enough.