Commit 5212c08472dec0729ef03bf734a5c630eac8f415

Authored by Adam Honse
Committed by Moritz Wirger
1 parent 9722744f

Function to stop streaming

include/hueplusplus/Bridge.h
... ... @@ -185,6 +185,11 @@ public:
185 185 //! \return bool - whether stream request was successful
186 186 bool StartStreaming(std::string group_identifier);
187 187  
  188 + //! \brief Function to set stream mode to active for entertainment mode
  189 + //!
  190 + //! \return bool - whether stream request was successful
  191 + bool StopStreaming(std::string group_identifier);
  192 +
188 193 //! \brief Function to get the port of the hue bridge
189 194 //!
190 195 //! \return integer containing port
... ...
src/Bridge.cpp
... ... @@ -276,6 +276,34 @@ bool Bridge::StartStreaming(std::string group_identifier)
276 276 return false;
277 277 }
278 278  
  279 +bool Bridge::StopStreaming(std::string group_identifier)
  280 +{
  281 + nlohmann::json request;
  282 +
  283 + request["stream"]["active"] = false;
  284 +
  285 + nlohmann::json answer;
  286 +
  287 + std::string uri = "/api/" + username + "/groups/" + group_identifier;
  288 +
  289 + answer = http_handler->PUTJson(uri, request, ip, port);
  290 +
  291 + if(answer[0].contains("success"))
  292 + {
  293 + std::string key = "/groups/" + group_identifier + "/stream/active";
  294 +
  295 + if(answer[0]["success"].contains(key))
  296 + {
  297 + if(answer[0]["success"][key] == false)
  298 + {
  299 + return true;
  300 + }
  301 + }
  302 + }
  303 +
  304 + return false;
  305 +}
  306 +
279 307 std::string Bridge::getUsername() const
280 308 {
281 309 return username;
... ...