Trigger periodic OCC POLL commands when the OCCs are running

The OCC control app will periodically trigger kernel poll commands
to the OCC when the OCCs are active.
Code change also adds an interface to allow any OCC command to be
sent to an OCC. The pass-through interface was also updated to
use the new command object.

Tested: I did several IPLs on multiple Rainier systems to verify
the changes. I forced OCC resets to ensure polling stopped when
OCCs were disabled and restarted after it came out of reset.

Change-Id: I56970e781a988bb94f17ac38173ace8a68bb5fad
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/occ_status.hpp b/occ_status.hpp
index 24dcb0e..abdc3ed 100644
--- a/occ_status.hpp
+++ b/occ_status.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "i2c_occ.hpp"
+#include "occ_command.hpp"
 #include "occ_device.hpp"
 #include "occ_events.hpp"
 
@@ -94,7 +95,11 @@
                 sdbusRule::argN(0, Control::convertForMessage(
                                        Control::Host::Command::OCCReset)),
             std::bind(std::mem_fn(&Status::hostControlEvent), this,
-                      std::placeholders::_1))
+                      std::placeholders::_1)),
+        occCmd(instance, bus,
+               (fs::path(OCC_CONTROL_ROOT) /
+                (std::string(OCC_NAME) + std::to_string(instance)))
+                   .c_str())
 #ifdef PLDM
         ,
         resetCallBack(resetCallBack)
@@ -142,6 +147,9 @@
         return device.addPresenceWatchMaster();
     }
 
+    /** @brief Read OCC state (will trigger kernel to poll the OCC) */
+    void readOccState();
+
   private:
     /** @brief sdbus handle */
     sdbusplus::bus::bus& bus;
@@ -155,7 +163,10 @@
     std::function<void(bool)> callBack;
 
     /** @brief OCC instance number. Ex, 0,1, etc */
-    int instance;
+    unsigned int instance;
+
+    /** @brief The last state read from the OCC */
+    unsigned int lastState = 0;
 
     /** @brief OCC instance to Sensor definitions mapping */
     static const std::map<instanceID, sensorDefs> sensorMap;
@@ -171,6 +182,9 @@
      **/
     sdbusplus::bus::match_t hostControlSignal;
 
+    /** @brief Command object to send commands to the OCC */
+    OccCommand occCmd;
+
     /** @brief Callback handler when device errors are detected
      *
      *  @param[in]  error - True if an error is reported, false otherwise