Struct EmberMug

Source
pub struct EmberMug { /* private fields */ }
Expand description

An Ember Mug device

Create an instance with EmberMug::find_and_connect or EmberMug::connect_mug

Implementations§

Source§

impl EmberMug

Source

pub async fn get_battery(&self) -> Result<Battery, ReadError>

Retrieves the battery percentage of the mug and other values.

Examples found in repository?
examples/example.rs (line 9)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let mug = EmberMug::find_and_connect().await?;
6    let name = mug.get_name().await?;
7    println!("Connected to an Ember Mug with the name '{name}'");
8
9    let battery = mug.get_battery().await?;
10    println!("Battery level: {}%", battery.battery);
11
12    let current_temp = mug.get_current_temperature().await?;
13    let target_temp = mug.get_target_temperature().await?;
14    let unit = mug.get_temperature_unit().await?;
15    println!("Current temperature: {current_temp}{unit}");
16    println!("Target temperature: {target_temp}{unit}");
17
18    mug.set_target_temperature(&Temperature::from_degree(60.0))
19        .await?;
20
21    let target_temp = mug.get_target_temperature().await?;
22    println!("Changed target temperature to {target_temp}{unit}");
23
24    Ok(())
25}
More examples
Hide additional examples
examples/info.rs (line 29)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source§

impl EmberMug

Source

pub async fn get_current_temperature(&self) -> Result<Temperature, ReadError>

Retrieves the current temperature of the mug

Examples found in repository?
examples/example.rs (line 12)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let mug = EmberMug::find_and_connect().await?;
6    let name = mug.get_name().await?;
7    println!("Connected to an Ember Mug with the name '{name}'");
8
9    let battery = mug.get_battery().await?;
10    println!("Battery level: {}%", battery.battery);
11
12    let current_temp = mug.get_current_temperature().await?;
13    let target_temp = mug.get_target_temperature().await?;
14    let unit = mug.get_temperature_unit().await?;
15    println!("Current temperature: {current_temp}{unit}");
16    println!("Target temperature: {target_temp}{unit}");
17
18    mug.set_target_temperature(&Temperature::from_degree(60.0))
19        .await?;
20
21    let target_temp = mug.get_target_temperature().await?;
22    println!("Changed target temperature to {target_temp}{unit}");
23
24    Ok(())
25}
More examples
Hide additional examples
examples/info.rs (line 30)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source§

impl EmberMug

Source

pub async fn get_dsk(&self) -> Result<Vec<u8>, ReadError>

Retrieves the dsk of the cup

Examples found in repository?
examples/info.rs (line 41)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source

pub async fn get_udsk(&self) -> Result<Vec<u8>, ReadError>

Retrieves the dsk of the cup

Examples found in repository?
examples/info.rs (line 42)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source§

impl EmberMug

Source

pub async fn get_liquid_level(&self) -> Result<LiquidLevel, ReadError>

Retrieves the level of liquid present in the cup

Source§

impl EmberMug

Source

pub async fn get_liquid_state(&self) -> Result<LiquidState, ReadError>

The current state of the mug

Examples found in repository?
examples/info.rs (line 33)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source§

impl EmberMug

Source

pub async fn get_mug_color(&self) -> Result<Color, ReadError>

Retrieves the color of the mug’s LED indicator.

Examples found in repository?
examples/info.rs (line 31)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source

pub async fn set_mug_color(&self, color: &Color) -> Result<(), WriteError>

Sets the color of the mug’s LED indicator.

Source§

impl EmberMug

Source

pub async fn get_mug_meta(&self) -> Result<MugMeta, ReadError>

Retrieves id of the mug

Examples found in repository?
examples/info.rs (line 40)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source§

impl EmberMug

Source

pub async fn get_name(&self) -> Result<String, ReadError>

Retreives the name of the mug.

Examples found in repository?
examples/example.rs (line 6)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let mug = EmberMug::find_and_connect().await?;
6    let name = mug.get_name().await?;
7    println!("Connected to an Ember Mug with the name '{name}'");
8
9    let battery = mug.get_battery().await?;
10    println!("Battery level: {}%", battery.battery);
11
12    let current_temp = mug.get_current_temperature().await?;
13    let target_temp = mug.get_target_temperature().await?;
14    let unit = mug.get_temperature_unit().await?;
15    println!("Current temperature: {current_temp}{unit}");
16    println!("Target temperature: {target_temp}{unit}");
17
18    mug.set_target_temperature(&Temperature::from_degree(60.0))
19        .await?;
20
21    let target_temp = mug.get_target_temperature().await?;
22    println!("Changed target temperature to {target_temp}{unit}");
23
24    Ok(())
25}
More examples
Hide additional examples
examples/info.rs (line 32)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source

pub async fn set_name(&self, name: &str) -> Result<(), WriteError>

Sets the name of the mug.

Source§

impl EmberMug

Source

pub async fn get_ota(&self) -> Result<Ota, ReadError>

Info about the current firmware running on the mug.

Examples found in repository?
examples/info.rs (line 38)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source§

impl EmberMug

Source

pub async fn get_push_event(&self) -> Result<PushEvent, ReadError>

Events sent by the mug for the application to register to.

Call subscribe_push_events first, and prefer to use listen_push_events instead

Source

pub async fn subscribe_push_events(&self) -> Result<(), ReadError>

Subscribe to events sent by the mug

Source

pub async fn listen_push_events( &self, ) -> Result<impl Stream<Item = Result<PushEvent, ReadError>> + Send + '_, ReadError>

Get a stream of events sent by the mug. You need to use subscribe_push_events to get events. The stream is not valid across connections.

Source

pub async fn unsubscribe_push_events(&self) -> Result<(), ReadError>

Unsubscribe to events sent by the mug

Source§

impl EmberMug

Source

pub async fn get_target_temperature(&self) -> Result<Temperature, ReadError>

Retrieves the target temperature of the mug

Examples found in repository?
examples/example.rs (line 13)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let mug = EmberMug::find_and_connect().await?;
6    let name = mug.get_name().await?;
7    println!("Connected to an Ember Mug with the name '{name}'");
8
9    let battery = mug.get_battery().await?;
10    println!("Battery level: {}%", battery.battery);
11
12    let current_temp = mug.get_current_temperature().await?;
13    let target_temp = mug.get_target_temperature().await?;
14    let unit = mug.get_temperature_unit().await?;
15    println!("Current temperature: {current_temp}{unit}");
16    println!("Target temperature: {target_temp}{unit}");
17
18    mug.set_target_temperature(&Temperature::from_degree(60.0))
19        .await?;
20
21    let target_temp = mug.get_target_temperature().await?;
22    println!("Changed target temperature to {target_temp}{unit}");
23
24    Ok(())
25}
More examples
Hide additional examples
examples/info.rs (line 36)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source

pub async fn set_target_temperature( &self, temperature: &Temperature, ) -> Result<(), WriteError>

Set the target temperature of the mug

Examples found in repository?
examples/example.rs (line 18)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let mug = EmberMug::find_and_connect().await?;
6    let name = mug.get_name().await?;
7    println!("Connected to an Ember Mug with the name '{name}'");
8
9    let battery = mug.get_battery().await?;
10    println!("Battery level: {}%", battery.battery);
11
12    let current_temp = mug.get_current_temperature().await?;
13    let target_temp = mug.get_target_temperature().await?;
14    let unit = mug.get_temperature_unit().await?;
15    println!("Current temperature: {current_temp}{unit}");
16    println!("Target temperature: {target_temp}{unit}");
17
18    mug.set_target_temperature(&Temperature::from_degree(60.0))
19        .await?;
20
21    let target_temp = mug.get_target_temperature().await?;
22    println!("Changed target temperature to {target_temp}{unit}");
23
24    Ok(())
25}
Source§

impl EmberMug

Source

pub async fn get_temperature_unit(&self) -> Result<TemperatureUnit, ReadError>

Retrieve the current unit of temperature used by the mug.

Examples found in repository?
examples/example.rs (line 14)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let mug = EmberMug::find_and_connect().await?;
6    let name = mug.get_name().await?;
7    println!("Connected to an Ember Mug with the name '{name}'");
8
9    let battery = mug.get_battery().await?;
10    println!("Battery level: {}%", battery.battery);
11
12    let current_temp = mug.get_current_temperature().await?;
13    let target_temp = mug.get_target_temperature().await?;
14    let unit = mug.get_temperature_unit().await?;
15    println!("Current temperature: {current_temp}{unit}");
16    println!("Target temperature: {target_temp}{unit}");
17
18    mug.set_target_temperature(&Temperature::from_degree(60.0))
19        .await?;
20
21    let target_temp = mug.get_target_temperature().await?;
22    println!("Changed target temperature to {target_temp}{unit}");
23
24    Ok(())
25}
Source

pub async fn set_temperature_unit( &self, temperature_unit: &TemperatureUnit, ) -> Result<(), WriteError>

Set the current unit of temperature used by the mug.

Source§

impl EmberMug

Source

pub async fn get_time_date_zone(&self) -> Result<TimeDateZone, ReadError>

Get the current date and timezone on the mug

Examples found in repository?
examples/info.rs (line 39)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source

pub async fn set_time_date_zone( &self, time_date_zone: &TimeDateZone, ) -> Result<(), WriteError>

A sink for the mug to store the current date and timezone

Source§

impl EmberMug

Source

pub async fn find_and_connect() -> Result<Self, ConnectError>

Find and connect to the first available Ember Mug

Examples found in repository?
examples/example.rs (line 5)
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    let mug = EmberMug::find_and_connect().await?;
6    let name = mug.get_name().await?;
7    println!("Connected to an Ember Mug with the name '{name}'");
8
9    let battery = mug.get_battery().await?;
10    println!("Battery level: {}%", battery.battery);
11
12    let current_temp = mug.get_current_temperature().await?;
13    let target_temp = mug.get_target_temperature().await?;
14    let unit = mug.get_temperature_unit().await?;
15    println!("Current temperature: {current_temp}{unit}");
16    println!("Target temperature: {target_temp}{unit}");
17
18    mug.set_target_temperature(&Temperature::from_degree(60.0))
19        .await?;
20
21    let target_temp = mug.get_target_temperature().await?;
22    println!("Changed target temperature to {target_temp}{unit}");
23
24    Ok(())
25}
More examples
Hide additional examples
examples/info.rs (line 15)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source

pub async fn connect_mug( adapter: Adapter, peripheral: <Adapter as Central>::Peripheral, ) -> Result<Self, ConnectError>

Connect to specific Ember Mug

Source

pub async fn is_connected(&self) -> Result<bool, Error>

Returns true if the device is connected, the device might be considered disconnected if it doesn’t respond in 1 second

Source

pub async fn disconnected(&self) -> Result<(), Error>

Returns when the device is disconnected.

Source§

impl EmberMug

Source

pub fn get_characteristic(&self, uuid: &Uuid) -> Option<&Characteristic>

Get characteristic on EMBER_MUG_SERVICE_UUID with given UUID

Source

pub fn get_characteristics(&self) -> impl Iterator<Item = &Characteristic>

Get all characteristics

Examples found in repository?
examples/info.rs (line 16)
13async fn run() -> Result<(), color_eyre::Report> {
14    for _ in 0..2 {
15        let mug = ember_mug::EmberMug::find_and_connect().await?;
16        let mut chars: Vec<_> = mug.get_characteristics().collect();
17        let known = ember_mug::KnownCharacteristic::all();
18        for k in known {
19            let Some(char) = chars.iter().position(|&c| c.uuid == k.get()) else {
20                println!("couldn't find {k:?}");
21                continue;
22            };
23            let char = chars.remove(char);
24            println!("known: {k:?}\n{} cap: {:?}", char.uuid, char.properties);
25        }
26        for ch in chars {
27            tracing::info!(?ch, "was left");
28        }
29        println!("battery: {:?}", mug.get_battery().await?);
30        println!("current_temp: {}", mug.get_current_temperature().await?);
31        println!("color: {:?}", mug.get_mug_color().await?);
32        println!("name: {:?}", mug.get_name().await?);
33        println!("state: {:?}", mug.get_liquid_state().await?);
34        println!(
35            "target_temperature: {}",
36            mug.get_target_temperature().await?
37        );
38        println!("ota: {:?}", mug.get_ota().await?);
39        println!("tdz: {:?}", mug.get_time_date_zone().await?);
40        println!("meta: {:?}", mug.get_mug_meta().await?);
41        println!("dsk: {:?}", mug.get_dsk().await?);
42        println!("udsk: {:?}", mug.get_udsk().await?);
43    }
44    Ok(())
45}
Source

pub fn get_characteristic_on_service( &self, uuid: &Uuid, service_uuid: &Uuid, ) -> Option<&Characteristic>

Get characteristic on given service UUID with given UUID

Source§

impl EmberMug

Source

pub async fn read_deserialize<T: BinRead + ReadEndian>( &self, uuid: &KnownCharacteristic, ) -> Result<T, ReadError>
where for<'a> T::Args<'a>: Default,

Read data from given characteristic with uuid

Source

pub async fn read( &self, uuid: &KnownCharacteristic, ) -> Result<Vec<u8>, ReadError>

Deserialize data on given characteristic with uuid

Source

pub async fn write<D>( &self, write: WriteType, uuid: &KnownCharacteristic, data: &D, ) -> Result<(), WriteError>
where D: BinWrite + WriteEndian + Send + Sync, for<'a> <D as BinWrite>::Args<'a>: Default,

Write data to given characteristic on uuid

Source

pub async fn command<D>( &self, uuid: &KnownCharacteristic, data: &D, ) -> Result<(), WriteError>
where D: BinWrite + WriteEndian + Send + Sync, for<'a> <D as BinWrite>::Args<'a>: Default,

Send command to given characteristic on uuid

Source

pub async fn request<D>( &self, uuid: &KnownCharacteristic, data: &D, ) -> Result<(), WriteError>
where D: BinWrite + WriteEndian + Send + Sync, for<'a> <D as BinWrite>::Args<'a>: Default,

Send request to given characteristic on uuid

Trait Implementations§

Source§

impl Clone for EmberMug

Source§

fn clone(&self) -> EmberMug

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more