Device.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef UNIFI_DEVICE_H
  2. #define UNIFI_DEVICE_H
  3. #include "Util/StaticDevice.h"
  4. #include <HttpClient.h>
  5. #include <Timer.h>
  6. #include <mutex>
  7. #include <string>
  8. #include <vector>
  9. namespace PresenceDetection {
  10. namespace UniFi {
  11. class Device
  12. {
  13. public:
  14. Device(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);
  15. ~Device();
  16. void Start();
  17. void Stop();
  18. void Wait();
  19. private:
  20. bool Login();
  21. void Logout();
  22. void ClearDevices();
  23. void UpdateDevicesFromInventory();
  24. void UpdatePresentDevices();
  25. void SendStateChange(bool present, const std::string& macAddress);
  26. private:
  27. Timer::Timer m_deviceTimer;
  28. Timer::Timer m_inventoryTimer;
  29. Http::HttpClient m_httpClient;
  30. std::mutex m_mutex;
  31. bool m_loggedIn;
  32. std::string m_hostname;
  33. int m_port;
  34. std::string m_username;
  35. std::string m_password;
  36. std::string m_cookieFile;
  37. std::vector<std::string> m_devices;
  38. int m_timeout;
  39. int m_checkInterval;
  40. std::string m_inventoryURL;
  41. std::string m_target;
  42. std::vector<Util::StaticDevice> m_staticDevices;
  43. std::vector<std::string> m_presentDevices;
  44. };
  45. } // namespace UniFi
  46. } // namespace PresenceDetection
  47. #endif // UNIFI_DEVICE_H