61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
#ifndef UNIFI_DEVICE_H
|
|
#define UNIFI_DEVICE_H
|
|
|
|
#include "Util/Device.h"
|
|
#include <HttpClient.h>
|
|
#include <Timer.h>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
|
|
namespace PresenceDetection {
|
|
namespace UniFi {
|
|
|
|
class Device
|
|
{
|
|
public:
|
|
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::Device>& devices);
|
|
~Device();
|
|
|
|
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);
|
|
|
|
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;
|
|
std::string m_inventoryURL;
|
|
std::string m_target;
|
|
std::vector<Util::Device> m_staticDevices;
|
|
|
|
std::vector<std::string> m_presentDevices;
|
|
};
|
|
|
|
} // namespace UniFi
|
|
} // namespace PresenceDetection
|
|
|
|
#endif // UNIFI_DEVICE_H
|