Rust Bluetooth Low Energy (BLE) central module library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples A bunch of doc work Apr 9, 2018
src Add support for disconnection handling May 28, 2018
.gitignore Clean-ups for release Jan 2, 2018
.travis.yml add travis ci config Jan 29, 2018
Cargo.lock Update version to 0.2.1 May 28, 2018
Cargo.toml Update version to 0.2.1 May 28, 2018
LICENSE-APACHE Add licenses Jan 2, 2018
LICENSE-MIT Add licenses Jan 2, 2018 A bunch of doc work Apr 9, 2018


Build Status Version docs

Rumble is a Bluetooth Low Energy (BLE) central module library for Rust. Currently only Linux (with the BlueZ bluetooth library) is supported, although other operating systems may be supported in the future. Rumble interfaces with BlueZ using its socket interface rather than DBus. This offers much more control and reliability over the DBus interface, and does not require running BlueZ in experimental mode for BLE.

As of version 0.2, the API is becoming more stable and the library itself more useful. You should still expect to encounter bugs, limitations, and odd behaviors. Pull requests (and wireshark traces) welcome!


An example of how to use the library to control some BLE smart lights:

extern crate rumble;
extern crate rand;

use std::thread;
use std::time::Duration;
use rand::{Rng, thread_rng};
use rumble::bluez::manager::Manager;
use rumble::api::{UUID, Central, Peripheral};

pub fn main() {
    let manager = Manager::new().unwrap();

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

    // reset the adapter -- clears out any errant state
    adapter = manager.down(&adapter).unwrap();
    adapter = manager.up(&adapter).unwrap();

    // connect to the adapter
    let central = adapter.connect().unwrap();

    // start scanning for devices
    // instead of waiting, you can use central.on_event to be notified of
    // new devices

    // find the device we're interested in
    let light = central.peripherals().into_iter()
            .any(|name| name.contains("LEDBlue"))).unwrap();

    // connect to the device

    // discover characteristics

    // find the characteristic we want
    let chars = light.characteristics();
    let cmd_char = chars.iter().find(|c| c.uuid == UUID::B16(0xFFE9)).unwrap();

    // dance party
    let mut rng = thread_rng();
    for _ in 0..20 {
        let color_cmd = vec![0x56, rng.gen(), rng.gen(), rng.gen(), 0x00, 0xF0, 0xAA];
        light.command(&cmd_char, &color_cmd).unwrap();