Struct esp32_simple::gps::Sensor

source ·
pub struct Sensor<'a, T: Trigger> { /* private fields */ }
Expand description

Represents a GPS sensor.

§Type Parameters

  • 'a - Lifetime of the sensor.
  • T - The trigger type implementing the Trigger trait.

Implementations§

source§

impl<'a, T: Trigger> Sensor<'a, T>

source

pub fn new( notifier: Notifier<T>, trigger: &'static T, state: Arc<Mutex<State>>, uart: UartRxDriver<'a>, data: Arc<Mutex<Option<Reading>>>, ) -> Self

Creates a new GPS Sensor.

§Arguments
  • notifier - A notifier to send GPS data available events.
  • trigger - The trigger to emit when a new reading is available.
  • state - Shared on/off state controlling whether the sensor reads data.
  • uart - UART receive driver connected to the GPS module.
  • data - Shared storage for the latest GPS reading.
§Returns

A new Sensor instance ready to poll.

Trait Implementations§

source§

impl<T: Trigger> Poller for Sensor<'_, T>

source§

fn poll(&mut self) -> Result<!>

Continuously reads NMEA sentences from the UART and publishes GPS readings.

Skips reading when the shared state is off. When a valid RMC sentence is parsed, stores the reading in the shared data mutex and sends a notification.

§Errors

Returns an error if UART reading, mutex locking, or notification fails.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Sensor<'a, T>

§

impl<'a, T> RefUnwindSafe for Sensor<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Sensor<'a, T>

§

impl<'a, T> Sync for Sensor<'a, T>

§

impl<'a, T> Unpin for Sensor<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for Sensor<'a, T>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

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

Performs the conversion.
§

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

§

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

The type returned in the event of a conversion error.
§

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

Performs the conversion.