Add signal based update

update sensors whenever there is a update in parameter
dbus sensor. This will register a signal for each dbus
sensor parameter and will calculate new value is there
is a change in any param sensor value.

Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
Change-Id: I164bbb32eea6f29a2378119cdf3ac07492758b09
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/dbusSensor.hpp b/dbusSensor.hpp
index 8ab17a2..4756cad 100644
--- a/dbusSensor.hpp
+++ b/dbusSensor.hpp
@@ -1,9 +1,12 @@
 #include "dbusUtils.hpp"
 
 #include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
 
 const char* sensorIntf = "xyz.openbmc_project.Sensor.Value";
 
+int handleDbusSignal(sd_bus_message* msg, void* usrData, sd_bus_error* err);
+
 class DbusSensor
 {
   public:
@@ -15,8 +18,12 @@
      * @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)
+    DbusSensor(sdbusplus::bus::bus& bus, const std::string& path, void* ctx) :
+        bus(bus), path(path),
+        signal(
+            bus,
+            sdbusplus::bus::match::rules::propertiesChanged(path, sensorIntf),
+            handleDbusSignal, ctx)
     {
         servName = getService(bus, path, sensorIntf);
     }
@@ -35,4 +42,6 @@
     std::string path;
     /** @brief service name for the sensor daemon */
     std::string servName;
+    /** @brief signal for sensor value change */
+    sdbusplus::server::match::match signal;
 };