Device.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef BLUETOOTH_DEVICE_H
  2. #define BLUETOOTH_DEVICE_H
  3. #include <string>
  4. #include <vector>
  5. #include "Util/Device.h"
  6. #include "Util/Timer.h"
  7. #include "Util/HttpClient.h"
  8. namespace PresenceDetection {
  9. namespace Bluetooth {
  10. class Device
  11. {
  12. public:
  13. Device(int timeout, const std::string& inventoryURL, const std::string& target, const std::vector<Util::Device>& devices);
  14. ~Device();
  15. void Start();
  16. void Stop();
  17. void Wait();
  18. private:
  19. void ClearDevices();
  20. void UpdateDevicesFromInventory();
  21. void UpdateOnlineDevices();
  22. void UpdateOfflineDevices();
  23. void UpdatePresentDevices(bool updateOnlineDevices);
  24. void SendStateChange(bool present, const std::string& macAddress);
  25. private:
  26. Util::Timer m_onlineDeviceTimer;
  27. Util::Timer m_offlineDeviceTimer;
  28. Util::Timer m_inventoryTimer;
  29. Util::HttpClient m_httpClient;
  30. std::vector<std::string> m_devices;
  31. int m_timeout;
  32. std::string m_inventoryURL;
  33. std::string m_target;
  34. std::vector<Util::Device> m_staticDevices;
  35. std::vector<std::string> m_presentDevices;
  36. };
  37. } // namespace Bluetooth
  38. } // namespace PresenceDetection
  39. #endif // BLUETOOTH_DEVICE_H