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/include/TachSensor.hpp b/include/TachSensor.hpp
index af39d0c..1e5347f 100644
--- a/include/TachSensor.hpp
+++ b/include/TachSensor.hpp
@@ -73,7 +73,8 @@
std::vector<thresholds::Threshold>&& thresholds,
const std::string& sensorConfiguration,
const std::pair<size_t, size_t>& limits,
- const PowerState& powerState = PowerState::on);
+ const PowerState& powerState,
+ const std::optional<std::string>& led);
~TachSensor();
private:
@@ -86,6 +87,8 @@
boost::asio::deadline_timer waitTimer;
boost::asio::streambuf readBuf;
std::string path;
+ std::optional<std::string> led;
+ bool ledState = false;
size_t errCount;
void setupRead(void);
void handleResponse(const boost::system::error_code& err);
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 2c6ce9e..7f529e1 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -81,6 +81,7 @@
{
constexpr const char* interface = "org.freedesktop.DBus.Properties";
constexpr const char* get = "Get";
+constexpr const char* set = "Set";
} // namespace properties
namespace power
@@ -152,6 +153,22 @@
}
}
+inline void setLed(std::shared_ptr<sdbusplus::asio::connection> conn,
+ const std::string& name, bool on)
+{
+ conn->async_method_call(
+ [name](const boost::system::error_code ec) {
+ if (ec)
+ {
+ std::cerr << "Failed to set LED " << name << "\n";
+ }
+ },
+ "xyz.openbmc_project.LED.GroupManager",
+ "/xyz/openbmc_project/led/groups/" + name, properties::interface,
+ properties::set, "xyz.openbmc_project.Led.Group", "Asserted",
+ std::variant<bool>(on));
+}
+
void createInventoryAssoc(
std::shared_ptr<sdbusplus::asio::connection> conn,
std::shared_ptr<sdbusplus::asio::dbus_interface> association,