Device.h 959 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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& target);
  14. ~Device();
  15. void Start();
  16. void Stop();
  17. void Wait();
  18. private:
  19. bool Login();
  20. void Logout();
  21. void UpdatePresentDevices();
  22. void SendStateChange(bool present, const std::string& macAddress);
  23. private:
  24. Util::Timer m_timer;
  25. Util::HttpClient m_httpClient;
  26. std::mutex m_mutex;
  27. bool m_loggedIn;
  28. std::string m_hostname;
  29. std::string m_username;
  30. std::string m_password;
  31. std::string m_cookieFile;
  32. std::string m_target;
  33. int m_offlineTimeout;
  34. std::vector<std::string> m_presentDevices;
  35. };
  36. } // namespace UniFi
  37. } // namespace PresenceDetection
  38. #endif // UNIFI_DEVICE_H