Commit 74b51fb2c0d1ac063def640a6314f2fe27bcb121

Authored by Moritz Wirger
1 parent 2fb7a9a0

Fix naming convention

README.md
@@ -26,12 +26,12 @@ A simple and easy to use library for Philips Hue Lights @@ -26,12 +26,12 @@ A simple and easy to use library for Philips Hue Lights
26 To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. The options are a "WinHttpHandler" (for windows) or a "LinHttpHandler" (for linux). 26 To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. The options are a "WinHttpHandler" (for windows) or a "LinHttpHandler" (for linux).
27 Then create a BridgeFinder object with the handler. 27 Then create a BridgeFinder object with the handler.
28 The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network. 28 The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network.
29 -After that you can call FindBridges(), which will return a vector containing the ip and mac address of all found Bridges. 29 +After that you can call findBridges(), which will return a vector containing the ip and mac address of all found Bridges.
30 ```C++ 30 ```C++
31 // For windows use std::make_shared<hueplusplus::WinHttpHandler>(); 31 // For windows use std::make_shared<hueplusplus::WinHttpHandler>();
32 handler = std::make_shared<hueplusplus::LinHttpHandler>(); 32 handler = std::make_shared<hueplusplus::LinHttpHandler>();
33 hueplusplus::BridgeFinder finder(handler); 33 hueplusplus::BridgeFinder finder(handler);
34 -std::vector<hueplusplus::BridgeFinder::BridgeIdentification> bridges = finder.FindBridges(); 34 +std::vector<hueplusplus::BridgeFinder::BridgeIdentification> bridges = finder.findBridges();
35 if (bridges.empty()) 35 if (bridges.empty())
36 { 36 {
37 std::cerr << "No bridges found\n"; 37 std::cerr << "No bridges found\n";
@@ -42,15 +42,15 @@ if (bridges.empty()) @@ -42,15 +42,15 @@ if (bridges.empty())
42 42
43 ### Authenticate Bridges 43 ### Authenticate Bridges
44 If you have found the Bridge you were looking for, you can then move on with the authentication process. 44 If you have found the Bridge you were looking for, you can then move on with the authentication process.
45 -To get a new username from the Bridge (for now) you simply call GetBridge(bridges[\<index\>]), 45 +To get a new username from the Bridge (for now) you simply call getBridge(bridges[\<index\>]),
46 where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges). 46 where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges).
47 ```C++ 47 ```C++
48 -hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); 48 +hueplusplus::Bridge bridge = finder.getBridge(bridges[0]);
49 ``` 49 ```
50 If you on the other hand already have a username you can add your bridge like so 50 If you on the other hand already have a username you can add your bridge like so
51 ```C++ 51 ```C++
52 -finder.AddUsername(bridges[0].mac, "<username>");  
53 -hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); 52 +finder.addUsername(bridges[0].mac, "<username>");
  53 +hueplusplus::Bridge bridge = finder.getBridge(bridges[0]);
54 ``` 54 ```
55 If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object. 55 If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object.
56 Here you will need to provide the ip address, the port number, a username and an HttpHandler 56 Here you will need to provide the ip address, the port number, a username and an HttpHandler
@@ -74,12 +74,12 @@ std::vector&lt;hueplusplus::Light&gt; lights = bridge.lights().getAll(); @@ -74,12 +74,12 @@ std::vector&lt;hueplusplus::Light&gt; lights = bridge.lights().getAll();
74 ``` 74 ```
75 If you now want to control a light, call a specific function of it. 75 If you now want to control a light, call a specific function of it.
76 ```C++ 76 ```C++
77 -light1.On(); 77 +light1.on();
78 light1.setBrightness(120); 78 light1.setBrightness(120);
79 light1.alertHueSaturation(25500, 255); 79 light1.alertHueSaturation(25500, 255);
80 light1.setColorLoop(true); 80 light1.setColorLoop(true);
81 light1.setColorRGB(255, 128, 0); 81 light1.setColorRGB(255, 128, 0);
82 -lights[1].Off(); 82 +lights[1].off();
83 lights.at(1).setColorHue(4562); 83 lights.at(1).setColorHue(4562);
84 ``` 84 ```
85 But keep in mind that some light types do not have all functions available. So you might call a 85 But keep in mind that some light types do not have all functions available. So you might call a
doc/markdown/Mainpage.md
@@ -22,12 +22,12 @@ To start searching for a Hue Bridge you will need to choose an IHttpHandler and @@ -22,12 +22,12 @@ To start searching for a Hue Bridge you will need to choose an IHttpHandler and
22 22
23 Then create a [BridgeFinder](@ref hueplusplus::BridgeFinder) object with the handler. 23 Then create a [BridgeFinder](@ref hueplusplus::BridgeFinder) object with the handler.
24 The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network. 24 The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network.
25 -After that you can call [FindBridges()](@ref hueplusplus::BridgeFinder::FindBridges), which will return a vector containing the ip and mac address of all found Bridges. 25 +After that you can call [findBridges()](@ref hueplusplus::BridgeFinder::findBridges), which will return a vector containing the ip and mac address of all found Bridges.
26 ```{.cpp} 26 ```{.cpp}
27 // For windows use std::make_shared<hueplusplus::WinHttpHandler>(); 27 // For windows use std::make_shared<hueplusplus::WinHttpHandler>();
28 handler = std::make_shared<hueplusplus::LinHttpHandler>(); 28 handler = std::make_shared<hueplusplus::LinHttpHandler>();
29 hueplusplus::BridgeFinder finder(handler); 29 hueplusplus::BridgeFinder finder(handler);
30 -std::vector<hueplusplus::BridgeFinder::BridgeIdentification> bridges = finder.FindBridges(); 30 +std::vector<hueplusplus::BridgeFinder::BridgeIdentification> bridges = finder.findBridges();
31 if (bridges.empty()) 31 if (bridges.empty())
32 { 32 {
33 std::cerr << "No bridges found\n"; 33 std::cerr << "No bridges found\n";
@@ -38,15 +38,15 @@ if (bridges.empty()) @@ -38,15 +38,15 @@ if (bridges.empty())
38 38
39 ### Authenticate Bridges 39 ### Authenticate Bridges
40 If you have found the Bridge you were looking for, you can then move on with the authentication process. 40 If you have found the Bridge you were looking for, you can then move on with the authentication process.
41 -To get a new username from the Bridge (for now) you simply call [GetBridge(bridges[\<index\>])](@ref hueplusplus::BridgeFinder::GetBridge), 41 +To get a new username from the Bridge (for now) you simply call [getBridge(bridges[\<index\>])](@ref hueplusplus::BridgeFinder::getBridge),
42 where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges). This requires the user to press the link button. 42 where index is your preferred Bridge from the part [Searching for Bridges](#searchingBridges). This requires the user to press the link button.
43 ```{.cpp} 43 ```{.cpp}
44 -hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); 44 +hueplusplus::Bridge bridge = finder.getBridge(bridges[0]);
45 ``` 45 ```
46 If you on the other hand already have a username you can add your bridge like so 46 If you on the other hand already have a username you can add your bridge like so
47 ```{.cpp} 47 ```{.cpp}
48 -finder.AddUsername(bridges[0].mac, "<username>");  
49 -hueplusplus::Bridge bridge = finder.GetBridge(bridges[0]); 48 +finder.addUsername(bridges[0].mac, "<username>");
  49 +hueplusplus::Bridge bridge = finder.getBridge(bridges[0]);
50 ``` 50 ```
51 If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object. 51 If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object.
52 Here you will need to provide the ip address, the port number, a username and an HttpHandler 52 Here you will need to provide the ip address, the port number, a username and an HttpHandler
@@ -70,12 +70,12 @@ std::vector&lt;hueplusplus::Light&gt; lights = bridge.lights().getAll(); @@ -70,12 +70,12 @@ std::vector&lt;hueplusplus::Light&gt; lights = bridge.lights().getAll();
70 ``` 70 ```
71 If you now want to control a light, call a specific function of it. 71 If you now want to control a light, call a specific function of it.
72 ```{.cpp} 72 ```{.cpp}
73 -light1.On(); 73 +light1.on();
74 light1.setBrightness(120); 74 light1.setBrightness(120);
75 light1.alertHueSaturation(25500, 255); 75 light1.alertHueSaturation(25500, 255);
76 light1.setColorLoop(true); 76 light1.setColorLoop(true);
77 light1.setColorRGB(255, 128, 0); 77 light1.setColorRGB(255, 128, 0);
78 -lights[1].Off(); 78 +lights[1].off();
79 lights.at(1).setColorHue(4562); 79 lights.at(1).setColorHue(4562);
80 ``` 80 ```
81 But keep in mind that some light types do not have all functions available. So you might call a 81 But keep in mind that some light types do not have all functions available. So you might call a
include/hueplusplus/Bridge.h
@@ -80,7 +80,7 @@ public: @@ -80,7 +80,7 @@ public:
80 //! \return vector containing ip and mac of all found bridges 80 //! \return vector containing ip and mac of all found bridges
81 //! \throws std::system_error when system or socket operations fail 81 //! \throws std::system_error when system or socket operations fail
82 //! \throws HueException when response contained no body 82 //! \throws HueException when response contained no body
83 - std::vector<BridgeIdentification> FindBridges() const; 83 + std::vector<BridgeIdentification> findBridges() const;
84 84
85 //! \brief Gets a Hue bridge based on its identification 85 //! \brief Gets a Hue bridge based on its identification
86 //! 86 //!
@@ -91,31 +91,31 @@ public: @@ -91,31 +91,31 @@ public:
91 //! \throws HueException when response contained no body or username could not be requested 91 //! \throws HueException when response contained no body or username could not be requested
92 //! \throws HueAPIResponseException when response contains an error 92 //! \throws HueAPIResponseException when response contains an error
93 //! \throws nlohmann::json::parse_error when response could not be parsed 93 //! \throws nlohmann::json::parse_error when response could not be parsed
94 - Bridge GetBridge(const BridgeIdentification& identification, bool sharedState = false); 94 + Bridge getBridge(const BridgeIdentification& identification, bool sharedState = false);
95 95
96 //! \brief Function that adds a username to the usernames map 96 //! \brief Function that adds a username to the usernames map
97 //! 97 //!
98 //! \param mac MAC address of Hue bridge 98 //! \param mac MAC address of Hue bridge
99 //! \param username Username that is used to control the Hue bridge 99 //! \param username Username that is used to control the Hue bridge
100 - void AddUsername(const std::string& mac, const std::string& username); 100 + void addUsername(const std::string& mac, const std::string& username);
101 101
102 //! \brief Function that adds a client key to the clientkeys map 102 //! \brief Function that adds a client key to the clientkeys map
103 //! 103 //!
104 //! The client key is only needed for entertainment mode, otherwise it is optional. 104 //! The client key is only needed for entertainment mode, otherwise it is optional.
105 //! \param mac MAC address of Hue bridge 105 //! \param mac MAC address of Hue bridge
106 //! \param clientkey Client key that is used to control the Hue bridge in entertainment mode 106 //! \param clientkey Client key that is used to control the Hue bridge in entertainment mode
107 - void AddClientKey(const std::string& mac, const std::string& clientkey); 107 + void addClientKey(const std::string& mac, const std::string& clientkey);
108 108
109 //! \brief Function that returns a map of mac addresses and usernames. 109 //! \brief Function that returns a map of mac addresses and usernames.
110 //! 110 //!
111 - //! Note these should be saved at the end and re-loaded with \ref AddUsername 111 + //! Note these should be saved at the end and re-loaded with \ref addUsername
112 //! next time, so only one username is generated per bridge. \returns A map 112 //! next time, so only one username is generated per bridge. \returns A map
113 //! mapping mac address to username for every bridge 113 //! mapping mac address to username for every bridge
114 - const std::map<std::string, std::string>& GetAllUsernames() const; 114 + const std::map<std::string, std::string>& getAllUsernames() const;
115 115
116 //! \brief Normalizes mac address to plain hex number. 116 //! \brief Normalizes mac address to plain hex number.
117 //! \returns \p input without separators and whitespace, in lower case. 117 //! \returns \p input without separators and whitespace, in lower case.
118 - static std::string NormalizeMac(std::string input); 118 + static std::string normalizeMac(std::string input);
119 119
120 private: 120 private:
121 //! \brief Parses mac address from description.xml 121 //! \brief Parses mac address from description.xml
@@ -123,12 +123,12 @@ private: @@ -123,12 +123,12 @@ private:
123 //! \param description Content of description.xml file as returned by GET request. 123 //! \param description Content of description.xml file as returned by GET request.
124 //! \returns Content of xml element \c serialNumber if description matches a Hue bridge, otherwise an empty 124 //! \returns Content of xml element \c serialNumber if description matches a Hue bridge, otherwise an empty
125 //! string. 125 //! string.
126 - static std::string ParseDescription(const std::string& description); 126 + static std::string parseDescription(const std::string& description);
127 127
128 std::map<std::string, std::string> usernames; //!< Maps all macs to usernames added by \ref 128 std::map<std::string, std::string> usernames; //!< Maps all macs to usernames added by \ref
129 - //!< BridgeFinder::AddUsername 129 + //!< BridgeFinder::addUsername
130 std::map<std::string, std::string> clientkeys; //!< Maps all macs to clientkeys added by \ref 130 std::map<std::string, std::string> clientkeys; //!< Maps all macs to clientkeys added by \ref
131 - //!< BridgeFinder::AddClientKey 131 + //!< BridgeFinder::addClientKey
132 std::shared_ptr<const IHttpHandler> http_handler; 132 std::shared_ptr<const IHttpHandler> http_handler;
133 }; 133 };
134 134
@@ -184,12 +184,12 @@ public: @@ -184,12 +184,12 @@ public:
184 //! \brief Function to set stream mode to active for entertainment mode 184 //! \brief Function to set stream mode to active for entertainment mode
185 //! 185 //!
186 //! \return bool - whether stream request was successful 186 //! \return bool - whether stream request was successful
187 - bool StartStreaming(std::string group_identifier); 187 + bool startStreaming(std::string group_identifier);
188 188
189 //! \brief Function to set stream mode to active for entertainment mode 189 //! \brief Function to set stream mode to active for entertainment mode
190 //! 190 //!
191 //! \return bool - whether stream request was successful 191 //! \return bool - whether stream request was successful
192 - bool StopStreaming(std::string group_identifier); 192 + bool stopStreaming(std::string group_identifier);
193 193
194 //! \brief Function to get the port of the hue bridge 194 //! \brief Function to get the port of the hue bridge
195 //! 195 //!
include/hueplusplus/ColorHueStrategy.h
@@ -79,8 +79,8 @@ public: @@ -79,8 +79,8 @@ public:
79 //! through every color on the current hue and saturation settings. Notice 79 //! through every color on the current hue and saturation settings. Notice
80 //! that none of the setter functions check whether this feature is enabled 80 //! that none of the setter functions check whether this feature is enabled
81 //! and the colorloop can only be disabled with this function or by simply 81 //! and the colorloop can only be disabled with this function or by simply
82 - //! calling Off()/OffNoRefresh() and then On()/OnNoRefresh(), so you could  
83 - //! alternatively call Off() and then use any of the setter functions. \param 82 + //! calling off() and then on(), so you could
  83 + //! alternatively call off() and then use any of the setter functions. \param
84 //! on Boolean to turn this feature on or off, true/1 for on and false/0 for 84 //! on Boolean to turn this feature on or off, true/1 for on and false/0 for
85 //! off \param light A reference of the light 85 //! off \param light A reference of the light
86 virtual bool setColorLoop(bool on, Light& light) const = 0; 86 virtual bool setColorLoop(bool on, Light& light) const = 0;
include/hueplusplus/EntertainmentMode.h
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 \file EntertainmentMode.h 2 \file EntertainmentMode.h
3 Copyright Notice\n 3 Copyright Notice\n
4 Copyright (C) 2020 Adam Honse - developer\n 4 Copyright (C) 2020 Adam Honse - developer\n
  5 + Copyright (C) 2021 Moritz Wirger - developer\n
5 6
6 This file is part of hueplusplus. 7 This file is part of hueplusplus.
7 8
@@ -35,42 +36,42 @@ struct TLSContext; @@ -35,42 +36,42 @@ struct TLSContext;
35 class EntertainmentMode 36 class EntertainmentMode
36 { 37 {
37 public: 38 public:
38 - //! @brief Constructor 39 + //! \brief Constructor
39 //! 40 //!
40 - //! @param b Bridge reference  
41 - //! @param g Group to control in entertainment mode reference 41 + //! \param b Bridge reference
  42 + //! \param g Group to control in entertainment mode reference
42 EntertainmentMode(Bridge& b, Group& g); 43 EntertainmentMode(Bridge& b, Group& g);
43 44
44 - //! @brief Destroy the Entertainment Mode object 45 + //! \brief Destroy the Entertainment Mode object
45 ~EntertainmentMode(); 46 ~EntertainmentMode();
46 47
47 - //! @brief Connect and start streaming 48 + //! \brief Connect and start streaming
48 //! 49 //!
49 - //! @return true If conected and ready to receive commands  
50 - //! @return false If an error occured  
51 - bool Connect(); 50 + //! \return true If conected and ready to receive commands
  51 + //! \return false If an error occured
  52 + bool connect();
52 53
53 - //! @brief Disconnect and stop streaming 54 + //! \brief Disconnect and stop streaming
54 //! 55 //!
55 - //! @return true If disconnected successfully  
56 - //! @return false If an error occurred  
57 - bool Disconnect(); 56 + //! \return true If disconnected successfully
  57 + //! \return false If an error occurred
  58 + bool disconnect();
58 59
59 - //! @brief Set the color of the given light in RGB format 60 + //! \brief Set the color of the given light in RGB format
60 //! 61 //!
61 - //! @param light_index Light index inside the group  
62 - //! @param red Red color value (0-255)  
63 - //! @param green Green color value (0-255)  
64 - //! @param blue Blue color value (0-255)  
65 - //! @return true If light_index was valid  
66 - //! @return false If light_index was invalid  
67 - bool SetColorRGB(uint8_t light_index, uint8_t red, uint8_t green, uint8_t blue);  
68 -  
69 - //! @brief Update all set colors by @ref SetColorRGB 62 + //! \param light_index Light index inside the group
  63 + //! \param red Red color value (0-255)
  64 + //! \param green Green color value (0-255)
  65 + //! \param blue Blue color value (0-255)
  66 + //! \return true If light_index was valid
  67 + //! \return false If light_index was invalid
  68 + bool setColorRGB(uint8_t light_index, uint8_t red, uint8_t green, uint8_t blue);
  69 +
  70 + //! \brief Update all set colors by \ref setColorRGB
70 //! 71 //!
71 - //! @return true If all color values for all lights have ben written/sent  
72 - //! @return false If there was an error while writing  
73 - bool Update(); 72 + //! \return true If all color values for all lights have ben written/sent
  73 + //! \return false If there was an error while writing
  74 + bool update();
74 75
75 protected: 76 protected:
76 Bridge* bridge; //!< Associated bridge 77 Bridge* bridge; //!< Associated bridge
include/hueplusplus/Light.h
@@ -95,7 +95,7 @@ public: @@ -95,7 +95,7 @@ public:
95 //! \throws HueException when response contained no body 95 //! \throws HueException when response contained no body
96 //! \throws HueAPIResponseException when response contains an error 96 //! \throws HueAPIResponseException when response contains an error
97 //! \throws nlohmann::json::parse_error when response could not be parsed 97 //! \throws nlohmann::json::parse_error when response could not be parsed
98 - virtual bool On(uint8_t transition = 4); 98 + virtual bool on(uint8_t transition = 4);
99 99
100 //! \brief Function that turns the light off. 100 //! \brief Function that turns the light off.
101 //! 101 //!
@@ -105,7 +105,7 @@ public: @@ -105,7 +105,7 @@ public:
105 //! \throws HueException when response contained no body 105 //! \throws HueException when response contained no body
106 //! \throws HueAPIResponseException when response contains an error 106 //! \throws HueAPIResponseException when response contains an error
107 //! \throws nlohmann::json::parse_error when response could not be parsed 107 //! \throws nlohmann::json::parse_error when response could not be parsed
108 - virtual bool Off(uint8_t transition = 4); 108 + virtual bool off(uint8_t transition = 4);
109 109
110 //! \brief Function to check whether a light is on or off 110 //! \brief Function to check whether a light is on or off
111 //! 111 //!
@@ -145,13 +145,13 @@ public: @@ -145,13 +145,13 @@ public:
145 //! 145 //!
146 //! \param kelvin Unsigned integer value in Kelvin 146 //! \param kelvin Unsigned integer value in Kelvin
147 //! \return Unsigned integer value in Mired 147 //! \return Unsigned integer value in Mired
148 - unsigned int KelvinToMired(unsigned int kelvin) const; 148 + unsigned int kelvinToMired(unsigned int kelvin) const;
149 149
150 //! \brief Const function that converts Mired to Kelvin. 150 //! \brief Const function that converts Mired to Kelvin.
151 //! 151 //!
152 //! \param mired Unsigned integer value in Mired 152 //! \param mired Unsigned integer value in Mired
153 //! \return Unsigned integer value in Kelvin 153 //! \return Unsigned integer value in Kelvin
154 - unsigned int MiredToKelvin(unsigned int mired) const; 154 + unsigned int miredToKelvin(unsigned int mired) const;
155 155
156 //! \brief Function that sets the brightness of this light. 156 //! \brief Function that sets the brightness of this light.
157 //! 157 //!
@@ -524,8 +524,8 @@ public: @@ -524,8 +524,8 @@ public:
524 //! colors on current hue and saturation levels. Notice that none of the 524 //! colors on current hue and saturation levels. Notice that none of the
525 //! setter functions check whether this feature is enabled and the colorloop 525 //! setter functions check whether this feature is enabled and the colorloop
526 //! can only be disabled with this function or by simply calling 526 //! can only be disabled with this function or by simply calling
527 - //! Off()/OffNoRefresh() and then On()/OnNoRefresh(), so you could  
528 - //! alternatively call Off() and then use any of the setter functions. 527 + //! off() and then on(), so you could
  528 + //! alternatively call off() and then use any of the setter functions.
529 //! \param on bool that enables this feature when true and disables it when false 529 //! \param on bool that enables this feature when true and disables it when false
530 //! \return Bool that is true on success 530 //! \return Bool that is true on success
531 //! \throws std::system_error when system or socket operations fail 531 //! \throws std::system_error when system or socket operations fail
include/hueplusplus/SimpleColorHueStrategy.h
@@ -68,7 +68,7 @@ public: @@ -68,7 +68,7 @@ public:
68 //! of 100ms, 4 = 400ms and should be seen as the default \param light A 68 //! of 100ms, 4 = 400ms and should be seen as the default \param light A
69 //! reference of the light 69 //! reference of the light
70 bool setColorXY(const XYBrightness& xy, uint8_t transition, Light& light) const override; 70 bool setColorXY(const XYBrightness& xy, uint8_t transition, Light& light) const override;
71 - 71 +
72 //! \brief Function for turning on/off the color loop feature of a light. 72 //! \brief Function for turning on/off the color loop feature of a light.
73 //! 73 //!
74 //! Can be theoretically set for any light, but it only works for lights that 74 //! Can be theoretically set for any light, but it only works for lights that
@@ -76,8 +76,8 @@ public: @@ -76,8 +76,8 @@ public:
76 //! through every color on the current hue and saturation settings. Notice 76 //! through every color on the current hue and saturation settings. Notice
77 //! that none of the setter functions check whether this feature is enabled 77 //! that none of the setter functions check whether this feature is enabled
78 //! and the colorloop can only be disabled with this function or by simply 78 //! and the colorloop can only be disabled with this function or by simply
79 - //! calling Off()/OffNoRefresh() and then On()/OnNoRefresh(), so you could  
80 - //! alternatively call Off() and then use any of the setter functions. 79 + //! calling off() and then on(), so you could
  80 + //! alternatively call off() and then use any of the setter functions.
81 //! \param on Boolean to turn this feature on or off, true/1 for on and 81 //! \param on Boolean to turn this feature on or off, true/1 for on and
82 //! false/0 for off \param light A reference of the light 82 //! false/0 for off \param light A reference of the light
83 bool setColorLoop(bool on, Light& light) const override; 83 bool setColorLoop(bool on, Light& light) const override;
src/Bridge.cpp
@@ -39,7 +39,7 @@ namespace hueplusplus @@ -39,7 +39,7 @@ namespace hueplusplus
39 { 39 {
40 BridgeFinder::BridgeFinder(std::shared_ptr<const IHttpHandler> handler) : http_handler(std::move(handler)) { } 40 BridgeFinder::BridgeFinder(std::shared_ptr<const IHttpHandler> handler) : http_handler(std::move(handler)) { }
41 41
42 -std::vector<BridgeFinder::BridgeIdentification> BridgeFinder::FindBridges() const 42 +std::vector<BridgeFinder::BridgeIdentification> BridgeFinder::findBridges() const
43 { 43 {
44 UPnP uplug; 44 UPnP uplug;
45 std::vector<std::pair<std::string, std::string>> foundDevices = uplug.getDevices(http_handler); 45 std::vector<std::pair<std::string, std::string>> foundDevices = uplug.getDevices(http_handler);
@@ -58,10 +58,10 @@ std::vector&lt;BridgeFinder::BridgeIdentification&gt; BridgeFinder::FindBridges() cons @@ -58,10 +58,10 @@ std::vector&lt;BridgeFinder::BridgeIdentification&gt; BridgeFinder::FindBridges() cons
58 { 58 {
59 std::string desc 59 std::string desc
60 = http_handler->GETString("/description.xml", "application/xml", "", bridge.ip, bridge.port); 60 = http_handler->GETString("/description.xml", "application/xml", "", bridge.ip, bridge.port);
61 - std::string mac = ParseDescription(desc); 61 + std::string mac = parseDescription(desc);
62 if (!mac.empty()) 62 if (!mac.empty())
63 { 63 {
64 - bridge.mac = NormalizeMac(mac); 64 + bridge.mac = normalizeMac(mac);
65 foundBridges.push_back(std::move(bridge)); 65 foundBridges.push_back(std::move(bridge));
66 } 66 }
67 } 67 }
@@ -74,9 +74,9 @@ std::vector&lt;BridgeFinder::BridgeIdentification&gt; BridgeFinder::FindBridges() cons @@ -74,9 +74,9 @@ std::vector&lt;BridgeFinder::BridgeIdentification&gt; BridgeFinder::FindBridges() cons
74 return foundBridges; 74 return foundBridges;
75 } 75 }
76 76
77 -Bridge BridgeFinder::GetBridge(const BridgeIdentification& identification, bool sharedState) 77 +Bridge BridgeFinder::getBridge(const BridgeIdentification& identification, bool sharedState)
78 { 78 {
79 - std::string normalizedMac = NormalizeMac(identification.mac); 79 + std::string normalizedMac = normalizeMac(identification.mac);
80 auto pos = usernames.find(normalizedMac); 80 auto pos = usernames.find(normalizedMac);
81 auto key = clientkeys.find(normalizedMac); 81 auto key = clientkeys.find(normalizedMac);
82 if (pos != usernames.end()) 82 if (pos != usernames.end())
@@ -92,35 +92,35 @@ Bridge BridgeFinder::GetBridge(const BridgeIdentification&amp; identification, bool @@ -92,35 +92,35 @@ Bridge BridgeFinder::GetBridge(const BridgeIdentification&amp; identification, bool
92 std::chrono::seconds(10), sharedState); 92 std::chrono::seconds(10), sharedState);
93 } 93 }
94 } 94 }
95 - Bridge bridge(identification.ip, identification.port, "", http_handler, std::chrono::seconds(10), sharedState); 95 + Bridge bridge(identification.ip, identification.port, "", http_handler, "", std::chrono::seconds(10), sharedState);
96 bridge.requestUsername(); 96 bridge.requestUsername();
97 if (bridge.getUsername().empty()) 97 if (bridge.getUsername().empty())
98 { 98 {
99 std::cerr << "Failed to request username for ip " << identification.ip << std::endl; 99 std::cerr << "Failed to request username for ip " << identification.ip << std::endl;
100 throw HueException(CURRENT_FILE_INFO, "Failed to request username!"); 100 throw HueException(CURRENT_FILE_INFO, "Failed to request username!");
101 } 101 }
102 - AddUsername(normalizedMac, bridge.getUsername());  
103 - AddClientKey(normalizedMac, bridge.getClientKey()); 102 + addUsername(normalizedMac, bridge.getUsername());
  103 + addClientKey(normalizedMac, bridge.getClientKey());
104 104
105 return bridge; 105 return bridge;
106 } 106 }
107 107
108 -void BridgeFinder::AddUsername(const std::string& mac, const std::string& username) 108 +void BridgeFinder::addUsername(const std::string& mac, const std::string& username)
109 { 109 {
110 - usernames[NormalizeMac(mac)] = username; 110 + usernames[normalizeMac(mac)] = username;
111 } 111 }
112 112
113 -void BridgeFinder::AddClientKey(const std::string& mac, const std::string& clientkey) 113 +void BridgeFinder::addClientKey(const std::string& mac, const std::string& clientkey)
114 { 114 {
115 - clientkeys[NormalizeMac(mac)] = clientkey; 115 + clientkeys[normalizeMac(mac)] = clientkey;
116 } 116 }
117 117
118 -const std::map<std::string, std::string>& BridgeFinder::GetAllUsernames() const 118 +const std::map<std::string, std::string>& BridgeFinder::getAllUsernames() const
119 { 119 {
120 return usernames; 120 return usernames;
121 } 121 }
122 122
123 -std::string BridgeFinder::NormalizeMac(std::string input) 123 +std::string BridgeFinder::normalizeMac(std::string input)
124 { 124 {
125 // Remove any non alphanumeric characters (e.g. ':' and whitespace) 125 // Remove any non alphanumeric characters (e.g. ':' and whitespace)
126 input.erase(std::remove_if(input.begin(), input.end(), [](char c) { return !std::isalnum(c, std::locale()); }), 126 input.erase(std::remove_if(input.begin(), input.end(), [](char c) { return !std::isalnum(c, std::locale()); }),
@@ -130,7 +130,7 @@ std::string BridgeFinder::NormalizeMac(std::string input) @@ -130,7 +130,7 @@ std::string BridgeFinder::NormalizeMac(std::string input)
130 return input; 130 return input;
131 } 131 }
132 132
133 -std::string BridgeFinder::ParseDescription(const std::string& description) 133 +std::string BridgeFinder::parseDescription(const std::string& description)
134 { 134 {
135 const char* model = "<modelName>Philips hue bridge"; 135 const char* model = "<modelName>Philips hue bridge";
136 const char* serialBegin = "<serialNumber>"; 136 const char* serialBegin = "<serialNumber>";
@@ -248,7 +248,7 @@ std::string Bridge::requestUsername() @@ -248,7 +248,7 @@ std::string Bridge::requestUsername()
248 return username; 248 return username;
249 } 249 }
250 250
251 -bool Bridge::StartStreaming(std::string group_identifier) 251 +bool Bridge::startStreaming(std::string group_identifier)
252 { 252 {
253 if (clientkey.empty()) 253 if (clientkey.empty())
254 { 254 {
@@ -271,7 +271,7 @@ bool Bridge::StartStreaming(std::string group_identifier) @@ -271,7 +271,7 @@ bool Bridge::StartStreaming(std::string group_identifier)
271 return success == true; 271 return success == true;
272 } 272 }
273 273
274 -bool Bridge::StopStreaming(std::string group_identifier) 274 +bool Bridge::stopStreaming(std::string group_identifier)
275 { 275 {
276 nlohmann::json request; 276 nlohmann::json request;
277 277
src/EntertainmentMode.cpp
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 \file EntertainmentMode.cpp 2 \file EntertainmentMode.cpp
3 Copyright Notice\n 3 Copyright Notice\n
4 Copyright (C) 2020 Adam Honse - developer\n 4 Copyright (C) 2020 Adam Honse - developer\n
  5 + Copyright (C) 2021 Moritz Wirger - developer\n
5 6
6 This file is part of hueplusplus. 7 This file is part of hueplusplus.
7 8
@@ -45,7 +46,7 @@ struct TLSContext @@ -45,7 +46,7 @@ struct TLSContext
45 mbedtls_timing_delay_context timer; 46 mbedtls_timing_delay_context timer;
46 }; 47 };
47 48
48 -std::vector<char> HexToBytes(const std::string& hex) 49 +std::vector<char> hexToBytes(const std::string& hex)
49 { 50 {
50 std::vector<char> bytes; 51 std::vector<char> bytes;
51 52
@@ -65,7 +66,7 @@ EntertainmentMode::EntertainmentMode(Bridge&amp; b, Group&amp; g) @@ -65,7 +66,7 @@ EntertainmentMode::EntertainmentMode(Bridge&amp; b, Group&amp; g)
65 /*-------------------------------------------------*\ 66 /*-------------------------------------------------*\
66 | Signal the bridge to start streaming | 67 | Signal the bridge to start streaming |
67 \*-------------------------------------------------*/ 68 \*-------------------------------------------------*/
68 - bridge->StartStreaming(std::to_string(group->getId())); 69 + bridge->startStreaming(std::to_string(group->getId()));
69 70
70 /*-------------------------------------------------*\ 71 /*-------------------------------------------------*\
71 | Get the number of lights from the group | 72 | Get the number of lights from the group |
@@ -139,13 +140,13 @@ EntertainmentMode::~EntertainmentMode() @@ -139,13 +140,13 @@ EntertainmentMode::~EntertainmentMode()
139 mbedtls_net_free(&tls_context->server_fd); 140 mbedtls_net_free(&tls_context->server_fd);
140 } 141 }
141 142
142 -bool EntertainmentMode::Connect() 143 +bool EntertainmentMode::connect()
143 { 144 {
144 /*-------------------------------------------------*\ 145 /*-------------------------------------------------*\
145 | Signal the bridge to start streaming | 146 | Signal the bridge to start streaming |
146 | If successful, connect to the UDP port | 147 | If successful, connect to the UDP port |
147 \*-------------------------------------------------*/ 148 \*-------------------------------------------------*/
148 - if (bridge->StartStreaming(std::to_string(group->getId()))) 149 + if (bridge->startStreaming(std::to_string(group->getId())))
149 { 150 {
150 /*-------------------------------------------------*\ 151 /*-------------------------------------------------*\
151 | Connect to the Hue bridge UDP server | 152 | Connect to the Hue bridge UDP server |
@@ -159,7 +160,7 @@ bool EntertainmentMode::Connect() @@ -159,7 +160,7 @@ bool EntertainmentMode::Connect()
159 if (ret != 0) 160 if (ret != 0)
160 { 161 {
161 mbedtls_ssl_close_notify(&tls_context->ssl); 162 mbedtls_ssl_close_notify(&tls_context->ssl);
162 - bridge->StopStreaming(std::to_string(group->getId())); 163 + bridge->stopStreaming(std::to_string(group->getId()));
163 return false; 164 return false;
164 } 165 }
165 166
@@ -175,7 +176,7 @@ bool EntertainmentMode::Connect() @@ -175,7 +176,7 @@ bool EntertainmentMode::Connect()
175 if (ret != 0) 176 if (ret != 0)
176 { 177 {
177 mbedtls_ssl_close_notify(&tls_context->ssl); 178 mbedtls_ssl_close_notify(&tls_context->ssl);
178 - bridge->StopStreaming(std::to_string(group->getId())); 179 + bridge->stopStreaming(std::to_string(group->getId()));
179 return false; 180 return false;
180 } 181 }
181 182
@@ -186,7 +187,7 @@ bool EntertainmentMode::Connect() @@ -186,7 +187,7 @@ bool EntertainmentMode::Connect()
186 /*-------------------------------------------------*\ 187 /*-------------------------------------------------*\
187 | Convert client key to binary array | 188 | Convert client key to binary array |
188 \*-------------------------------------------------*/ 189 \*-------------------------------------------------*/
189 - std::vector<char> psk_binary = HexToBytes(bridge->getClientKey()); 190 + std::vector<char> psk_binary = hexToBytes(bridge->getClientKey());
190 191
191 /*-------------------------------------------------*\ 192 /*-------------------------------------------------*\
192 | Configure SSL pre-shared key and identity | 193 | Configure SSL pre-shared key and identity |
@@ -202,7 +203,7 @@ bool EntertainmentMode::Connect() @@ -202,7 +203,7 @@ bool EntertainmentMode::Connect()
202 if (ret != 0) 203 if (ret != 0)
203 { 204 {
204 mbedtls_ssl_close_notify(&tls_context->ssl); 205 mbedtls_ssl_close_notify(&tls_context->ssl);
205 - bridge->StopStreaming(std::to_string(group->getId())); 206 + bridge->stopStreaming(std::to_string(group->getId()));
206 return false; 207 return false;
207 } 208 }
208 209
@@ -217,7 +218,7 @@ bool EntertainmentMode::Connect() @@ -217,7 +218,7 @@ bool EntertainmentMode::Connect()
217 if (ret != 0) 218 if (ret != 0)
218 { 219 {
219 mbedtls_ssl_close_notify(&tls_context->ssl); 220 mbedtls_ssl_close_notify(&tls_context->ssl);
220 - bridge->StopStreaming(std::to_string(group->getId())); 221 + bridge->stopStreaming(std::to_string(group->getId()));
221 return false; 222 return false;
222 } 223 }
223 224
@@ -229,7 +230,7 @@ bool EntertainmentMode::Connect() @@ -229,7 +230,7 @@ bool EntertainmentMode::Connect()
229 if (ret != 0) 230 if (ret != 0)
230 { 231 {
231 mbedtls_ssl_close_notify(&tls_context->ssl); 232 mbedtls_ssl_close_notify(&tls_context->ssl);
232 - bridge->StopStreaming(std::to_string(group->getId())); 233 + bridge->stopStreaming(std::to_string(group->getId()));
233 return false; 234 return false;
234 } 235 }
235 236
@@ -252,7 +253,7 @@ bool EntertainmentMode::Connect() @@ -252,7 +253,7 @@ bool EntertainmentMode::Connect()
252 if (ret != 0) 253 if (ret != 0)
253 { 254 {
254 mbedtls_ssl_close_notify(&tls_context->ssl); 255 mbedtls_ssl_close_notify(&tls_context->ssl);
255 - bridge->StopStreaming(std::to_string(group->getId())); 256 + bridge->stopStreaming(std::to_string(group->getId()));
256 return false; 257 return false;
257 } 258 }
258 259
@@ -264,13 +265,13 @@ bool EntertainmentMode::Connect() @@ -264,13 +265,13 @@ bool EntertainmentMode::Connect()
264 } 265 }
265 } 266 }
266 267
267 -bool EntertainmentMode::Disconnect() 268 +bool EntertainmentMode::disconnect()
268 { 269 {
269 mbedtls_ssl_close_notify(&tls_context->ssl); 270 mbedtls_ssl_close_notify(&tls_context->ssl);
270 - return bridge->StopStreaming(std::to_string(group->getId())); 271 + return bridge->stopStreaming(std::to_string(group->getId()));
271 } 272 }
272 273
273 -bool EntertainmentMode::SetColorRGB(uint8_t light_index, uint8_t red, uint8_t green, uint8_t blue) 274 +bool EntertainmentMode::setColorRGB(uint8_t light_index, uint8_t red, uint8_t green, uint8_t blue)
274 { 275 {
275 if (light_index < entertainment_num_lights) 276 if (light_index < entertainment_num_lights)
276 { 277 {
@@ -291,7 +292,7 @@ bool EntertainmentMode::SetColorRGB(uint8_t light_index, uint8_t red, uint8_t gr @@ -291,7 +292,7 @@ bool EntertainmentMode::SetColorRGB(uint8_t light_index, uint8_t red, uint8_t gr
291 } 292 }
292 } 293 }
293 294
294 -bool EntertainmentMode::Update() 295 +bool EntertainmentMode::update()
295 { 296 {
296 int ret; 297 int ret;
297 unsigned int total = 0; 298 unsigned int total = 0;
src/Light.cpp
@@ -20,24 +20,23 @@ @@ -20,24 +20,23 @@
20 along with hueplusplus. If not, see <http://www.gnu.org/licenses/>. 20 along with hueplusplus. If not, see <http://www.gnu.org/licenses/>.
21 **/ 21 **/
22 22
23 -#include "hueplusplus/Light.h"  
24 -  
25 #include <cmath> 23 #include <cmath>
26 #include <iostream> 24 #include <iostream>
27 #include <thread> 25 #include <thread>
28 26
29 #include "hueplusplus/HueExceptionMacro.h" 27 #include "hueplusplus/HueExceptionMacro.h"
  28 +#include "hueplusplus/Light.h"
30 #include "hueplusplus/Utils.h" 29 #include "hueplusplus/Utils.h"
31 #include "json/json.hpp" 30 #include "json/json.hpp"
32 31
33 namespace hueplusplus 32 namespace hueplusplus
34 { 33 {
35 -bool Light::On(uint8_t transition) 34 +bool Light::on(uint8_t transition)
36 { 35 {
37 return transaction().setOn(true).setTransition(transition).commit(); 36 return transaction().setOn(true).setTransition(transition).commit();
38 } 37 }
39 38
40 -bool Light::Off(uint8_t transition) 39 +bool Light::off(uint8_t transition)
41 { 40 {
42 return transaction().setOn(false).setTransition(transition).commit(); 41 return transaction().setOn(false).setTransition(transition).commit();
43 } 42 }
@@ -91,12 +90,12 @@ ColorGamut Light::getColorGamut() const @@ -91,12 +90,12 @@ ColorGamut Light::getColorGamut() const
91 } 90 }
92 } 91 }
93 92
94 -unsigned int Light::KelvinToMired(unsigned int kelvin) const 93 +unsigned int Light::kelvinToMired(unsigned int kelvin) const
95 { 94 {
96 return int(0.5f + (1000000 / kelvin)); 95 return int(0.5f + (1000000 / kelvin));
97 } 96 }
98 97
99 -unsigned int Light::MiredToKelvin(unsigned int mired) const 98 +unsigned int Light::miredToKelvin(unsigned int mired) const
100 { 99 {
101 return int(0.5f + (1000000 / mired)); 100 return int(0.5f + (1000000 / mired));
102 } 101 }
test/mocks/mock_Light.h
@@ -38,16 +38,16 @@ class MockLight : public hueplusplus::Light @@ -38,16 +38,16 @@ class MockLight : public hueplusplus::Light
38 public: 38 public:
39 MockLight(std::shared_ptr<const hueplusplus::IHttpHandler> handler) 39 MockLight(std::shared_ptr<const hueplusplus::IHttpHandler> handler)
40 : Light(1, hueplusplus::HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), nullptr, 40 : Light(1, hueplusplus::HueCommandAPI(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler), nullptr,
41 - nullptr, nullptr, std::chrono::steady_clock::duration::max(), nullptr) 41 + nullptr, nullptr, std::chrono::steady_clock::duration::max(), nullptr)
42 { 42 {
43 // Set refresh duration to max, so random refreshes do not hinder the test setups 43 // Set refresh duration to max, so random refreshes do not hinder the test setups
44 } 44 }
45 45
46 nlohmann::json& getState() { return state.getValue(); } 46 nlohmann::json& getState() { return state.getValue(); }
47 47
48 - MOCK_METHOD1(On, bool(uint8_t transition)); 48 + MOCK_METHOD1(on, bool(uint8_t transition));
49 49
50 - MOCK_METHOD1(Off, bool(uint8_t transition)); 50 + MOCK_METHOD1(off, bool(uint8_t transition));
51 51
52 MOCK_METHOD0(isOn, bool()); 52 MOCK_METHOD0(isOn, bool());
53 53
@@ -124,7 +124,7 @@ public: @@ -124,7 +124,7 @@ public:
124 MOCK_METHOD1(setColorLoop, bool(bool on)); 124 MOCK_METHOD1(setColorLoop, bool(bool on));
125 125
126 MOCK_METHOD3(sendPutRequest, 126 MOCK_METHOD3(sendPutRequest,
127 - nlohmann::json(const std::string& subPath, const nlohmann::json& request,hueplusplus::FileInfo fileInfo)); 127 + nlohmann::json(const std::string& subPath, const nlohmann::json& request, hueplusplus::FileInfo fileInfo));
128 }; 128 };
129 129
130 #endif 130 #endif
test/test_Bridge.cpp
@@ -62,10 +62,10 @@ protected: @@ -62,10 +62,10 @@ protected:
62 ~BridgeFinderTest() {}; 62 ~BridgeFinderTest() {};
63 }; 63 };
64 64
65 -TEST_F(BridgeFinderTest, FindBridges) 65 +TEST_F(BridgeFinderTest, findBridges)
66 { 66 {
67 BridgeFinder finder(handler); 67 BridgeFinder finder(handler);
68 - std::vector<BridgeFinder::BridgeIdentification> bridges = finder.FindBridges(); 68 + std::vector<BridgeFinder::BridgeIdentification> bridges = finder.findBridges();
69 69
70 BridgeFinder::BridgeIdentification bridge_to_comp; 70 BridgeFinder::BridgeIdentification bridge_to_comp;
71 bridge_to_comp.ip = getBridgeIp(); 71 bridge_to_comp.ip = getBridgeIp();
@@ -81,11 +81,11 @@ TEST_F(BridgeFinderTest, FindBridges) @@ -81,11 +81,11 @@ TEST_F(BridgeFinderTest, FindBridges)
81 EXPECT_CALL(*handler, GETString("/description.xml", "application/xml", "", getBridgeIp(), getBridgePort())) 81 EXPECT_CALL(*handler, GETString("/description.xml", "application/xml", "", getBridgeIp(), getBridgePort()))
82 .Times(1) 82 .Times(1)
83 .WillOnce(::testing::Return("invalid stuff")); 83 .WillOnce(::testing::Return("invalid stuff"));
84 - bridges = finder.FindBridges(); 84 + bridges = finder.findBridges();
85 EXPECT_TRUE(bridges.empty()); 85 EXPECT_TRUE(bridges.empty());
86 } 86 }
87 87
88 -TEST_F(BridgeFinderTest, GetBridge) 88 +TEST_F(BridgeFinderTest, getBridge)
89 { 89 {
90 using namespace ::testing; 90 using namespace ::testing;
91 nlohmann::json request {{"devicetype", "HuePlusPlus#User"}, {"generateclientkey", true}}; 91 nlohmann::json request {{"devicetype", "HuePlusPlus#User"}, {"generateclientkey", true}};
@@ -98,9 +98,9 @@ TEST_F(BridgeFinderTest, GetBridge) @@ -98,9 +98,9 @@ TEST_F(BridgeFinderTest, GetBridge)
98 .WillRepeatedly(Return(errorResponse)); 98 .WillRepeatedly(Return(errorResponse));
99 99
100 BridgeFinder finder(handler); 100 BridgeFinder finder(handler);
101 - std::vector<BridgeFinder::BridgeIdentification> bridges = finder.FindBridges(); 101 + std::vector<BridgeFinder::BridgeIdentification> bridges = finder.findBridges();
102 102
103 - ASSERT_THROW(finder.GetBridge(bridges[0]), HueException); 103 + ASSERT_THROW(finder.getBridge(bridges[0]), HueException);
104 104
105 nlohmann::json successResponse = {{{"success", {{"username", getBridgeUsername()}}}}}; 105 nlohmann::json successResponse = {{{"success", {{"username", getBridgeUsername()}}}}};
106 106
@@ -109,9 +109,9 @@ TEST_F(BridgeFinderTest, GetBridge) @@ -109,9 +109,9 @@ TEST_F(BridgeFinderTest, GetBridge)
109 .WillOnce(Return(successResponse)); 109 .WillOnce(Return(successResponse));
110 110
111 finder = BridgeFinder(handler); 111 finder = BridgeFinder(handler);
112 - bridges = finder.FindBridges(); 112 + bridges = finder.findBridges();
113 113
114 - Bridge test_bridge = finder.GetBridge(bridges[0]); 114 + Bridge test_bridge = finder.getBridge(bridges[0]);
115 115
116 EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching"; 116 EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching";
117 EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching"; 117 EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching";
@@ -120,27 +120,27 @@ TEST_F(BridgeFinderTest, GetBridge) @@ -120,27 +120,27 @@ TEST_F(BridgeFinderTest, GetBridge)
120 Mock::VerifyAndClearExpectations(handler.get()); 120 Mock::VerifyAndClearExpectations(handler.get());
121 } 121 }
122 122
123 -TEST_F(BridgeFinderTest, AddUsername) 123 +TEST_F(BridgeFinderTest, addUsername)
124 { 124 {
125 BridgeFinder finder(handler); 125 BridgeFinder finder(handler);
126 - std::vector<BridgeFinder::BridgeIdentification> bridges = finder.FindBridges(); 126 + std::vector<BridgeFinder::BridgeIdentification> bridges = finder.findBridges();
127 127
128 - finder.AddUsername(bridges[0].mac, getBridgeUsername());  
129 - Bridge test_bridge = finder.GetBridge(bridges[0]); 128 + finder.addUsername(bridges[0].mac, getBridgeUsername());
  129 + Bridge test_bridge = finder.getBridge(bridges[0]);
130 130
131 EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching"; 131 EXPECT_EQ(test_bridge.getBridgeIP(), getBridgeIp()) << "Bridge IP not matching";
132 EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching"; 132 EXPECT_EQ(test_bridge.getBridgePort(), getBridgePort()) << "Bridge Port not matching";
133 EXPECT_EQ(test_bridge.getUsername(), getBridgeUsername()) << "Bridge username not matching"; 133 EXPECT_EQ(test_bridge.getUsername(), getBridgeUsername()) << "Bridge username not matching";
134 } 134 }
135 135
136 -TEST_F(BridgeFinderTest, GetAllUsernames) 136 +TEST_F(BridgeFinderTest, getAllUsernames)
137 { 137 {
138 BridgeFinder finder(handler); 138 BridgeFinder finder(handler);
139 - std::vector<BridgeFinder::BridgeIdentification> bridges = finder.FindBridges(); 139 + std::vector<BridgeFinder::BridgeIdentification> bridges = finder.findBridges();
140 140
141 - finder.AddUsername(bridges[0].mac, getBridgeUsername()); 141 + finder.addUsername(bridges[0].mac, getBridgeUsername());
142 142
143 - std::map<std::string, std::string> users = finder.GetAllUsernames(); 143 + std::map<std::string, std::string> users = finder.getAllUsernames();
144 EXPECT_EQ(users[getBridgeMac()], getBridgeUsername()) << "Username of MAC:" << getBridgeMac() << "not matching"; 144 EXPECT_EQ(users[getBridgeMac()], getBridgeUsername()) << "Username of MAC:" << getBridgeMac() << "not matching";
145 } 145 }
146 146
@@ -299,7 +299,8 @@ TEST(Bridge, SharedState) @@ -299,7 +299,8 @@ TEST(Bridge, SharedState)
299 *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort())) 299 *handler, GETJson("/api/" + getBridgeUsername(), nlohmann::json::object(), getBridgeIp(), getBridgePort()))
300 .Times(1) 300 .Times(1)
301 .WillOnce(Return(hue_bridge_state)); 301 .WillOnce(Return(hue_bridge_state));
302 - Bridge test_bridge(getBridgeIp(), getBridgePort(), getBridgeUsername(), handler, std::chrono::seconds(10), true); 302 + Bridge test_bridge(
  303 + getBridgeIp(), getBridgePort(), getBridgeUsername(), handler, "", std::chrono::seconds(10), true);
303 304
304 // Test when correct data is sent 305 // Test when correct data is sent
305 Light test_light_1 = test_bridge.lights().get(1); 306 Light test_light_1 = test_bridge.lights().get(1);
test/test_Light.cpp
@@ -89,7 +89,7 @@ TEST_F(HueLightTest, Constructor) @@ -89,7 +89,7 @@ TEST_F(HueLightTest, Constructor)
89 Light test_light_3 = test_bridge.lights().get(3); 89 Light test_light_3 = test_bridge.lights().get(3);
90 } 90 }
91 91
92 -TEST_F(HueLightTest, On) 92 +TEST_F(HueLightTest, on)
93 { 93 {
94 using namespace ::testing; 94 using namespace ::testing;
95 EXPECT_CALL(*handler, PUTJson("/api/" + getBridgeUsername() + "/lights/2/state", _, getBridgeIp(), 80)) 95 EXPECT_CALL(*handler, PUTJson("/api/" + getBridgeUsername() + "/lights/2/state", _, getBridgeIp(), 80))
@@ -112,12 +112,12 @@ TEST_F(HueLightTest, On) @@ -112,12 +112,12 @@ TEST_F(HueLightTest, On)
112 Light test_light_2 = test_bridge.lights().get(2); 112 Light test_light_2 = test_bridge.lights().get(2);
113 Light test_light_3 = test_bridge.lights().get(3); 113 Light test_light_3 = test_bridge.lights().get(3);
114 114
115 - EXPECT_EQ(true, test_light_1.On(33));  
116 - EXPECT_EQ(false, test_light_2.On());  
117 - EXPECT_EQ(true, test_light_3.On(255)); 115 + EXPECT_EQ(true, test_light_1.on(33));
  116 + EXPECT_EQ(false, test_light_2.on());
  117 + EXPECT_EQ(true, test_light_3.on(255));
118 } 118 }
119 119
120 -TEST_F(HueLightTest, Off) 120 +TEST_F(HueLightTest, off)
121 { 121 {
122 using namespace ::testing; 122 using namespace ::testing;
123 nlohmann::json prep_ret; 123 nlohmann::json prep_ret;
@@ -136,9 +136,9 @@ TEST_F(HueLightTest, Off) @@ -136,9 +136,9 @@ TEST_F(HueLightTest, Off)
136 Light test_light_2 = test_bridge.lights().get(2); 136 Light test_light_2 = test_bridge.lights().get(2);
137 Light test_light_3 = test_bridge.lights().get(3); 137 Light test_light_3 = test_bridge.lights().get(3);
138 138
139 - EXPECT_EQ(true, test_light_1.Off(33));  
140 - EXPECT_EQ(true, test_light_2.Off());  
141 - EXPECT_EQ(true, test_light_3.Off(255)); 139 + EXPECT_EQ(true, test_light_1.off(33));
  140 + EXPECT_EQ(true, test_light_2.off());
  141 + EXPECT_EQ(true, test_light_3.off(255));
142 } 142 }
143 143
144 TEST_F(HueLightTest, isOn) 144 TEST_F(HueLightTest, isOn)
@@ -362,7 +362,7 @@ TEST_F(HueLightTest, getColorType) @@ -362,7 +362,7 @@ TEST_F(HueLightTest, getColorType)
362 EXPECT_EQ(ColorType::GAMUT_C_TEMPERATURE, test_light_3.getColorType()); 362 EXPECT_EQ(ColorType::GAMUT_C_TEMPERATURE, test_light_3.getColorType());
363 } 363 }
364 364
365 -TEST_F(HueLightTest, KelvinToMired) 365 +TEST_F(HueLightTest, kelvinToMired)
366 { 366 {
367 const Light ctest_light_1 = test_bridge.lights().get(1); 367 const Light ctest_light_1 = test_bridge.lights().get(1);
368 const Light ctest_light_2 = test_bridge.lights().get(2); 368 const Light ctest_light_2 = test_bridge.lights().get(2);
@@ -371,15 +371,15 @@ TEST_F(HueLightTest, KelvinToMired) @@ -371,15 +371,15 @@ TEST_F(HueLightTest, KelvinToMired)
371 Light test_light_2 = test_bridge.lights().get(2); 371 Light test_light_2 = test_bridge.lights().get(2);
372 Light test_light_3 = test_bridge.lights().get(3); 372 Light test_light_3 = test_bridge.lights().get(3);
373 373
374 - EXPECT_EQ(10000, ctest_light_1.KelvinToMired(100));  
375 - EXPECT_EQ(500, ctest_light_2.KelvinToMired(2000));  
376 - EXPECT_EQ(303, ctest_light_3.KelvinToMired(3300));  
377 - EXPECT_EQ(250, test_light_1.KelvinToMired(4000));  
378 - EXPECT_EQ(200, test_light_2.KelvinToMired(5000));  
379 - EXPECT_EQ(166, test_light_3.KelvinToMired(6000)); 374 + EXPECT_EQ(10000, ctest_light_1.kelvinToMired(100));
  375 + EXPECT_EQ(500, ctest_light_2.kelvinToMired(2000));
  376 + EXPECT_EQ(303, ctest_light_3.kelvinToMired(3300));
  377 + EXPECT_EQ(250, test_light_1.kelvinToMired(4000));
  378 + EXPECT_EQ(200, test_light_2.kelvinToMired(5000));
  379 + EXPECT_EQ(166, test_light_3.kelvinToMired(6000));
380 } 380 }
381 381
382 -TEST_F(HueLightTest, MiredToKelvin) 382 +TEST_F(HueLightTest, miredToKelvin)
383 { 383 {
384 const Light ctest_light_1 = test_bridge.lights().get(1); 384 const Light ctest_light_1 = test_bridge.lights().get(1);
385 const Light ctest_light_2 = test_bridge.lights().get(2); 385 const Light ctest_light_2 = test_bridge.lights().get(2);
@@ -388,12 +388,12 @@ TEST_F(HueLightTest, MiredToKelvin) @@ -388,12 +388,12 @@ TEST_F(HueLightTest, MiredToKelvin)
388 Light test_light_2 = test_bridge.lights().get(2); 388 Light test_light_2 = test_bridge.lights().get(2);
389 Light test_light_3 = test_bridge.lights().get(3); 389 Light test_light_3 = test_bridge.lights().get(3);
390 390
391 - EXPECT_EQ(100, ctest_light_1.MiredToKelvin(10000));  
392 - EXPECT_EQ(2000, ctest_light_2.MiredToKelvin(500));  
393 - EXPECT_EQ(3300, ctest_light_3.MiredToKelvin(303));  
394 - EXPECT_EQ(4000, test_light_1.MiredToKelvin(250));  
395 - EXPECT_EQ(5000, test_light_2.MiredToKelvin(200));  
396 - EXPECT_EQ(6024, test_light_3.MiredToKelvin(166)); // 6000 kelvin should be 166 mired, but keep in 391 + EXPECT_EQ(100, ctest_light_1.miredToKelvin(10000));
  392 + EXPECT_EQ(2000, ctest_light_2.miredToKelvin(500));
  393 + EXPECT_EQ(3300, ctest_light_3.miredToKelvin(303));
  394 + EXPECT_EQ(4000, test_light_1.miredToKelvin(250));
  395 + EXPECT_EQ(5000, test_light_2.miredToKelvin(200));
  396 + EXPECT_EQ(6024, test_light_3.miredToKelvin(166)); // 6000 kelvin should be 166 mired, but keep in
397 // mind flops are not exact 397 // mind flops are not exact
398 } 398 }
399 399
test/test_LightFactory.cpp
@@ -20,9 +20,10 @@ @@ -20,9 +20,10 @@
20 along with hueplusplus. If not, see <http://www.gnu.org/licenses/>. 20 along with hueplusplus. If not, see <http://www.gnu.org/licenses/>.
21 **/ 21 **/
22 22
23 -#include <gtest/gtest.h>  
24 #include <hueplusplus/HueDeviceTypes.h> 23 #include <hueplusplus/HueDeviceTypes.h>
25 24
  25 +#include <gtest/gtest.h>
  26 +
26 #include "testhelper.h" 27 #include "testhelper.h"
27 28
28 #include "mocks/mock_HttpHandler.h" 29 #include "mocks/mock_HttpHandler.h"
@@ -70,12 +71,12 @@ TEST(LightFactory, createLight_gamutCapabilities) @@ -70,12 +71,12 @@ TEST(LightFactory, createLight_gamutCapabilities)
70 std::chrono::steady_clock::duration::max()); 71 std::chrono::steady_clock::duration::max());
71 72
72 nlohmann::json lightState 73 nlohmann::json lightState
73 - = { {"state", 74 + = {{"state",
74 {{"on", true}, {"bri", 254}, {"ct", 366}, {"alert", "none"}, {"colormode", "ct"}, {"reachable", true}}}, 75 {{"on", true}, {"bri", 254}, {"ct", 366}, {"alert", "none"}, {"colormode", "ct"}, {"reachable", true}}},
75 {"swupdate", {{"state", "noupdates"}, {"lastinstall", nullptr}}}, {"type", "Color light"}, 76 {"swupdate", {{"state", "noupdates"}, {"lastinstall", nullptr}}}, {"type", "Color light"},
76 {"name", "Hue ambiance lamp 1"}, {"modelid", "LTW001"}, {"manufacturername", "Philips"}, 77 {"name", "Hue ambiance lamp 1"}, {"modelid", "LTW001"}, {"manufacturername", "Philips"},
77 {"uniqueid", "00:00:00:00:00:00:00:00-00"}, {"swversion", "5.50.1.19085"}, 78 {"uniqueid", "00:00:00:00:00:00:00:00-00"}, {"swversion", "5.50.1.19085"},
78 - {"capabilities", {{"control", {{"colorgamuttype", "A"}}}}} }; 79 + {"capabilities", {{"control", {{"colorgamuttype", "A"}}}}}};
79 80
80 Light test_light_1 = factory.createLight(lightState, 1); 81 Light test_light_1 = factory.createLight(lightState, 1);
81 EXPECT_EQ(test_light_1.getColorType(), ColorType::GAMUT_A); 82 EXPECT_EQ(test_light_1.getColorType(), ColorType::GAMUT_A);
test/test_Scene.cpp
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 using namespace hueplusplus; 30 using namespace hueplusplus;
31 using namespace testing; 31 using namespace testing;
32 32
33 -TEST(LightState, On) 33 +TEST(LightState, on)
34 { 34 {
35 EXPECT_FALSE(LightState(nlohmann::json::object()).isOn()); 35 EXPECT_FALSE(LightState(nlohmann::json::object()).isOn());
36 EXPECT_TRUE(LightState(nlohmann::json {{"on", true}}).isOn()); 36 EXPECT_TRUE(LightState(nlohmann::json {{"on", true}}).isOn());
@@ -141,7 +141,7 @@ public: @@ -141,7 +141,7 @@ public:
141 {{"3", {{"on", false}, {"bri", 100}, {"xy", {0.3, 0.2}}}}, 141 {{"3", {{"on", false}, {"bri", 100}, {"xy", {0.3, 0.2}}}},
142 {"4", {{"on", true}, {"bri", 200}, {"xy", {0.3, 0.2}}, {"effect", "colorloop"}}}, 142 {"4", {{"on", true}, {"bri", 200}, {"xy", {0.3, 0.2}}, {"effect", "colorloop"}}},
143 {"5", {{"on", true}, {"bri", 100}, {"xy", {0.3, 0.2}}}}}}}) 143 {"5", {{"on", true}, {"bri", 100}, {"xy", {0.3, 0.2}}}}}}})
144 - {} 144 + { }
145 145
146 void expectGetState(const std::string& id) 146 void expectGetState(const std::string& id)
147 { 147 {
test/test_Sensor.cpp
@@ -72,7 +72,7 @@ TEST(Alert, alertToString) @@ -72,7 +72,7 @@ TEST(Alert, alertToString)
72 EXPECT_EQ("lselect", alertToString(Alert::lselect)); 72 EXPECT_EQ("lselect", alertToString(Alert::lselect));
73 } 73 }
74 74
75 -TEST_F(SensorTest, On) 75 +TEST_F(SensorTest, on)
76 { 76 {
77 EXPECT_FALSE(getSensor().hasOn()); 77 EXPECT_FALSE(getSensor().hasOn());
78 state["config"]["on"] = true; 78 state["config"]["on"] = true;
test/test_SensorImpls.cpp
@@ -159,7 +159,7 @@ class CLIPGenericFlagTest : public SensorImplTest&lt;CLIPGenericFlag&gt; @@ -159,7 +159,7 @@ class CLIPGenericFlagTest : public SensorImplTest&lt;CLIPGenericFlag&gt;
159 class CLIPGenericStatusTest : public SensorImplTest<CLIPGenericStatus> 159 class CLIPGenericStatusTest : public SensorImplTest<CLIPGenericStatus>
160 { }; 160 { };
161 161
162 -TYPED_TEST(SensorOnTest, On) 162 +TYPED_TEST(SensorOnTest, on)
163 { 163 {
164 this->state["config"]["on"] = false; 164 this->state["config"]["on"] = false;
165 EXPECT_FALSE(this->getSensor().isOn()); 165 EXPECT_FALSE(this->getSensor().isOn());
test/test_SimpleColorTemperatureStrategy.cpp
@@ -102,7 +102,7 @@ TEST(SimpleColorTemperatureStrategy, alertTemperature) @@ -102,7 +102,7 @@ TEST(SimpleColorTemperatureStrategy, alertTemperature)
102 light.getState()["state"]["on"] = false; 102 light.getState()["state"]["on"] = false;
103 EXPECT_EQ(false, SimpleColorTemperatureStrategy().alertTemperature(400, light)); 103 EXPECT_EQ(false, SimpleColorTemperatureStrategy().alertTemperature(400, light));
104 } 104 }
105 - // On 105 + // on
106 { 106 {
107 const nlohmann::json state = {{"colormode", "ct"}, {"on", true}, {"ct", 200}}; 107 const nlohmann::json state = {{"colormode", "ct"}, {"on", true}, {"ct", 200}};
108 light.getState()["state"] = state; 108 light.getState()["state"] = state;
@@ -123,7 +123,7 @@ TEST(SimpleColorTemperatureStrategy, alertTemperature) @@ -123,7 +123,7 @@ TEST(SimpleColorTemperatureStrategy, alertTemperature)
123 EXPECT_TRUE(SimpleColorTemperatureStrategy().alertTemperature(400, light)); 123 EXPECT_TRUE(SimpleColorTemperatureStrategy().alertTemperature(400, light));
124 Mock::VerifyAndClearExpectations(handler.get()); 124 Mock::VerifyAndClearExpectations(handler.get());
125 } 125 }
126 - // Off 126 + // off
127 { 127 {
128 const nlohmann::json state = {{"colormode", "ct"}, {"on", false}, {"ct", 200}}; 128 const nlohmann::json state = {{"colormode", "ct"}, {"on", false}, {"ct", 200}};
129 light.getState()["state"] = state; 129 light.getState()["state"] = state;
@@ -134,7 +134,6 @@ TEST(SimpleColorTemperatureStrategy, alertTemperature) @@ -134,7 +134,6 @@ TEST(SimpleColorTemperatureStrategy, alertTemperature)
134 reverseTransaction.expectSuccessfulPut(handler, Exactly(1)); 134 reverseTransaction.expectSuccessfulPut(handler, Exactly(1));
135 EXPECT_TRUE(SimpleColorTemperatureStrategy().alertTemperature(400, light)); 135 EXPECT_TRUE(SimpleColorTemperatureStrategy().alertTemperature(400, light));
136 Mock::VerifyAndClearExpectations(handler.get()); 136 Mock::VerifyAndClearExpectations(handler.get());
137 -  
138 } 137 }
139 } 138 }
140 139