hueplusplus  1.0.0
Classes | Public Member Functions | Static Public Member Functions | List of all members
hueplusplus::BridgeFinder Class Reference

#include <hueplusplus/Bridge.h>

Classes

struct  BridgeIdentification
 

Public Member Functions

 BridgeFinder (std::shared_ptr< const IHttpHandler > handler)
 Constructor of BridgeFinder class. More...
 
std::vector< BridgeIdentificationfindBridges () const
 Finds all bridges in the network and returns them. More...
 
Bridge getBridge (const BridgeIdentification &identification, bool sharedState=false)
 Gets a Hue bridge based on its identification. More...
 
void addUsername (const std::string &mac, const std::string &username)
 Function that adds a username to the usernames map. More...
 
void addClientKey (const std::string &mac, const std::string &clientkey)
 Function that adds a client key to the clientkeys map. More...
 
const std::map< std::string, std::string > & getAllUsernames () const
 Function that returns a map of mac addresses and usernames. More...
 

Static Public Member Functions

static std::string normalizeMac (std::string input)
 Normalizes mac address to plain hex number. More...
 

Detailed Description

Class to find all Hue bridges on the network and create usernames for them.

Constructor & Destructor Documentation

◆ BridgeFinder()

hueplusplus::BridgeFinder::BridgeFinder ( std::shared_ptr< const IHttpHandler handler)

Constructor of BridgeFinder class.

Parameters
handlerHttpHandler of type IHttpHandler for communication with the bridge

Member Function Documentation

◆ addClientKey()

void hueplusplus::BridgeFinder::addClientKey ( const std::string &  mac,
const std::string &  clientkey 
)

Function that adds a client key to the clientkeys map.

The client key is only needed for entertainment mode, otherwise it is optional.

Parameters
macMAC address of Hue bridge
clientkeyClient key that is used to control the Hue bridge in entertainment mode

◆ addUsername()

void hueplusplus::BridgeFinder::addUsername ( const std::string &  mac,
const std::string &  username 
)

Function that adds a username to the usernames map.

Parameters
macMAC address of Hue bridge
usernameUsername that is used to control the Hue bridge

◆ findBridges()

std::vector< BridgeFinder::BridgeIdentification > hueplusplus::BridgeFinder::findBridges ( ) const

Finds all bridges in the network and returns them.

The user should be given the opportunity to select the correct one based on the mac address.

Returns
vector containing ip and mac of all found bridges
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body

◆ getAllUsernames()

const std::map< std::string, std::string > & hueplusplus::BridgeFinder::getAllUsernames ( ) const

Function that returns a map of mac addresses and usernames.

Note these should be saved at the end and re-loaded with addUsername next time, so only one username is generated per bridge.

Returns
A map mapping mac address to username for every bridge

◆ getBridge()

Bridge hueplusplus::BridgeFinder::getBridge ( const BridgeIdentification identification,
bool  sharedState = false 
)

Gets a Hue bridge based on its identification.

Parameters
identificationBridgeIdentification that specifies a bridge
sharedStateUses a single, shared cache for all objects on the bridge.
Returns
Bridge class object
Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body or username could not be requested
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ normalizeMac()

std::string hueplusplus::BridgeFinder::normalizeMac ( std::string  input)
static

Normalizes mac address to plain hex number.

Returns
input without separators and whitespace, in lower case.

The documentation for this class was generated from the following files: