#include #include #include // This is a class GPIO explorer that uses the libgpiod library to read the state of a GPIO pin. class GPIOExplorer { public: GPIOExplorer(const char *chipname, int line_offset); ~GPIOExplorer(); int setWaitingTime(int nTime){ std::lock_guard lock(m_mutex); m_nWaitingTime = nTime; } int read(); int monitorRisingEdge(); bool getFailingStatus(int index) { return FailingStatus & (1 << index); }; void resetFailingStatus(int index) { std::lock_guard lock(m_mutex); FailingStatus = FailingStatus & ~(1 << index); } std::mutex* getMutex(){return &m_mutex;} bool detectZWave(); void close(); private: struct gpiod_chip *chip; struct gpiod_line *line; std::list m_StatusList; bool StatusKeep{false}; unsigned char FailingStatus{0x00}; std::mutex m_mutex; int m_nWaitingTime = 50; }; extern GPIOExplorer* g_gpioExplorer;