#bluetooth #dbus #zbus #async #bluez

bluebus

A Rust library for interacting with Bluetooth devices using the org.bluez D-Bus API

11 releases

0.1.10 Sep 30, 2025
0.1.9 Sep 30, 2025
0.1.7 May 12, 2025
0.1.5 Apr 29, 2025
0.1.4 Mar 17, 2025

#354 in Unix APIs

Download history 302/week @ 2025-10-12 265/week @ 2025-10-19 357/week @ 2025-10-26 566/week @ 2025-11-02 388/week @ 2025-11-09 248/week @ 2025-11-16 118/week @ 2025-11-23 413/week @ 2025-11-30 471/week @ 2025-12-07 325/week @ 2025-12-14 275/week @ 2025-12-21 247/week @ 2025-12-28 546/week @ 2026-01-04 1035/week @ 2026-01-11 561/week @ 2026-01-18 447/week @ 2026-01-25

2,648 downloads per month

MIT/Apache

50KB
886 lines

BlueBus

BlueBus is a Rust library for interacting with Bluetooth devices using the zbus. It provides an async-first interface for scanning, managing, and communicating with Bluetooth devices on Linux systems.

Features

Device Discovery: Scan for available Bluetooth devices.
Device Management: Connect, pair, unpair, and trust devices.
GATT Support: Read and write Bluetooth characteristics.
Low Energy Advertisement: Manage Bluetooth LE advertisements.
Async Support: Fully compatible with tokio and async/await.

Installation

Add bluebus to your Cargo.toml:

[dependencies]
bluebus = "0.1.10"

Example Usage

This example scans for Bluetooth devices and prints their addresses:

#[tokio::main]
async fn main() -> zbus::Result<()> {
    let conn = bluebus::get_system_connection().await.unwrap();
    let adapter = bluebus::AdapterProxy::builder(&conn)
        .path(bluebus::ADAPTER_PATH)?.build().await?;

    if !adapter.powered().await? {
        adapter.set_powered(true).await?;
    }

    adapter.start_discovery().await?;
    tokio::time::sleep(tokio::time::Duration::from_secs(3)).await;
    adapter.stop_discovery().await?;
    let monitor = Arc::new(bluebus::Monitor::new(conn.clone(), manager).await);
    let monitor_clone = Arc::clone(&monitor);
    bluebus::print_avaiable_devices(&objects);
    tokio::spawn(async move {monitor.monitor_device_added().await;});
    tokio::spawn(async move {monitor_clone.monitor_device_removed().await;});
    Ok(())
}

Documentation

Detailed API documentation is available on docs.rs.

License

BlueBus is licensed under either:

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request on GitHub.


Acknowledgments

Special thanks to REM Vision Lab and Sezai Acer for their support in improving this library.

Dependencies

~14–23MB
~365K SLoC