#ifndef WIFI_DRIVER_H #define WIFI_DRIVER_H #include "Util/StaticDevice.h" #include #include #include #include #include namespace PresenceDetection { namespace WiFi { class Driver { public: Driver(const std::string& hostname, int port, const std::string& username, const std::string& password, const std::string& cookieFile, int timeout, const std::string& inventoryURL, const std::string& target, const std::vector& staticDevices); ~Driver(); void Start(); void Stop(); void Wait(); private: bool Login(); void Logout(); void ClearDevices(); void UpdateDevicesFromInventory(); void UpdatePresentDevices(); void SendStateChange(bool present, const std::string& macAddress); void ClearCookiesFile(); private: struct PresentDevice { PresentDevice(const std::string& macAddress); PresentDevice(const std::string& macAddress, int lastSeen); std::string MacAddress; int LastSeen; bool operator==(const PresentDevice& other) const; bool operator!=(const PresentDevice& other) const; bool operator==(const std::string& other) const; bool operator!=(const std::string& other) const; }; private: Timer::Timer m_deviceTimer; Timer::Timer m_inventoryTimer; Http::HttpClient m_httpClient; std::mutex m_mutex; bool m_loggedIn; std::string m_hostname; int m_port; std::string m_username; std::string m_password; std::string m_cookieFile; std::vector m_devices; int m_timeout; int m_checkInterval; std::string m_inventoryURL; std::string m_target; std::vector m_staticDevices; std::vector m_presentDevices; }; } // namespace WiFi } // namespace PresenceDetection #endif // WIFI_DRIVER_H