Loading...
Searching...
No Matches
BridgeConfig.h
Go to the documentation of this file.
#ifndef INCLUDE_HUEPLUSPLUS_BRIDGE_CONFIG_H
#define INCLUDE_HUEPLUSPLUS_BRIDGE_CONFIG_H
#include <string>
#include <vector>
#include "APICache.h"
#include "TimePattern.h"
namespace hueplusplus
{
struct Version
{
int major;
int minor;
int patch;
};
struct WhitelistedUser
{
std::string key;
std::string name;
time::AbsoluteTime lastUsed;
time::AbsoluteTime created;
};
class BridgeConfig
{
public:
BridgeConfig(std::shared_ptr<APICache> baseCache, std::chrono::steady_clock::duration refreshDuration);
void refresh(bool force = false);
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration);
std::vector<WhitelistedUser> getWhitelistedUsers() const;
void removeUser(const std::string& userKey);
bool getLinkButton() const;
void pressLinkButton();
void touchLink();
std::string getMACAddress() const;
time::AbsoluteTime getUTCTime() const;
std::string getTimezone() const;
protected:
BridgeConfig(const BridgeConfig&) = default;
BridgeConfig(BridgeConfig&&) = default;
BridgeConfig& operator=(const BridgeConfig&) = default;
BridgeConfig& operator=(BridgeConfig&&) = default;
private:
APICache cache;
};
} // namespace hueplusplus
#endif
APICache.h
TimePattern.h
hueplusplus::APICache
Caches API GET requests and refreshes regularly.
Definition APICache.h:38
hueplusplus::BridgeConfig
General bridge configuration properties.
Definition BridgeConfig.h:56
hueplusplus::BridgeConfig::operator=
BridgeConfig & operator=(BridgeConfig &&)=default
hueplusplus::BridgeConfig::setRefreshDuration
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for the config.
Definition BridgeConfig.cpp:43
hueplusplus::BridgeConfig::BridgeConfig
BridgeConfig(BridgeConfig &&)=default
hueplusplus::BridgeConfig::getLinkButton
bool getLinkButton() const
Get link button state.
Definition BridgeConfig.cpp:64
hueplusplus::BridgeConfig::getMACAddress
std::string getMACAddress() const
Get bridge MAC address.
Definition BridgeConfig.cpp:76
hueplusplus::BridgeConfig::refresh
void refresh(bool force=false)
Refreshes internal cached state.
Definition BridgeConfig.cpp:31
hueplusplus::BridgeConfig::getUTCTime
time::AbsoluteTime getUTCTime() const
Get current (of last refresh) UTC time of the bridge.
Definition BridgeConfig.cpp:80
hueplusplus::BridgeConfig::getTimezone
std::string getTimezone() const
Get configured timezone for the bridge.
Definition BridgeConfig.cpp:84
hueplusplus::BridgeConfig::operator=
BridgeConfig & operator=(const BridgeConfig &)=default
hueplusplus::BridgeConfig::BridgeConfig
BridgeConfig(const BridgeConfig &)=default
hueplusplus::BridgeConfig::removeUser
void removeUser(const std::string &userKey)
Remove user from the whitelist.
Definition BridgeConfig.cpp:60
hueplusplus::BridgeConfig::pressLinkButton
void pressLinkButton()
Set the link button state to pressed.
Definition BridgeConfig.cpp:68
hueplusplus::BridgeConfig::getWhitelistedUsers
std::vector< WhitelistedUser > getWhitelistedUsers() const
Get the list of whitelisted users.
Definition BridgeConfig.cpp:48
hueplusplus::BridgeConfig::touchLink
void touchLink()
Add the closest lamp to the network.
Definition BridgeConfig.cpp:72
hueplusplus::time::AbsoluteTime
One-time, absolute time point.
Definition TimePattern.h:73
hueplusplus
Namespace for the hueplusplus library.
Definition Action.h:28
hueplusplus::Version
API version consisting of major, minor and patch version.
Definition BridgeConfig.h:35
hueplusplus::Version::patch
int patch
Definition BridgeConfig.h:38
hueplusplus::Version::minor
int minor
Definition BridgeConfig.h:37
hueplusplus::Version::major
int major
Definition BridgeConfig.h:36
hueplusplus::WhitelistedUser
User that is whitelisted for Hue API usage.
Definition BridgeConfig.h:43
hueplusplus::WhitelistedUser::lastUsed
time::AbsoluteTime lastUsed
Last time the user was used.
Definition BridgeConfig.h:49
hueplusplus::WhitelistedUser::created
time::AbsoluteTime created
Time the user was created.
Definition BridgeConfig.h:51
hueplusplus::WhitelistedUser::key
std::string key
API username of the user.
Definition BridgeConfig.h:45
hueplusplus::WhitelistedUser::name
std::string name
Name provided on user creation.
Definition BridgeConfig.h:47