Add fan presence support

Async montitor GPIO to get fan presence.

Tested-by: Pulled every fan on a 2U and monitored
presence.

Change-Id: Ibad2251e5c6a0ce480812051c103785f79fa60bb
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/sensors/include/TachSensor.hpp b/sensors/include/TachSensor.hpp
index 33d2da0..2dc6216 100644
--- a/sensors/include/TachSensor.hpp
+++ b/sensors/include/TachSensor.hpp
@@ -4,6 +4,25 @@
 #include <sdbusplus/asio/object_server.hpp>
 #include <sensor.hpp>
 
+constexpr const char *gpioPath = "/sys/class/gpio/";
+class PresenceSensor
+{
+
+  public:
+    PresenceSensor(const size_t index, bool inverted,
+                   boost::asio::io_service &io);
+    ~PresenceSensor();
+
+    void monitorPresence(void);
+    void read(void);
+    bool getValue(void);
+
+  private:
+    bool status = true;
+    bool inverted;
+    boost::asio::ip::tcp::socket inputDev;
+    int fd;
+};
 class TachSensor : public Sensor
 {
   public:
@@ -12,6 +31,7 @@
     TachSensor(const std::string &path,
                sdbusplus::asio::object_server &objectServer,
                std::shared_ptr<sdbusplus::asio::connection> &conn,
+               std::unique_ptr<PresenceSensor> &&presence,
                boost::asio::io_service &io, const std::string &fanName,
                std::vector<thresholds::Threshold> &&thresholds,
                const std::string &sensorConfiguration);
@@ -21,6 +41,7 @@
     std::string path;
     sdbusplus::asio::object_server &objServer;
     std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
+    std::unique_ptr<PresenceSensor> presence;
     boost::asio::posix::stream_descriptor inputDev;
     boost::asio::deadline_timer waitTimer;
     boost::asio::streambuf readBuf;