From ca795d883ec4dda14203b8f0ffa7bf3d4c06731d Mon Sep 17 00:00:00 2001 From: penfold42 Date: Sun, 10 Jul 2016 20:42:21 +1000 Subject: [PATCH] Add "enable" to forwarder, fix udp listener (#91) * Add "enable" to forwarder fix udp listener - address and port parsing was broken * updated example configs * updated example config with comments --- config/hyperion.config.json.commented | 2 ++ config/hyperion.config.json.default | 1 + libsrc/hyperion/Hyperion.cpp | 2 +- libsrc/udplistener/UDPListener.cpp | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index 92000001..b44f7bb9 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -252,12 +252,14 @@ /// The configuration of the Json/Proto forwarder. Forward messages to multiple instances of Hyperion on same and/or other hosts /// 'proto' is mostly used for video streams and 'json' for effects + /// * enable : Enable or disable the forwarder (true/false) /// * proto : Proto server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19447"] or more instances to forward ["127.0.0.1:19447","192.168.0.24:19449"] /// * json : Json server adress and port of your target. Syntax:[IP:PORT] -> ["127.0.0.1:19446"] or more instances to forward ["127.0.0.1:19446","192.168.0.24:19448"] /// HINT:If you redirect to "127.0.0.1" (localhost) you could start a second hyperion with another device/led config! /// Be sure your client(s) is/are listening on the configured ports. The second Hyperion (if used) also needs to be configured! (HyperCon -> External -> Json Server/Proto Server) "forwarder" : { + "enable" : false, "proto" : ["127.0.0.1:19447"], "json" : ["127.0.0.1:19446"] }, diff --git a/config/hyperion.config.json.default b/config/hyperion.config.json.default index 92674819..7f9a01c8 100644 --- a/config/hyperion.config.json.default +++ b/config/hyperion.config.json.default @@ -149,6 +149,7 @@ "forwarder" : { + "enable" : false, "json" : ["127.0.0.1:19446"], "proto" : ["127.0.0.1:19447"] }, diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index b5b31c29..595c7d57 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -522,7 +522,7 @@ LedDevice * Hyperion::createColorSmoothing(const Json::Value & smoothingConfig, MessageForwarder * Hyperion::createMessageForwarder(const Json::Value & forwarderConfig) { MessageForwarder * forwarder = new MessageForwarder(); - if ( ! forwarderConfig.isNull() ) + if ( ( ! forwarderConfig.isNull() ) && ( forwarderConfig.get("enable", true).asBool() ) ) { if ( ! forwarderConfig["json"].isNull() && forwarderConfig["json"].isArray() ) { diff --git a/libsrc/udplistener/UDPListener.cpp b/libsrc/udplistener/UDPListener.cpp index 70ed4c77..4b1aa77e 100644 --- a/libsrc/udplistener/UDPListener.cpp +++ b/libsrc/udplistener/UDPListener.cpp @@ -20,10 +20,11 @@ UDPListener::UDPListener(const int priority, const int timeout, const std::strin _ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb::BLACK), _log(Logger::getInstance("UDPLISTENER")), _isActive(false), + _listenPort(listenPort), _bondage(shared ? QAbstractSocket::ShareAddress : QAbstractSocket::DefaultForPlatform) { _server = new QUdpSocket(this); - QHostAddress listenAddress = address.empty() + _listenAddress = address.empty() ? QHostAddress::AnyIPv4 : QHostAddress( QString::fromStdString(address) );