pub trait AirQualityDriver<'a> {
    // Required methods
    fn set_client(&self, client: &'a dyn AirQualityClient);
    fn specify_environment(
        &self,
        temp: Option<i32>,
        humidity: Option<u32>
    ) -> Result<(), ErrorCode>;
    fn read_co2(&self) -> Result<(), ErrorCode>;
    fn read_tvoc(&self) -> Result<(), ErrorCode>;
}
Expand description

A basic interface for a Air Quality sensor

Required Methods§

source

fn set_client(&self, client: &'a dyn AirQualityClient)

Set the client to be notified when the capsule has data ready.

source

fn specify_environment( &self, temp: Option<i32>, humidity: Option<u32> ) -> Result<(), ErrorCode>

Specify the temperature and humidity used in calculating the air quality.

The temperature is specified in degrees Celsius and the humidity is specified as a percentage.

This is an optional call and doesn’t have to be used, but on most hardware can be used to improve the measurement accuracy.

This function might return the following errors:

  • BUSY: Indicates that the hardware is busy with an existing operation or initialisation/calibration.
  • NOSUPPORT: Indicates that this data type isn’t supported.
source

fn read_co2(&self) -> Result<(), ErrorCode>

Read the CO2 or equivalent CO2 (eCO2) from the sensor. This will trigger the AirQualityClient co2_data_available() callback when the data is ready.

This function might return the following errors:

  • BUSY: Indicates that the hardware is busy with an existing operation or initialisation/calibration.
  • NOSUPPORT: Indicates that this data type isn’t supported.
source

fn read_tvoc(&self) -> Result<(), ErrorCode>

Read the Total Organic Compound (TVOC) from the sensor. This will trigger the AirQualityClient tvoc_data_available() callback when the data is ready.

This function might return the following errors:

  • BUSY: Indicates that the hardware is busy with an existing operation or initialisation/calibration.
  • NOSUPPORT: Indicates that this data type isn’t supported.

Implementors§