Skip to content

watcher.SetUseCodedPhy(true) breaks scanning on Windows #473

Description

@Finomnis

maybe related: #472

I just upgraded from btleplug 0.12.0 to 0.13.0.

Now, scanning no longer yields any events on my Windows System.

use btleplug::api::{Central, Manager as _, ScanFilter};
use btleplug::platform::Manager;
use futures_util::StreamExt as _;
use std::error::Error;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let manager = Manager::new().await.unwrap();

    // get the first bluetooth adapter
    let adapters = manager.adapters().await?;
    let central = adapters.into_iter().nth(0).unwrap();

    let mut events = central.events().await?;

    central.start_scan(ScanFilter::default()).await?;
    let _ = tokio::time::timeout(Duration::from_secs(2), async {
        loop {
            println!("{:?}", events.next().await.unwrap());
        }
    })
    .await;
    let _ = central.stop_scan().await;

    Ok(())
}

Expected behavior
A lot of printed lines containing discovery events of the BLE devices around me.

Actual behavior
Absolutely nothing.

Additional context
When I comment out the line let _ = self.watcher.SetUseCodedPhy(true); in src\winrtble\ble\watcher.rs:84, it works as expected.

System informations

I'm on Windows 11.
My BLE adapter is a tp-link UB400.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions