Sensor.Threshold.*: use PDI constants
Use PDI constants instead of local definitions.
Tested: Unit Tests Pass
Change-Id: I2472307d1f4f2d65ad99440243444057c652b85a
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index aa23a96..2814b65 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -35,6 +35,8 @@
#include <xyz/openbmc_project/Control/FanPwm/client.hpp>
#include <xyz/openbmc_project/Control/ThermalMode/common.hpp>
#include <xyz/openbmc_project/ObjectMapper/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
#include <xyz/openbmc_project/Sensor/Value/client.hpp>
#include <algorithm>
@@ -59,6 +61,10 @@
using ControlFanPwm = sdbusplus::common::xyz::openbmc_project::control::FanPwm;
using ControlThermalMode =
sdbusplus::common::xyz::openbmc_project::control::ThermalMode;
+using SensorThresholdWarning =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
+using SensorThresholdCritical =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
namespace pid_control
{
@@ -77,10 +83,6 @@
namespace thresholds
{
-constexpr const char* warningInterface =
- "xyz.openbmc_project.Sensor.Threshold.Warning";
-constexpr const char* criticalInterface =
- "xyz.openbmc_project.Sensor.Threshold.Critical";
const std::array<const char*, 4> types = {"CriticalLow", "CriticalHigh",
"WarningLow", "WarningHigh"};
@@ -351,14 +353,16 @@
if (thresholdProperty != nullptr)
{
std::string interface;
- if (*thresholdProperty == "WarningHigh" ||
- *thresholdProperty == "WarningLow")
+ if (*thresholdProperty ==
+ SensorThresholdWarning::property_names::warning_high ||
+ *thresholdProperty ==
+ SensorThresholdWarning::property_names::warning_low)
{
- interface = thresholds::warningInterface;
+ interface = SensorThresholdWarning::interface;
}
else
{
- interface = thresholds::criticalInterface;
+ interface = SensorThresholdCritical::interface;
}
// Although this checks only the first vector element for the
diff --git a/dbus/dbushelper.cpp b/dbus/dbushelper.cpp
index 4a692cb..589b368 100644
--- a/dbus/dbushelper.cpp
+++ b/dbus/dbushelper.cpp
@@ -148,7 +148,7 @@
{
auto critical = _bus.new_method_call(service.c_str(), path.c_str(),
propertiesintf, "GetAll");
- critical.append(criticalThreshInf);
+ critical.append(SensorThresholdCritical::interface);
PropertyMap criticalMap;
try
@@ -164,8 +164,10 @@
#endif
}
- auto findCriticalLow = criticalMap.find("CriticalAlarmLow");
- auto findCriticalHigh = criticalMap.find("CriticalAlarmHigh");
+ auto findCriticalLow = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_alarm_low);
+ auto findCriticalHigh = criticalMap.find(
+ SensorThresholdCritical::property_names::critical_alarm_high);
bool asserted = false;
if (findCriticalLow != criticalMap.end())
@@ -197,7 +199,8 @@
// sensors don't have to expose non-critical thresholds
return false;
}
- auto findWarningHigh = warningMap.find("WarningAlarmHigh");
+ auto findWarningHigh = warningMap.find(
+ SensorThresholdWarning::property_names::warning_alarm_high);
if (findWarningHigh != warningMap.end())
{
diff --git a/dbus/dbushelper.hpp b/dbus/dbushelper.hpp
index 43a9d3a..94cf664 100644
--- a/dbus/dbushelper.hpp
+++ b/dbus/dbushelper.hpp
@@ -5,10 +5,17 @@
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/exception.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
#include <string>
#include <variant>
+using SensorThresholdWarning =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
+using SensorThresholdCritical =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
+
namespace pid_control
{
@@ -16,10 +23,6 @@
{
public:
static constexpr char propertiesintf[] = "org.freedesktop.DBus.Properties";
- static constexpr char criticalThreshInf[] =
- "xyz.openbmc_project.Sensor.Threshold.Critical";
- static constexpr char warningThreshInf[] =
- "xyz.openbmc_project.Sensor.Threshold.Warning";
static constexpr char availabilityIntf[] =
"xyz.openbmc_project.State.Decorator.Availability";
diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp
index 3e56b52..f346d67 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -17,6 +17,8 @@
#include <sdbusplus/bus.hpp>
#include <sdbusplus/message.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Critical/common.hpp>
+#include <xyz/openbmc_project/Sensor/Threshold/Warning/common.hpp>
#include <xyz/openbmc_project/Sensor/Value/client.hpp>
#include <chrono>
@@ -35,6 +37,10 @@
#include "failsafeloggers/failsafe_logger.cpp"
using SensorValue = sdbusplus::common::xyz::openbmc_project::sensor::Value;
+using SensorThresholdWarning =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Warning;
+using SensorThresholdCritical =
+ sdbusplus::common::xyz::openbmc_project::sensor::threshold::Critical;
namespace pid_control
{
@@ -403,10 +409,12 @@
owner->updateValue(value, false);
}
}
- else if (msgSensor == "xyz.openbmc_project.Sensor.Threshold.Critical")
+ else if (msgSensor == SensorThresholdCritical::interface)
{
- auto criticalAlarmLow = msgData.find("CriticalAlarmLow");
- auto criticalAlarmHigh = msgData.find("CriticalAlarmHigh");
+ auto criticalAlarmLow = msgData.find(
+ SensorThresholdCritical::property_names::critical_alarm_low);
+ auto criticalAlarmHigh = msgData.find(
+ SensorThresholdCritical::property_names::critical_alarm_high);
if (criticalAlarmHigh == msgData.end() &&
criticalAlarmLow == msgData.end())
{
@@ -428,9 +436,10 @@
owner->setFailed(asserted);
}
#ifdef UNC_FAILSAFE
- else if (msgSensor == "xyz.openbmc_project.Sensor.Threshold.Warning")
+ else if (msgSensor == SensorThresholdWarning::interface)
{
- auto warningAlarmHigh = msgData.find("WarningAlarmHigh");
+ auto warningAlarmHigh = msgData.find(
+ SensorThresholdWarning::property_names::warning_alarm_high);
if (warningAlarmHigh == msgData.end())
{
return 0;
diff --git a/util.hpp b/util.hpp
index 75433cb..29f1c33 100644
--- a/util.hpp
+++ b/util.hpp
@@ -28,10 +28,6 @@
double upperThreshold = std::numeric_limits<double>::quiet_NaN();
};
-const std::string criticalThreshInf =
- "xyz.openbmc_project.Sensor.Threshold.Critical";
-const std::string propertiesintf = "org.freedesktop.DBus.Properties";
-
/*
* Given a path that optionally has a glob portion, fill it out.
*/