PSUSensor: Add associations
Add associations for Redfish support.
Tested: Avaliable in rest-dbus
Change-Id: I9d55949cd43a6e3a0b70d4ac4c70f77470d3fcac
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index 5410b08..86997d3 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -26,6 +26,8 @@
#include <sdbusplus/asio/object_server.hpp>
#include <string>
+static constexpr const char* sensorPathPrefix = "/xyz/openbmc_project/sensors/";
+
PSUSensor::PSUSensor(const std::string& path, const std::string& objectType,
sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& conn,
@@ -39,22 +41,24 @@
objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
waitTimer(io), errCount(0), sensorFactor(factor)
{
+ std::string dbusPath = sensorPathPrefix + sensorTypeName + name;
+
sensorInterface = objectServer.add_interface(
- "/xyz/openbmc_project/sensors/" + sensorTypeName + name,
- "xyz.openbmc_project.Sensor.Value");
+ dbusPath, "xyz.openbmc_project.Sensor.Value");
if (thresholds::hasWarningInterface(thresholds))
{
thresholdInterfaceWarning = objectServer.add_interface(
- "/xyz/openbmc_project/sensors/" + sensorTypeName + name,
- "xyz.openbmc_project.Sensor.Threshold.Warning");
+ dbusPath, "xyz.openbmc_project.Sensor.Threshold.Warning");
}
if (thresholds::hasCriticalInterface(thresholds))
{
thresholdInterfaceCritical = objectServer.add_interface(
- "/xyz/openbmc_project/sensors/" + sensorTypeName + name,
- "xyz.openbmc_project.Sensor.Threshold.Critical");
+ dbusPath, "xyz.openbmc_project.Sensor.Threshold.Critical");
}
+ association =
+ objectServer.add_interface(dbusPath, "org.openbmc.Associations");
+
setInitialProperties(conn);
setupRead();
}