pub struct CurrentReading {Show 15 fields
pub co2: u16,
pub temperature: f32,
pub pressure: f32,
pub humidity: u8,
pub battery: u8,
pub status: Status,
pub interval: u16,
pub age: u16,
pub captured_at: Option<OffsetDateTime>,
pub radon: Option<u32>,
pub radiation_rate: Option<f32>,
pub radiation_total: Option<f64>,
pub radon_avg_24h: Option<u32>,
pub radon_avg_7d: Option<u32>,
pub radon_avg_30d: Option<u32>,
}Expand description
Current reading from an Aranet sensor.
This struct supports all Aranet device types:
- Aranet4: CO2, temperature, pressure, humidity
- Aranet2: Temperature, humidity (co2 and pressure will be 0)
AranetRn+(Radon): Radon, temperature, pressure, humidity (co2 will be 0)- Aranet Radiation: Radiation dose, temperature (uses
radiation_*fields)
Fields§
§co2: u16CO2 concentration in ppm (Aranet4 only, 0 for other devices).
temperature: f32Temperature in degrees Celsius.
pressure: f32Atmospheric pressure in hPa (0 for Aranet2).
humidity: u8Relative humidity percentage (0-100).
battery: u8Battery level percentage (0-100).
status: StatusCO2 status indicator.
interval: u16Measurement interval in seconds.
age: u16Age of reading in seconds since last measurement.
captured_at: Option<OffsetDateTime>Timestamp when the reading was captured (if known).
This is typically set by the library when reading from a device,
calculated as now - age.
radon: Option<u32>Radon concentration in Bq/m³ (AranetRn+ only).
radiation_rate: Option<f32>Radiation dose rate in µSv/h (Aranet Radiation only).
radiation_total: Option<f64>Total radiation dose in mSv (Aranet Radiation only).
radon_avg_24h: Option<u32>24-hour average radon concentration in Bq/m³ (AranetRn+ only).
radon_avg_7d: Option<u32>7-day average radon concentration in Bq/m³ (AranetRn+ only).
radon_avg_30d: Option<u32>30-day average radon concentration in Bq/m³ (AranetRn+ only).
Implementations§
Source§impl CurrentReading
impl CurrentReading
Sourcepub fn from_bytes(data: &[u8]) -> Result<CurrentReading, ParseError>
pub fn from_bytes(data: &[u8]) -> Result<CurrentReading, ParseError>
Parse a CurrentReading from raw bytes (Aranet4 format).
The byte format is:
- bytes 0-1: CO2 (u16 LE)
- bytes 2-3: Temperature (u16 LE, divide by 20 for Celsius)
- bytes 4-5: Pressure (u16 LE, divide by 10 for hPa)
- byte 6: Humidity (u8)
- byte 7: Battery (u8)
- byte 8: Status (u8)
- bytes 9-10: Interval (u16 LE)
- bytes 11-12: Age (u16 LE)
§Errors
Returns ParseError::InsufficientBytes if data contains fewer than
MIN_CURRENT_READING_BYTES (13) bytes.
Sourcepub fn from_bytes_aranet4(data: &[u8]) -> Result<CurrentReading, ParseError>
pub fn from_bytes_aranet4(data: &[u8]) -> Result<CurrentReading, ParseError>
Parse a CurrentReading from raw bytes (Aranet4 format).
This is an alias for from_bytes for explicit device type parsing.
§Errors
Returns ParseError::InsufficientBytes if data contains fewer than
MIN_CURRENT_READING_BYTES (13) bytes.
Sourcepub fn from_bytes_aranet2(data: &[u8]) -> Result<CurrentReading, ParseError>
pub fn from_bytes_aranet2(data: &[u8]) -> Result<CurrentReading, ParseError>
Parse a CurrentReading from raw bytes (Aranet2 format).
The byte format is:
- bytes 0-1: Temperature (u16 LE, divide by 20 for Celsius)
- byte 2: Humidity (u8)
- byte 3: Battery (u8)
- byte 4: Status (u8)
- bytes 5-6: Interval (u16 LE)
§Errors
Returns ParseError::InsufficientBytes if data contains fewer than
MIN_ARANET2_READING_BYTES (7) bytes.
Sourcepub fn from_bytes_radon(data: &[u8]) -> Result<CurrentReading, ParseError>
pub fn from_bytes_radon(data: &[u8]) -> Result<CurrentReading, ParseError>
Parse a CurrentReading from raw bytes (Aranet Radon GATT format).
The byte format is:
- bytes 0-1: Device type marker (u16 LE, 0x0003 for radon)
- bytes 2-3: Interval (u16 LE, seconds)
- bytes 4-5: Age (u16 LE, seconds since update)
- byte 6: Battery (u8)
- bytes 7-8: Temperature (u16 LE, divide by 20 for Celsius)
- bytes 9-10: Pressure (u16 LE, divide by 10 for hPa)
- bytes 11-12: Humidity (u16 LE, divide by 10 for percent)
- bytes 13-16: Radon (u32 LE, Bq/m³)
- byte 17: Status (u8)
Extended format (47 bytes) includes working averages:
- bytes 18-21: 24h average time (u32 LE)
- bytes 22-25: 24h average value (u32 LE, Bq/m³)
- bytes 26-29: 7d average time (u32 LE)
- bytes 30-33: 7d average value (u32 LE, Bq/m³)
- bytes 34-37: 30d average time (u32 LE)
- bytes 38-41: 30d average value (u32 LE, Bq/m³)
- bytes 42-45: Initial progress (u32 LE, optional)
- byte 46: Display type (u8, optional)
Note: If an average value >= 0xff000000, it indicates the average is still being calculated (in progress) and is not yet available.
§Errors
Returns ParseError::InsufficientBytes if data contains fewer than
MIN_RADON_GATT_READING_BYTES (18) bytes.
Sourcepub fn from_bytes_radiation(data: &[u8]) -> Result<CurrentReading, ParseError>
pub fn from_bytes_radiation(data: &[u8]) -> Result<CurrentReading, ParseError>
Parse a CurrentReading from raw bytes (Aranet Radiation GATT format).
The byte format is:
- bytes 0-1: Unknown/header (u16 LE)
- bytes 2-3: Interval (u16 LE, seconds)
- bytes 4-5: Age (u16 LE, seconds)
- byte 6: Battery (u8)
- bytes 7-10: Dose rate (u32 LE, nSv/h, divide by 1000 for µSv/h)
- bytes 11-18: Total dose (u64 LE, nSv, divide by
1_000_000for mSv) - bytes 19-26: Duration (u64 LE, seconds) - not stored in
CurrentReading - byte 27: Status (u8)
§Errors
Returns ParseError::InsufficientBytes if data contains fewer than
MIN_RADIATION_READING_BYTES (28) bytes.
Sourcepub fn from_bytes_for_device(
data: &[u8],
device_type: DeviceType,
) -> Result<CurrentReading, ParseError>
pub fn from_bytes_for_device( data: &[u8], device_type: DeviceType, ) -> Result<CurrentReading, ParseError>
Parse a CurrentReading from raw bytes based on device type.
This dispatches to the appropriate parsing method based on the device type.
§Errors
Returns ParseError::InsufficientBytes if data doesn’t contain enough bytes
for the specified device type.
Sourcepub fn with_captured_at(self, now: OffsetDateTime) -> CurrentReading
pub fn with_captured_at(self, now: OffsetDateTime) -> CurrentReading
Set the captured timestamp to the current time minus the age.
This is useful for setting the timestamp when reading from a device.
Sourcepub fn builder() -> CurrentReadingBuilder
pub fn builder() -> CurrentReadingBuilder
Create a builder for constructing CurrentReading with optional fields.
Trait Implementations§
Source§impl Clone for CurrentReading
impl Clone for CurrentReading
Source§fn clone(&self) -> CurrentReading
fn clone(&self) -> CurrentReading
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more