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
impl EmberMug
Sourcepub async fn get_battery(&self) -> Result<Battery, ReadError>
pub async fn get_battery(&self) -> Result<Battery, ReadError>
Retrieves the battery percentage of the mug and other values.
Examples found in repository?
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
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
impl EmberMug
Sourcepub async fn get_current_temperature(&self) -> Result<Temperature, ReadError>
pub async fn get_current_temperature(&self) -> Result<Temperature, ReadError>
Retrieves the current temperature of the mug
Examples found in repository?
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
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
impl EmberMug
Sourcepub async fn get_dsk(&self) -> Result<Vec<u8>, ReadError>
pub async fn get_dsk(&self) -> Result<Vec<u8>, ReadError>
Retrieves the dsk of the cup
Examples found in repository?
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}Sourcepub async fn get_udsk(&self) -> Result<Vec<u8>, ReadError>
pub async fn get_udsk(&self) -> Result<Vec<u8>, ReadError>
Retrieves the dsk of the cup
Examples found in repository?
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
impl EmberMug
Sourcepub async fn get_liquid_level(&self) -> Result<LiquidLevel, ReadError>
pub async fn get_liquid_level(&self) -> Result<LiquidLevel, ReadError>
Retrieves the level of liquid present in the cup
Source§impl EmberMug
impl EmberMug
Sourcepub async fn get_liquid_state(&self) -> Result<LiquidState, ReadError>
pub async fn get_liquid_state(&self) -> Result<LiquidState, ReadError>
The current state of the mug
Examples found in repository?
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
impl EmberMug
Sourcepub async fn get_mug_color(&self) -> Result<Color, ReadError>
pub async fn get_mug_color(&self) -> Result<Color, ReadError>
Retrieves the color of the mug’s LED indicator.
Examples found in repository?
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}Sourcepub async fn set_mug_color(&self, color: &Color) -> Result<(), WriteError>
pub async fn set_mug_color(&self, color: &Color) -> Result<(), WriteError>
Sets the color of the mug’s LED indicator.
Source§impl EmberMug
impl EmberMug
Sourcepub async fn get_mug_meta(&self) -> Result<MugMeta, ReadError>
pub async fn get_mug_meta(&self) -> Result<MugMeta, ReadError>
Retrieves id of the mug
Examples found in repository?
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
impl EmberMug
Sourcepub async fn get_name(&self) -> Result<String, ReadError>
pub async fn get_name(&self) -> Result<String, ReadError>
Retreives the name of the mug.
Examples found in repository?
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
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
impl EmberMug
Sourcepub async fn get_ota(&self) -> Result<Ota, ReadError>
pub async fn get_ota(&self) -> Result<Ota, ReadError>
Info about the current firmware running on the mug.
Examples found in repository?
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
impl EmberMug
Sourcepub async fn get_push_event(&self) -> Result<PushEvent, ReadError>
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
Sourcepub async fn subscribe_push_events(&self) -> Result<(), ReadError>
pub async fn subscribe_push_events(&self) -> Result<(), ReadError>
Subscribe to events sent by the mug
Sourcepub async fn listen_push_events(
&self,
) -> Result<impl Stream<Item = Result<PushEvent, ReadError>> + Send + '_, ReadError>
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.
Sourcepub async fn unsubscribe_push_events(&self) -> Result<(), ReadError>
pub async fn unsubscribe_push_events(&self) -> Result<(), ReadError>
Unsubscribe to events sent by the mug
Source§impl EmberMug
impl EmberMug
Sourcepub async fn get_target_temperature(&self) -> Result<Temperature, ReadError>
pub async fn get_target_temperature(&self) -> Result<Temperature, ReadError>
Retrieves the target temperature of the mug
Examples found in repository?
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
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}Sourcepub async fn set_target_temperature(
&self,
temperature: &Temperature,
) -> Result<(), WriteError>
pub async fn set_target_temperature( &self, temperature: &Temperature, ) -> Result<(), WriteError>
Set the target temperature of the mug
Examples found in repository?
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
impl EmberMug
Sourcepub async fn get_temperature_unit(&self) -> Result<TemperatureUnit, ReadError>
pub async fn get_temperature_unit(&self) -> Result<TemperatureUnit, ReadError>
Retrieve the current unit of temperature used by the mug.
Examples found in repository?
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}Sourcepub async fn set_temperature_unit(
&self,
temperature_unit: &TemperatureUnit,
) -> Result<(), WriteError>
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
impl EmberMug
Sourcepub async fn get_time_date_zone(&self) -> Result<TimeDateZone, ReadError>
pub async fn get_time_date_zone(&self) -> Result<TimeDateZone, ReadError>
Get the current date and timezone on the mug
Examples found in repository?
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}Sourcepub async fn set_time_date_zone(
&self,
time_date_zone: &TimeDateZone,
) -> Result<(), WriteError>
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
impl EmberMug
Sourcepub async fn find_and_connect() -> Result<Self, ConnectError>
pub async fn find_and_connect() -> Result<Self, ConnectError>
Find and connect to the first available Ember Mug
Examples found in repository?
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
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}Sourcepub async fn connect_mug(
adapter: Adapter,
peripheral: <Adapter as Central>::Peripheral,
) -> Result<Self, ConnectError>
pub async fn connect_mug( adapter: Adapter, peripheral: <Adapter as Central>::Peripheral, ) -> Result<Self, ConnectError>
Connect to specific Ember Mug
Sourcepub async fn is_connected(&self) -> Result<bool, Error>
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
Sourcepub async fn disconnected(&self) -> Result<(), Error>
pub async fn disconnected(&self) -> Result<(), Error>
Returns when the device is disconnected.
Source§impl EmberMug
impl EmberMug
Sourcepub fn get_characteristic(&self, uuid: &Uuid) -> Option<&Characteristic>
pub fn get_characteristic(&self, uuid: &Uuid) -> Option<&Characteristic>
Get characteristic on EMBER_MUG_SERVICE_UUID with given UUID
Sourcepub fn get_characteristics(&self) -> impl Iterator<Item = &Characteristic>
pub fn get_characteristics(&self) -> impl Iterator<Item = &Characteristic>
Get all characteristics
Examples found in repository?
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}Sourcepub fn get_characteristic_on_service(
&self,
uuid: &Uuid,
service_uuid: &Uuid,
) -> Option<&Characteristic>
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
impl EmberMug
Sourcepub async fn read_deserialize<T: BinRead + ReadEndian>(
&self,
uuid: &KnownCharacteristic,
) -> Result<T, ReadError>
pub async fn read_deserialize<T: BinRead + ReadEndian>( &self, uuid: &KnownCharacteristic, ) -> Result<T, ReadError>
Read data from given characteristic with uuid
Sourcepub async fn read(
&self,
uuid: &KnownCharacteristic,
) -> Result<Vec<u8>, ReadError>
pub async fn read( &self, uuid: &KnownCharacteristic, ) -> Result<Vec<u8>, ReadError>
Deserialize data on given characteristic with uuid
Sourcepub async fn write<D>(
&self,
write: WriteType,
uuid: &KnownCharacteristic,
data: &D,
) -> Result<(), WriteError>
pub async fn write<D>( &self, write: WriteType, uuid: &KnownCharacteristic, data: &D, ) -> Result<(), WriteError>
Write data to given characteristic on uuid
Sourcepub async fn command<D>(
&self,
uuid: &KnownCharacteristic,
data: &D,
) -> Result<(), WriteError>
pub async fn command<D>( &self, uuid: &KnownCharacteristic, data: &D, ) -> Result<(), WriteError>
Send command to given characteristic on uuid
Sourcepub async fn request<D>(
&self,
uuid: &KnownCharacteristic,
data: &D,
) -> Result<(), WriteError>
pub async fn request<D>( &self, uuid: &KnownCharacteristic, data: &D, ) -> Result<(), WriteError>
Send request to given characteristic on uuid