sensord: report edges, not every sample
Light drifts continuously; monitor-sensor emitted ~8 lines/sec and each was a socket round trip re-asserting the same Changing(false). The keepalive is what keeps silence meaningful, so only changes need reporting.
This commit is contained in:
parent
be72019883
commit
de3a332513
1 changed files with 14 additions and 1 deletions
|
|
@ -283,12 +283,25 @@ fn main() {
|
|||
continue;
|
||||
}
|
||||
let Some(value) = (s.parse)(&line, &mut state) else { continue };
|
||||
{
|
||||
// Only report when the value the machine sees actually
|
||||
// changes. monitor-sensor emits a line per lux sample and
|
||||
// ambient light drifts continuously — measured on device at
|
||||
// ~8 lines/second, every one of them a socket round trip
|
||||
// carrying `Changing(false)` again. The keepalive already
|
||||
// guarantees sessiond hears from every source inside
|
||||
// SOURCE_DOWN_AFTER, so silence between real changes is safe
|
||||
// and is exactly what §10 arranged for.
|
||||
let unchanged = {
|
||||
let mut guard = match last.lock() {
|
||||
Ok(g) => g,
|
||||
Err(p) => p.into_inner(),
|
||||
};
|
||||
let same = guard.get(s.name) == Some(&value);
|
||||
guard.insert(s.name, value.clone());
|
||||
same
|
||||
};
|
||||
if unchanged {
|
||||
break;
|
||||
}
|
||||
// Report both edges. "Far" matters as much as "near": it is
|
||||
// what re-enables a wake, and it is what proves the sensor is
|
||||
|
|
|
|||
Loading…
Reference in a new issue