Add Static Devices, Timeout and UniFi Port Directive
This commit is contained in:
+167
@@ -0,0 +1,167 @@
|
||||
#include <algorithm>
|
||||
#include "Device.h"
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
Device::Device(const std::string& wifiMac, const std::string& bluetoothMac) :
|
||||
m_wifiMac(wifiMac),
|
||||
m_wifiState(false),
|
||||
m_bluetoothMac(bluetoothMac),
|
||||
m_bluetoothState(false)
|
||||
{
|
||||
std::transform(m_wifiMac.begin(), m_wifiMac.end(), m_wifiMac.begin(), ::tolower);
|
||||
std::transform(m_bluetoothMac.begin(), m_bluetoothMac.end(), m_bluetoothMac.begin(), ::tolower);
|
||||
}
|
||||
|
||||
Device::Device(const Device &other) :
|
||||
m_wifiMac(other.m_wifiMac),
|
||||
m_wifiState(other.m_wifiState),
|
||||
m_bluetoothMac(other.m_bluetoothMac),
|
||||
m_bluetoothState(other.m_bluetoothState),
|
||||
m_onlineURL(other.m_onlineURL),
|
||||
m_wifiOnlineURL(other.m_wifiOnlineURL),
|
||||
m_bluetoothOnlineURL(other.m_bluetoothOnlineURL),
|
||||
m_offlineURL(other.m_offlineURL),
|
||||
m_wifiOfflineURL(other.m_wifiOfflineURL),
|
||||
m_bluetoothOfflineURL(other.m_bluetoothOfflineURL)
|
||||
{
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
}
|
||||
|
||||
bool Device::HasWifiMac() const
|
||||
{
|
||||
return !m_wifiMac.empty();
|
||||
}
|
||||
|
||||
std::string Device::WifiMac() const
|
||||
{
|
||||
return m_wifiMac;
|
||||
}
|
||||
|
||||
void Device::SetWifiState(bool present)
|
||||
{
|
||||
m_wifiState = present;
|
||||
}
|
||||
|
||||
bool Device::GetWifiState() const
|
||||
{
|
||||
return m_wifiState;
|
||||
}
|
||||
|
||||
bool Device::HasBluetoothMac() const
|
||||
{
|
||||
return !m_bluetoothMac.empty();
|
||||
}
|
||||
|
||||
std::string Device::BluetoothMac() const
|
||||
{
|
||||
return m_bluetoothMac;
|
||||
}
|
||||
|
||||
void Device::SetBluetoothState(bool present)
|
||||
{
|
||||
m_bluetoothState = present;
|
||||
}
|
||||
|
||||
bool Device::GetBluetoothState() const
|
||||
{
|
||||
return m_bluetoothState;
|
||||
}
|
||||
|
||||
bool Device::HasOnlineURL() const
|
||||
{
|
||||
return !m_onlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetOnlineURL(const std::string& url)
|
||||
{
|
||||
m_onlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::OnlineURL() const
|
||||
{
|
||||
return m_onlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasWifiOnlineURL() const
|
||||
{
|
||||
return !m_wifiOnlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetWifiOnlineURL(const std::string& url)
|
||||
{
|
||||
m_wifiOnlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::WifiOnlineURL() const
|
||||
{
|
||||
return m_wifiOnlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasBluetoothOnlineURL() const
|
||||
{
|
||||
return !m_bluetoothOnlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetBluetoothOnlineURL(const std::string& url)
|
||||
{
|
||||
m_bluetoothOnlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::BluetoothOnlineURL() const
|
||||
{
|
||||
return m_bluetoothOnlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasOfflineURL() const
|
||||
{
|
||||
return !m_offlineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetOfflineURL(const std::string& url)
|
||||
{
|
||||
m_offlineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::OfflineURL() const
|
||||
{
|
||||
return m_offlineURL;
|
||||
}
|
||||
|
||||
bool Device::HasWifiOfflineURL() const
|
||||
{
|
||||
return !m_wifiOfflineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetWifiOfflineURL(const std::string& url)
|
||||
{
|
||||
m_wifiOfflineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::WifiOfflineURL() const
|
||||
{
|
||||
return m_wifiOfflineURL;
|
||||
}
|
||||
|
||||
bool Device::HasBluetoothOfflineURL() const
|
||||
{
|
||||
return !m_bluetoothOfflineURL.empty();
|
||||
}
|
||||
|
||||
void Device::SetBluetoothOfflineURL(const std::string& url)
|
||||
{
|
||||
m_bluetoothOfflineURL = url;
|
||||
}
|
||||
|
||||
std::string Device::BluetoothOfflineURL() const
|
||||
{
|
||||
return m_bluetoothOfflineURL;
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef UTIL_DEVICE_H
|
||||
#define UTIL_DEVICE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace PresenceDetection {
|
||||
namespace Util {
|
||||
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
Device(const std::string& wifiMac, const std::string& bluetoothMac);
|
||||
Device(const Device &other);
|
||||
~Device();
|
||||
|
||||
bool HasWifiMac() const;
|
||||
std::string WifiMac() const;
|
||||
void SetWifiState(bool present);
|
||||
bool GetWifiState() const;
|
||||
|
||||
bool HasBluetoothMac() const;
|
||||
std::string BluetoothMac() const;
|
||||
void SetBluetoothState(bool present);
|
||||
bool GetBluetoothState() const;
|
||||
|
||||
bool HasOnlineURL() const;
|
||||
void SetOnlineURL(const std::string& url);
|
||||
std::string OnlineURL() const;
|
||||
bool HasWifiOnlineURL() const;
|
||||
void SetWifiOnlineURL(const std::string& url);
|
||||
std::string WifiOnlineURL() const;
|
||||
bool HasBluetoothOnlineURL() const;
|
||||
void SetBluetoothOnlineURL(const std::string& url);
|
||||
std::string BluetoothOnlineURL() const;
|
||||
|
||||
bool HasOfflineURL() const;
|
||||
void SetOfflineURL(const std::string& url);
|
||||
std::string OfflineURL() const;
|
||||
bool HasWifiOfflineURL() const;
|
||||
void SetWifiOfflineURL(const std::string& url);
|
||||
std::string WifiOfflineURL() const;
|
||||
bool HasBluetoothOfflineURL() const;
|
||||
void SetBluetoothOfflineURL(const std::string& url);
|
||||
std::string BluetoothOfflineURL() const;
|
||||
|
||||
private:
|
||||
std::string m_wifiMac;
|
||||
bool m_wifiState;
|
||||
|
||||
std::string m_bluetoothMac;
|
||||
bool m_bluetoothState;
|
||||
|
||||
std::string m_onlineURL;
|
||||
std::string m_wifiOnlineURL;
|
||||
std::string m_bluetoothOnlineURL;
|
||||
std::string m_offlineURL;
|
||||
std::string m_wifiOfflineURL;
|
||||
std::string m_bluetoothOfflineURL;
|
||||
};
|
||||
|
||||
} // namespace Util
|
||||
} // namespace PresenceDetection
|
||||
|
||||
#endif // UTIL_DEVICE_H
|
||||
Reference in New Issue
Block a user