Struct bsec::Bsec

source ·
pub struct Bsec<S: BmeSensor, C: Clock, B: Borrow<C>> { /* private fields */ }
Expand description

Handle to encapsulates the Bosch BSEC library and related state.

Implementations§

source§

impl<S: BmeSensor, C: Clock, B: Borrow<C>> Bsec<S, C, B>

source

pub fn init(bme: S, clock: B) -> Result<Self, Error<S::Error>>

Initialize the Bosch BSEC library and return a handle to interact with it.

  • bme: BmeSensor implementation to communicate with the BME sensor.
  • clock: Clock implementation to obtain timestamps.
source

pub fn update_subscription( &mut self, requests: &[SubscriptionRequest] ) -> Result<Vec<RequiredInput>, Error<S::Error>>

Change subscription to virtual sensor outputs.

  • requests: Configuration of virtual sensors and their sample rates to subscribe to.

Returns a vector describing physical sensor and sampling rates required as input to the BSEC algorithm.

source

pub fn next_measurement(&self) -> i64

Returns the timestamp when the next measurement has to be triggered.

source

pub fn start_next_measurement(&mut self) -> Result<Duration, Error<S::Error>>

Trigger the next measurement.

Returns the duration until the measurement becomes available. Call Self::process_last_measurement after the duration has passed.

source

pub fn process_last_measurement( &mut self ) -> Result<Vec<Output>, Error<S::Error>>

Process the last triggered measurement.

Call this method after the duration returned from a call to Self::start_next_measurement has passed.

Returns a vector of virtual sensor outputs calculated by the Bosch BSEC library.

source

pub fn get_state(&self) -> Result<Vec<u8>, Error<S::Error>>

Get the current raw Bosch BSEC state, e.g. to persist it before shutdown.

source

pub fn set_state(&mut self, state: &[u8]) -> Result<(), Error<S::Error>>

Set the raw Bosch BSEC state, e.g. to restore persisted state after shutdown.

source

pub fn get_configuration(&self) -> Result<Vec<u8>, Error<S::Error>>

Get the current (raw) Bosch BSEC configuration.

source

pub fn set_configuration( &mut self, serialized_settings: &[u8] ) -> Result<(), Error<S::Error>>

Set the (raw) Bosch BSEC configuration.

Your copy of the Bosch BSEC library should contain several different configuration files. See the Bosch BSEC documentation for more information.

source

pub fn reset_output(&mut self, sensor: OutputKind) -> Result<(), Error<S::Error>>

See documentation of bsec_reset_output in the Bosch BSEC documentation.

Trait Implementations§

source§

impl<S: BmeSensor, C: Clock, B: Borrow<C>> Drop for Bsec<S, C, B>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<S, C, B> RefUnwindSafe for Bsec<S, C, B>where B: RefUnwindSafe, C: RefUnwindSafe, S: RefUnwindSafe,

§

impl<S, C, B> Send for Bsec<S, C, B>where B: Send, C: Send, S: Send,

§

impl<S, C, B> Sync for Bsec<S, C, B>where B: Sync, C: Sync, S: Sync,

§

impl<S, C, B> Unpin for Bsec<S, C, B>where B: Unpin, C: Unpin, S: Unpin,

§

impl<S, C, B> UnwindSafe for Bsec<S, C, B>where B: UnwindSafe, C: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.