pub async fn activate_fake_host(
    control: ControlHarness,
    name: &str,
) -> Result<(String, Emulator), Error> {
    let initial_hosts: Vec<String> = control.read().hosts.keys().cloned().collect();
    let initial_hosts_ = initial_hosts.clone();

    let hci = Emulator::create_and_publish(name).await?;

    let state = control
        .when_satisfied(
            Predicate::<ControlState>::new(
                move |control| {
                    let added_fake_hosts = control.hosts.iter().filter(|(id, host)| {
                        host.address == FAKE_HCI_ADDRESS && !initial_hosts_.contains(id)
                    });
                    added_fake_hosts.count() > 0
                },
                Some("Fake Host Added"),
            ),
            control_timeout(),
        )
        .await?;

    let host = state
        .hosts
        .iter()
        .find(|(id, host)| host.address == FAKE_HCI_ADDRESS && !initial_hosts.contains(id))
        .unwrap()
        .1
        .identifier
        .to_string(); // We can safely unwrap here as this is guarded by the previous expectation

    let fut = control.aux().set_active_adapter(&host);
    fut.await?;
    control
        .when_satisfied(control_expectation::active_host_is(host.clone()), control_timeout())
        .await?;
    Ok((host, hci))
}
/// Create and publish an emulated HCI device, and wait until the host is bound and registered to
/// bt-gap
Create and publish an emulated HCI device, and wait until the host is bound and registered to
bt-gap
Create and publish an emulated HCI device and wait until the host is bound and registered to bt - gap
pub async fn activate_fake_host(
    control: ControlHarness,
    name: &str,
) -> Result<(String, Emulator), Error> {
    let initial_hosts: Vec<String> = control.read().hosts.keys().cloned().collect();
    let initial_hosts_ = initial_hosts.clone();
    let hci = Emulator::create_and_publish(name).await?;
    let state = control
        .when_satisfied(
            Predicate::<ControlState>::new(
                move |control| {
                    let added_fake_hosts = control.hosts.iter().filter(|(id, host)| {
                        host.address == FAKE_HCI_ADDRESS && !initial_hosts_.contains(id)
                    });
                    added_fake_hosts.count() > 0
                },
                Some("Fake Host Added"),
            ),
            control_timeout(),
        )
        .await?;
    let host = state
        .hosts
        .iter()
        .find(|(id, host)| host.address == FAKE_HCI_ADDRESS && !initial_hosts.contains(id))
        .unwrap()
        .1
        .identifier
        .to_string(); // We can safely unwrap here as this is guarded by the previous expectation
    let fut = control.aux().set_active_adapter(&host);
    fut.await?;
    control
        .when_satisfied(control_expectation::active_host_is(host.clone()), control_timeout())
        .await?;
    Ok((host, hci))
}
pub async fn activate_fake_host ( control : ControlHarness , name : & str , ) -> Result < ( String , Emulator ) , Error > { let initial_hosts : Vec < String > = control . read ( ) . hosts . keys ( ) . cloned ( ) . collect ( ) ; let initial_hosts_ = initial_hosts . clone ( ) ; let hci = Emulator :: create_and_publish ( name ) . await ? ; let state = control . when_satisfied ( Predicate :: < ControlState > :: new ( move | control | { let added_fake_hosts = control . hosts . iter ( ) . filter ( | ( id , host ) | { host . address == FAKE_HCI_ADDRESS && ! initial_hosts_ . contains ( id ) } ) ; added_fake_hosts . count ( ) > 0 } , Some ( " " ) , ) , control_timeout ( ) , ) . await ? ; let host = state . hosts . iter ( ) . find ( | ( id , host ) | host . address == FAKE_HCI_ADDRESS && ! initial_hosts . contains ( id ) ) . unwrap ( ) . 1 . identifier . to_string ( ) ; // We can safely unwrap here as this is guarded by the previous expectation let fut = control . aux ( ) . set_active_adapter ( & host ) ; fut . await ? ; control . when_satisfied ( control_expectation :: active_host_is ( host . clone ( ) ) , control_timeout ( ) ) . await ? ; Ok ( ( host , hci ) ) }
Create and publish an emulated HCI device, and wait until the host is bound and registered to
bt-gap
Create and publish an emulated HCI device and wait until the host is bound and registered to bt - gap
control
ControlHarness
name
&str