Struct SensorValues

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

Represents a set of values read from sensors on the device

Implementations§

Source§

impl SensorValues

Source

pub fn from_manufacturer_specific_data( id: u16, value: impl AsRef<[u8]>, ) -> Result<Self, ParseError>

Parses sensor values from the payload encoded in manufacturer specific data -field. The function returns a ParseError if the id does not match the exptected id in the manufacturer specific data, or the format of the value is not supported. At the moment only versions 3 and 5 of the format are supported.

§Examples
use ruuvi_sensor_protocol::{SensorValues, Temperature};

let id = 0x0499;
let value = [
    0x03, 0x17, 0x01, 0x45, 0x35, 0x58, 0x03, 0xE8, 0x04, 0xE7, 0x05, 0xE6, 0x08, 0x86,
];
let values = SensorValues::from_manufacturer_specific_data(id, value)?;
assert_eq!(values.temperature_as_millicelsius(), Some(1690));

Trait Implementations§

Source§

impl Acceleration for SensorValues

Source§

fn acceleration_vector_as_milli_g(&self) -> Option<AccelerationVector>

Returns a three-dimensional acceleration vector where each component is in milli-G if an acceleration measurement is available.
Source§

impl BatteryPotential for SensorValues

Source§

fn battery_potential_as_millivolts(&self) -> Option<u16>

Returns battery potential as milli-volts
Source§

impl Clone for SensorValues

Source§

fn clone(&self) -> SensorValues

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
Source§

impl Debug for SensorValues

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Humidity for SensorValues

Source§

fn humidity_as_ppm(&self) -> Option<u32>

Returns relative humidity as parts per million
Source§

impl MacAddress for SensorValues

Source§

fn mac_address(&self) -> Option<[u8; 6]>

Returns the MAC address of the sensor if available.
Source§

impl MeasurementSequenceNumber for SensorValues

Source§

fn measurement_sequence_number(&self) -> Option<u32>

Returns the measurement sequence number if available. The maximum value is not specified.
Source§

impl MovementCounter for SensorValues

Source§

fn movement_counter(&self) -> Option<u32>

Returns the movement count of the tag if available. The maximum value is not specified.
Source§

impl PartialEq for SensorValues

Source§

fn eq(&self, other: &SensorValues) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Pressure for SensorValues

Source§

fn pressure_as_pascals(&self) -> Option<u32>

Returns pressure as pascals
Source§

impl Temperature for SensorValues

Source§

fn temperature_as_millikelvins(&self) -> Option<u32>

Returns temperature as milli-kelvins if a temperature reading is available.
Source§

const ZERO_CELSIUS_IN_MILLIKELVINS: u32 = 273_150u32

Source§

fn temperature_as_millicelsius(&self) -> Option<i32>

Returns temperature as milli-Celsius if a temperature reading is available.
Source§

impl TransmitterPower for SensorValues

Source§

fn tx_power_as_dbm(&self) -> Option<i8>

Returns transmitter power as dBm if available.
Source§

impl Eq for SensorValues

Source§

impl StructuralPartialEq for SensorValues

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, 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.