diff --git a/src/reading.cpp b/src/reading.cpp new file mode 100644 index 0000000..f664bf3 --- /dev/null +++ b/src/reading.cpp @@ -0,0 +1,10 @@ +#include "reading.hpp" +#include + +ChannelAssessment assess_channel(const Reading& reading, std::int64_t now_ms) { + if (reading.timestamp_ms > now_ms || now_ms - reading.timestamp_ms > 5000) + return {reading, ChannelState::Stale}; + if (!std::isfinite(reading.celsius) || reading.celsius < -40.0 || reading.celsius > 125.0) + return {reading, ChannelState::OutOfRange}; + return {reading, ChannelState::Healthy}; +}