Update hueplusplus dependency to 1.2.0

This commit is contained in:
Adam Honse 2025-02-14 11:40:34 -06:00
parent bb6f8e2ddd
commit 0d6ae64b24
153 changed files with 305 additions and 23091 deletions

View file

@ -11,7 +11,7 @@
#include <iostream> #include <iostream>
#include "ElgatoKeyLightController.h" #include "ElgatoKeyLightController.h"
#include "json.hpp" #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;

View file

@ -14,7 +14,7 @@
#include <thread> #include <thread>
#include <vector> #include <vector>
#include "ElgatoLightStripController.h" #include "ElgatoLightStripController.h"
#include "json.hpp" #include <nlohmann/json.hpp>
#include "LogManager.h" #include "LogManager.h"
using json = nlohmann::json; using json = nlohmann::json;

View file

@ -11,7 +11,7 @@
#include <cstdint> #include <cstdint>
#include "KasaSmartController.h" #include "KasaSmartController.h"
#include "json.hpp" #include <nlohmann/json.hpp>
#include "hsv.h" #include "hsv.h"
using json = nlohmann::json; using json = nlohmann::json;
@ -273,7 +273,7 @@ void KasaSmartController::SetEffect(std::string effect)
is_initialized = false; is_initialized = false;
return; return;
} }
std::string response; std::string response;
KasaSmartController::SendCommand(effect, response); KasaSmartController::SendCommand(effect, response);
port.tcp_close(); port.tcp_close();

View file

@ -10,7 +10,7 @@
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
#include "LIFXController.h" #include "LIFXController.h"
#include "json.hpp" #include <nlohmann/json.hpp>
#include "hsv.h" #include "hsv.h"
using json = nlohmann::json; using json = nlohmann::json;

View file

@ -12,7 +12,7 @@
#include "RGBController_Nanoleaf.h" #include "RGBController_Nanoleaf.h"
#include "ResourceManager.h" #include "ResourceManager.h"
#include "LogManager.h" #include "LogManager.h"
#include "json.hpp" #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;

View file

@ -10,7 +10,7 @@
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
#include "PhilipsWizController.h" #include "PhilipsWizController.h"
#include "json.hpp" #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;
using namespace std::chrono_literals; using namespace std::chrono_literals;
@ -130,7 +130,7 @@ void PhilipsWizController::SetColor(unsigned char red, unsigned char green, unsi
command["params"]["w"] = 0; command["params"]["w"] = 0;
} }
/*-----------------------------------------------------------------*\ /*-----------------------------------------------------------------*\
| Fill in the setPilot command with RGB and brightness information. | | Fill in the setPilot command with RGB and brightness information. |
| The bulb will not respond to 0, 0, 0, so if all channels are zero,| | The bulb will not respond to 0, 0, 0, so if all channels are zero,|

View file

@ -10,7 +10,7 @@
\*---------------------------------------------------------*/ \*---------------------------------------------------------*/
#include "YeelightController.h" #include "YeelightController.h"
#include "json.hpp" #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;

View file

@ -15,7 +15,7 @@
#include <vector> #include <vector>
#include <queue> #include <queue>
#include <memory> #include <memory>
#include "json.hpp" #include <nlohmann/json.hpp>
#include "filesystem.h" #include "filesystem.h"
/*-------------------------------------------------*\ /*-------------------------------------------------*\
@ -78,7 +78,7 @@ private:
// Logfile max level // Logfile max level
unsigned int loglevel = LL_INFO; unsigned int loglevel = LL_INFO;
// Verbosity (stdout) max level // Verbosity (stdout) max level
unsigned int verbosity = LL_WARNING; unsigned int verbosity = LL_WARNING;

View file

@ -143,8 +143,8 @@ INCLUDEPATH +=
$$GUI_INCLUDES \ $$GUI_INCLUDES \
dependencies/ColorWheel \ dependencies/ColorWheel \
dependencies/CRCpp/ \ dependencies/CRCpp/ \
dependencies/hueplusplus-1.1.0/include \ dependencies/hueplusplus-1.2.0/include \
dependencies/hueplusplus-1.1.0/include/hueplusplus \ dependencies/hueplusplus-1.2.0/include/hueplusplus \
dependencies/httplib \ dependencies/httplib \
dependencies/json/ \ dependencies/json/ \
dependencies/mdns \ dependencies/mdns \
@ -170,7 +170,7 @@ HEADERS +=
$$CONTROLLER_H \ $$CONTROLLER_H \
Colors.h \ Colors.h \
dependencies/ColorWheel/ColorWheel.h \ dependencies/ColorWheel/ColorWheel.h \
dependencies/json/json.hpp \ dependencies/json/nlohmann/json.hpp \
LogManager.h \ LogManager.h \
NetworkClient.h \ NetworkClient.h \
NetworkProtocol.h \ NetworkProtocol.h \
@ -210,35 +210,35 @@ SOURCES +=
$$GUI_CPP \ $$GUI_CPP \
$$CONTROLLER_CPP \ $$CONTROLLER_CPP \
dependencies/ColorWheel/ColorWheel.cpp \ dependencies/ColorWheel/ColorWheel.cpp \
dependencies/hueplusplus-1.1.0/src/Action.cpp \ dependencies/hueplusplus-1.2.0/src/Action.cpp \
dependencies/hueplusplus-1.1.0/src/APICache.cpp \ dependencies/hueplusplus-1.2.0/src/APICache.cpp \
dependencies/hueplusplus-1.1.0/src/BaseDevice.cpp \ dependencies/hueplusplus-1.2.0/src/BaseDevice.cpp \
dependencies/hueplusplus-1.1.0/src/BaseHttpHandler.cpp \ dependencies/hueplusplus-1.2.0/src/BaseHttpHandler.cpp \
dependencies/hueplusplus-1.1.0/src/Bridge.cpp \ dependencies/hueplusplus-1.2.0/src/Bridge.cpp \
dependencies/hueplusplus-1.1.0/src/BridgeConfig.cpp \ dependencies/hueplusplus-1.2.0/src/BridgeConfig.cpp \
dependencies/hueplusplus-1.1.0/src/CLIPSensors.cpp \ dependencies/hueplusplus-1.2.0/src/CLIPSensors.cpp \
dependencies/hueplusplus-1.1.0/src/ColorUnits.cpp \ dependencies/hueplusplus-1.2.0/src/ColorUnits.cpp \
dependencies/hueplusplus-1.1.0/src/EntertainmentMode.cpp \ dependencies/hueplusplus-1.2.0/src/EntertainmentMode.cpp \
dependencies/hueplusplus-1.1.0/src/ExtendedColorHueStrategy.cpp \ dependencies/hueplusplus-1.2.0/src/ExtendedColorHueStrategy.cpp \
dependencies/hueplusplus-1.1.0/src/ExtendedColorTemperatureStrategy.cpp \ dependencies/hueplusplus-1.2.0/src/ExtendedColorTemperatureStrategy.cpp \
dependencies/hueplusplus-1.1.0/src/Group.cpp \ dependencies/hueplusplus-1.2.0/src/Group.cpp \
dependencies/hueplusplus-1.1.0/src/HueCommandAPI.cpp \ dependencies/hueplusplus-1.2.0/src/HueCommandAPI.cpp \
dependencies/hueplusplus-1.1.0/src/HueDeviceTypes.cpp \ dependencies/hueplusplus-1.2.0/src/HueDeviceTypes.cpp \
dependencies/hueplusplus-1.1.0/src/HueException.cpp \ dependencies/hueplusplus-1.2.0/src/HueException.cpp \
dependencies/hueplusplus-1.1.0/src/Light.cpp \ dependencies/hueplusplus-1.2.0/src/Light.cpp \
dependencies/hueplusplus-1.1.0/src/ModelPictures.cpp \ dependencies/hueplusplus-1.2.0/src/ModelPictures.cpp \
dependencies/hueplusplus-1.1.0/src/NewDeviceList.cpp \ dependencies/hueplusplus-1.2.0/src/NewDeviceList.cpp \
dependencies/hueplusplus-1.1.0/src/Scene.cpp \ dependencies/hueplusplus-1.2.0/src/Scene.cpp \
dependencies/hueplusplus-1.1.0/src/Schedule.cpp \ dependencies/hueplusplus-1.2.0/src/Schedule.cpp \
dependencies/hueplusplus-1.1.0/src/Sensor.cpp \ dependencies/hueplusplus-1.2.0/src/Sensor.cpp \
dependencies/hueplusplus-1.1.0/src/SimpleBrightnessStrategy.cpp \ dependencies/hueplusplus-1.2.0/src/SimpleBrightnessStrategy.cpp \
dependencies/hueplusplus-1.1.0/src/SimpleColorHueStrategy.cpp \ dependencies/hueplusplus-1.2.0/src/SimpleColorHueStrategy.cpp \
dependencies/hueplusplus-1.1.0/src/SimpleColorTemperatureStrategy.cpp \ dependencies/hueplusplus-1.2.0/src/SimpleColorTemperatureStrategy.cpp \
dependencies/hueplusplus-1.1.0/src/StateTransaction.cpp \ dependencies/hueplusplus-1.2.0/src/StateTransaction.cpp \
dependencies/hueplusplus-1.1.0/src/TimePattern.cpp \ dependencies/hueplusplus-1.2.0/src/TimePattern.cpp \
dependencies/hueplusplus-1.1.0/src/UPnP.cpp \ dependencies/hueplusplus-1.2.0/src/UPnP.cpp \
dependencies/hueplusplus-1.1.0/src/Utils.cpp \ dependencies/hueplusplus-1.2.0/src/Utils.cpp \
dependencies/hueplusplus-1.1.0/src/ZLLSensors.cpp \ dependencies/hueplusplus-1.2.0/src/ZLLSensors.cpp \
main.cpp \ main.cpp \
cli.cpp \ cli.cpp \
dmiinfo/dmiinfo.cpp \ dmiinfo/dmiinfo.cpp \
@ -333,7 +333,7 @@ win32:INCLUDEPATH +=
win32:SOURCES += $$CONTROLLER_CPP_WINDOWS win32:SOURCES += $$CONTROLLER_CPP_WINDOWS
win32:SOURCES += \ win32:SOURCES += \
dependencies/hueplusplus-1.1.0/src/WinHttpHandler.cpp \ dependencies/hueplusplus-1.2.0/src/WinHttpHandler.cpp \
dependencies/mbedtls-2.28.8/library/aes.c \ dependencies/mbedtls-2.28.8/library/aes.c \
dependencies/mbedtls-2.28.8/library/aesni.c \ dependencies/mbedtls-2.28.8/library/aesni.c \
dependencies/mbedtls-2.28.8/library/arc4.c \ dependencies/mbedtls-2.28.8/library/arc4.c \
@ -601,7 +601,7 @@ contains(QMAKE_PLATFORM, linux) {
SOURCES += $$CONTROLLER_CPP_LINUX SOURCES += $$CONTROLLER_CPP_LINUX
SOURCES += \ SOURCES += \
dependencies/hueplusplus-1.1.0/src/LinHttpHandler.cpp \ dependencies/hueplusplus-1.2.0/src/LinHttpHandler.cpp \
dependencies/NVFC/nvapi.cpp \ dependencies/NVFC/nvapi.cpp \
i2c_smbus/i2c_smbus_linux.cpp \ i2c_smbus/i2c_smbus_linux.cpp \
scsiapi/scsiapi_linux.c \ scsiapi/scsiapi_linux.c \
@ -727,7 +727,7 @@ contains(QMAKE_PLATFORM, freebsd) {
SOURCES += $$CONTROLLER_CPP_FREEBSD SOURCES += $$CONTROLLER_CPP_FREEBSD
SOURCES += \ SOURCES += \
dependencies/hueplusplus-1.1.0/src/LinHttpHandler.cpp \ dependencies/hueplusplus-1.2.0/src/LinHttpHandler.cpp \
serial_port/find_usb_serial_port_linux.cpp \ serial_port/find_usb_serial_port_linux.cpp \
AutoStart/AutoStart-FreeBSD.cpp \ AutoStart/AutoStart-FreeBSD.cpp \
SuspendResume/SuspendResume_Linux_FreeBSD.cpp \ SuspendResume/SuspendResume_Linux_FreeBSD.cpp \
@ -795,7 +795,7 @@ macx {
HEADERS += $$CONTROLLER_H_MACOS HEADERS += $$CONTROLLER_H_MACOS
SOURCES += \ SOURCES += \
dependencies/hueplusplus-1.1.0/src/LinHttpHandler.cpp \ dependencies/hueplusplus-1.2.0/src/LinHttpHandler.cpp \
serial_port/find_usb_serial_port_macos.cpp \ serial_port/find_usb_serial_port_macos.cpp \
AutoStart/AutoStart-MacOS.cpp \ AutoStart/AutoStart-MacOS.cpp \
qt/macutils.mm \ qt/macutils.mm \

View file

@ -24,7 +24,7 @@
#include "i2c_smbus.h" #include "i2c_smbus.h"
#include "ResourceManagerInterface.h" #include "ResourceManagerInterface.h"
#include "filesystem.h" #include "filesystem.h"
#include "json.hpp" #include <nlohmann/json.hpp>
using json = nlohmann::json; using json = nlohmann::json;

View file

@ -13,7 +13,7 @@
#pragma once #pragma once
#include "json.hpp" #include <nlohmann/json.hpp>
#include <mutex> #include <mutex>
#include "filesystem.h" #include "filesystem.h"

View file

@ -1,55 +0,0 @@
timestamps {
node('master')
{
stage('SCM')
{
checkout scm
}
stage('Build')
{
sh returnStatus: true, script: 'rm -r build'
sh '''#!/bin/bash
mkdir build
cd build
cmake .. -Dhueplusplus_TESTS=ON
make -j8 2>&1 | tee buildlog.txt
test ${PIPESTATUS[0]} -eq 0'''
}
stage('Test')
{
sh '''cd build
hueplusplus/test/test_HuePlusPlus --gtest_output=xml:test.xml
make -j8 coveragetest'''
step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: ''],
[$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']
],
tools: [
[$class: 'GoogleTestType', deleteOutputFiles: true, failIfNotNew: true, pattern: 'build/test.xml', skipNoTestFiles: false, stopProcessingIfError: true]
]
])
publishHTML(
[allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'build/coveragetest', reportFiles: 'index.html', reportName: 'Coveragetest', reportTitles: '']
)
}
stage('CppCheck')
{
sh 'cppcheck -j 8 --force -ihueplusplus/test -ihueplusplus/jsoncpp.cpp hueplusplus/ 2>build/CppCheckResult'
rtp nullAction: '1', parserName: 'HTML', stableText: '${FILE:build/CppCheckResult}'
}
stage('Documentation')
{
sh 'doxygen Doxyfile'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'doc/html/', reportFiles: 'index.html', reportName: 'Doxygen'])
}
stage('Parse warnings')
{
warnings canComputeNew: false, canResolveRelativePaths: false, categoriesPattern: '', defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'Doxygen', pattern: 'doxylog.txt']], unHealthy: ''
sh returnStatus: true, script: 'rm doxylog.txt'
warnings canComputeNew: false, canResolveRelativePaths: false, categoriesPattern: '', defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'GNU C Compiler 4 (gcc)', pattern: 'build/buildlog.txt']], unHealthy: ''
sh returnStatus: true, script: 'rm build/buildlog.txt'
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [enwi]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View file

@ -0,0 +1,72 @@
name: CI
on:
push:
branches:
- master
- development
pull_request:
jobs:
build:
runs-on: ubuntu-24.04
env:
LINUX_DIST: bionic
DEPS_DIR: ${{ github.workspace }}/deps
COMPILER_NAME: gcc
CXX: g++
CC: gcc
RUN_TESTS: true
COVERAGE: false
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# PATH: ${{ github.workspace }}/deps/cmake/bin:${{ env.PATH }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y gcc g++ lcov doxygen graphviz python3-yaml
# - name: Install CodeCov and LCOV
# run: |
# sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-7 90
# wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.13.orig.tar.gz
# tar xf lcov_1.13.orig.tar.gz
# make -C lcov-1.13 "PREFIX=${HOME}/.local" install
# echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Show tool versions
run: |
echo $PATH
echo $CXX
$CXX --version
$CXX -v
cmake --version
lcov --version
gcov --version
- name: Build project
run: |
mkdir -p build
cd build
cmake .. -Dhueplusplus_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -Dhueplusplus_EXAMPLES=ON
make hueplusplus_examples hueplusplus_snippets
make coveragetest
cd ..
doxygen Doxyfile
touch doc/html/.nojekyll
- name: Upload coverage to Codecov
run: |
bash <(curl -s https://codecov.io/bash)
- name: Deploy documentation to GitHub Pages
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc/html

View file

@ -1,3 +1,6 @@
[submodule "lib/mbedtls"] [submodule "lib/mbedtls"]
path = lib/mbedtls path = lib/mbedtls
url = https://github.com/ARMmbed/mbedtls.git url = https://github.com/ARMmbed/mbedtls.git
[submodule "lib/json"]
path = lib/json
url = https://github.com/nlohmann/json.git

View file

@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.10.2...3.28)
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 # Add cmake dir to module path, so Find*.cmake can be found
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
project(hueplusplus VERSION 1.1.0 LANGUAGES CXX) project(hueplusplus VERSION 1.2.0 LANGUAGES CXX)
# check whether hueplusplus is compiled directly or included as a subdirectory # check whether hueplusplus is compiled directly or included as a subdirectory
if(NOT DEFINED hueplusplus_master_project) if(NOT DEFINED hueplusplus_master_project)
@ -23,6 +17,16 @@ endif()
# options to set # options to set
option(hueplusplus_TESTS "Build tests" OFF) option(hueplusplus_TESTS "Build tests" OFF)
option(hueplusplus_EXAMPLES "Build examples" OFF) option(hueplusplus_EXAMPLES "Build examples" OFF)
option(hueplusplus_NO_EXTERNAL_LIBRARIES "Do not try to use external libraries" OFF)
# Try to find installed packages
if(NOT hueplusplus_NO_EXTERNAL_LIBRARIES)
# Suppress warnings if libraries are not found, they will be built from submodules
find_package(MbedTLS QUIET)
find_package(nlohmann_json QUIET)
endif()
set(NEED_SUBMODULES NOT (${MbedTLS_FOUND} AND ${nlohmann_json_FOUND}))
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF) option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable") find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable")
@ -38,7 +42,7 @@ endif()
find_package(Git QUIET) find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
option(GIT_SUBMODULE "Check submodules during build" ON) option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE) if(GIT_SUBMODULE AND NEED_SUBMODULES)
message(STATUS "Submodule update") message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT) RESULT_VARIABLE GIT_SUBMOD_RESULT)
@ -83,15 +87,34 @@ if (1 AND APPLE)
set(CMAKE_MACOSX_RPATH 1) set(CMAKE_MACOSX_RPATH 1)
endif() endif()
set(USE_STATIC_MBEDTLS_LIBRARY ON) if(NOT MbedTLS_FOUND)
set(USE_SHARED_MBEDTLS_LIBRARY OFF) # Build mbedtls if not installed
add_subdirectory("lib/mbedtls" EXCLUDE_FROM_ALL) message(STATUS "MbedTLS was not found, the submodule is used.")
set(USE_STATIC_MBEDTLS_LIBRARY ON)
set(USE_SHARED_MBEDTLS_LIBRARY OFF)
add_subdirectory("lib/mbedtls" EXCLUDE_FROM_ALL)
# Compile the mbedtls library as a static with position independent code, # Compile the mbedtls library as a static with position independent code,
# because we need it for both a shared and static library # because we need it for both a shared and static library
set_property(TARGET mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET mbedtls PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET mbedcrypto PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET mbedcrypto PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET mbedx509 PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET mbedx509 PROPERTY POSITION_INDEPENDENT_CODE ON)
if(CMAKE_VERSION VERSION_LESS 3.18)
# Aliases for compatibility with find_package, newer cmake versions add these already
add_library(MbedTLS::mbedtls ALIAS mbedtls)
add_library(MbedTLS::mbedcrypto ALIAS mbedcrypto)
add_library(MbedTLS::mbedx509 ALIAS mbedx509)
endif()
endif()
if(NOT nlohmann_json_FOUND)
# Use embedded json
message(STATUS "nlohmann_json was not found, the submodule is used.")
# disable tests for json
set(JSON_BuildTests OFF CACHE INTERNAL "")
add_subdirectory("lib/json" EXCLUDE_FROM_ALL)
endif()
add_subdirectory(src) add_subdirectory(src)

View file

@ -38,7 +38,7 @@ PROJECT_NAME = hueplusplus
# could be handy for archiving the generated documentation or if some version # could be handy for archiving the generated documentation or if some version
# control system is used. # control system is used.
PROJECT_NUMBER = 1.0.0 PROJECT_NUMBER = 1.2.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a # for a project that appears at the top of each page and should give viewer a

View file

@ -1,10 +1,10 @@
# hueplusplus # hueplusplus
A simple and easy to use library for Philips Hue Lights A simple and easy to use library for Philips Hue Lights
| Branch | Travis CI | Codecov | LGTM | Branch | CI | Codecov | LGTM
|:-|:-|:-|:-| |:-|:-|:-|:-|
| [Master](https://github.com/enwi/hueplusplus/tree/master) | [![Build Status](https://travis-ci.com/enwi/hueplusplus.svg?branch=master)](https://travis-ci.com/enwi/hueplusplus) | [![codecov](https://codecov.io/gh/enwi/hueplusplus/branch/master/graph/badge.svg)](https://codecov.io/gh/enwi/hueplusplus) | [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/enwi/hueplusplus.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/enwi/hueplusplus/context:cpp) | | [Master](https://github.com/enwi/hueplusplus/tree/master) | [![CI](https://github.com/enwi/hueplusplus/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/enwi/hueplusplus/actions/workflows/build.yml)| [![codecov](https://codecov.io/gh/enwi/hueplusplus/branch/master/graph/badge.svg)](https://codecov.io/gh/enwi/hueplusplus) | [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/enwi/hueplusplus.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/enwi/hueplusplus/context:cpp) |
| [Development](https://github.com/enwi/hueplusplus/tree/development) | [![Build Status](https://travis-ci.com/enwi/hueplusplus.svg?branch=development)](https://travis-ci.com/enwi/hueplusplus) | [![codecov](https://codecov.io/gh/enwi/hueplusplus/branch/development/graph/badge.svg)](https://codecov.io/gh/enwi/hueplusplus) | | | [Development](https://github.com/enwi/hueplusplus/tree/development) | [![CI](https://github.com/enwi/hueplusplus/actions/workflows/build.yml/badge.svg?branch=development)](https://github.com/enwi/hueplusplus/actions/workflows/build.yml) | [![codecov](https://codecov.io/gh/enwi/hueplusplus/branch/development/graph/badge.svg)](https://codecov.io/gh/enwi/hueplusplus) | |
## Features ## Features
* find bridges with SSDP or set an ip manually * find bridges with SSDP or set an ip manually

View file

@ -18,7 +18,7 @@ When you want to update the library for a new version, use pull with rebase.
``` ```
## Build with CMake {#build-cmake} ## Build with CMake {#build-cmake}
To build the library, you need to use [CMake](https://cmake.org) version 3.8 or higher. To build the library, you need to use [CMake](https://cmake.org) version 3.10 or higher.
It is easiest to create a separate build directory where the build files are stored. It is easiest to create a separate build directory where the build files are stored.
```{.sh} ```{.sh}
~/hueplusplus $ mkdir build ~/hueplusplus $ mkdir build
@ -84,3 +84,7 @@ cd build
cmake .. -Dhueplusplus_EXAMPLES=ON cmake .. -Dhueplusplus_EXAMPLES=ON
make hueplusplus_examples make hueplusplus_examples
``` ```
## External libraries
Hueplusplus requires a few external libraries (e.g. Mbed TLS and GTest), which are included automatically. If these are pre-installed on your system, those versions will be used by default. This can potentially cause issues if your installed versions are incompatible.
In this case, set `hueplusplus_NO_EXTERNAL_LIBRARIES=ON` to force using the embedded versions instead of the installed libraries.

View file

@ -22,7 +22,7 @@
#ifndef INCLUDE_HUEPLUSPLUS_ACTION_H #ifndef INCLUDE_HUEPLUSPLUS_ACTION_H
#define INCLUDE_HUEPLUSPLUS_ACTION_H #define INCLUDE_HUEPLUSPLUS_ACTION_H
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -27,7 +27,7 @@
#include "APICache.h" #include "APICache.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -30,7 +30,7 @@
#include "IHttpHandler.h" #include "IHttpHandler.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -47,7 +47,7 @@
#include "SensorList.h" #include "SensorList.h"
#include "Utils.h" #include "Utils.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
//! \brief Namespace for the hueplusplus library //! \brief Namespace for the hueplusplus library
namespace hueplusplus namespace hueplusplus

View file

@ -24,7 +24,7 @@
#include "TimePattern.h" #include "TimePattern.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -31,7 +31,7 @@
#include "HueCommandAPI.h" #include "HueCommandAPI.h"
#include "StateTransaction.h" #include "StateTransaction.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -26,7 +26,7 @@
#include <exception> #include <exception>
#include <string> #include <string>
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -29,7 +29,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -33,7 +33,7 @@
#include "HueCommandAPI.h" #include "HueCommandAPI.h"
#include "StateTransaction.h" #include "StateTransaction.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -28,7 +28,7 @@
#include "BaseHttpHandler.h" #include "BaseHttpHandler.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -27,7 +27,7 @@
#include "TimePattern.h" #include "TimePattern.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -26,7 +26,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <json/json.hpp> #include <nlohmann/json.hpp>
#include "APICache.h" #include "APICache.h"
#include "ColorUnits.h" #include "ColorUnits.h"

View file

@ -30,7 +30,7 @@
#include "HueCommandAPI.h" #include "HueCommandAPI.h"
#include "TimePattern.h" #include "TimePattern.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -29,7 +29,7 @@
#include "ColorUnits.h" #include "ColorUnits.h"
#include "HueCommandAPI.h" #include "HueCommandAPI.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -23,7 +23,7 @@
#ifndef INCLUDE_HUEPLUSPLUS_UTILS_H #ifndef INCLUDE_HUEPLUSPLUS_UTILS_H
#define INCLUDE_HUEPLUSPLUS_UTILS_H #define INCLUDE_HUEPLUSPLUS_UTILS_H
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -27,7 +27,7 @@
#include "hueplusplus/HueExceptionMacro.h" #include "hueplusplus/HueExceptionMacro.h"
#include "hueplusplus/Utils.h" #include "hueplusplus/Utils.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

View file

@ -57,20 +57,33 @@ foreach(src ${hueplusplus_SOURCES})
endforeach() endforeach()
set(hueplusplus_SOURCES ${_srcList} PARENT_SCOPE) set(hueplusplus_SOURCES ${_srcList} PARENT_SCOPE)
# For install dir variables
include(GNUInstallDirs)
# hueplusplus shared library # hueplusplus shared library
add_library(hueplusplusshared SHARED ${hueplusplus_SOURCES}) add_library(hueplusplusshared SHARED ${hueplusplus_SOURCES})
target_link_libraries(hueplusplusshared PRIVATE mbedtls) target_link_libraries(hueplusplusshared PRIVATE MbedTLS::mbedtls)
target_link_libraries(hueplusplusshared PUBLIC nlohmann_json::nlohmann_json)
target_compile_features(hueplusplusshared PUBLIC cxx_std_14) target_compile_features(hueplusplusshared PUBLIC cxx_std_14)
target_include_directories(hueplusplusshared PUBLIC $<BUILD_INTERFACE:${hueplusplus_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>) target_include_directories(hueplusplusshared PUBLIC $<BUILD_INTERFACE:${hueplusplus_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
install(TARGETS hueplusplusshared DESTINATION lib)
# hueplusplus static library # hueplusplus static library
add_library(hueplusplusstatic STATIC ${hueplusplus_SOURCES}) add_library(hueplusplusstatic STATIC ${hueplusplus_SOURCES})
target_link_libraries(hueplusplusstatic PRIVATE mbedtls) target_link_libraries(hueplusplusstatic PRIVATE MbedTLS::mbedtls)
target_link_libraries(hueplusplusstatic PUBLIC nlohmann_json::nlohmann_json)
target_compile_features(hueplusplusstatic PUBLIC cxx_std_14) target_compile_features(hueplusplusstatic PUBLIC cxx_std_14)
install(TARGETS hueplusplusstatic DESTINATION lib) if(NOT WIN32)
# On windows, a shared library will also generate a .lib import library, making different names necessary.
# On other platforms the file endings are different, so the names can be the same.
set_target_properties(hueplusplusshared PROPERTIES OUTPUT_NAME hueplusplus SOVERSION 1)
set_target_properties(hueplusplusstatic PROPERTIES OUTPUT_NAME hueplusplus)
endif()
install(TARGETS hueplusplusshared DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS hueplusplusstatic DESTINATION ${CMAKE_INSTALL_LIBDIR})
target_include_directories(hueplusplusstatic PUBLIC $<BUILD_INTERFACE:${hueplusplus_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>) target_include_directories(hueplusplusstatic PUBLIC $<BUILD_INTERFACE:${hueplusplus_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" DESTINATION include) install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Export the package for use from the build-tree # Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry) # (this registers the build-tree with a global CMake-registry)

View file

@ -21,7 +21,6 @@
**/ **/
#include "hueplusplus/EntertainmentMode.h" #include "hueplusplus/EntertainmentMode.h"
#include "mbedtls/certs.h"
#include "mbedtls/ctr_drbg.h" #include "mbedtls/ctr_drbg.h"
#include "mbedtls/debug.h" #include "mbedtls/debug.h"
#include "mbedtls/entropy.h" #include "mbedtls/entropy.h"
@ -30,6 +29,8 @@
#include "mbedtls/ssl.h" #include "mbedtls/ssl.h"
#include "mbedtls/timing.h" #include "mbedtls/timing.h"
#include "hueplusplus/HueExceptionMacro.h"
namespace hueplusplus namespace hueplusplus
{ {
constexpr uint8_t HUE_ENTERTAINMENT_HEADER_SIZE = 16; constexpr uint8_t HUE_ENTERTAINMENT_HEADER_SIZE = 16;
@ -121,7 +122,16 @@ EntertainmentMode::EntertainmentMode(Bridge& b, Group& g)
/*-------------------------------------------------*\ /*-------------------------------------------------*\
| Seed the Deterministic Random Bit Generator (RNG) | | Seed the Deterministic Random Bit Generator (RNG) |
\*-------------------------------------------------*/ \*-------------------------------------------------*/
int ret = mbedtls_ctr_drbg_seed(&tls_context->ctr_drbg, mbedtls_entropy_func, &tls_context->entropy, NULL, 0); if (mbedtls_ctr_drbg_seed(&tls_context->ctr_drbg, mbedtls_entropy_func, &tls_context->entropy, NULL, 0) != 0)
{
mbedtls_entropy_free(&tls_context->entropy);
mbedtls_ctr_drbg_free(&tls_context->ctr_drbg);
mbedtls_x509_crt_free(&tls_context->cacert);
mbedtls_ssl_config_free(&tls_context->conf);
mbedtls_ssl_free(&tls_context->ssl);
mbedtls_net_free(&tls_context->server_fd);
throw HueException(CURRENT_FILE_INFO, "Failed to seed mbedtls RNG");
}
} }
EntertainmentMode::~EntertainmentMode() EntertainmentMode::~EntertainmentMode()

View file

@ -267,10 +267,7 @@ nlohmann::json CreateGroup::getRequest() const
{ {
result["name"] = name; result["name"] = name;
} }
if (!roomType.empty()) result["class"] = roomType.empty() ? "Other" : roomType;
{
result["class"] = roomType;
}
return result; return result;
} }

View file

@ -27,7 +27,7 @@
#include "hueplusplus/HueExceptionMacro.h" #include "hueplusplus/HueExceptionMacro.h"
#include "hueplusplus/Light.h" #include "hueplusplus/Light.h"
#include "hueplusplus/Utils.h" #include "hueplusplus/Utils.h"
#include "json/json.hpp" #include <nlohmann/json.hpp>
namespace hueplusplus namespace hueplusplus
{ {

Some files were not shown because too many files have changed in this diff Show more