pldm: Add support for OCC state changes

When the state of the OCC changes, host sends stateSensorEvent to
indicate going active or not active which is send as a D-Bus signal
by PLDM daemon. openpower-occ-control app listens for this signal
and updates the OCC D-Bus object. The lowest entity instance number
in the PDRs corresponds to first instance of the OCC.

Tested:

1) On a simics session verified that the sensor event is handled for
OCC going active and OCCActive property is set to true.
2) A sensorEvent is generated for OCC going non active and verified
OCCActive property is set to false.
3) Powered off the host and OCCActive property is set to false.

Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Change-Id: I0469cc483184b66acabc5f0cea1613a7768b3393
diff --git a/occ_manager.hpp b/occ_manager.hpp
index 20002e4..d8282b1 100644
--- a/occ_manager.hpp
+++ b/occ_manager.hpp
@@ -2,6 +2,9 @@
 
 #include "occ_pass_through.hpp"
 #include "occ_status.hpp"
+#ifdef PLDM
+#include "pldm.hpp"
+#endif
 #include "powercap.hpp"
 
 #include <cstring>
@@ -34,7 +37,15 @@
      *  @param[in] bus   - handle to the bus
      *  @param[in] event - Unique ptr reference to sd_event
      */
-    Manager(sdbusplus::bus::bus& bus, EventPtr& event) : bus(bus), event(event)
+    Manager(sdbusplus::bus::bus& bus, EventPtr& event) :
+        bus(bus), event(event)
+#ifdef PLDM
+        ,
+        pldmHandle(std::make_unique<pldm::Interface>(
+            bus, std::bind(std::mem_fn(&Manager::updateOCCActive), this,
+                           std::placeholders::_1, std::placeholders::_2)))
+#endif
+
     {
 #ifdef I2C_OCC
         // I2C OCC status objects are initialized directly
@@ -114,6 +125,23 @@
      */
     void initStatusObjects();
 #endif
+
+#ifdef PLDM
+    /** @brief Callback handler invoked by the PLDM event handler when state of
+     *         the OCC is toggled by the host. The caller passes the instance
+     *         of the OCC and state of the OCC.
+     *
+     *  @param[in] instance - instance of the OCC
+     *  @param[in] status - true when the OCC goes active and false when the OCC
+     *                      goes inactive
+     *
+     *  @return true if setting the state of OCC is successful and false if it
+     *          fails.
+     */
+    bool updateOCCActive(instanceID instance, bool status);
+
+    std::unique_ptr<pldm::Interface> pldmHandle = nullptr;
+#endif
 };
 
 } // namespace occ