Loading...
Searching...
No Matches
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.
std::vector< BridgeIdentification > | findBridges () const
| Finds all bridges in the network and returns them.
Bridge | getBridge (const BridgeIdentification &identification, bool sharedState=false)
| Gets a Hue bridge based on its identification.
void | addUsername (const std::string &mac, const std::string &username)
| Function that adds a username to the usernames map.
void | addClientKey (const std::string &mac, const std::string &clientkey)
| Function that adds a client key to the clientkeys map.
const std::map< std::string, std::string > & | getAllUsernames () const
| Function that returns a map of mac addresses and usernames.

## Static Public Member Functions

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

## Detailed Description

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

Examples
  BridgeSetup.cpp, LightsOff.cpp, and UsernameConfig.cpp.

## Constructor & Destructor Documentation

## BridgeFinder()

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

Constructor of BridgeFinder class.

Parameters

  handler | HttpHandler 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

  mac | MAC address of Hue bridge
  clientkey | Client 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

  mac | MAC address of Hue bridge
  username | Username that is used to control the Hue bridge

Examples
  BridgeSetup.cpp, and LightsOff.cpp.

## 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_error | when system or socket operations fail
  HueException | when response contained no body

Examples
  BridgeSetup.cpp, and LightsOff.cpp.

## 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

  identification | BridgeIdentification that specifies a bridge
  sharedState | Uses a single, shared cache for all objects on the bridge.

Returns
  Bridge class object

Exceptions

  std::system_error | when system or socket operations fail
  HueException | when response contained no body or username could not be requested
  HueAPIResponseException | when response contains an error
  nlohmann::json::parse_error | when response could not be parsed

Examples
  BridgeSetup.cpp, and LightsOff.cpp.

## 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:

- include/hueplusplus/Bridge.h
- src/Bridge.cpp