Add support for dbus parameter
Added support for parameter type dbus sensor and utility functions
to read dbus sensor value.
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Change-Id: I04db0016f312edea095442a693500c3b4e571d6c
diff --git a/dbusSensor.hpp b/dbusSensor.hpp
new file mode 100644
index 0000000..8ab17a2
--- /dev/null
+++ b/dbusSensor.hpp
@@ -0,0 +1,38 @@
+#include "dbusUtils.hpp"
+
+#include <sdbusplus/bus.hpp>
+
+const char* sensorIntf = "xyz.openbmc_project.Sensor.Value";
+
+class DbusSensor
+{
+ public:
+ DbusSensor() = delete;
+ virtual ~DbusSensor() = default;
+
+ /** @brief Constructs DbusSensor
+ *
+ * @param[in] bus - Handle to system dbus
+ * @param[in] path - The Dbus path of sensor
+ */
+ DbusSensor(sdbusplus::bus::bus& bus, const std::string& path) :
+ bus(bus), path(path)
+ {
+ servName = getService(bus, path, sensorIntf);
+ }
+
+ /** @brief Get sensor value property from D-bus interface */
+ double getSensorValue()
+ {
+ return getDbusProperty<double>(bus, servName, path, sensorIntf,
+ "Value");
+ }
+
+ private:
+ /** @brief sdbusplus bus client connection. */
+ sdbusplus::bus::bus& bus;
+ /** @brief complete path for sensor */
+ std::string path;
+ /** @brief service name for the sensor daemon */
+ std::string servName;
+};