Skip to main content

Crate wayle_bluetooth

Crate wayle_bluetooth 

Source
Expand description

Bluetooth device management via BlueZ D-Bus.

§Quick Start

use wayle_bluetooth::BluetoothService;

let bt = BluetoothService::new().await?;

// Check adapter state
if bt.available.get() {
    println!("Bluetooth available, powered: {}", bt.enabled.get());
}

// List paired devices
for device in bt.devices.get().iter() {
    let name = device.name.get().unwrap_or_default();
    println!("{}: {}", name, device.address.get());
}

§Watching for Changes

use wayle_bluetooth::BluetoothService;
use futures::StreamExt;

// React to new devices
let mut stream = bt.devices.watch();
while let Some(devices) = stream.next().await {
    println!("Device count: {}", devices.len());
}

§Discovery and Pairing

// Scan for 30 seconds
bt.start_timed_discovery(Duration::from_secs(30)).await?;

// Connect to a device
for device in bt.devices.get().iter() {
    if device.name.get().as_deref() == Some("My Headphones") {
        device.connect().await?;
    }
}

§Reactive Properties

All fields are Property<T>:

  • .get() - Current value snapshot
  • .watch() - Stream yielding on changes

§Service Fields

FieldTypeDescription
adaptersVec<Arc<Adapter>>All Bluetooth adapters
primary_adapterOption<Arc<Adapter>>Active adapter for operations
devicesVec<Arc<Device>>All discovered devices
availableboolWhether any adapter is present
enabledboolWhether any adapter is powered
connectedVec<String>Addresses of connected devices
pairing_requestOption<PairingRequest>Pending pairing request

§Control Methods

Device-level: connect(), disconnect(), pair(), forget()

Modules§

core
Bluetooth domain models for adapters and devices.
types
BlueZ type definitions for adapter/device properties.

Structs§

BluetoothService
Bluetooth connectivity via BlueZ D-Bus.

Enums§

Error
Bluetooth service errors.