[][src]Struct mijia::MijiaSession

pub struct MijiaSession {
    pub bt_session: BluetoothSession,
}

A wrapper around a Bluetooth session which adds some methods for dealing with Mijia sensors. The underlying Bluetooth session may still be accessed.

Fields

bt_session: BluetoothSession

Implementations

impl MijiaSession[src]

pub async fn new(
) -> Result<(impl Future<Output = Result<(), SpawnError>>, Self), BluetoothError>
[src]

Returns a tuple of (join handle, Self). If the join handle ever completes then you're in trouble and should probably restart the process.

pub async fn get_sensors<'_>(
    &'_ self
) -> Result<Vec<SensorProps>, BluetoothError>
[src]

Get a list of all Mijia sensors which have currently been discovered.

pub async fn get_time<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<SystemTime, MijiaError>
[src]

Get the current time of the sensor.

pub async fn set_time<'_, '_>(
    &'_ self,
    id: &'_ DeviceId,
    time: SystemTime
) -> Result<(), MijiaError>
[src]

Set the current time of the sensor.

pub async fn get_temperature_unit<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<TemperatureUnit, MijiaError>
[src]

Get the temperature unit which the sensor uses for its display.

pub async fn set_temperature_unit<'_, '_>(
    &'_ self,
    id: &'_ DeviceId,
    unit: TemperatureUnit
) -> Result<(), BluetoothError>
[src]

Set the temperature unit which the sensor uses for its display.

pub async fn get_comfort_level<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<ComfortLevel, MijiaError>
[src]

Get the comfort level configuration which determines when the sensor displays a happy face.

pub async fn set_comfort_level<'_, '_, '_>(
    &'_ self,
    id: &'_ DeviceId,
    comfort_level: &'_ ComfortLevel
) -> Result<(), MijiaError>
[src]

Set the comfort level configuration which determines when the sensor displays a happy face.

pub async fn get_history_range<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<Range<u32>, MijiaError>
[src]

Get the range of indices for historical data stored on the sensor.

pub async fn delete_history<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<(), BluetoothError>
[src]

Delete all historical data stored on the sensor.

pub async fn get_last_history_record<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<HistoryRecord, MijiaError>
[src]

Get the last historical record stored on the sensor.

pub async fn start_notify_history<'_, '_>(
    &'_ self,
    id: &'_ DeviceId,
    start_index: Option<u32>
) -> Result<(), BluetoothError>
[src]

Start receiving historical records from the sensor.

Arguments

  • id: The ID of the sensor to request records from.
  • start_index: The record index to start at. If this is not specified then all records which have not yet been received from the sensor since it was connected will be requested.

pub async fn stop_notify_history<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<(), BluetoothError>
[src]

Stop receiving historical records from the sensor.

pub async fn get_all_history<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<Vec<Option<HistoryRecord>>, MijiaError>
[src]

Try to get all historical records for the sensor.

pub async fn start_notify_sensor<'_, '_>(
    &'_ self,
    id: &'_ DeviceId
) -> Result<(), BluetoothError>
[src]

Assuming that the given device ID refers to a Mijia sensor device and that it has already been connected, subscribe to notifications of temperature/humidity readings, and adjust the connection interval to save power.

Notifications will be delivered as events by MijiaSession::event_stream().

pub async fn event_stream<'_>(
    &'_ self
) -> Result<(MsgMatch, impl Stream<Item = MijiaEvent>), BluetoothError>
[src]

Get a stream of reading/history/disconnected events for all sensors.

If the MsgMatch is dropped then the Stream will close.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.