Commit 175c4cde37b07b84a4867617b7c6f1307830b273
Committed by
GitHub
1 parent
8f03c48c
Update README
Describe new way of finding/creating Hue objects aka bridges
Showing
1 changed file
with
15 additions
and
6 deletions
README.md
| ... | ... | @@ -10,12 +10,15 @@ A simple and easy to use library for Philips Hue Lights |
| 10 | 10 | * starting to test with google test, google mock and gcov/lcov |
| 11 | 11 | |
| 12 | 12 | ## How to use |
| 13 | -### <a name="findingBridges"></a>Finding Bridges | |
| 14 | -If you want to find a Hue Bridge make a HueFinder object and call FindBridges() | |
| 15 | -it will return a vector containing the ip and mac address of all found Bridges. | |
| 13 | +### <a name="searchingBridges"></a>Searching for Bridges | |
| 14 | +To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. For now there is only one, the "HttpHandler". | |
| 15 | +Then create a HueFinder object with the handler. | |
| 16 | +The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network. | |
| 17 | +After that you can call FindBridges(), which will return a vector containing the ip and mac address of all found Bridges. | |
| 16 | 18 | If no Bridges were found the vector is empty, so make sure that in that case you provide an ip and mac address. |
| 17 | 19 | ```C++ |
| 18 | -HueFinder finder; | |
| 20 | +handler = std::make_shared<HttpHandler>(); | |
| 21 | +HueFinder finder(handler); | |
| 19 | 22 | std::vector<HueFinder::HueIdentification> bridges = finder.FindBridges(); |
| 20 | 23 | if (bridges.empty()) |
| 21 | 24 | { |
| ... | ... | @@ -23,10 +26,10 @@ if (bridges.empty()) |
| 23 | 26 | } |
| 24 | 27 | ``` |
| 25 | 28 | |
| 26 | -### Using Bridges | |
| 29 | +### Authenticate Bridges | |
| 27 | 30 | If you have found the Bridge you were looking for, you can then move on with the authentication process. |
| 28 | 31 | To get a new username from the Bridge (for now) you simply call GetBridge(bridges[\<index\>]), |
| 29 | -where index is your preferred Bridge from the part [Finding Bridges](#findingBridges). | |
| 32 | +where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges). | |
| 30 | 33 | ```C++ |
| 31 | 34 | Hue bridge = finder.GetBridge(bridges[0]); |
| 32 | 35 | ``` |
| ... | ... | @@ -35,6 +38,12 @@ If you on the other hand already have a username you can add your bridge like so |
| 35 | 38 | finder.AddUsername(bridges[0].mac, "<username>"); |
| 36 | 39 | Hue bridge = finder.GetBridge(bridges[0]); |
| 37 | 40 | ``` |
| 41 | +If you do not want to use the HueFinder or you already know the ip and username of your bridge you have the option to create your own Hue object. | |
| 42 | +Here you will need to provide the ip address, a username and an HttpHandler | |
| 43 | +```C++ | |
| 44 | +handler = std::make_shared<HttpHandler>(); | |
| 45 | +Hue bridge("192.168.2.102", "<username>", handler); | |
| 46 | +``` | |
| 38 | 47 | |
| 39 | 48 | ### Controlling lights |
| 40 | 49 | If you have your Bridge all set up, you can now control its lights. | ... | ... |