0

i'm new to rust and currently trying to use bluer 0.15.0 in a new project i'm working on. I work exactly according to the documentation of bluer but still I am not able to use parts of the crate as it is given in the documentation.

This is the code I currently have for testing purposes (it's copied from this part of bluers documentation)

async fn main() -> bluer::Result<()> {
env_logger::init();
let session = bluer::Session::new().await?;
let adapter = session.default_adapter().await?;
adapter.set_powered(true).await?;

println!("Advertising on Bluetooth adapter {} with address {}", adapter.name(), adapter.address().await?);
let le_advertisement = Advertisement {
    advertisement_type: bluer::adv::Type::Peripheral,
    service_uuids: vec!["123e4567-e89b-12d3-a456-426614174000".parse().unwrap()].into_iter().collect(),
    discoverable: Some(true),
    local_name: Some("le_advertise".to_string()),
    ..Default::default()
};
println!("{:?}", &le_advertisement);
let handle = adapter.advertise(le_advertisement).await?;

println!("Press enter to quit");
let stdin = BufReader::new(tokio::io::stdin());
let mut lines = stdin.lines();
let _ = lines.next_line().await;

println!("Removing advertisement");
drop(handle);
sleep(Duration::from_secs(1)).await;

Ok(())

And currently i'm not able to use, for example, Advertisement or bluer::Result because they are (according to cargo) not existing in the project.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Dome
  • 7
  • 5
  • See the top of the page that you just linked: _"Available on crate feature bluetoothd only."_ You likely forgot to add this feature. – E_net4 Aug 24 '22 at 12:30
  • @E_net4thecommentflagger you are completely right. I didn't know this yet. I added the feature and it worked. Many thanks for your help! – Dome Aug 24 '22 at 12:35

0 Answers0