Struct CayenneLPP

Source
pub struct CayenneLPP<'a> { /* private fields */ }
Expand description

This struct contains the data of the added payload objects and an index that points to the next free value in the array. All newly added values will increase the index. After adding all the values, the buffer contains the payloads of the different data types and has a length of ’‘index’’.

Implementations§

Source§

impl<'a> CayenneLPP<'a>

Source

pub fn new(buffer: &'a mut [u8]) -> Self

Creates a new buffer for the Cayenne LPP. Since the library works without a memory allocator, it is necessary to provide it with an array that equals the length or is bigger then the data that shall be added to it.

It is possible to use the size constants for the data types (e.g. LPP_TEMPERATURE_SIZE), to exactly calculate the size of the needed array.

Source

pub fn reset(&mut self)

Resets the index that is pointing into the buffer, so it is possible to reuse the buffer and add new payloads to it. Remark: the buffer is not cleared by this operation.

Source

pub fn payload_slice(&self) -> &[u8]

Returns the slice of the buffer that contains the payload of the added data types.

Source

pub fn add_digital_input(&mut self, channel: u8, value: u8) -> Result<(), Error>

Adds the payload for a digital input to the Cayenne LPP data structure.

Source

pub fn add_digital_output( &mut self, channel: u8, value: u8, ) -> Result<(), Error>

Adds the payload for a digital output to the Cayenne LPP data structure.

Source

pub fn add_analog_input(&mut self, channel: u8, value: f32) -> Result<(), Error>

Adds the payload for an analog input to the Cayenne LPP data structure.

Source

pub fn add_analog_output( &mut self, channel: u8, value: f32, ) -> Result<(), Error>

Adds the payload for an analog output to the Cayenne LPP data structure.

Source

pub fn add_luminosity(&mut self, channel: u8, lux: u16) -> Result<(), Error>

Adds the payload for luminosity to the Cayenne LPP data structure. The value should be provided in lux.

Source

pub fn add_presence(&mut self, channel: u8, value: u8) -> Result<(), Error>

Adds the payload for a presence sensor to the Cayenne LPP data structure.

Source

pub fn add_temperature( &mut self, channel: u8, celsius: f32, ) -> Result<(), Error>

Adds the payload for temperature to the Cayenne LPP data structure.

Source

pub fn add_relative_humidity( &mut self, channel: u8, relative_humidity: f32, ) -> Result<(), Error>

Adds the payload for relative humidity to the Cayenne LPP data structure.

Source

pub fn add_accelerometer( &mut self, channel: u8, x: f32, y: f32, z: f32, ) -> Result<(), Error>

Adds the payload of an accelerometer to the Cayenne LPP data structure.

Source

pub fn add_barometric_pressure( &mut self, channel: u8, hpa: f32, ) -> Result<(), Error>

Adds the payload for barometric pressure to the Cayenne LPP data structure.

Source

pub fn add_gyrometer( &mut self, channel: u8, x: f32, y: f32, z: f32, ) -> Result<(), Error>

Adds the payload for a gyrometer to the Cayenne LPP data structure.

Source

pub fn add_gps( &mut self, channel: u8, latitude: f32, longitude: f32, meters: f32, ) -> Result<(), Error>

Adds the payload for GPS to the Cayenne LPP data structure.

Auto Trait Implementations§

§

impl<'a> Freeze for CayenneLPP<'a>

§

impl<'a> RefUnwindSafe for CayenneLPP<'a>

§

impl<'a> Send for CayenneLPP<'a>

§

impl<'a> Sync for CayenneLPP<'a>

§

impl<'a> Unpin for CayenneLPP<'a>

§

impl<'a> !UnwindSafe for CayenneLPP<'a>

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