Commit 9722744f64a6d77821529d7b3dfd7b9b7e540977
Committed by
Moritz Wirger
1 parent
741dd74c
Function to start streaming
Showing
2 changed files
with
33 additions
and
0 deletions
include/hueplusplus/Bridge.h
| @@ -180,6 +180,11 @@ public: | @@ -180,6 +180,11 @@ public: | ||
| 180 | //! \return string containing ip | 180 | //! \return string containing ip |
| 181 | std::string getBridgeIP() const; | 181 | std::string getBridgeIP() const; |
| 182 | 182 | ||
| 183 | + //! \brief Function to set stream mode to active for entertainment mode | ||
| 184 | + //! | ||
| 185 | + //! \return bool - whether stream request was successful | ||
| 186 | + bool StartStreaming(std::string group_identifier); | ||
| 187 | + | ||
| 183 | //! \brief Function to get the port of the hue bridge | 188 | //! \brief Function to get the port of the hue bridge |
| 184 | //! | 189 | //! |
| 185 | //! \return integer containing port | 190 | //! \return integer containing port |
src/Bridge.cpp
| @@ -248,6 +248,34 @@ std::string Bridge::requestUsername() | @@ -248,6 +248,34 @@ std::string Bridge::requestUsername() | ||
| 248 | return username; | 248 | return username; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | +bool Bridge::StartStreaming(std::string group_identifier) | ||
| 252 | +{ | ||
| 253 | + nlohmann::json request; | ||
| 254 | + | ||
| 255 | + request["stream"]["active"] = true; | ||
| 256 | + | ||
| 257 | + nlohmann::json answer; | ||
| 258 | + | ||
| 259 | + std::string uri = "/api/" + username + "/groups/" + group_identifier; | ||
| 260 | + | ||
| 261 | + answer = http_handler->PUTJson(uri, request, ip, port); | ||
| 262 | + | ||
| 263 | + if(answer[0].contains("success")) | ||
| 264 | + { | ||
| 265 | + std::string key = "/groups/" + group_identifier + "/stream/active"; | ||
| 266 | + | ||
| 267 | + if(answer[0]["success"].contains(key)) | ||
| 268 | + { | ||
| 269 | + if(answer[0]["success"][key] == true) | ||
| 270 | + { | ||
| 271 | + return true; | ||
| 272 | + } | ||
| 273 | + } | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + return false; | ||
| 277 | +} | ||
| 278 | + | ||
| 251 | std::string Bridge::getUsername() const | 279 | std::string Bridge::getUsername() const |
| 252 | { | 280 | { |
| 253 | return username; | 281 | return username; |