From 0f45635072fa0c87d46d593f8ad965d73a1e34f4 Mon Sep 17 00:00:00 2001
From: Jojo-1000 <33495614+Jojo-1000@users.noreply.github.com>
Date: Thu, 9 Apr 2020 21:41:50 +0200
Subject: [PATCH] Rename directory structure (not building).
---
CMakeLists.txt | 14 ++++++++++++--
cmake/cmake_uninstall.cmake.in | 21 +++++++++++++++++++++
cmake/hueplusplus-config.cmake.in | 7 +++++++
cmake_uninstall.cmake.in | 21 ---------------------
extern | 0
hueplusplus/BaseHttpHandler.cpp | 117 ---------------------------------------------------------------------------------------------------------------------
hueplusplus/CMakeLists.txt | 78 ------------------------------------------------------------------------------
hueplusplus/ExtendedColorHueStrategy.cpp | 275 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/ExtendedColorTemperatureStrategy.cpp | 151 -------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/Hue.cpp | 457 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/HueCommandAPI.cpp | 135 ---------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/HueException.cpp | 103 -------------------------------------------------------------------------------------------------------
hueplusplus/HueLight.cpp | 252 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/LinHttpHandler.cpp | 223 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/SimpleBrightnessStrategy.cpp | 88 ----------------------------------------------------------------------------------------
hueplusplus/SimpleColorHueStrategy.cpp | 428 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/SimpleColorTemperatureStrategy.cpp | 113 -----------------------------------------------------------------------------------------------------------------
hueplusplus/UPnP.cpp | 57 ---------------------------------------------------------
hueplusplus/Utils.cpp | 82 ----------------------------------------------------------------------------------
hueplusplus/WinHttpHandler.cpp | 298 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/hueplusplus-config.cmake.in | 7 -------
hueplusplus/include/BaseHttpHandler.h | 175 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/include/BrightnessStrategy.h | 58 ----------------------------------------------------------
hueplusplus/include/ColorHueStrategy.h | 155 -----------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/include/ColorTemperatureStrategy.h | 70 ----------------------------------------------------------------------
hueplusplus/include/ExtendedColorHueStrategy.h | 63 ---------------------------------------------------------------
hueplusplus/include/ExtendedColorTemperatureStrategy.h | 52 ----------------------------------------------------
hueplusplus/include/Hue.h | 282 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/include/HueCommandAPI.h | 123 ---------------------------------------------------------------------------------------------------------------------------
hueplusplus/include/HueConfig.h | 29 -----------------------------
hueplusplus/include/HueException.h | 118 ----------------------------------------------------------------------------------------------------------------------
hueplusplus/include/HueExceptionMacro.h | 27 ---------------------------
hueplusplus/include/HueLight.h | 790 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/include/IHttpHandler.h | 196 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/include/LinHttpHandler.h | 60 ------------------------------------------------------------
hueplusplus/include/SimpleBrightnessStrategy.h | 55 -------------------------------------------------------
hueplusplus/include/SimpleColorHueStrategy.h | 152 --------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/include/SimpleColorTemperatureStrategy.h | 66 ------------------------------------------------------------------
hueplusplus/include/UPnP.h | 46 ----------------------------------------------
hueplusplus/include/Units.h | 60 ------------------------------------------------------------
hueplusplus/include/Utils.h | 83 -----------------------------------------------------------------------------------
hueplusplus/include/WinHttpHandler.h | 69 ---------------------------------------------------------------------
hueplusplus/include/json/json.hpp | 22875 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/CMakeLists.txt | 109 -------------------------------------------------------------------------------------------------------------
hueplusplus/test/CMakeLists.txt.in | 15 ---------------
hueplusplus/test/CodeCoverage.cmake | 234 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/mocks/mock_BaseHttpHandler.h | 44 --------------------------------------------
hueplusplus/test/mocks/mock_HttpHandler.h | 78 ------------------------------------------------------------------------------
hueplusplus/test/mocks/mock_HueLight.h | 134 --------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_BaseHttpHandler.cpp | 237 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_ExtendedColorHueStrategy.cpp | 248 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_ExtendedColorTemperatureStrategy.cpp | 148 ----------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_Hue.cpp | 523 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_HueCommandAPI.cpp | 240 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_HueLight.cpp | 904 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_Main.cpp | 29 -----------------------------
hueplusplus/test/test_SimpleBrightnessStrategy.cpp | 93 ---------------------------------------------------------------------------------------------
hueplusplus/test/test_SimpleColorHueStrategy.cpp | 418 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_SimpleColorTemperatureStrategy.cpp | 125 -----------------------------------------------------------------------------------------------------------------------------
hueplusplus/test/test_UPnP.cpp | 51 ---------------------------------------------------
hueplusplus/test/testhelper.h | 283 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
include/hueplusplus/BaseHttpHandler.h | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/BrightnessStrategy.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/ColorHueStrategy.h | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/ColorTemperatureStrategy.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/ExtendedColorHueStrategy.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/ExtendedColorTemperatureStrategy.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/Hue.h | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/HueCommandAPI.h | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/HueConfig.h | 29 +++++++++++++++++++++++++++++
include/hueplusplus/HueException.h | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/HueExceptionMacro.h | 27 +++++++++++++++++++++++++++
include/hueplusplus/HueLight.h | 790 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/IHttpHandler.h | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/LinHttpHandler.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/SimpleBrightnessStrategy.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/SimpleColorHueStrategy.h | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/SimpleColorTemperatureStrategy.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/UPnP.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/Units.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/Utils.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/hueplusplus/WinHttpHandler.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/json/json.hpp | 22875 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/BaseHttpHandler.cpp | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/CMakeLists.txt | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ExtendedColorHueStrategy.cpp | 275 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/ExtendedColorTemperatureStrategy.cpp | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/Hue.cpp | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/HueCommandAPI.cpp | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/HueException.cpp | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/HueLight.cpp | 252 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/LinHttpHandler.cpp | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/SimpleBrightnessStrategy.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/SimpleColorHueStrategy.cpp | 428 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/SimpleColorTemperatureStrategy.cpp | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/UPnP.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/Utils.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/WinHttpHandler.cpp | 298 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/CMakeLists.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/CMakeLists.txt.in | 15 +++++++++++++++
src/test/CodeCoverage.cmake | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/mocks/mock_BaseHttpHandler.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/test/mocks/mock_HttpHandler.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/mocks/mock_HueLight.h | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_BaseHttpHandler.cpp | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_ExtendedColorHueStrategy.cpp | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_ExtendedColorTemperatureStrategy.cpp | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_Hue.cpp | 523 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_HueCommandAPI.cpp | 240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_HueLight.cpp | 904 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_Main.cpp | 29 +++++++++++++++++++++++++++++
src/test/test_SimpleBrightnessStrategy.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_SimpleColorHueStrategy.cpp | 418 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_SimpleColorTemperatureStrategy.cpp | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/test_UPnP.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/test/testhelper.h | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
116 files changed, 32402 insertions(+), 32404 deletions(-)
create mode 100644 cmake/cmake_uninstall.cmake.in
create mode 100644 cmake/hueplusplus-config.cmake.in
delete mode 100755 cmake_uninstall.cmake.in
create mode 100644 extern
delete mode 100644 hueplusplus/BaseHttpHandler.cpp
delete mode 100755 hueplusplus/CMakeLists.txt
delete mode 100755 hueplusplus/ExtendedColorHueStrategy.cpp
delete mode 100644 hueplusplus/ExtendedColorTemperatureStrategy.cpp
delete mode 100644 hueplusplus/Hue.cpp
delete mode 100644 hueplusplus/HueCommandAPI.cpp
delete mode 100644 hueplusplus/HueException.cpp
delete mode 100644 hueplusplus/HueLight.cpp
delete mode 100755 hueplusplus/LinHttpHandler.cpp
delete mode 100644 hueplusplus/SimpleBrightnessStrategy.cpp
delete mode 100644 hueplusplus/SimpleColorHueStrategy.cpp
delete mode 100644 hueplusplus/SimpleColorTemperatureStrategy.cpp
delete mode 100755 hueplusplus/UPnP.cpp
delete mode 100644 hueplusplus/Utils.cpp
delete mode 100755 hueplusplus/WinHttpHandler.cpp
delete mode 100755 hueplusplus/hueplusplus-config.cmake.in
delete mode 100644 hueplusplus/include/BaseHttpHandler.h
delete mode 100755 hueplusplus/include/BrightnessStrategy.h
delete mode 100755 hueplusplus/include/ColorHueStrategy.h
delete mode 100755 hueplusplus/include/ColorTemperatureStrategy.h
delete mode 100755 hueplusplus/include/ExtendedColorHueStrategy.h
delete mode 100755 hueplusplus/include/ExtendedColorTemperatureStrategy.h
delete mode 100644 hueplusplus/include/Hue.h
delete mode 100644 hueplusplus/include/HueCommandAPI.h
delete mode 100755 hueplusplus/include/HueConfig.h
delete mode 100644 hueplusplus/include/HueException.h
delete mode 100644 hueplusplus/include/HueExceptionMacro.h
delete mode 100644 hueplusplus/include/HueLight.h
delete mode 100755 hueplusplus/include/IHttpHandler.h
delete mode 100755 hueplusplus/include/LinHttpHandler.h
delete mode 100755 hueplusplus/include/SimpleBrightnessStrategy.h
delete mode 100755 hueplusplus/include/SimpleColorHueStrategy.h
delete mode 100755 hueplusplus/include/SimpleColorTemperatureStrategy.h
delete mode 100755 hueplusplus/include/UPnP.h
delete mode 100644 hueplusplus/include/Units.h
delete mode 100644 hueplusplus/include/Utils.h
delete mode 100644 hueplusplus/include/WinHttpHandler.h
delete mode 100644 hueplusplus/include/json/json.hpp
delete mode 100755 hueplusplus/test/CMakeLists.txt
delete mode 100755 hueplusplus/test/CMakeLists.txt.in
delete mode 100755 hueplusplus/test/CodeCoverage.cmake
delete mode 100755 hueplusplus/test/mocks/mock_BaseHttpHandler.h
delete mode 100755 hueplusplus/test/mocks/mock_HttpHandler.h
delete mode 100644 hueplusplus/test/mocks/mock_HueLight.h
delete mode 100755 hueplusplus/test/test_BaseHttpHandler.cpp
delete mode 100755 hueplusplus/test/test_ExtendedColorHueStrategy.cpp
delete mode 100755 hueplusplus/test/test_ExtendedColorTemperatureStrategy.cpp
delete mode 100644 hueplusplus/test/test_Hue.cpp
delete mode 100644 hueplusplus/test/test_HueCommandAPI.cpp
delete mode 100644 hueplusplus/test/test_HueLight.cpp
delete mode 100755 hueplusplus/test/test_Main.cpp
delete mode 100755 hueplusplus/test/test_SimpleBrightnessStrategy.cpp
delete mode 100755 hueplusplus/test/test_SimpleColorHueStrategy.cpp
delete mode 100755 hueplusplus/test/test_SimpleColorTemperatureStrategy.cpp
delete mode 100755 hueplusplus/test/test_UPnP.cpp
delete mode 100644 hueplusplus/test/testhelper.h
create mode 100644 include/hueplusplus/BaseHttpHandler.h
create mode 100644 include/hueplusplus/BrightnessStrategy.h
create mode 100644 include/hueplusplus/ColorHueStrategy.h
create mode 100644 include/hueplusplus/ColorTemperatureStrategy.h
create mode 100644 include/hueplusplus/ExtendedColorHueStrategy.h
create mode 100644 include/hueplusplus/ExtendedColorTemperatureStrategy.h
create mode 100644 include/hueplusplus/Hue.h
create mode 100644 include/hueplusplus/HueCommandAPI.h
create mode 100644 include/hueplusplus/HueConfig.h
create mode 100644 include/hueplusplus/HueException.h
create mode 100644 include/hueplusplus/HueExceptionMacro.h
create mode 100644 include/hueplusplus/HueLight.h
create mode 100644 include/hueplusplus/IHttpHandler.h
create mode 100644 include/hueplusplus/LinHttpHandler.h
create mode 100644 include/hueplusplus/SimpleBrightnessStrategy.h
create mode 100644 include/hueplusplus/SimpleColorHueStrategy.h
create mode 100644 include/hueplusplus/SimpleColorTemperatureStrategy.h
create mode 100644 include/hueplusplus/UPnP.h
create mode 100644 include/hueplusplus/Units.h
create mode 100644 include/hueplusplus/Utils.h
create mode 100644 include/hueplusplus/WinHttpHandler.h
create mode 100644 include/json/json.hpp
create mode 100644 src/BaseHttpHandler.cpp
create mode 100644 src/CMakeLists.txt
create mode 100644 src/ExtendedColorHueStrategy.cpp
create mode 100644 src/ExtendedColorTemperatureStrategy.cpp
create mode 100644 src/Hue.cpp
create mode 100644 src/HueCommandAPI.cpp
create mode 100644 src/HueException.cpp
create mode 100644 src/HueLight.cpp
create mode 100644 src/LinHttpHandler.cpp
create mode 100644 src/SimpleBrightnessStrategy.cpp
create mode 100644 src/SimpleColorHueStrategy.cpp
create mode 100644 src/SimpleColorTemperatureStrategy.cpp
create mode 100644 src/UPnP.cpp
create mode 100644 src/Utils.cpp
create mode 100644 src/WinHttpHandler.cpp
create mode 100644 src/test/CMakeLists.txt
create mode 100644 src/test/CMakeLists.txt.in
create mode 100644 src/test/CodeCoverage.cmake
create mode 100644 src/test/mocks/mock_BaseHttpHandler.h
create mode 100644 src/test/mocks/mock_HttpHandler.h
create mode 100644 src/test/mocks/mock_HueLight.h
create mode 100644 src/test/test_BaseHttpHandler.cpp
create mode 100644 src/test/test_ExtendedColorHueStrategy.cpp
create mode 100644 src/test/test_ExtendedColorTemperatureStrategy.cpp
create mode 100644 src/test/test_Hue.cpp
create mode 100644 src/test/test_HueCommandAPI.cpp
create mode 100644 src/test/test_HueLight.cpp
create mode 100644 src/test/test_Main.cpp
create mode 100644 src/test/test_SimpleBrightnessStrategy.cpp
create mode 100644 src/test/test_SimpleColorHueStrategy.cpp
create mode 100644 src/test/test_SimpleColorTemperatureStrategy.cpp
create mode 100644 src/test/test_UPnP.cpp
create mode 100644 src/test/testhelper.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02789de..279cf3a 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,15 @@
-cmake_minimum_required(VERSION 2.8.3)
-project(hueplusplus)
+cmake_minimum_required(VERSION 3.2)
+
+if(${CMAKE_VERSION} VERSION_LESS 3.11)
+ cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
+else()
+ cmake_policy(VERSION 3.11)
+endif()
+
+# Add cmake dir to module path, so Find*.cmake can be found
+set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
+
+project(hueplusplus LANGUAGES CXX)
# options to set
option(hueplusplus_TESTS "Build tests" OFF)
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..4c07dc7
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
diff --git a/cmake/hueplusplus-config.cmake.in b/cmake/hueplusplus-config.cmake.in
new file mode 100644
index 0000000..dc1490f
--- /dev/null
+++ b/cmake/hueplusplus-config.cmake.in
@@ -0,0 +1,7 @@
+# -config file of the hueplusplus package
+# It defines the following
+# hueplusplus_FOUND - which indicates that the module was found
+# hueplusplus_INCLUDE_DIR
+
+set(hueplusplus_FOUND TRUE)
+set(hueplusplus_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@")
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
deleted file mode 100755
index 4c07dc7..0000000
--- a/cmake_uninstall.cmake.in
+++ /dev/null
@@ -1,21 +0,0 @@
-if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
- message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
-endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
-
-file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
-string(REGEX REPLACE "\n" ";" files "${files}")
-foreach(file ${files})
- message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
- if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
- exec_program(
- "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
- OUTPUT_VARIABLE rm_out
- RETURN_VALUE rm_retval
- )
- if(NOT "${rm_retval}" STREQUAL 0)
- message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
- endif(NOT "${rm_retval}" STREQUAL 0)
- else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
- message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
- endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
-endforeach(file)
diff --git a/extern b/extern
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/extern
diff --git a/hueplusplus/BaseHttpHandler.cpp b/hueplusplus/BaseHttpHandler.cpp
deleted file mode 100644
index f0cd07d..0000000
--- a/hueplusplus/BaseHttpHandler.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- \file BaseHttpHandler.cpp
- Copyright Notice\n
- Copyright (C) 2020 Jan Rogall - developer\n
- Copyright (C) 2020 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/BaseHttpHandler.h"
-
-#include "include/HueExceptionMacro.h"
-
-std::string BaseHttpHandler::sendGetHTTPBody(const std::string& msg, const std::string& adr, int port) const
-{
- std::string response = send(msg, adr, port);
- size_t start = response.find("\r\n\r\n");
- if (start == std::string::npos)
- {
- std::cerr << "BaseHttpHandler: Failed to find body in response\n";
- std::cerr << "Request:\n";
- std::cerr << "\"" << msg << "\"\n";
- std::cerr << "Response:\n";
- std::cerr << "\"" << response << "\"\n";
- throw HueException(CURRENT_FILE_INFO, "Failed to find body in response");
- }
- response.erase(0, start + 4);
- return response;
-}
-
-std::string BaseHttpHandler::sendHTTPRequest(const std::string& method, const std::string& uri,
- const std::string& contentType, const std::string& body, const std::string& adr, int port) const
-{
- std::string request;
- // Protocol reference:
- // https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html Request-Line
- request.append(method); // Method
- request.append(" "); // Separation
- request.append(uri); // Request-URI
- request.append(" "); // Separation
- request.append("HTTP/1.0"); // HTTP-Version
- request.append("\r\n"); // Ending
- // Entities
- request.append("Content-Type:"); // entity-header
- request.append(" "); // Separation
- request.append(contentType); // media-type
- request.append("\r\n"); // Entity ending
- request.append("Content-Length:"); // entity-header
- request.append(" "); // Separation
- request.append(std::to_string(body.size())); // length
- request.append("\r\n\r\n"); // Entity ending & Request-Line ending
- request.append(body); // message-body
- request.append("\r\n\r\n"); // Ending
-
- return sendGetHTTPBody(request.c_str(), adr, port);
-}
-
-std::string BaseHttpHandler::GETString(const std::string& uri, const std::string& contentType, const std::string& body,
- const std::string& adr, int port) const
-{
- return sendHTTPRequest("GET", uri, contentType, body, adr, port);
-}
-
-std::string BaseHttpHandler::POSTString(const std::string& uri, const std::string& contentType, const std::string& body,
- const std::string& adr, int port) const
-{
- return sendHTTPRequest("POST", uri, contentType, body, adr, port);
-}
-
-std::string BaseHttpHandler::PUTString(const std::string& uri, const std::string& contentType, const std::string& body,
- const std::string& adr, int port) const
-{
- return sendHTTPRequest("PUT", uri, contentType, body, adr, port);
-}
-
-std::string BaseHttpHandler::DELETEString(const std::string& uri, const std::string& contentType,
- const std::string& body, const std::string& adr, int port) const
-{
- return sendHTTPRequest("DELETE", uri, contentType, body, adr, port);
-}
-
-nlohmann::json BaseHttpHandler::GETJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
-{
- return nlohmann::json::parse(GETString(uri, "application/json", body.dump(), adr, port));
-}
-
-nlohmann::json BaseHttpHandler::POSTJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
-{
- return nlohmann::json::parse(POSTString(uri, "application/json", body.dump(), adr, port));
-}
-
-nlohmann::json BaseHttpHandler::PUTJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
-{
- return nlohmann::json::parse(PUTString(uri, "application/json", body.dump(), adr, port));
-}
-
-nlohmann::json BaseHttpHandler::DELETEJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port) const
-{
- return nlohmann::json::parse(DELETEString(uri, "application/json", body.dump(), adr, port));
-}
diff --git a/hueplusplus/CMakeLists.txt b/hueplusplus/CMakeLists.txt
deleted file mode 100755
index 608e2ad..0000000
--- a/hueplusplus/CMakeLists.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-file(GLOB hueplusplus_HEADERS include/*.h include/*.hpp)
-set(hueplusplus_SOURCES
- ${CMAKE_CURRENT_SOURCE_DIR}/BaseHttpHandler.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/ExtendedColorHueStrategy.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/ExtendedColorTemperatureStrategy.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/Hue.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/HueCommandAPI.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/HueDeviceTypes.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/HueException.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/HueLight.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/SimpleBrightnessStrategy.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/SimpleColorHueStrategy.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/SimpleColorTemperatureStrategy.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/UPnP.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/Utils.cpp
-)
-
-# on windows we want to compile the WinHttpHandler
-if(WIN32)
- set(hueplusplus_SOURCES
- ${hueplusplus_SOURCES}
- ${CMAKE_CURRENT_SOURCE_DIR}/WinHttpHandler.cpp
- )
-endif()
-# whereas on linux we want the LinHttpHandler
-if(UNIX)
- set(hueplusplus_SOURCES
- ${hueplusplus_SOURCES}
- ${CMAKE_CURRENT_SOURCE_DIR}/LinHttpHandler.cpp
- )
-endif()
-if(ESP_PLATFORM)
- set(hueplusplus_SOURCES
- ${hueplusplus_SOURCES}
- ${CMAKE_CURRENT_SOURCE_DIR}/LinHttpHandler.cpp
- )
-endif()
-
-
-# Set global includes BEFORE adding any targets for legacy CMake versions
-if(CMAKE_VERSION VERSION_LESS 2.8.12)
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/json")
-endif()
-
-
-# hueplusplus shared library
-add_library(hueplusplusshared SHARED ${hueplusplus_SOURCES})
-set_property(TARGET hueplusplusshared PROPERTY CXX_STANDARD 14)
-set_property(TARGET hueplusplusshared PROPERTY CXX_EXTENSIONS OFF)
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
- target_include_directories(hueplusplusshared PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
-endif()
-install(TARGETS hueplusplusshared DESTINATION lib)
-
-# hueplusplus static library
-add_library(hueplusplusstatic STATIC ${hueplusplus_SOURCES})
-set_property(TARGET hueplusplusstatic PROPERTY CXX_STANDARD 14)
-set_property(TARGET hueplusplusstatic PROPERTY CXX_EXTENSIONS OFF)
-install(TARGETS hueplusplusstatic DESTINATION lib)
-if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
- target_include_directories(hueplusplusstatic PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
-endif()
-install(FILES ${hueplusplus_HEADERS} DESTINATION include/hueplusplus)
-
-# Export the package for use from the build-tree
-# (this registers the build-tree with a global CMake-registry)
-export(PACKAGE hueplusplus)
-# Create the hueplusplus-config.cmake
-configure_file (hueplusplus-config.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hueplusplus-config.cmake" @ONLY)
-# Install hueplusplus-config.cmake
-install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/hueplusplus-config.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
-
-# if the user decided to use tests add the subdirectory
-if(hueplusplus_TESTS)
- set(HuePlusPlus_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
- add_subdirectory("test")
-endif()
diff --git a/hueplusplus/ExtendedColorHueStrategy.cpp b/hueplusplus/ExtendedColorHueStrategy.cpp
deleted file mode 100755
index 6199855..0000000
--- a/hueplusplus/ExtendedColorHueStrategy.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- \file ExtendedColorHueStrategy.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/ExtendedColorHueStrategy.h"
-
-#include
-#include
-#include
-
-#include "include/HueConfig.h"
-
-bool ExtendedColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "hs")
- {
- uint16_t oldHue = light.state["state"]["hue"].get();
- uint8_t oldSat = light.state["state"]["sat"].get();
- if (!light.setColorHueSaturation(hue, sat, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorHueSaturation(oldHue, oldSat, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorHueSaturation(oldHue, oldSat, 1);
- }
- }
- else if (cType == "xy")
- {
- float oldX = light.state["state"]["xy"][0].get();
- float oldY = light.state["state"]["xy"][1].get();
- if (!light.setColorHueSaturation(hue, sat, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorXY(oldX, oldY, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorXY(oldX, oldY, 1);
- }
- }
- else if (cType == "ct")
- {
- uint16_t oldCT = light.state["state"]["ct"].get();
- if (!light.setColorHueSaturation(hue, sat, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorTemperature(oldCT, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorTemperature(oldCT, 1);
- }
- }
- else
- {
- return false;
- }
-}
-
-bool ExtendedColorHueStrategy::alertXY(float x, float y, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "hs")
- {
- uint16_t oldHue = light.state["state"]["hue"].get();
- uint8_t oldSat = light.state["state"]["sat"].get();
- if (!light.setColorXY(x, y, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorHueSaturation(oldHue, oldSat, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorHueSaturation(oldHue, oldSat, 1);
- }
- }
- else if (cType == "xy")
- {
- float oldX = light.state["state"]["xy"][0].get();
- float oldY = light.state["state"]["xy"][1].get();
- if (!light.setColorXY(x, y, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorXY(oldX, oldY, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorXY(oldX, oldY, 1);
- }
- }
- else if (cType == "ct")
- {
- uint16_t oldCT = light.state["state"]["ct"].get();
- if (!light.setColorXY(x, y, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorTemperature(oldCT, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorTemperature(oldCT, 1);
- }
- }
- else
- {
- return false;
- }
-}
-
-bool ExtendedColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "hs")
- {
- uint16_t oldHue = light.state["state"]["hue"].get();
- uint8_t oldSat = light.state["state"]["sat"].get();
- if (!light.setColorRGB(r, g, b, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorHueSaturation(oldHue, oldSat, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorHueSaturation(oldHue, oldSat, 1);
- }
- }
- else if (cType == "xy")
- {
- float oldX = light.state["state"]["xy"][0].get();
- float oldY = light.state["state"]["xy"][1].get();
- if (!light.setColorRGB(r, g, b, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorXY(oldX, oldY, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorXY(oldX, oldY, 1);
- }
- }
- else if (cType == "ct")
- {
- uint16_t oldCT = light.state["state"]["ct"].get();
- if (!light.setColorRGB(r, g, b, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorTemperature(oldCT, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorTemperature(oldCT, 1);
- }
- }
- else
- {
- return false;
- }
-}
diff --git a/hueplusplus/ExtendedColorTemperatureStrategy.cpp b/hueplusplus/ExtendedColorTemperatureStrategy.cpp
deleted file mode 100644
index 202096a..0000000
--- a/hueplusplus/ExtendedColorTemperatureStrategy.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- \file ExtendedColorTemperatureStrategy.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/ExtendedColorTemperatureStrategy.h"
-
-#include
-#include
-#include
-
-#include "include/HueConfig.h"
-#include "include/HueExceptionMacro.h"
-#include "include/Utils.h"
-
-bool ExtendedColorTemperatureStrategy::setColorTemperature(
- unsigned int mired, uint8_t transition, HueLight& light) const
-{
- light.refreshState();
- nlohmann::json request = nlohmann::json::object();
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- if (light.state["state"]["ct"] != mired || light.state["state"]["colormode"] != "ct")
- {
- if (mired > 500)
- {
- mired = 500;
- }
- if (mired < 153)
- {
- mired = 153;
- }
- request["ct"] = mired;
- }
-
- if (!request.count("on") && !request.count("ct"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
-}
-
-bool ExtendedColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "hs")
- {
- uint16_t oldHue = light.state["state"]["hue"].get();
- uint8_t oldSat = light.state["state"]["sat"].get();
- if (!light.setColorTemperature(mired, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorHueSaturation(oldHue, oldSat, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorHueSaturation(oldHue, oldSat, 1);
- }
- }
- else if (cType == "xy")
- {
- float oldX = light.state["state"]["xy"][0].get();
- float oldY = light.state["state"]["xy"][1].get();
- if (!light.setColorTemperature(mired, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorXY(oldX, oldY, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorXY(oldX, oldY, 1);
- }
- }
- else if (cType == "ct")
- {
- uint16_t oldCT = light.state["state"]["ct"].get();
- if (!light.setColorTemperature(mired, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorTemperature(oldCT, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorTemperature(oldCT, 1);
- }
- }
- else
- {
- return false;
- }
-}
diff --git a/hueplusplus/Hue.cpp b/hueplusplus/Hue.cpp
deleted file mode 100644
index d088f4e..0000000
--- a/hueplusplus/Hue.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/**
- \file Hue.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/Hue.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "include/HueDeviceTypes.h"
-#include "include/ExtendedColorHueStrategy.h"
-#include "include/ExtendedColorTemperatureStrategy.h"
-#include "include/HueExceptionMacro.h"
-#include "include/SimpleBrightnessStrategy.h"
-#include "include/SimpleColorHueStrategy.h"
-#include "include/SimpleColorTemperatureStrategy.h"
-#include "include/UPnP.h"
-#include "include/Utils.h"
-
-HueFinder::HueFinder(std::shared_ptr handler) : http_handler(std::move(handler)) {}
-
-std::vector HueFinder::FindBridges() const
-{
- UPnP uplug;
- std::vector> foundDevices = uplug.getDevices(http_handler);
-
- std::vector foundBridges;
- for (const std::pair& p : foundDevices)
- {
- size_t found = p.second.find("IpBridge");
- if (found != std::string::npos)
- {
- HueIdentification bridge;
- size_t start = p.first.find("//") + 2;
- size_t length = p.first.find(":", start) - start;
- bridge.ip = p.first.substr(start, length);
- std::string desc
- = http_handler->GETString("/description.xml", "application/xml", "", bridge.ip, bridge.port);
- std::string mac = ParseDescription(desc);
- if (!mac.empty())
- {
- bridge.mac = NormalizeMac(mac);
- foundBridges.push_back(std::move(bridge));
- }
- }
- }
- return foundBridges;
-}
-
-Hue HueFinder::GetBridge(const HueIdentification& identification)
-{
- std::string normalizedMac = NormalizeMac(identification.mac);
- auto pos = usernames.find(normalizedMac);
- if (pos != usernames.end())
- {
- return Hue(identification.ip, identification.port, pos->second, http_handler);
- }
- Hue bridge(identification.ip, identification.port, "", http_handler);
- bridge.requestUsername();
- if (bridge.getUsername().empty())
- {
- std::cerr << "Failed to request username for ip " << identification.ip << std::endl;
- throw HueException(CURRENT_FILE_INFO, "Failed to request username!");
- }
- AddUsername(normalizedMac, bridge.getUsername());
-
- return bridge;
-}
-
-void HueFinder::AddUsername(const std::string& mac, const std::string& username)
-{
- usernames[NormalizeMac(mac)] = username;
-}
-
-const std::map& HueFinder::GetAllUsernames() const
-{
- return usernames;
-}
-
-std::string HueFinder::NormalizeMac(std::string input)
-{
- // Remove any non alphanumeric characters (e.g. ':' and whitespace)
- input.erase(std::remove_if(input.begin(), input.end(), [](char c) { return !std::isalnum(c, std::locale()); }),
- input.end());
- // Convert to lower case
- std::transform(input.begin(), input.end(), input.begin(), [](char c) { return std::tolower(c, std::locale()); });
- return input;
-}
-
-std::string HueFinder::ParseDescription(const std::string& description)
-{
- const char* model = "Philips hue bridge";
- const char* serialBegin = "";
- const char* serialEnd = "";
- if (description.find(model) != std::string::npos)
- {
- std::size_t begin = description.find(serialBegin);
- std::size_t end = description.find(serialEnd, begin);
- if (begin != std::string::npos && end != std::string::npos)
- {
- begin += std::strlen(serialBegin);
- if (begin < description.size())
- {
- std::string result = description.substr(begin, end - begin);
- return result;
- }
- }
- }
- return std::string();
-}
-
-Hue::Hue(
- const std::string& ip, const int port, const std::string& username, std::shared_ptr handler)
- : ip(ip),
- port(port),
- username(username),
- simpleBrightnessStrategy(std::make_shared()),
- simpleColorHueStrategy(std::make_shared()),
- extendedColorHueStrategy(std::make_shared()),
- simpleColorTemperatureStrategy(std::make_shared()),
- extendedColorTemperatureStrategy(std::make_shared()),
- http_handler(std::move(handler)),
- commands(ip, port, username, http_handler)
-{}
-
-std::string Hue::getBridgeIP()
-{
- return ip;
-}
-
-int Hue::getBridgePort()
-{
- return port;
-}
-
-std::string Hue::requestUsername()
-{
- std::cout << "Please press the link Button! You've got 35 secs!\n"; // when the link
- // button was
- // pressed we
- // got 30
- // seconds to
- // get our
- // username for
- // control
-
- nlohmann::json request;
- request["devicetype"] = "HuePlusPlus#User";
-
- nlohmann::json answer;
- std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
- std::chrono::steady_clock::time_point lastCheck;
- while (std::chrono::steady_clock::now() - start < std::chrono::seconds(35))
- {
- if (std::chrono::steady_clock::now() - lastCheck > std::chrono::seconds(1))
- {
- lastCheck = std::chrono::steady_clock::now();
- answer = http_handler->POSTJson("/api", request, ip, port);
- nlohmann::json jsonUser = utils::safeGetMember(answer, 0, "success", "username");
- if (jsonUser != nullptr)
- {
- // [{"success":{"username": ""}}]
- username = jsonUser.get();
- // Update commands with new username and ip
- commands = HueCommandAPI(ip, port, username, http_handler);
- std::cout << "Success! Link button was pressed!\n";
- std::cout << "Username is \"" << username << "\"\n";
- break;
- }
- else if (answer.size() > 0 && answer[0].count("error"))
- {
- // All errors except 101: Link button not pressed
- if (utils::safeGetMember(answer, 0, "error", "type") != 101)
- {
- throw HueAPIResponseException::Create(CURRENT_FILE_INFO, answer[0]);
- }
- }
-
- std::this_thread::sleep_until(lastCheck + std::chrono::seconds(1));
- }
- }
- return username;
-}
-
-std::string Hue::getUsername()
-{
- return username;
-}
-
-void Hue::setIP(const std::string& ip)
-{
- this->ip = ip;
-}
-
-void Hue::setPort(const int port)
-{
- this->port = port;
-}
-
-HueLight& Hue::getLight(int id)
-{
- auto pos = lights.find(id);
- if (pos != lights.end())
- {
- pos->second.refreshState();
- return pos->second;
- }
- refreshState();
- if (!state["lights"].count(std::to_string(id)))
- {
- std::cerr << "Error in Hue getLight(): light with id " << id << " is not valid\n";
- throw HueException(CURRENT_FILE_INFO, "Light id is not valid");
- }
- // std::cout << state["lights"][std::to_string(id)] << std::endl;
- std::string type = state["lights"][std::to_string(id)]["modelid"].get();
- // std::cout << type << std::endl;
- auto light = MakeHueLight()(type, id, commands, simpleBrightnessStrategy,
- extendedColorTemperatureStrategy, simpleColorTemperatureStrategy, extendedColorHueStrategy,
- simpleColorHueStrategy);
- lights.emplace(id, light);
- return lights.find(id)->second;
-}
-
-bool Hue::removeLight(int id)
-{
- nlohmann::json result
- = commands.DELETERequest("/lights/" + std::to_string(id), nlohmann::json::object(), CURRENT_FILE_INFO);
- bool success = utils::safeGetMember(result, 0, "success") == "/lights/" + std::to_string(id) + " deleted";
- if (success && lights.count(id) != 0)
- {
- lights.erase(id);
- }
- return success;
-}
-
-std::vector> Hue::getAllLights()
-{
- refreshState();
- nlohmann::json lightsState = state["lights"];
- for (nlohmann::json::iterator it = lightsState.begin(); it != lightsState.end(); ++it)
- {
- getLight(std::stoi(it.key()));
- }
- std::vector> result;
- for (auto& entry : lights)
- {
- result.emplace_back(entry.second);
- }
- return result;
-}
-
-bool Hue::lightExists(int id)
-{
- refreshState();
- auto pos = lights.find(id);
- if (pos != lights.end())
- {
- return true;
- }
- if (state["lights"].count(std::to_string(id)))
- {
- return true;
- }
- return false;
-}
-
-bool Hue::lightExists(int id) const
-{
- auto pos = lights.find(id);
- if (pos != lights.end())
- {
- return true;
- }
- if (state["lights"].count(std::to_string(id)))
- {
- return true;
- }
- return false;
-}
-
-std::string Hue::getPictureOfLight(int id) const
-{
- std::string ret = "";
- auto pos = lights.find(id);
- if (pos != lights.end())
- {
- ret = getPictureOfModel(pos->second.getModelId());
- }
- return ret;
-}
-
-std::string Hue::getPictureOfModel(const std::string& model_id) const
-{
- std::string ret = "";
- if (model_id == "LCT001" || model_id == "LCT007" || model_id == "LCT010" || model_id == "LCT014"
- || model_id == "LTW010" || model_id == "LTW001" || model_id == "LTW004" || model_id == "LTW015"
- || model_id == "LWB004" || model_id == "LWB006")
- {
- ret.append("e27_waca");
- }
- else if (model_id == "LWB010" || model_id == "LWB014")
- {
- ret.append("e27_white");
- }
- else if (model_id == "LCT012" || model_id == "LTW012")
- {
- ret.append("e14");
- }
- else if (model_id == "LCT002")
- {
- ret.append("br30");
- }
- else if (model_id == "LCT011" || model_id == "LTW011")
- {
- ret.append("br30_slim");
- }
- else if (model_id == "LCT003")
- {
- ret.append("gu10");
- }
- else if (model_id == "LTW013")
- {
- ret.append("gu10_perfectfit");
- }
- else if (model_id == "LST001" || model_id == "LST002")
- {
- ret.append("lightstrip");
- }
- else if (model_id == "LLC006 " || model_id == "LLC010")
- {
- ret.append("iris");
- }
- else if (model_id == "LLC005" || model_id == "LLC011" || model_id == "LLC012" || model_id == "LLC007")
- {
- ret.append("bloom");
- }
- else if (model_id == "LLC014")
- {
- ret.append("aura");
- }
- else if (model_id == "LLC013")
- {
- ret.append("storylight");
- }
- else if (model_id == "LLC020")
- {
- ret.append("go");
- }
- else if (model_id == "HBL001" || model_id == "HBL002" || model_id == "HBL003")
- {
- ret.append("beyond_ceiling_pendant_table");
- }
- else if (model_id == "HIL001 " || model_id == "HIL002")
- {
- ret.append("impulse");
- }
- else if (model_id == "HEL001 " || model_id == "HEL002")
- {
- ret.append("entity");
- }
- else if (model_id == "HML001" || model_id == "HML002" || model_id == "HML003" || model_id == "HML004"
- || model_id == "HML005")
- {
- ret.append("phoenix_ceiling_pendant_table_wall");
- }
- else if (model_id == "HML006")
- {
- ret.append("phoenix_down");
- }
- else if (model_id == "LTP001" || model_id == "LTP002" || model_id == "LTP003" || model_id == "LTP004"
- || model_id == "LTP005" || model_id == "LTD003")
- {
- ret.append("pendant");
- }
- else if (model_id == "LDF002" || model_id == "LTF001" || model_id == "LTF002" || model_id == "LTC001"
- || model_id == "LTC002" || model_id == "LTC003" || model_id == "LTC004" || model_id == "LTD001"
- || model_id == "LTD002" || model_id == "LDF001")
- {
- ret.append("ceiling");
- }
- else if (model_id == "LDD002 " || model_id == "LFF001")
- {
- ret.append("floor");
- }
- else if (model_id == "LDD001 " || model_id == "LTT001")
- {
- ret.append("table");
- }
- else if (model_id == "LDT001 " || model_id == "MWM001")
- {
- ret.append("recessed");
- }
- else if (model_id == "BSB001")
- {
- ret.append("bridge_v1");
- }
- else if (model_id == "BSB002")
- {
- ret.append("bridge_v2");
- }
- else if (model_id == "SWT001")
- {
- ret.append("tap");
- }
- else if (model_id == "RWL021")
- {
- ret.append("hds");
- }
- else if (model_id == "SML001")
- {
- ret.append("motion_sensor");
- }
- return ret;
-}
-
-void Hue::refreshState()
-{
- if (username.empty())
- {
- return;
- }
- nlohmann::json answer = commands.GETRequest("", nlohmann::json::object(), CURRENT_FILE_INFO);
- if (answer.is_object() && answer.count("lights"))
- {
- state = answer;
- }
- else
- {
- std::cout << "Answer in Hue::refreshState of http_handler->GETJson(...) is "
- "not expected!\nAnswer:\n\t"
- << answer.dump() << std::endl;
- }
-}
diff --git a/hueplusplus/HueCommandAPI.cpp b/hueplusplus/HueCommandAPI.cpp
deleted file mode 100644
index b818d44..0000000
--- a/hueplusplus/HueCommandAPI.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- \file HueCommandAPI.h
- Copyright Notice\n
- Copyright (C) 2018 Jan Rogall - developer\n
- Copyright (C) 2018 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/HueCommandAPI.h"
-
-#include
-
-#include "include/HueExceptionMacro.h"
-
-constexpr std::chrono::steady_clock::duration HueCommandAPI::minDelay;
-
-namespace
-{
- // Runs functor with appropriate timeout and retries when timed out or connection reset
- template
- nlohmann::json RunWithTimeout(
- std::shared_ptr timeout, std::chrono::steady_clock::duration minDelay, Fun fun)
- {
- auto now = std::chrono::steady_clock::now();
- std::lock_guard lock(timeout->mutex);
- if (timeout->timeout > now)
- {
- std::this_thread::sleep_until(timeout->timeout);
- }
- try
- {
- nlohmann::json response = fun();
- timeout->timeout = now + minDelay;
- return response;
- }
- catch (const std::system_error& e)
- {
- if (e.code() == std::errc::connection_reset || e.code() == std::errc::timed_out)
- {
- // Happens when hue is too busy, wait and try again (once)
- std::this_thread::sleep_for(minDelay);
- nlohmann::json v = fun();
- timeout->timeout = std::chrono::steady_clock::now() + minDelay;
- return v;
- }
- // Cannot recover from other types of errors
- throw;
- }
- }
-} // namespace
-
-HueCommandAPI::HueCommandAPI(
- const std::string& ip, const int port, const std::string& username, std::shared_ptr httpHandler)
- : ip(ip),
- port(port),
- username(username),
- httpHandler(std::move(httpHandler)),
- timeout(new TimeoutData{std::chrono::steady_clock::now(), {}})
-{}
-
-nlohmann::json HueCommandAPI::PUTRequest(const std::string& path, const nlohmann::json& request) const
-{
- return PUTRequest(path, request, CURRENT_FILE_INFO);
-}
-
-nlohmann::json HueCommandAPI::PUTRequest(
- const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const
-{
- return HandleError(fileInfo,
- RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->PUTJson(CombinedPath(path), request, ip); }));
-}
-
-nlohmann::json HueCommandAPI::GETRequest(const std::string& path, const nlohmann::json& request) const
-{
- return GETRequest(path, request, CURRENT_FILE_INFO);
-}
-
-nlohmann::json HueCommandAPI::GETRequest(
- const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const
-{
- return HandleError(fileInfo,
- RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->GETJson(CombinedPath(path), request, ip); }));
-}
-
-nlohmann::json HueCommandAPI::DELETERequest(const std::string& path, const nlohmann::json& request) const
-{
- return DELETERequest(path, request, CURRENT_FILE_INFO);
-}
-
-nlohmann::json HueCommandAPI::DELETERequest(
- const std::string& path, const nlohmann::json& request, FileInfo fileInfo) const
-{
- return HandleError(fileInfo,
- RunWithTimeout(timeout, minDelay, [&]() { return httpHandler->DELETEJson(CombinedPath(path), request, ip); }));
-}
-
-nlohmann::json HueCommandAPI::HandleError(FileInfo fileInfo, const nlohmann::json& response) const
-{
- if (response.count("error"))
- {
- throw HueAPIResponseException::Create(std::move(fileInfo), response);
- }
- else if (response.is_array() && response.size() > 0 && response[0].count("error"))
- {
- throw HueAPIResponseException::Create(std::move(fileInfo), response[0]);
- }
- return response;
-}
-
-std::string HueCommandAPI::CombinedPath(const std::string& path) const
-{
- std::string result = "/api/";
- result.append(username);
- // If path does not begin with '/', insert it unless it is empty
- if (!path.empty() && path.front() != '/')
- {
- result.append("/");
- }
- result.append(path);
- return result;
-}
diff --git a/hueplusplus/HueException.cpp b/hueplusplus/HueException.cpp
deleted file mode 100644
index d54f6c7..0000000
--- a/hueplusplus/HueException.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- \file HueException.cpp
- Copyright Notice\n
- Copyright (C) 2020 Jan Rogall - developer\n
- Copyright (C) 2020 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/HueException.h"
-
-HueException::HueException(FileInfo fileInfo, const std::string& message)
- : HueException("HueException", std::move(fileInfo), message)
-{}
-
-const char* HueException::what() const noexcept
-{
- return whatMessage.c_str();
-}
-
-const FileInfo& HueException::GetFile() const noexcept
-{
- return fileInfo;
-}
-
-HueException::HueException(const char* exceptionName, FileInfo fileInfo, const std::string& message)
- : fileInfo(std::move(fileInfo))
-{
- whatMessage = exceptionName;
- whatMessage.append(" from ");
- whatMessage.append(this->fileInfo.ToString());
- whatMessage.append(" ");
- whatMessage.append(message);
-}
-
-HueAPIResponseException::HueAPIResponseException(
- FileInfo fileInfo, int error, std::string address, std::string description)
- : HueException("HueApiResponseException", std::move(fileInfo), GetMessage(error, address, description)),
- error(error),
- address(std::move(address)),
- description(std::move(description))
-{}
-
-int HueAPIResponseException::GetErrorNumber() const noexcept
-{
- return error;
-}
-
-const std::string& HueAPIResponseException::GetAddress() const noexcept
-{
- return address;
-}
-
-const std::string& HueAPIResponseException::GetDescription() const noexcept
-{
- return description;
-}
-
-HueAPIResponseException HueAPIResponseException::Create(FileInfo fileInfo, const nlohmann::json& response)
-{
- const nlohmann::json error = response.at("error");
- int errorCode = error.value("type", -1);
- std::string address = error.value("address", "");
- std::string description = error.value("description", "");
- return HueAPIResponseException(std::move(fileInfo), errorCode, std::move(address), std::move(description));
-}
-
-std::string HueAPIResponseException::GetMessage(int error, const std::string& addr, const std::string& description)
-{
- std::string result = std::to_string(error);
- result.append(" ");
- result.append(addr);
- result.append(" ");
- result.append(description);
- return result;
-}
-
-std::string FileInfo::ToString() const
-{
- if (filename.empty() || line < 0)
- {
- return "Unknown file";
- }
- std::string result = func;
- result.append(" in ");
- result.append(filename);
- result.append(":");
- result.append(std::to_string(line));
- return result;
-}
diff --git a/hueplusplus/HueLight.cpp b/hueplusplus/HueLight.cpp
deleted file mode 100644
index dc705ff..0000000
--- a/hueplusplus/HueLight.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/**
- \file HueLight.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/HueLight.h"
-
-#include
-#include
-#include
-
-#include "include/HueExceptionMacro.h"
-#include "include/Utils.h"
-#include "include/json/json.hpp"
-
-bool HueLight::On(uint8_t transition)
-{
- refreshState();
- return OnNoRefresh(transition);
-}
-
-bool HueLight::Off(uint8_t transition)
-{
- refreshState();
- return OffNoRefresh(transition);
-}
-
-bool HueLight::isOn()
-{
- refreshState();
- return state["state"]["on"].get();
-}
-
-bool HueLight::isOn() const
-{
- return state["state"]["on"].get();
-}
-
-int HueLight::getId() const
-{
- return id;
-}
-
-std::string HueLight::getType() const
-{
- return state["type"].get();
-}
-
-std::string HueLight::getName()
-{
- refreshState();
- return state["name"].get();
-}
-
-std::string HueLight::getName() const
-{
- return state["name"].get();
-}
-
-std::string HueLight::getModelId() const
-{
- return state["modelid"].get();
-}
-
-std::string HueLight::getUId() const
-{
- if (state.count("uniqueid"))
- {
- return state["uniqueid"].get();
- }
- return std::string();
-}
-
-std::string HueLight::getManufacturername() const
-{
- if (state.count("manufacturername"))
- {
- return state["manufacturername"].get();
- }
- return std::string();
-}
-
-std::string HueLight::getProductname() const
-{
- if (state.count("productname"))
- {
- return state["productname"].get();
- }
- return std::string();
-}
-
-std::string HueLight::getLuminaireUId() const
-{
- if (state.count("luminaireuniqueid"))
- {
- return state["luminaireuniqueid"].get();
- }
- return std::string();
-}
-
-std::string HueLight::getSwVersion()
-{
- refreshState();
- return state["swversion"].get();
-}
-
-std::string HueLight::getSwVersion() const
-{
- return state["swversion"].get();
-}
-
-bool HueLight::setName(const std::string& name)
-{
- nlohmann::json request = nlohmann::json::object();
- request["name"] = name;
- nlohmann::json reply = SendPutRequest(request, "/name", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::safeGetMember(reply, 0, "success", "/lights/" + std::to_string(id) + "/name") == name;
-}
-
-ColorType HueLight::getColorType() const
-{
- return colorType;
-}
-
-unsigned int HueLight::KelvinToMired(unsigned int kelvin) const
-{
- return int(0.5f + (1000000 / kelvin));
-}
-
-unsigned int HueLight::MiredToKelvin(unsigned int mired) const
-{
- return int(0.5f + (1000000 / mired));
-}
-
-bool HueLight::alert()
-{
- nlohmann::json request;
- request["alert"] = "select";
-
- nlohmann::json reply = SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- return utils::validateReplyForLight(request, reply, id);
-}
-
-HueLight::HueLight(int id, const HueCommandAPI& commands) : HueLight(id, commands, nullptr, nullptr, nullptr) {}
-
-HueLight::HueLight(int id, const HueCommandAPI& commands, std::shared_ptr brightnessStrategy,
- std::shared_ptr colorTempStrategy,
- std::shared_ptr colorHueStrategy)
- : id(id),
- brightnessStrategy(std::move(brightnessStrategy)),
- colorTemperatureStrategy(std::move(colorTempStrategy)),
- colorHueStrategy(std::move(colorHueStrategy)),
- commands(commands)
-
-{
- refreshState();
-}
-
-bool HueLight::OnNoRefresh(uint8_t transition)
-{
- nlohmann::json request = nlohmann::json::object();
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (state["state"]["on"] != true)
- {
- request["on"] = true;
- }
-
- if (!request.count("on"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, id);
-}
-
-bool HueLight::OffNoRefresh(uint8_t transition)
-{
- nlohmann::json request = nlohmann::json::object();
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (state["state"]["on"] != false)
- {
- request["on"] = false;
- }
-
- if (!request.count("on"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, id);
-}
-
-nlohmann::json HueLight::SendPutRequest(const nlohmann::json& request, const std::string& subPath, FileInfo fileInfo)
-{
- return commands.PUTRequest("/lights/" + std::to_string(id) + subPath, request, std::move(fileInfo));
-}
-
-void HueLight::refreshState()
-{
- // std::chrono::steady_clock::time_point start =
- // std::chrono::steady_clock::now(); std::cout << "\tRefreshing lampstate of
- // lamp with id: " << id << ", ip: " << ip << "\n";
- nlohmann::json answer
- = commands.GETRequest("/lights/" + std::to_string(id), nlohmann::json::object(), CURRENT_FILE_INFO);
- if (answer.count("state"))
- {
- state = answer;
- }
- else
- {
- std::cout << "Answer in HueLight::refreshState of "
- "http_handler->GETJson(...) is not expected!\nAnswer:\n\t"
- << answer.dump() << std::endl;
- }
- // std::cout << "\tRefresh state took: " <<
- // std::chrono::duration_cast(std::chrono::steady_clock::now()
- // - start).count() << "ms" << std::endl;
-}
diff --git a/hueplusplus/LinHttpHandler.cpp b/hueplusplus/LinHttpHandler.cpp
deleted file mode 100755
index c8f7132..0000000
--- a/hueplusplus/LinHttpHandler.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
- \file LinHttpHandler.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/LinHttpHandler.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include // struct hostent, gethostbyname
-#include // struct sockaddr_in, struct sockaddr
-#include // printf, sprintf
-#include // exit
-#include // functions for C style null-terminated strings
-#include // socket, connect
-#include // read, write, close
-
-class SocketCloser
-{
-public:
- explicit SocketCloser(int sockFd) : s(sockFd) {}
- ~SocketCloser() { close(s); }
-
-private:
- int s;
-};
-
-std::string LinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const
-{
- // create socket
- int socketFD = socket(AF_INET, SOCK_STREAM, 0);
-
- SocketCloser closeMySocket(socketFD);
- if (socketFD < 0)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: Failed to open socket: " << std::strerror(errCode) << "\n";
- throw(std::system_error(errCode, std::generic_category(), "LinHttpHandler: Failed to open socket"));
- }
-
- // lookup ip address
- hostent* server;
- server = gethostbyname(adr.c_str());
- if (server == NULL)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: Failed to find host with address " << adr << ": " << std::strerror(errCode)
- << "\n";
- throw(std::system_error(errCode, std::generic_category(), "LinHttpHandler: gethostbyname"));
- }
-
- // fill in the structure
- sockaddr_in server_addr;
- memset(&server_addr, 0, sizeof(server_addr));
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = htons(port);
- memcpy(&server_addr.sin_addr.s_addr, server->h_addr, server->h_length);
-
- // connect the socket
- if (connect(socketFD, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: Failed to connect socket: " << std::strerror(errCode) << "\n";
- throw(std::system_error(errCode, std::generic_category(), "LinHttpHandler: Failed to connect socket"));
- }
-
- // send the request
- size_t total = msg.length();
- size_t sent = 0;
- do
- {
- ssize_t bytes = write(socketFD, msg.c_str() + sent, total - sent);
- if (bytes < 0)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: Failed to write message to socket: " << std::strerror(errCode) << "\n";
- throw(std::system_error(
- errCode, std::generic_category(), "LinHttpHandler: Failed to write message to socket"));
- }
- else if (bytes == 0)
- {
- break;
- }
- else
- {
- sent += bytes;
- }
- } while (sent < total);
-
- // receive the response
- std::string response;
- char buffer[128] = {};
- do
- {
- ssize_t bytes = read(socketFD, buffer, 127);
- if (bytes < 0)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: Failed to read response from socket: " << std::strerror(errCode) << std::endl;
- throw(std::system_error(
- errCode, std::generic_category(), "LinHttpHandler: Failed to read response from socket"));
- }
- else if (bytes == 0)
- {
- break;
- }
- else
- {
- response.append(buffer, bytes);
- }
- } while (true);
-
- return response;
-}
-
-std::vector LinHttpHandler::sendMulticast(
- const std::string& msg, const std::string& adr, int port, int timeout) const
-{
- hostent* server; // host information
- sockaddr_in server_addr; // server address
-
- // fill in the server's address and data
- memset((char*)&server_addr, 0, sizeof(server_addr));
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = htons(port);
-
- // look up the address of the server given its name
- server = gethostbyname(adr.c_str());
- if (!server)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: sendMulticast: Failed to obtain address of " << msg << ": "
- << std::strerror(errCode) << "\n";
- throw(std::system_error(
- errCode, std::generic_category(), "LinHttpHandler: sendMulticast: Failed to obtain address of host"));
- }
-
- // put the host's address into the server address structure
- memcpy((void*)&server_addr.sin_addr, server->h_addr_list[0], server->h_length);
-
- // create the socket
- int socketFD = socket(AF_INET, SOCK_DGRAM, 0);
- SocketCloser closeMySendSocket(socketFD);
- if (socketFD < 0)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: sendMulticast: Failed to open socket: " << std::strerror(errCode) << "\n";
- throw(std::system_error(
- errCode, std::generic_category(), "LinHttpHandler: sendMulticast: Failed to open socket"));
- }
-
- // send a message to the server
- if (sendto(socketFD, msg.c_str(), strlen(msg.c_str()), 0, (struct sockaddr*)&server_addr, sizeof(server_addr)) < 0)
- {
- int errCode = errno;
- std::cerr << "LinHttpHandler: sendMulticast: Failed to send message: " << std::strerror(errCode) << "\n";
- throw(std::system_error(
- errCode, std::generic_category(), "LinHttpHandler: sendMulticast: Failed to send message"));
- }
-
- std::string response;
- char buffer[2048] = {}; // receive buffer
-
- std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
- while (std::chrono::steady_clock::now() - start < std::chrono::seconds(timeout))
- {
- ssize_t bytesReceived = recv(socketFD, &buffer, 2048, MSG_DONTWAIT);
- if (bytesReceived < 0)
- {
- int errCode = errno;
- if (errCode != EAGAIN && errCode != EWOULDBLOCK)
- {
- std::cerr << "LinHttpHandler: sendMulticast: Failed to read response "
- "from socket: "
- << std::strerror(errCode) << "\n";
- throw(std::system_error(errCode, std::generic_category(),
- "LinHttpHandler: sendMulticast: Failed to read "
- "response from socket"));
- }
- continue;
- }
- if (bytesReceived)
- {
- response.append(buffer, bytesReceived);
- }
- }
-
- // construct return vector
- std::vector returnString;
- size_t pos = response.find("\r\n\r\n");
- size_t prevpos = 0;
- while (pos != std::string::npos)
- {
- returnString.push_back(response.substr(prevpos, pos - prevpos));
- pos += 4;
- prevpos = pos;
- pos = response.find("\r\n\r\n", pos);
- }
- return returnString;
-}
diff --git a/hueplusplus/SimpleBrightnessStrategy.cpp b/hueplusplus/SimpleBrightnessStrategy.cpp
deleted file mode 100644
index d0d00ac..0000000
--- a/hueplusplus/SimpleBrightnessStrategy.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- \file SimpleBrightnessStrategy.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/SimpleBrightnessStrategy.h"
-
-#include
-#include
-#include
-
-#include "include/HueExceptionMacro.h"
-#include "include/Utils.h"
-
-bool SimpleBrightnessStrategy::setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const
-{
- light.refreshState();
- if (bri == 0)
- {
- if (light.state["state"]["on"] == true)
- {
- return light.OffNoRefresh(transition);
- }
- else
- {
- return true;
- }
- }
- else
- {
- nlohmann::json request = nlohmann::json::object();
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- if (light.state["state"]["bri"] != bri)
- {
- if (bri > 254)
- {
- bri = 254;
- }
- request["bri"] = bri;
- }
-
- if (!request.count("on") && !request.count("bri"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
- }
-}
-
-unsigned int SimpleBrightnessStrategy::getBrightness(HueLight& light) const
-{
- light.refreshState();
- return light.state["state"]["bri"].get();
-}
-
-unsigned int SimpleBrightnessStrategy::getBrightness(const HueLight& light) const
-{
- return light.state["state"]["bri"].get();
-}
diff --git a/hueplusplus/SimpleColorHueStrategy.cpp b/hueplusplus/SimpleColorHueStrategy.cpp
deleted file mode 100644
index 86c5ee4..0000000
--- a/hueplusplus/SimpleColorHueStrategy.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/**
- \file SimpleColorHueStrategy.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/SimpleColorHueStrategy.h"
-
-#include
-#include
-#include
-
-#include "include/HueConfig.h"
-#include "include/HueExceptionMacro.h"
-#include "include/Utils.h"
-
-bool SimpleColorHueStrategy::setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const
-{
- light.refreshState();
- nlohmann::json request = nlohmann::json::object();
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- if (light.state["state"]["hue"] != hue || light.state["state"]["colormode"] != "hs")
- {
- hue = hue % 65535;
- request["hue"] = hue;
- }
-
- if (!request.count("on") && !request.count("hue"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
-}
-
-bool SimpleColorHueStrategy::setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const
-{
- light.refreshState();
- nlohmann::json request = nlohmann::json::object();
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- if (light.state["state"]["sat"] != sat)
- {
- if (sat > 254)
- {
- sat = 254;
- }
- request["sat"] = sat;
- }
-
- if (!request.count("on") && !request.count("sat"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
-}
-
-bool SimpleColorHueStrategy::setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const
-{
- light.refreshState();
- nlohmann::json request = nlohmann::json::object();
-
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- if (light.state["state"]["hue"] != hue || light.state["state"]["colormode"] != "hs")
- {
- hue = hue % 65535;
- request["hue"] = hue;
- }
- if (light.state["state"]["sat"] != sat || light.state["state"]["colormode"] != "hs")
- {
- if (sat > 254)
- {
- sat = 254;
- }
- request["sat"] = sat;
- }
-
- if (!request.count("on") && !request.count("hue") && !request.count("sat"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
-}
-
-bool SimpleColorHueStrategy::setColorXY(float x, float y, uint8_t transition, HueLight& light) const
-{
- light.refreshState();
- nlohmann::json request = nlohmann::json::object();
-
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- if (std::abs(light.state["state"]["xy"][0].get() - x) > 1E-4f
- || std::abs(light.state["state"]["xy"][1].get() - y) > 1E-4f
- || light.state["state"]["colormode"] != "xy")
- {
- request["xy"][0] = x;
- request["xy"][1] = y;
- }
-
- if (!request.count("on") && !request.count("xy"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
-}
-
-bool SimpleColorHueStrategy::setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const
-{
- if ((r == 0) && (g == 0) && (b == 0))
- {
- return light.OffNoRefresh();
- }
-
- const float red = float(r) / 255;
- const float green = float(g) / 255;
- const float blue = float(b) / 255;
-
- // gamma correction
- const float redCorrected = (red > 0.04045f) ? pow((red + 0.055f) / (1.0f + 0.055f), 2.4f) : (red / 12.92f);
- const float greenCorrected = (green > 0.04045f) ? pow((green + 0.055f) / (1.0f + 0.055f), 2.4f) : (green / 12.92f);
- const float blueCorrected = (blue > 0.04045f) ? pow((blue + 0.055f) / (1.0f + 0.055f), 2.4f) : (blue / 12.92f);
-
- const float X = redCorrected * 0.664511f + greenCorrected * 0.154324f + blueCorrected * 0.162028f;
- const float Y = redCorrected * 0.283881f + greenCorrected * 0.668433f + blueCorrected * 0.047685f;
- const float Z = redCorrected * 0.000088f + greenCorrected * 0.072310f + blueCorrected * 0.986039f;
-
- const float x = X / (X + Y + Z);
- const float y = Y / (X + Y + Z);
-
- return light.setColorXY(x, y, transition);
-}
-
-bool SimpleColorHueStrategy::setColorLoop(bool on, HueLight& light) const
-{
- // colorloop
- light.refreshState();
- nlohmann::json request = nlohmann::json::object();
-
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- std::string effect;
- if ((effect = on ? "colorloop" : "none") != light.state["state"]["effect"])
- {
- request["effect"] = effect;
- }
- if (!request.count("on") && !request.count("effect"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
-}
-
-bool SimpleColorHueStrategy::alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "hs")
- {
- uint16_t oldHue = light.state["state"]["hue"].get();
- uint8_t oldSat = light.state["state"]["sat"].get();
- if (!light.setColorHueSaturation(hue, sat, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorHueSaturation(oldHue, oldSat, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorHueSaturation(oldHue, oldSat, 1);
- }
- }
- else if (cType == "xy")
- {
- float oldX = light.state["state"]["xy"][0].get();
- float oldY = light.state["state"]["xy"][1].get();
- if (!light.setColorHueSaturation(hue, sat, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorXY(oldX, oldY, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorXY(oldX, oldY, 1);
- }
- }
- else
- {
- return false;
- }
-}
-
-bool SimpleColorHueStrategy::alertXY(float x, float y, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "hs")
- {
- uint16_t oldHue = light.state["state"]["hue"].get();
- uint8_t oldSat = light.state["state"]["sat"].get();
- if (!light.setColorXY(x, y, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorHueSaturation(oldHue, oldSat, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorHueSaturation(oldHue, oldSat, 1);
- }
- }
- else if (cType == "xy")
- {
- float oldX = light.state["state"]["xy"][0].get();
- float oldY = light.state["state"]["xy"][1].get();
- if (!light.setColorXY(x, y, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorXY(oldX, oldY, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorXY(oldX, oldY, 1);
- }
- }
- else
- {
- return false;
- }
-}
-
-bool SimpleColorHueStrategy::alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "hs")
- {
- uint16_t oldHue = light.state["state"]["hue"].get();
- uint8_t oldSat = light.state["state"]["sat"].get();
- if (!light.setColorRGB(r, g, b, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorHueSaturation(oldHue, oldSat, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorHueSaturation(oldHue, oldSat, 1);
- }
- }
- else if (cType == "xy")
- {
- float oldX = light.state["state"]["xy"][0].get();
- float oldY = light.state["state"]["xy"][1].get();
- if (!light.setColorRGB(r, g, b, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorXY(oldX, oldY, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorXY(oldX, oldY, 1);
- }
- }
- else
- {
- return false;
- }
-}
-
-std::pair SimpleColorHueStrategy::getColorHueSaturation(HueLight& light) const
-{
- light.refreshState();
- return std::make_pair(light.state["state"]["hue"].get(), light.state["state"]["sat"].get());
-}
-
-std::pair SimpleColorHueStrategy::getColorHueSaturation(const HueLight& light) const
-{
- return std::make_pair(light.state["state"]["hue"].get(), light.state["state"]["sat"].get());
-}
-
-std::pair SimpleColorHueStrategy::getColorXY(HueLight& light) const
-{
- light.refreshState();
- return std::make_pair(light.state["state"]["xy"][0].get(), light.state["state"]["xy"][1].get());
-}
-
-std::pair SimpleColorHueStrategy::getColorXY(const HueLight& light) const
-{
- return std::make_pair(light.state["state"]["xy"][0].get(), light.state["state"]["xy"][1].get());
-}
-/*bool SimpleColorHueStrategy::pointInTriangle(float pointx, float pointy, float
-x0, float y0, float x1, float y1, float x2, float y2)
-{
-float A = (-y1 * x2 + y0*(-x1 + x2) + x0*(y1 - y2) + x1 * y1);
-int8_t sign = A < 0 ? -1 : 1;
-float s = (y0 * x2 - x0 * y2 + (y2 - y0) * pointx + (x0 - x2) * pointy) * sign;
-float t = (x0 * y1 - y0 * x1 + (y0 - y1) * pointx + (x1 - x0) * pointy) * sign;
-
-return s > 0 && t > 0 && (s + t) < A * sign;
-}*/
diff --git a/hueplusplus/SimpleColorTemperatureStrategy.cpp b/hueplusplus/SimpleColorTemperatureStrategy.cpp
deleted file mode 100644
index 8dac10f..0000000
--- a/hueplusplus/SimpleColorTemperatureStrategy.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- \file SimpleColorTemperatureStrategy.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/SimpleColorTemperatureStrategy.h"
-
-#include
-#include
-#include
-
-#include "include/HueConfig.h"
-#include "include/HueExceptionMacro.h"
-#include "include/Utils.h"
-
-bool SimpleColorTemperatureStrategy::setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const
-{
- light.refreshState();
- nlohmann::json request = nlohmann::json::object();
- if (transition != 4)
- {
- request["transitiontime"] = transition;
- }
- if (light.state["state"]["on"] != true)
- {
- request["on"] = true;
- }
- if (light.state["state"]["ct"] != mired)
- {
- if (mired > 500)
- {
- mired = 500;
- }
- if (mired < 153)
- {
- mired = 153;
- }
- request["ct"] = mired;
- }
-
- if (!request.count("on") && !request.count("ct"))
- {
- // Nothing needs to be changed
- return true;
- }
-
- nlohmann::json reply = light.SendPutRequest(request, "/state", CURRENT_FILE_INFO);
-
- // Check whether request was successful
- return utils::validateReplyForLight(request, reply, light.id);
-}
-
-bool SimpleColorTemperatureStrategy::alertTemperature(unsigned int mired, HueLight& light) const
-{
- light.refreshState();
- std::string cType = light.state["state"]["colormode"].get();
- bool on = light.state["state"]["on"].get();
- if (cType == "ct")
- {
- uint16_t oldCT = light.state["state"]["ct"].get();
- if (!light.setColorTemperature(mired, 1))
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_PRE_ALERT_DELAY));
- if (!light.alert())
- {
- return false;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(c_POST_ALERT_DELAY));
- if (!on)
- {
- light.setColorTemperature(oldCT, 1);
- return light.OffNoRefresh(1);
- }
- else
- {
- return light.setColorTemperature(oldCT, 1);
- }
- }
- else
- {
- return false;
- }
-}
-
-unsigned int SimpleColorTemperatureStrategy::getColorTemperature(HueLight& light) const
-{
- light.refreshState();
- return light.state["state"]["ct"].get();
-}
-
-unsigned int SimpleColorTemperatureStrategy::getColorTemperature(const HueLight& light) const
-{
- return light.state["state"]["ct"].get();
-}
diff --git a/hueplusplus/UPnP.cpp b/hueplusplus/UPnP.cpp
deleted file mode 100755
index 1d5b349..0000000
--- a/hueplusplus/UPnP.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- \file UPnP.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/UPnP.h"
-
-#include
-#include
-
-std::vector> UPnP::getDevices(std::shared_ptr handler)
-{
- // send UPnP M-Search request
- std::vector foundDevices
- = handler->sendMulticast("M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: "
- "\"ssdp:discover\"\r\nMX: 5\r\nST: ssdp:all\r\n\r\n",
- "239.255.255.250", 1900, 5);
-
- std::vector> devices;
-
- // filter out devices
- for (const std::string& s : foundDevices)
- {
- std::pair device;
- int start = s.find("LOCATION:") + 10;
- device.first = s.substr(start, s.find("\r\n", start) - start);
- start = s.find("SERVER:") + 8;
- device.second = s.substr(start, s.find("\r\n", start) - start);
- if (std::find_if(devices.begin(), devices.end(),
- [&](const std::pair& item) { return item.first == device.first; })
- == devices.end())
- {
- devices.push_back(device);
-
- // std::cout << "Device: \t" << device.first << std::endl;
- // std::cout << " \t" << device.second << std::endl;
- }
- }
- return devices;
-}
diff --git a/hueplusplus/Utils.cpp b/hueplusplus/Utils.cpp
deleted file mode 100644
index 2b55488..0000000
--- a/hueplusplus/Utils.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- \file Utils.cpp
- Copyright Notice\n
- Copyright (C) 2020 Jan Rogall - developer\n
- Copyright (C) 2020 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/Utils.h"
-
-#include
-
-namespace utils
-{
- bool validateReplyForLight(const nlohmann::json& request, const nlohmann::json& reply, int lightId)
- {
- bool success = false;
- std::string path = "/lights/" + std::to_string(lightId) + "/state/";
- for (auto it = reply.begin(); it != reply.end(); ++it)
- {
- success = it.value().count("success");
- if (success)
- {
- // Traverse through first object
- nlohmann::json successObject = it.value()["success"];
- for (auto successIt = successObject.begin(); successIt != successObject.end(); ++successIt)
- {
- const std::string successPath = successIt.key();
- if (successPath.find(path) == 0)
- {
- const std::string valueKey = successPath.substr(path.size());
- auto requestIt = request.find(valueKey);
- success = requestIt != request.end();
- if (success)
- {
- if (valueKey == "xy")
- {
- success
- = std::abs(requestIt.value()[0].get() - successIt.value()[0].get())
- <= 1E-4f
- && std::abs(requestIt.value()[1].get() - successIt.value()[1].get())
- <= 1E-4f;
- }
- else
- {
- success = requestIt.value() == successIt.value();
- }
- if (!success)
- {
- std::cout << "Value " << requestIt.value() << " does not match reply "
- << successIt.value() << std::endl;
- }
- }
- }
- else
- {
- success = false;
- }
- }
- }
- if (!success) // Fail fast
- {
- break;
- }
- }
- return success;
- }
-} // namespace utils
\ No newline at end of file
diff --git a/hueplusplus/WinHttpHandler.cpp b/hueplusplus/WinHttpHandler.cpp
deleted file mode 100755
index 23a53cf..0000000
--- a/hueplusplus/WinHttpHandler.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-/**
- \file WinHttpHandler.cpp
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#include "include/WinHttpHandler.h"
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#pragma comment(lib, "Ws2_32.lib")
-
-namespace
-{
- class AddrInfoFreer
- {
- public:
- explicit AddrInfoFreer(addrinfo* p) : p(p) {}
- ~AddrInfoFreer() { freeaddrinfo(p); }
-
- private:
- addrinfo* p;
- };
- class SocketCloser
- {
- public:
- explicit SocketCloser(SOCKET s) : s(s) {}
- ~SocketCloser() { closesocket(s); }
-
- private:
- SOCKET s;
- };
-} // namespace
-
-WinHttpHandler::WinHttpHandler()
-{
- // Initialize Winsock
- int return_code = WSAStartup(MAKEWORD(2, 2), &wsaData);
- if (return_code != 0)
- {
- std::cerr << "WinHttpHandler: Failed to open socket: " << return_code << std::endl;
- throw(std::system_error(return_code, std::system_category(), "WinHttpHandler: Failed to open socket"));
- }
-}
-
-WinHttpHandler::~WinHttpHandler()
-{
- WSACleanup();
-}
-
-std::string WinHttpHandler::send(const std::string& msg, const std::string& adr, int port) const
-{
- struct addrinfo hints = {};
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
-
- // Resolve the server address and port
- struct addrinfo* result = nullptr;
- if (getaddrinfo(adr.c_str(), std::to_string(port).c_str(), &hints, &result) != 0)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: getaddrinfo failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: getaddrinfo failed"));
- }
- SOCKET connect_socket = INVALID_SOCKET;
- int connectError = 0;
- {
- AddrInfoFreer freeResult(result);
-
- // Attempt to connect to the first address returned by
- // the call to getaddrinfo
- struct addrinfo* ptr = result;
-
- // Create a SOCKET for connecting to server
- connect_socket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
-
- if (connect_socket == INVALID_SOCKET)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: Error at socket(): " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: Error at socket()"));
- }
-
- // Connect to server.
- if (connect(connect_socket, ptr->ai_addr, (int)ptr->ai_addrlen) == SOCKET_ERROR)
- {
- connectError = WSAGetLastError();
- closesocket(connect_socket);
- connect_socket = INVALID_SOCKET;
- }
-
- // Should really try the next address returned by getaddrinfo
- // if the connect call failed
- // But for this simple example we just free the resources
- // returned by getaddrinfo and print an error message
- }
-
- if (connect_socket == INVALID_SOCKET)
- {
- std::cerr << "WinHttpHandler: Unable to connect to server!" << std::endl;
- throw std::system_error(connectError, std::system_category(), "WinHttpHandler: Unable to connect to server!");
- }
- SocketCloser closeSocket(connect_socket);
-
- // Send an initial buffer
- if (::send(connect_socket, msg.c_str(), msg.size(), 0) == SOCKET_ERROR)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: send failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: send failed"));
- }
-
- // shutdown the connection for sending since no more data will be sent
- // the client can still use the ConnectSocket for receiving data
- if (shutdown(connect_socket, SD_SEND) == SOCKET_ERROR)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: shutdown failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: shutdown failed"));
- }
-
- const int recvbuflen = 128;
- char recvbuf[recvbuflen];
-
- // Receive data until the server closes the connection
- std::string response;
- int res;
- do
- {
- res = recv(connect_socket, recvbuf, recvbuflen, 0);
- if (res > 0)
- {
- // std::cout << "WinHttpHandler: Bytes received: " << res << std::endl;
- response.append(recvbuf, res);
- }
- else if (res == 0)
- {
- // std::cout << "WinHttpHandler: Connection closed " << std::endl;
- }
- else
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: recv failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: recv failed"));
- }
- } while (res > 0);
-
- return response;
-}
-
-std::vector WinHttpHandler::sendMulticast(
- const std::string& msg, const std::string& adr, int port, int timeout) const
-{
- struct addrinfo hints = {};
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_TCP;
-
- // Resolve the server address and port
- struct addrinfo* result = nullptr;
- if (getaddrinfo(adr.c_str(), std::to_string(port).c_str(), &hints, &result) != 0)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: sendMulticast: getaddrinfo failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: getaddrinfo failed"));
- }
- AddrInfoFreer freeResult(result);
-
- // Attempt to connect to the first address returned by
- // the call to getaddrinfo
- struct addrinfo* ptr = result;
-
- // Create a SOCKET for connecting to server
- SOCKET connect_socket = socket(ptr->ai_family, ptr->ai_socktype, 0);
- if (connect_socket == INVALID_SOCKET)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: sendMulticast: Error at socket(): " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: Error at socket()"));
- }
- SocketCloser closeSocket(connect_socket);
-
- // Fill out source socket's address information.
- SOCKADDR_IN source_sin;
- source_sin.sin_family = AF_INET;
- source_sin.sin_port = htons(0);
- source_sin.sin_addr.s_addr = htonl(INADDR_ANY);
-
- // Associate the source socket's address with the socket, Sock.
- if (bind(connect_socket, (struct sockaddr FAR*)&source_sin, sizeof(source_sin)) == SOCKET_ERROR)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: sendMulticast: Binding socket failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: Binding socket failed"));
- }
-
- u_long sock_mode = 1;
- ioctlsocket(connect_socket, FIONBIO, &sock_mode);
-
- BOOL bOptVal = TRUE;
- setsockopt(connect_socket, SOL_SOCKET, SO_BROADCAST, (char*)&bOptVal, sizeof(bOptVal));
-
- // Set the Time-to-Live of the multicast.
- int iOptVal = 1; // for same subnet, but might be increased to 16
- if (setsockopt(connect_socket, IPPROTO_IP, IP_MULTICAST_TTL, (char FAR*)&iOptVal, sizeof(int)) == SOCKET_ERROR)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: sendMulticast: setsockopt failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: setsockopt failed"));
- }
-
- // Fill out the desination socket's address information.
- SOCKADDR_IN dest_sin;
- dest_sin.sin_family = AF_INET;
- dest_sin.sin_port = htons(port);
- dest_sin.sin_addr.s_addr = inet_addr((const char*)ptr->ai_addr);
-
- // Send a message to the multicasting address.
- if (sendto(connect_socket, msg.c_str(), msg.size(), 0, (struct sockaddr FAR*)&dest_sin, sizeof(dest_sin))
- == SOCKET_ERROR)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: sendMulticast: sendto failed: " << WSAGetLastError() << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: sendto failed"));
- }
-
- // shutdown the connection for sending since no more data will be sent
- // the client can still use the ConnectSocket for receiving data
- if (shutdown(connect_socket, SD_SEND) == SOCKET_ERROR)
- {
- int err = WSAGetLastError();
- std::cerr << "WinHttpHandler: sendMulticast: shutdown failed: " << err << std::endl;
- throw(std::system_error(err, std::system_category(), "WinHttpHandler: sendMulticast: shutdown failed"));
- }
-
- std::string response;
- const int recvbuflen = 2048;
- char recvbuf[recvbuflen] = {};
- std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
- while (std::chrono::steady_clock::now() - start < std::chrono::seconds(timeout))
- {
- int res = recv(connect_socket, recvbuf, recvbuflen, 0);
- if (res > 0)
- {
- // std::cout << "WinHttpHandler: sendMulticast: Bytes received: " << res
- // << std::endl;
- response.append(recvbuf, res);
- }
- else if (res == 0)
- {
- // std::cout << "WinHttpHandler: sendMulticast: Connection closed " <<
- // std::endl;
- }
- else
- {
- // No exception here due to non blocking socket
- // std::cerr << "sendMulticast: recv failed: " << WSAGetLastError() <<
- // std::endl; throw(std::runtime_error("recv failed"));
- }
- }
-
- // construct return vector
- std::vector returnString;
- size_t pos = response.find("\r\n\r\n");
- size_t prevpos = 0;
- while (pos != std::string::npos)
- {
- returnString.push_back(response.substr(prevpos, pos - prevpos));
- pos += 4;
- prevpos = pos;
- pos = response.find("\r\n\r\n", pos);
- }
-
- return returnString;
-}
diff --git a/hueplusplus/hueplusplus-config.cmake.in b/hueplusplus/hueplusplus-config.cmake.in
deleted file mode 100755
index dc1490f..0000000
--- a/hueplusplus/hueplusplus-config.cmake.in
+++ /dev/null
@@ -1,7 +0,0 @@
-# -config file of the hueplusplus package
-# It defines the following
-# hueplusplus_FOUND - which indicates that the module was found
-# hueplusplus_INCLUDE_DIR
-
-set(hueplusplus_FOUND TRUE)
-set(hueplusplus_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@")
diff --git a/hueplusplus/include/BaseHttpHandler.h b/hueplusplus/include/BaseHttpHandler.h
deleted file mode 100644
index 22d29c6..0000000
--- a/hueplusplus/include/BaseHttpHandler.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- \file BaseHttpHandler.h
- Copyright Notice\n
- Copyright (C) 2020 Jan Rogall - developer\n
- Copyright (C) 2020 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef _BASE_HTTPHANDLER_H
-#define _BASE_HTTPHANDLER_H
-
-#include
-#include
-#include
-#include
-
-#include "IHttpHandler.h"
-
-#include "json/json.hpp"
-
-//! Base class for classes that handle http requests and multicast requests
-class BaseHttpHandler : public IHttpHandler
-{
-public:
- //! \brief Virtual dtor
- virtual ~BaseHttpHandler() = default;
-
- //! \brief Send a message to a specified host and return the body of the response.
- //!
- //! \param msg The message that should sent to the specified address
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! \return The body of the response of the host as a string
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- std::string sendGetHTTPBody(const std::string& msg, const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP request with the given method to the specified host and return the body of the response.
- //!
- //! \param method HTTP method type e.g. GET, HEAD, POST, PUT, DELETE, ...
- //! \param uri Uniform Resource Identifier in the request
- //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ...
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! \return Body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- std::string sendHTTPRequest(const std::string& method, const std::string& uri, const std::string& contentType,
- const std::string& body, const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP GET request to the specified host and return the body of the response.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ...
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! that specifies the port to which the request is sent to. Default is 80
- //! \return Body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- std::string GETString(const std::string& uri, const std::string& contentType, const std::string& body,
- const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP POST request to the specified host and return the body of the response.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ...
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! that specifies the port to which the request is sent to. Default is 80
- //! \return Body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- std::string POSTString(const std::string& uri, const std::string& contentType, const std::string& body,
- const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP PUT request to the specified host and return the body of the response.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ...
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! that specifies the port to which the request is sent to. Default is 80
- //! \return Body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- std::string PUTString(const std::string& uri, const std::string& contentType, const std::string& body,
- const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP DELETE request to the specified host and return the body of the response.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param contentType MIME type of the body data e.g. "text/html", "application/json", ...
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! that specifies the port to which the request is sent to. Default is 80
- //! \return Body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- std::string DELETEString(const std::string& uri, const std::string& contentType, const std::string& body,
- const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP GET request to the specified host and return the body of the response parsed as JSON.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! \return Parsed body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- //! \throws nlohmann::json::parse_error when the body could not be parsed
- nlohmann::json GETJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP POST request to the specified host and return the body of the response parsed as JSON.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! \return Parsed body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- //! \throws nlohmann::json::parse_error when the body could not be parsed
- nlohmann::json POSTJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP PUT request to the specified host and return the body of the response parsed as JSON.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! \return Parsed body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- //! \throws nlohmann::json::parse_error when the body could not be parsed
- nlohmann::json PUTJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
-
- //! \brief Send a HTTP DELETE request to the specified host and return the body of the response parsed as JSON.
- //!
- //! \param uri Uniform Resource Identifier in the request
- //! \param body Request body, may be empty
- //! \param adr Ip or hostname in dotted decimal notation like "192.168.2.1"
- //! \param port Optional port the request is sent to, default is 80
- //! \return Parsed body of the response of the host
- //! \throws std::system_error when system or socket operations fail
- //! \throws HueException when response contained no body
- //! \throws nlohmann::json::parse_error when the body could not be parsed
- nlohmann::json DELETEJson(
- const std::string& uri, const nlohmann::json& body, const std::string& adr, int port = 80) const override;
-};
-
-#endif
diff --git a/hueplusplus/include/BrightnessStrategy.h b/hueplusplus/include/BrightnessStrategy.h
deleted file mode 100755
index 1c12704..0000000
--- a/hueplusplus/include/BrightnessStrategy.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- \file BrightnessStrategy.h
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef _BRIGHTNESS_STRATEGY_H
-#define _BRIGHTNESS_STRATEGY_H
-
-#include
-
-class HueLight;
-
-//! Virtual base class for all BrightnessStrategies
-class BrightnessStrategy
-{
-public:
- //! \brief Virtual function for changing a lights brightness with a specified
- //! transition.
- //!
- //! \param bri The brightness raning from 0 = off to 255 = fully lit
- //! \param transition The time it takes to fade to the new brightness in
- //! multiples of 100ms, 4 = 400ms and should be seen as the default \param
- //! light A reference of the light
- virtual bool setBrightness(unsigned int bri, uint8_t transition, HueLight& light) const = 0;
- //! \brief Virtual function that returns the current brightnessof the light
- //!
- //! Should update the lights state by calling refreshState()
- //! \param light A reference of the light
- //! \return Unsigned int representing the brightness
- virtual unsigned int getBrightness(HueLight& light) const = 0;
- //! \brief Virtual function that returns the current brightness of the light
- //!
- //! \note This should not update the lights state
- //! \param light A const reference of the light
- //! \return Unsigned int representing the brightness
- virtual unsigned int getBrightness(const HueLight& light) const = 0;
- //! \brief Virtual dtor
- virtual ~BrightnessStrategy() = default;
-};
-
-#endif
diff --git a/hueplusplus/include/ColorHueStrategy.h b/hueplusplus/include/ColorHueStrategy.h
deleted file mode 100755
index 7d40d8a..0000000
--- a/hueplusplus/include/ColorHueStrategy.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- \file ColorHueStrategy.h
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef _COLOR_HUE_STRATEGY_H
-#define _COLOR_HUE_STRATEGY_H
-
-#include
-
-#include
-
-class HueLight;
-
-//! Virtual base class for all ColorHueStrategies
-class ColorHueStrategy
-{
-public:
- //! \brief Virtual function for changing a lights color in hue with a
- //! specified transition.
- //!
- //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is
- //! green and 46920 is blue. \param hue The hue of the color \param transition
- //! The time it takes to fade to the new color in multiples of 100ms, 4 =
- //! 400ms and should be seen as the default \param light A reference of the
- //! light
- virtual bool setColorHue(uint16_t hue, uint8_t transition, HueLight& light) const = 0;
- //! \brief Virtual function for changing a lights color in saturation with a
- //! specified transition.
- //!
- //! The saturation ranges from 0 to 254, whereas 0 is least saturated (white)
- //! and 254 is most saturated (vibrant). \param sat The saturation of the
- //! color \param transition The time it takes to fade to the new color in
- //! multiples of 100ms, 4 = 400ms and should be seen as the default \param
- //! light A reference of the light
- virtual bool setColorSaturation(uint8_t sat, uint8_t transition, HueLight& light) const = 0;
- //! \brief Virtual function for changing a lights color in hue and saturation
- //! format with a specified transition.
- //!
- //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is
- //! green and 46920 is blue. The saturation ranges from 0 to 254, whereas 0 is
- //! least saturated (white) and 254 is most saturated (vibrant). \param hue
- //! The hue of the color \param sat The saturation of the color \param
- //! transition The time it takes to fade to the new color in multiples of
- //! 100ms, 4 = 400ms and should be seen as the default \param light A
- //! reference of the light
- virtual bool setColorHueSaturation(uint16_t hue, uint8_t sat, uint8_t transition, HueLight& light) const = 0;
- //! \brief Virtual function for changing a lights color in CIE format with a
- //! specified transition.
- //!
- //! \param x The x coordinate in CIE, ranging from 0 to 1
- //! \param y The y coordinate in CIE, ranging from 0 to 1
- //! \param transition The time it takes to fade to the new color in multiples
- //! of 100ms, 4 = 400ms and should be seen as the default \param light A
- //! reference of the light
- virtual bool setColorXY(float x, float y, uint8_t transition, HueLight& light) const = 0;
- //! \brief Virtual function for changing a lights color in rgb format with a
- //! specified transition.
- //!
- //! Red, green and blue are ranging from 0 to 255.
- //! \param r The red portion of the color
- //! \param g The green portion of the color
- //! \param b The blue portion of the color
- //! \param transition The time it takes to fade to the new color in multiples
- //! of 100ms, 4 = 400ms and should be seen as the default \param light A
- //! reference of the light
- virtual bool setColorRGB(uint8_t r, uint8_t g, uint8_t b, uint8_t transition, HueLight& light) const = 0;
- //! \brief Virtual function for turning on/off the color loop feature of a
- //! light.
- //!
- //! Can be theoretically set for any light, but it only works for lights that
- //! support this feature. When this feature is activated the light will fade
- //! through every color on the current hue and saturation settings. Notice
- //! that none of the setter functions check whether this feature is enabled
- //! and the colorloop can only be disabled with this function or by simply
- //! calling Off()/OffNoRefresh() and then On()/OnNoRefresh(), so you could
- //! alternatively call Off() and then use any of the setter functions. \param
- //! on Boolean to turn this feature on or off, true/1 for on and false/0 for
- //! off \param light A reference of the light
- virtual bool setColorLoop(bool on, HueLight& light) const = 0;
- //! \brief Virtual function that lets the light perform one breath cycle in
- //! the specified color.
- //!
- //! The hue ranges from 0 to 65535, whereas 65535 and 0 are red, 25500 is
- //! green and 46920 is blue. The saturation ranges from 0 to 254, whereas 0 is
- //! least saturated (white) and 254 is most saturated (vibrant). \param hue
- //! The hue of the color \param sat The saturation of the color \param light A
- //! reference of the light
- virtual bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const = 0;
- //! \brief Virtual function that lets the light perform one breath cycle in
- //! the specified color.
- //!
- //! \param x The x coordinate in CIE, ranging from 0 to 1
- //! \param y The y coordinate in CIE, ranging from 0 to 1
- //! \param light A reference of the light
- virtual bool alertXY(float x, float y, HueLight& light) const = 0;
- //! \brief Virtual function that lets the light perform one breath cycle in
- //! the specified color.
- //!
- //! Red, green and blue are ranging from 0 to 255.
- //! \param r The red portion of the color
- //! \param g The green portion of the color
- //! \param b The blue portion of the color
- //! \param light A reference of the light
- virtual bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const = 0;
- //! \brief Virtual function that returns the current color of the light as hue
- //! and saturation
- //!
- //! Should update the lights state by calling refreshState()
- //! \param light A reference of the light
- //! \return Pair containing the hue as first value and saturation as second
- //! value
- virtual std::pair getColorHueSaturation(HueLight& light) const = 0;
- //! \brief Virtual function that returns the current color of the light as hue
- //! and saturation
- //!
- //! \note This should not update the lights state
- //! \param light A const reference of the light
- //! \return Pair containing the hue as first value and saturation as second
- //! value
- virtual std::pair getColorHueSaturation(const HueLight& light) const = 0;
- //! \brief Virtual function that returns the current color of the light as xy
- //!
- //! Should update the lights state by calling refreshState()
- //! \param light A reference of the light
- //! \return Pair containing the x as first value and y as second value
- virtual std::pair getColorXY(HueLight& light) const = 0;
- //! \brief Virtual function that returns the current color of the light as xy
- //!
- //! \note This should not update the lights state
- //! \param light A const reference of the light
- //! \return Pair containing the x as first value and y as second value
- virtual std::pair getColorXY(const HueLight& light) const = 0;
- //! \brief Virtual dtor
- virtual ~ColorHueStrategy() = default;
-};
-
-#endif
diff --git a/hueplusplus/include/ColorTemperatureStrategy.h b/hueplusplus/include/ColorTemperatureStrategy.h
deleted file mode 100755
index 37be4fe..0000000
--- a/hueplusplus/include/ColorTemperatureStrategy.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- \file ColorTemperatureStrategy.h
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef _COLOR_TEMPERATURE_STRATEGY_H
-#define _COLOR_TEMPERATURE_STRATEGY_H
-
-#include
-
-class HueLight;
-
-//! Virtual base class for all ColorTemperatureStrategies
-class ColorTemperatureStrategy
-{
-public:
- //! \brief Virtual function for changing a lights color temperature in mired
- //! with a specified transition.
- //!
- //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold
- //! and 500 is warm. \param mired The color temperature in mired \param
- //! transition The time it takes to fade to the new color in multiples of
- //! 100ms, 4 = 400ms and should be seen as the default \param light A
- //! reference of the light
- virtual bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const = 0;
- //! \brief Virtual function that lets the light perform one breath cycle in
- //! the specified color.
- //!
- //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold
- //! and 500 is warm. \param mired The color temperature in mired \param light
- //! A reference of the light
- virtual bool alertTemperature(unsigned int mired, HueLight& light) const = 0;
- //! \brief Virtual function that returns the current color temperature of the
- //! light
- //!
- //! Should update the lights state by calling refreshState()
- //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold
- //! and 500 is warm. \param light A reference of the light \return Unsigned
- //! int representing the color temperature in mired
- virtual unsigned int getColorTemperature(HueLight& light) const = 0;
- //! \brief Virtual function that returns the current color temperature of the
- //! light
- //!
- //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold
- //! and 500 is warm. \note This should not update the lights state \param
- //! light A const reference of the light \return Unsigned int representing the
- //! color temperature in mired
- virtual unsigned int getColorTemperature(const HueLight& light) const = 0;
- //! \brief Virtual dtor
- virtual ~ColorTemperatureStrategy() = default;
-};
-
-#endif
diff --git a/hueplusplus/include/ExtendedColorHueStrategy.h b/hueplusplus/include/ExtendedColorHueStrategy.h
deleted file mode 100755
index 000418f..0000000
--- a/hueplusplus/include/ExtendedColorHueStrategy.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- \file ExtendedColorHueStrategy.h
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef _EXTENDED_COLOR_HUE_STRATEGY_H
-#define _EXTENDED_COLOR_HUE_STRATEGY_H
-
-#include "HueLight.h"
-#include "SimpleColorHueStrategy.h"
-
-//! Class extending the implementation of SimpleColorHueStrategy
-class ExtendedColorHueStrategy : public SimpleColorHueStrategy
-{
-public:
- //! \brief Function that lets the light perform one breath cycle in the
- //! specified color.
- //!
- //! It uses this_thread::sleep_for to accomodate for the time an \ref
- //! HueLight::alert() needs The hue ranges from 0 to 65535, whereas 65535 and
- //! 0 are red, 25500 is green and 46920 is blue. The saturation ranges from 0
- //! to 254, whereas 0 is least saturated (white) and 254 is most saturated
- //! (vibrant). \param hue The hue of the color \param sat The saturation of
- //! the color \param light A reference of the light
- bool alertHueSaturation(uint16_t hue, uint8_t sat, HueLight& light) const override;
- //! \brief Function that lets the light perform one breath cycle in the
- //! specified color.
- //!
- //! It uses this_thread::sleep_for to accomodate for the time an \ref
- //! HueLight::alert() needs \param x The x coordinate in CIE, ranging from 0
- //! to 1 \param y The y coordinate in CIE, ranging from 0 to 1 \param light A
- //! reference of the light
- bool alertXY(float x, float y, HueLight& light) const override;
- //! \brief Function that lets the light perform one breath cycle in the
- //! specified color.
- //!
- //! It uses this_thread::sleep_for to accomodate for the time an \ref
- //! HueLight::alert() needs Red, green and blue are ranging from 0 to 255.
- //! \param r The red portion of the color
- //! \param g The green portion of the color
- //! \param b The blue portion of the color
- //! \param light A reference of the light
- bool alertRGB(uint8_t r, uint8_t g, uint8_t b, HueLight& light) const override;
-};
-
-#endif
diff --git a/hueplusplus/include/ExtendedColorTemperatureStrategy.h b/hueplusplus/include/ExtendedColorTemperatureStrategy.h
deleted file mode 100755
index e24137c..0000000
--- a/hueplusplus/include/ExtendedColorTemperatureStrategy.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- \file ExtendedColorTemperatureStrategy.h
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef _EXTENDED_COLOR_TEMPERATURE_STRATEGY_H
-#define _EXTENDED_COLOR_TEMPERATURE_STRATEGY_H
-
-#include "HueLight.h"
-#include "SimpleColorTemperatureStrategy.h"
-
-//! Class implementing the functions of ColorTemperatureStrategy
-class ExtendedColorTemperatureStrategy : public SimpleColorTemperatureStrategy
-{
-public:
- //! \brief Function for changing a lights color temperature in mired with a
- //! specified transition.
- //!
- //! The color temperature in mired ranges from 153 to 500 whereas 153 is cold
- //! and 500 is warm. \param mired The color temperature in mired \param
- //! transition The time it takes to fade to the new color in multiples of
- //! 100ms, 4 = 400ms and should be seen as the default \param light A
- //! reference of the light
- bool setColorTemperature(unsigned int mired, uint8_t transition, HueLight& light) const override;
- //! \brief Function that lets the light perform one breath cycle in the
- //! specified color.
- //!
- //! It uses this_thread::sleep_for to accomodate for the time an \ref
- //! HueLight::alert() needs The color temperature in mired ranges from 153 to
- //! 500 whereas 153 is cold and 500 is warm. \param mired The color
- //! temperature in mired \param light A reference of the light
- bool alertTemperature(unsigned int mired, HueLight& light) const override;
-};
-
-#endif
diff --git a/hueplusplus/include/Hue.h b/hueplusplus/include/Hue.h
deleted file mode 100644
index 1aa8360..0000000
--- a/hueplusplus/include/Hue.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/**
- \file Hue.h
- Copyright Notice\n
- Copyright (C) 2017 Jan Rogall - developer\n
- Copyright (C) 2017 Moritz Wirger - developer\n
-
- This file is part of hueplusplus.
-
- hueplusplus is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- hueplusplus is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with hueplusplus. If not, see .
-**/
-
-#ifndef _HUE_H
-#define _HUE_H
-
-#include