Add LED Support to Fan Sensor
This allows the fan sensor to trip an LED when a critical
threshold is crossed.
Tested: Saw LED d-bus object in Group manager get set
using sensor override
Change-Id: Iab5a69ded20de6e3ac99e9ac687c60605d5763d1
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index d39e92c..0490135 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -51,13 +51,15 @@
std::vector<thresholds::Threshold>&& _thresholds,
const std::string& sensorConfiguration,
const std::pair<size_t, size_t>& limits,
- const PowerState& powerState) :
+ const PowerState& powerState,
+ const std::optional<std::string>& ledIn) :
Sensor(boost::replace_all_copy(fanName, " ", "_"), std::move(_thresholds),
sensorConfiguration, objectType, limits.second, limits.first, conn,
powerState),
objServer(objectServer), redundancy(redundancy),
presence(std::move(presenceSensor)),
- inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), path(path)
+ inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), path(path),
+ led(ledIn)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/fan_tach/" + name,
@@ -192,6 +194,13 @@
(*redundancy)
->update("/xyz/openbmc_project/sensors/fan_tach/" + name, !status);
}
+
+ bool curLed = !status;
+ if (led && ledState != curLed)
+ {
+ ledState = curLed;
+ setLed(dbusConnection, *led, curLed);
+ }
}
PresenceSensor::PresenceSensor(const std::string& gpioName, bool inverted,