| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef WIFI_DRIVER_H
- #define WIFI_DRIVER_H
- #include "Util/StaticDevice.h"
- #include <HttpClient.h>
- #include <Timer.h>
- #include <mutex>
- #include <string>
- #include <vector>
- 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<Util::StaticDevice>& 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<std::string> m_devices;
- int m_timeout;
- int m_checkInterval;
- std::string m_inventoryURL;
- std::string m_target;
- std::vector<Util::StaticDevice> m_staticDevices;
- std::vector<PresentDevice> m_presentDevices;
- };
- } // namespace WiFi
- } // namespace PresenceDetection
- #endif // WIFI_DRIVER_H
|