pub struct Sensor {
pub id: String,
pub reading: Reading,
pub battery: Option<f32>,
pub mode: Mode,
pub history: Vec<f32>,
pub events: Vec<EventRecord>,
pub peer: Option<String>,
pub lat: Option<f64>,
pub lon: Option<f64>,
}Expand description
A single sensor: its current reading, recent history, power, and recent events.
Fields§
§id: StringA stable, human-readable sensor identifier, such as "fridge-1".
reading: ReadingThe sensor’s current reading.
battery: Option<f32>The sensor’s battery state of charge in [0.0, 1.0], if it has one.
mode: ModeThe work cadence the sensor’s node is running at.
history: Vec<f32>Recent values of the reading, oldest first, for a sparkline and min/max.
events: Vec<EventRecord>The most recent telemetry events for this sensor, newest first.
peer: Option<String>The mesh peer (node or station) that hosts this sensor, if any. Sensors sharing a peer name are drawn on one node in the mesh map; an empty peer is the node itself.
lat: Option<f64>The sensor’s (or its hosting peer’s) latitude in decimal degrees, if known. When set
with lon the mesh map can place the peer by real position.
lon: Option<f64>The sensor’s (or its hosting peer’s) longitude in decimal degrees, if known.
Implementations§
Source§impl Sensor
impl Sensor
Sourcepub fn new(id: impl Into<String>, reading: Reading) -> Self
pub fn new(id: impl Into<String>, reading: Reading) -> Self
Creates a sensor with an id and current reading, no battery, history, or events yet.
§Arguments
id- the stable sensor identifier.reading- the sensor’s current reading.
§Returns
An Mode::Active sensor carrying just the reading.