Device.h 1.1 KB

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