Crate ember_mug

source ·
Expand description

ember_mug | Rust crate for controlling and retrieving data from an Ember Ceramic Mug using Bluetooth Low Energy (BLE)

githubcrates-iodocs-rs-big

You can see current unpublished docs here: local-docs

Provides a Rust interface for interacting with Ember Mug devices through the btleplug crate. Used to create applications that can control and monitor Ember Mug devices; retrieving the current temperature or battery level, setting the target temperature or mug color and accessing device metadata.

Example

use ember_mug::{mug::Temperature, EmberMug};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mug = EmberMug::find_and_connect().await?;
    let name = mug.get_name().await?;
    println!("Connected to an Ember Mug with the name '{}'", name);

    let battery = mug.get_battery().await?;
    println!("Battery level: {}%", battery.battery);

    let current_temp = mug.get_current_temperature().await?;
    let target_temp = mug.get_target_temperature().await?;
    let unit = mug.get_temperature_unit().await?;
    println!("Current temperature: {}{}", current_temp, unit);
    println!("Target temperature: {}{}", target_temp, unit);

    mug.set_target_temperature(&Temperature::from_degree(60.0))
        .await?;

    let target_temp = mug.get_target_temperature().await?;
    println!("Changed target temperature to {}{}", target_temp, unit);

    Ok(())
}

Results in

Connected to an Ember Mug with the name 'EMBER'
Battery level: 100%
Current temperature: 20.5°C
Target temperature: 54°C
Changed target temperature to 60°C

Kudos

Thanks to orlopau/ember-mug and sopelj/python-ember-mug for providing hints towards the various BLE characteristics

License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Re-exports

Modules

  • Functions for communicating with BLE to connect to Ember Mugs
  • Hosts EmberMug and related functions

Enums

Constants

Statics