Remove Configuration interface prefix from utils APIs
This eliminates some repetitive verbosity from daemons that handle a lot
of different sensor types (such as hwmontempsensor and psusensor). It
also positions us to more cleanly use a single data structure for both
existing APIs like GetSensorConfiguration() and
setupPropertiesChangedMatches(), as well as upcoming I2C
device-management support.
Tested: hwmontempsensor and adcsensor on romed8hm3 continue to behave as
they did previously.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I9d80475ca4160c8d2ff0afab942709496d51238d
diff --git a/include/NVMeSensor.hpp b/include/NVMeSensor.hpp
index e58e3c7..4e0000f 100644
--- a/include/NVMeSensor.hpp
+++ b/include/NVMeSensor.hpp
@@ -6,8 +6,7 @@
class NVMeSensor : public Sensor
{
public:
- static constexpr const char* configType =
- "xyz.openbmc_project.Configuration.NVME1000";
+ static constexpr const char* sensorType = "NVME1000";
NVMeSensor(sdbusplus::asio::object_server& objectServer,
boost::asio::io_service& io,
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 2d6bac3..b39492e 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -91,6 +91,14 @@
bool readingStateGood(const PowerState& powerState);
+constexpr const char* configInterfacePrefix =
+ "xyz.openbmc_project.Configuration.";
+
+inline std::string configInterfaceName(const std::string& type)
+{
+ return std::string(configInterfacePrefix) + type;
+}
+
namespace mapper
{
constexpr const char* busName = "xyz.openbmc_project.ObjectMapper";
@@ -258,7 +266,7 @@
interface);
}
- void getConfiguration(const std::vector<std::string>& interfaces,
+ void getConfiguration(const std::vector<std::string>& types,
size_t retries = 0)
{
if (retries > 5)
@@ -266,6 +274,12 @@
retries = 5;
}
+ std::vector<std::string> interfaces(types.size());
+ for (const auto& type : types)
+ {
+ interfaces.push_back(configInterfaceName(type));
+ }
+
std::shared_ptr<GetSensorConfiguration> self = shared_from_this();
dbusConnection->async_method_call(
[self, interfaces, retries](const boost::system::error_code ec,
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 2bc55f5..290b78b 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -63,7 +63,8 @@
std::shared_ptr<sdbusplus::asio::connection>& conn,
PowerState readState = PowerState::always) :
name(sensor_paths::escapePathForDbus(name)),
- configurationPath(configurationPath), objectType(objectType),
+ configurationPath(configurationPath),
+ objectType(configInterfaceName(objectType)),
isSensorSettable(isSettable), isValueMutable(isMutable), maxValue(max),
minValue(min), thresholds(std::move(thresholdData)),
hysteresisTrigger((max - min) * 0.01),