IPv6 support (#1369)

* hyperion-remote - Support IPv6

* LEDDevices - Remove IPv6 limitations

* Separate JsonEditorHostValidation

* Standalone grabbers & JSON/Flatbuffer forwarder: IPv6 support

* remote: Fix setting multiple colors via Hex, add standard logging

* IPv6 Updates -Add db migration activities

* Addressing non-Windows compile issues

* Code cleanup, address clang feedback

* Update address (hostname, IPv4/IPv6) help text

* Apply migration steps to "old" configurations imported

* Show user the UI-Url, if hyperion is already running, address clang findings

* Windows Cmake OpenSLL output

* Minor Text update
This commit is contained in:
LordGrey
2021-11-17 20:30:43 +00:00
committed by GitHub
parent b33466d392
commit ad293b2fb6
61 changed files with 1714 additions and 926 deletions

View File

@@ -392,6 +392,20 @@ bool API::saveSettings(const QJsonObject &data)
return rc;
}
bool API::restoreSettings(const QJsonObject &data)
{
bool rc = true;
if (!_adminAuthorized)
{
rc = false;
}
else
{
QMetaObject::invokeMethod(_hyperion, "restoreSettings", Qt::DirectConnection, Q_RETURN_ARG(bool, rc), Q_ARG(QJsonObject, data), Q_ARG(bool, true));
}
return rc;
}
bool API::updateHyperionPassword(const QString &password, const QString &newPassword)
{
if (!_adminAuthorized)

View File

@@ -10,7 +10,7 @@
"subcommand": {
"type" : "string",
"required" : true,
"enum" : ["setconfig","getconfig","getschema","reload"]
"enum" : ["getconfig","getschema","setconfig","restoreconfig","reload"]
},
"tan" : {
"type" : "integer"

View File

@@ -860,6 +860,13 @@ void JsonAPI::handleConfigCommand(const QJsonObject &message, const QString &com
{
handleSchemaGetCommand(message, full_command, tan);
}
else if (subcommand == "getconfig")
{
if (_adminAuthorized)
sendSuccessDataReply(QJsonDocument(_hyperion->getQJsonConfig()), full_command, tan);
else
sendErrorReply("No Authorization", command, tan);
}
else if (subcommand == "setconfig")
{
if (_adminAuthorized)
@@ -867,10 +874,10 @@ void JsonAPI::handleConfigCommand(const QJsonObject &message, const QString &com
else
sendErrorReply("No Authorization", command, tan);
}
else if (subcommand == "getconfig")
else if (subcommand == "restoreconfig")
{
if (_adminAuthorized)
sendSuccessDataReply(QJsonDocument(_hyperion->getQJsonConfig()), full_command, tan);
handleConfigRestoreCommand(message, full_command, tan);
else
sendErrorReply("No Authorization", command, tan);
}
@@ -916,6 +923,27 @@ void JsonAPI::handleConfigSetCommand(const QJsonObject &message, const QString &
}
}
void JsonAPI::handleConfigRestoreCommand(const QJsonObject &message, const QString &command, int tan)
{
if (message.contains("config"))
{
QJsonObject config = message["config"].toObject();
if (API::isHyperionEnabled())
{
if ( API::restoreSettings(config) )
{
sendSuccessReply(command, tan);
}
else
{
sendErrorReply("Restore settings failed", command, tan);
}
}
else
sendErrorReply("Restoring configuration while Hyperion is disabled isn't possible", command, tan);
}
}
void JsonAPI::handleSchemaGetCommand(const QJsonObject &message, const QString &command, int tan)
{
// create result

View File

@@ -17,15 +17,18 @@ bool ColorsOption::validate(Parser & parser, QString & value)
return true;
}
// check if we can create the color by hex RRGGBB getColors
QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = hexRe.match(value);
if(match.hasMatch())
// check if we can create the colors by hex RRGGBB getColors
QRegularExpression re("(([A-F0-9]){6})(?=(?:..)*)");
QRegularExpressionMatchIterator i = re.globalMatch(value);
while (i.hasNext()) {
QRegularExpressionMatch match = i.next();
QString captured = match.captured(1);
_colors.push_back(QColor(QString("#%1").arg(captured)));
}
if (!_colors.isEmpty() && (_colors.size() * 6) == value.length())
{
for(const QString & m : match.capturedTexts())
{
_colors.push_back(QColor(QString("#%1").arg(m)));
}
return true;
}

View File

@@ -11,33 +11,21 @@
#include "hyperion_reply_generated.h"
#include "hyperion_request_generated.h"
FlatBufferConnection::FlatBufferConnection(const QString& origin, const QString & address, int priority, bool skipReply)
FlatBufferConnection::FlatBufferConnection(const QString& origin, const QString& host, int priority, bool skipReply, quint16 port)
: _socket()
, _origin(origin)
, _priority(priority)
, _host(host)
, _port(port)
, _prevSocketState(QAbstractSocket::UnconnectedState)
, _log(Logger::getInstance("FLATBUFCONN"))
, _registered(false)
{
QStringList parts = address.split(":");
if (parts.size() != 2)
{
throw std::runtime_error(QString("FLATBUFCONNECTION ERROR: Unable to parse address (%1)").arg(address).toStdString());
}
_host = parts[0];
bool ok;
_port = parts[1].toUShort(&ok);
if (!ok)
{
throw std::runtime_error(QString("FLATBUFCONNECTION ERROR: Unable to parse the port (%1)").arg(parts[1]).toStdString());
}
if(!skipReply)
connect(&_socket, &QTcpSocket::readyRead, this, &FlatBufferConnection::readData, Qt::UniqueConnection);
// init connect
Info(_log, "Connecting to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
Info(_log, "Connecting to Hyperion: %s:%u", QSTRING_CSTR(_host), _port);
connectToHost();
// start the connection timer
@@ -167,13 +155,13 @@ void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size)
switch (_socket.state() )
{
case QAbstractSocket::UnconnectedState:
Info(_log, "No connection to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
Info(_log, "No connection to Hyperion: %s:%u", QSTRING_CSTR(_host), _port);
break;
case QAbstractSocket::ConnectedState:
Info(_log, "Connected to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
Info(_log, "Connected to Hyperion: %s:%u", QSTRING_CSTR(_host), _port);
break;
default:
Debug(_log, "Connecting to Hyperion: %s:%d", _host.toStdString().c_str(), _port);
Debug(_log, "Connecting to Hyperion: %s:%u", QSTRING_CSTR(_host), _port);
break;
}
_prevSocketState = _socket.state();

View File

@@ -279,6 +279,11 @@ bool Hyperion::saveSettings(const QJsonObject& config, bool correct)
return _settingsManager->saveSettings(config, correct);
}
bool Hyperion::restoreSettings(const QJsonObject& config, bool correct)
{
return _settingsManager->restoreSettings(config, correct);
}
int Hyperion::getLatchTime() const
{
return _ledDeviceWrapper->getLatchTime();

View File

@@ -9,16 +9,18 @@
// utils includes
#include <utils/Logger.h>
#include <utils/NetUtils.h>
// qt includes
#include <QTcpServer>
#include <QTcpSocket>
#include <QHostInfo>
#include <QNetworkInterface>
#include <flatbufserver/FlatBufferConnection.h>
MessageForwarder::MessageForwarder(Hyperion *hyperion)
: QObject()
, _hyperion(hyperion)
MessageForwarder::MessageForwarder(Hyperion* hyperion)
: _hyperion(hyperion)
, _log(Logger::getInstance("NETFORWARDER"))
, _muxer(_hyperion->getMuxerInstance())
, _forwarder_enabled(true)
@@ -40,58 +42,74 @@ MessageForwarder::MessageForwarder(Hyperion *hyperion)
MessageForwarder::~MessageForwarder()
{
while (!_forwardClients.isEmpty())
{
delete _forwardClients.takeFirst();
}
}
void MessageForwarder::handleSettingsUpdate(settings::type type, const QJsonDocument &config)
void MessageForwarder::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
{
if(type == settings::NETFORWARD)
if (type == settings::NETFORWARD)
{
// clear the current targets
_jsonSlaves.clear();
_flatSlaves.clear();
_jsonTargets.clear();
_flatbufferTargets.clear();
while (!_forwardClients.isEmpty())
{
delete _forwardClients.takeFirst();
}
// build new one
const QJsonObject &obj = config.object();
if ( !obj["json"].isNull() )
const QJsonObject& obj = config.object();
if (!obj["json"].isNull())
{
const QJsonArray & addr = obj["json"].toArray();
const QJsonArray& addr = obj["json"].toArray();
for (const auto& entry : addr)
{
addJsonSlave(entry.toString());
addJsonTarget(entry.toObject());
}
}
if ( !obj["flat"].isNull() )
if (!obj["flat"].isNull())
{
const QJsonArray & addr = obj["flat"].toArray();
const QJsonArray& addr = obj["flat"].toArray();
for (const auto& entry : addr)
{
addFlatbufferSlave(entry.toString());
addFlatbufferTarget(entry.toObject());
}
}
if (!_jsonSlaves.isEmpty() && obj["enable"].toBool() && _forwarder_enabled)
bool isForwarderEnabledinSettings = obj["enable"].toBool(false);
if (!_jsonTargets.isEmpty() && isForwarderEnabledinSettings && _forwarder_enabled)
{
InfoIf(obj["enable"].toBool(true), _log, "Forward now to json targets '%s'", QSTRING_CSTR(_jsonSlaves.join(", ")));
for (const auto& targetHost : qAsConst(_jsonTargets))
{
InfoIf(isForwarderEnabledinSettings, _log, "Forwarding now to JSON-target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port);
}
connect(_hyperion, &Hyperion::forwardJsonMessage, this, &MessageForwarder::forwardJsonMessage, Qt::UniqueConnection);
} else if (_jsonSlaves.isEmpty() || ! obj["enable"].toBool() || !_forwarder_enabled)
disconnect(_hyperion, &Hyperion::forwardJsonMessage, 0, 0);
if (!_flatSlaves.isEmpty() && obj["enable"].toBool() && _forwarder_enabled)
{
InfoIf(obj["enable"].toBool(true), _log, "Forward now to flatbuffer targets '%s'", QSTRING_CSTR(_flatSlaves.join(", ")));
}
else if ( _flatSlaves.isEmpty() || ! obj["enable"].toBool() || !_forwarder_enabled)
else if (_jsonTargets.isEmpty() || !isForwarderEnabledinSettings || !_forwarder_enabled)
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0);
disconnect(_hyperion, &Hyperion::forwardJsonMessage, nullptr, nullptr);
}
if (!_flatbufferTargets.isEmpty() && isForwarderEnabledinSettings && _forwarder_enabled)
{
for (const auto& targetHost : qAsConst(_flatbufferTargets))
{
InfoIf(isForwarderEnabledinSettings, _log, "Forwarding now to Flatbuffer-target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port);
}
}
else if (_flatbufferTargets.isEmpty() || !isForwarderEnabledinSettings || !_forwarder_enabled)
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
}
// update comp state
_hyperion->setNewComponentState(hyperion::COMP_FORWARDER, obj["enable"].toBool(true));
_hyperion->setNewComponentState(hyperion::COMP_FORWARDER, isForwarderEnabledinSettings);
}
}
@@ -111,146 +129,161 @@ void MessageForwarder::handlePriorityChanges(quint8 priority)
const QJsonObject obj = _hyperion->getSetting(settings::NETFORWARD).object();
if (priority != 0 && _forwarder_enabled && obj["enable"].toBool())
{
//_flatSlaves.clear();
//while (!_forwardClients.isEmpty())
// delete _forwardClients.takeFirst();
hyperion::Components activeCompId = _hyperion->getPriorityInfo(priority).componentId;
if (activeCompId == hyperion::COMP_GRABBER || activeCompId == hyperion::COMP_V4L)
{
if ( !obj["flat"].isNull() )
if (!obj["flat"].isNull())
{
const QJsonArray & addr = obj["flat"].toArray();
const QJsonArray& addr = obj["flat"].toArray();
for (const auto& entry : addr)
{
addFlatbufferSlave(entry.toString());
addFlatbufferTarget(entry.toObject());
}
}
switch(activeCompId)
switch (activeCompId)
{
case hyperion::COMP_GRABBER:
{
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0);
connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
}
break;
case hyperion::COMP_V4L:
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0);
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
}
break;
default:
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0);
}
case hyperion::COMP_GRABBER:
{
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
connect(_hyperion, &Hyperion::forwardSystemProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
}
break;
case hyperion::COMP_V4L:
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
connect(_hyperion, &Hyperion::forwardV4lProtoMessage, this, &MessageForwarder::forwardFlatbufferMessage, Qt::UniqueConnection);
}
break;
default:
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
}
}
}
else
{
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, 0, 0);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, 0, 0);
disconnect(_hyperion, &Hyperion::forwardSystemProtoMessage, nullptr, nullptr);
disconnect(_hyperion, &Hyperion::forwardV4lProtoMessage, nullptr, nullptr);
}
}
}
void MessageForwarder::addJsonSlave(const QString& slave)
void MessageForwarder::addJsonTarget(const QJsonObject& targetConfig)
{
QStringList parts = slave.split(":");
if (parts.size() != 2)
{
Error(_log, "Unable to parse address (%s)",QSTRING_CSTR(slave));
return;
}
TargetHost targetHost;
bool ok;
parts[1].toUShort(&ok);
if (!ok)
QString config_host = targetConfig["host"].toString();
if (NetUtils::resolveHostAddress(_log, config_host, targetHost.host))
{
Error(_log, "Unable to parse port number (%s)",QSTRING_CSTR(parts[1]));
return;
}
int config_port = targetConfig["port"].toInt();
if (NetUtils::isValidPort(_log, config_port, config_host))
{
targetHost.port = static_cast<quint16>(config_port);
// verify loop with jsonserver
const QJsonObject &obj = _hyperion->getSetting(settings::JSONSERVER).object();
if(QHostAddress(parts[0]) == QHostAddress::LocalHost && parts[1].toInt() == obj["port"].toInt())
{
Error(_log, "Loop between JsonServer and Forwarder! (%s)",QSTRING_CSTR(slave));
return;
}
// verify loop with JSON-server
const QJsonObject& obj = _hyperion->getSetting(settings::JSONSERVER).object();
if ((QNetworkInterface::allAddresses().indexOf(targetHost.host) != -1) && targetHost.port == static_cast<quint16>(obj["port"].toInt()))
{
Error(_log, "Loop between JSON-Server and Forwarder! Configuration for host: %s, port: %d is ignored.", QSTRING_CSTR(config_host), config_port);
}
else
{
if (_forwarder_enabled)
{
if (_jsonTargets.indexOf(targetHost) == -1)
{
Info(_log, "JSON-Forwarder settings: Adding target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port);
_jsonTargets << targetHost;
}
else
{
Warning(_log, "JSON Forwarder settings: Duplicate target host configuration! Configuration for host: %s, port: %d is ignored.", QSTRING_CSTR(targetHost.host.toString()), targetHost.port);
}
}
if (_forwarder_enabled && !_jsonSlaves.contains(slave))
_jsonSlaves << slave;
}
void MessageForwarder::addFlatbufferSlave(const QString& slave)
{
QStringList parts = slave.split(":");
if (parts.size() != 2)
{
Error(_log, "Unable to parse address (%s)",QSTRING_CSTR(slave));
return;
}
bool ok;
parts[1].toUShort(&ok);
if (!ok)
{
Error(_log, "Unable to parse port number (%s)",QSTRING_CSTR(parts[1]));
return;
}
// verify loop with flatbufserver
const QJsonObject &obj = _hyperion->getSetting(settings::FLATBUFSERVER).object();
if(QHostAddress(parts[0]) == QHostAddress::LocalHost && parts[1].toInt() == obj["port"].toInt())
{
Error(_log, "Loop between Flatbuffer Server and Forwarder! (%s)",QSTRING_CSTR(slave));
return;
}
if (_forwarder_enabled && !_flatSlaves.contains(slave))
{
_flatSlaves << slave;
FlatBufferConnection* flatbuf = new FlatBufferConnection("Forwarder", slave.toLocal8Bit().constData(), _priority, false);
_forwardClients << flatbuf;
}
}
}
}
void MessageForwarder::forwardJsonMessage(const QJsonObject &message)
void MessageForwarder::addFlatbufferTarget(const QJsonObject& targetConfig)
{
TargetHost targetHost;
QString config_host = targetConfig["host"].toString();
if (NetUtils::resolveHostAddress(_log, config_host, targetHost.host))
{
int config_port = targetConfig["port"].toInt();
if (NetUtils::isValidPort(_log, config_port, config_host))
{
targetHost.port = static_cast<quint16>(config_port);
// verify loop with Flatbuffer-server
const QJsonObject& obj = _hyperion->getSetting(settings::FLATBUFSERVER).object();
if ((QNetworkInterface::allAddresses().indexOf(targetHost.host) != -1) && targetHost.port == static_cast<quint16>(obj["port"].toInt()))
{
Error(_log, "Loop between Flatbuffer-Server and Forwarder! Configuration for host: %s, port: %d is ignored.", QSTRING_CSTR(config_host), config_port);
}
else
{
if (_forwarder_enabled)
{
if (_flatbufferTargets.indexOf(targetHost) == -1)
{
Info(_log, "Flatbuffer-Forwarder settings: Adding target host: %s port: %u", QSTRING_CSTR(targetHost.host.toString()), targetHost.port);
_flatbufferTargets << targetHost;
FlatBufferConnection* flatbuf = new FlatBufferConnection("Forwarder", targetHost.host.toString(), _priority, false, targetHost.port);
_forwardClients << flatbuf;
}
else
{
Warning(_log, "Flatbuffer Forwarder settings: Duplicate target host configuration! Configuration for host: %s, port: %d is ignored.", QSTRING_CSTR(targetHost.host.toString()), targetHost.port);
}
}
}
}
}
}
void MessageForwarder::forwardJsonMessage(const QJsonObject& message)
{
if (_forwarder_enabled)
{
QTcpSocket client;
for (int i=0; i<_jsonSlaves.size(); i++)
for (const auto& targetHost : qAsConst(_jsonTargets))
{
QStringList parts = _jsonSlaves.at(i).split(":");
client.connectToHost(QHostAddress(parts[0]), parts[1].toUShort());
if ( client.waitForConnected(500) )
client.connectToHost(targetHost.host, targetHost.port);
if (client.waitForConnected(500))
{
sendJsonMessage(message,&client);
sendJsonMessage(message, &client);
client.close();
}
}
}
}
void MessageForwarder::forwardFlatbufferMessage(const QString& name, const Image<ColorRgb> &image)
void MessageForwarder::forwardFlatbufferMessage(const QString& /*name*/, const Image<ColorRgb>& image)
{
if (_forwarder_enabled)
{
for (int i=0; i < _forwardClients.size(); i++)
for (int i = 0; i < _forwardClients.size(); i++)
{
_forwardClients.at(i)->setImage(image);
}
}
}
void MessageForwarder::sendJsonMessage(const QJsonObject &message, QTcpSocket *socket)
void MessageForwarder::sendJsonMessage(const QJsonObject& message, QTcpSocket* socket)
{
// for hyperion classic compatibility
QJsonObject jsonMessage = message;
if (jsonMessage.contains("tan") && jsonMessage["tan"].isNull())
{
jsonMessage["tan"] = 100;
}
// serialize message
QJsonDocument writer(jsonMessage);
@@ -280,7 +313,7 @@ void MessageForwarder::sendJsonMessage(const QJsonObject &message, QTcpSocket *s
// parse reply data
QJsonParseError error;
QJsonDocument reply = QJsonDocument::fromJson(serializedReply ,&error);
QJsonDocument::fromJson(serializedReply, &error);
if (error.error != QJsonParseError::NoError)
{
@@ -288,3 +321,4 @@ void MessageForwarder::sendJsonMessage(const QJsonObject &message, QTcpSocket *s
return;
}
}

View File

@@ -3,6 +3,8 @@
// util
#include <utils/JsonUtils.h>
#include <utils/QStringUtils.h>
#include <db/SettingsTable.h>
#include "HyperionConfig.h"
@@ -14,6 +16,7 @@
#include <utils/JsonUtils.h>
#include <utils/version.hpp>
using namespace semver;
// Constants
@@ -25,23 +28,23 @@ QJsonObject SettingsManager::schemaJson;
SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonlyMode)
: QObject(parent)
, _log(Logger::getInstance("SETTINGSMGR"))
, _instance(instance)
, _sTable(new SettingsTable(instance, this))
, _configVersion(DEFAULT_VERSION)
, _previousVersion(DEFAULT_VERSION)
, _readonlyMode(readonlyMode)
, _log(Logger::getInstance("SETTINGSMGR"))
, _instance(instance)
, _sTable(new SettingsTable(instance, this))
, _configVersion(DEFAULT_VERSION)
, _previousVersion(DEFAULT_VERSION)
, _readonlyMode(readonlyMode)
{
_sTable->setReadonlyMode(_readonlyMode);
// get schema
if(schemaJson.isEmpty())
if (schemaJson.isEmpty())
{
Q_INIT_RESOURCE(resource);
try
{
schemaJson = QJsonFactory::readSchema(":/hyperion-schema");
}
catch(const std::runtime_error& error)
catch (const std::runtime_error& error)
{
throw std::runtime_error(error.what());
}
@@ -49,7 +52,7 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly
// get default config
QJsonObject defaultConfig;
if(!JsonUtils::readFile(":/hyperion_default.config", defaultConfig, _log))
if (!JsonUtils::readFile(":/hyperion_default.config", defaultConfig, _log))
{
throw std::runtime_error("Failed to read default config");
}
@@ -57,45 +60,51 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly
// transform json to string lists
QStringList keyList = defaultConfig.keys();
QStringList defValueList;
for(const auto & key : keyList)
for (const auto& key : qAsConst(keyList))
{
if(defaultConfig[key].isObject())
if (defaultConfig[key].isObject())
{
defValueList << QString(QJsonDocument(defaultConfig[key].toObject()).toJson(QJsonDocument::Compact));
}
else if(defaultConfig[key].isArray())
else if (defaultConfig[key].isArray())
{
defValueList << QString(QJsonDocument(defaultConfig[key].toArray()).toJson(QJsonDocument::Compact));
}
}
// fill database with default data if required
for(const auto & key : keyList)
for (const auto& key : qAsConst(keyList))
{
QString val = defValueList.takeFirst();
// prevent overwrite
if(!_sTable->recordExist(key))
_sTable->createSettingsRecord(key,val);
if (!_sTable->recordExist(key))
{
_sTable->createSettingsRecord(key, val);
}
}
// need to validate all data in database construct the entire data object
// TODO refactor schemaChecker to accept QJsonArray in validate(); QJsonDocument container? To validate them per entry...
QJsonObject dbConfig;
for(const auto & key : keyList)
for (const auto& key : qAsConst(keyList))
{
QJsonDocument doc = _sTable->getSettingsRecord(key);
if(doc.isArray())
if (doc.isArray())
{
dbConfig[key] = doc.array();
}
else
{
dbConfig[key] = doc.object();
}
}
//Check, if database requires migration
bool isNewRelease = false;
// Use instance independent SettingsManager to track migration status
if ( instance == GLOABL_INSTANCE_ID)
if (_instance == GLOABL_INSTANCE_ID)
{
if ( resolveConfigVersion(dbConfig) )
if (resolveConfigVersion(dbConfig))
{
QJsonObject newGeneralConfig = dbConfig["general"].toObject();
@@ -107,16 +116,16 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly
exit(1);
}
if ( _configVersion > BUILD_VERSION )
if (_configVersion > BUILD_VERSION)
{
Error(_log, "Database version [%s] is greater than current Hyperion version [%s]", _configVersion.getVersion().c_str(), BUILD_VERSION.getVersion().c_str());
// TODO: Remove version checking and Settingsmanager from components' constructor to be able to stop hyperion.
}
else
{
if ( _previousVersion < BUILD_VERSION )
if (_previousVersion < BUILD_VERSION)
{
if ( _configVersion == BUILD_VERSION )
if (_configVersion == BUILD_VERSION)
{
newGeneralConfig["previousVersion"] = BUILD_VERSION.getVersion().c_str();
dbConfig["general"] = newGeneralConfig;
@@ -139,7 +148,7 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly
// possible data upgrade steps to prevent data loss
bool migrated = handleConfigUpgrade(dbConfig);
if ( isNewRelease || migrated )
if (isNewRelease || migrated)
{
saveSettings(dbConfig, true);
}
@@ -147,28 +156,34 @@ SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonly
// validate full dbconfig against schema, on error we need to rewrite entire table
QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson);
QPair<bool,bool> valid = schemaChecker.validate(dbConfig);
QPair<bool, bool> valid = schemaChecker.validate(dbConfig);
// check if our main schema syntax is IO
if (!valid.second)
{
for (auto & schemaError : schemaChecker.getMessages())
for (auto& schemaError : schemaChecker.getMessages())
{
Error(_log, "Schema Syntax Error: %s", QSTRING_CSTR(schemaError));
}
throw std::runtime_error("The config schema has invalid syntax. This should never happen! Go fix it!");
}
if (!valid.first)
{
Info(_log,"Table upgrade required...");
Info(_log, "Table upgrade required...");
dbConfig = schemaChecker.getAutoCorrectedConfig(dbConfig);
for (auto & schemaError : schemaChecker.getMessages())
for (auto& schemaError : schemaChecker.getMessages())
{
Warning(_log, "Config Fix: %s", QSTRING_CSTR(schemaError));
}
saveSettings(dbConfig,true);
saveSettings(dbConfig, true);
}
else
{
_qconfig = dbConfig;
}
Debug(_log,"Settings database initialized");
Debug(_log, "Settings database initialized");
}
QJsonDocument SettingsManager::getSetting(settings::type type) const
@@ -179,11 +194,11 @@ QJsonDocument SettingsManager::getSetting(settings::type type) const
QJsonObject SettingsManager::getSettings() const
{
QJsonObject config;
for(const auto & key : _qconfig.keys())
for (const auto& key : _qconfig.keys())
{
//Read all records from database to ensure that global settings are read across instances
QJsonDocument doc = _sTable->getSettingsRecord(key);
if(doc.isArray())
if (doc.isArray())
{
config.insert(key, doc.array());
}
@@ -195,26 +210,32 @@ QJsonObject SettingsManager::getSettings() const
return config;
}
bool SettingsManager::saveSettings(QJsonObject config, bool correct)
bool SettingsManager::restoreSettings(QJsonObject config, bool correct)
{
// optional data upgrades e.g. imported legacy/older configs
// handleConfigUpgrade(config);
handleConfigUpgrade(config);
return saveSettings(config, correct);
}
bool SettingsManager::saveSettings(QJsonObject config, bool correct)
{
// we need to validate data against schema
QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson);
if (!schemaChecker.validate(config).first)
{
if(!correct)
if (!correct)
{
Error(_log,"Failed to save configuration, errors during validation");
Error(_log, "Failed to save configuration, errors during validation");
return false;
}
Warning(_log,"Fixing json data!");
Warning(_log, "Fixing json data!");
config = schemaChecker.getAutoCorrectedConfig(config);
for (const auto & schemaError : schemaChecker.getMessages())
for (const auto& schemaError : schemaChecker.getMessages())
{
Warning(_log, "Config Fix: %s", QSTRING_CSTR(schemaError));
}
}
// store the new config
@@ -223,26 +244,26 @@ bool SettingsManager::saveSettings(QJsonObject config, bool correct)
// extract keys and data
QStringList keyList = config.keys();
QStringList newValueList;
for(const auto & key : keyList)
for (const auto& key : qAsConst(keyList))
{
if(config[key].isObject())
if (config[key].isObject())
{
newValueList << QString(QJsonDocument(config[key].toObject()).toJson(QJsonDocument::Compact));
}
else if(config[key].isArray())
else if (config[key].isArray())
{
newValueList << QString(QJsonDocument(config[key].toArray()).toJson(QJsonDocument::Compact));
}
}
int rc = true;
bool rc = true;
// compare database data with new data to emit/save changes accordingly
for(const auto & key : keyList)
for (const auto& key : qAsConst(keyList))
{
QString data = newValueList.takeFirst();
if(_sTable->getSettingsRecordString(key) != data)
if (_sTable->getSettingsRecordString(key) != data)
{
if ( ! _sTable->createSettingsRecord(key, data) )
if (!_sTable->createSettingsRecord(key, data))
{
rc = false;
}
@@ -255,7 +276,7 @@ bool SettingsManager::saveSettings(QJsonObject config, bool correct)
return rc;
}
inline QString fixVersion (const QString& version)
inline QString fixVersion(const QString& version)
{
QString newVersion;
//Try fixing version number, remove dot separated pre-release identifiers not supported
@@ -279,12 +300,12 @@ bool SettingsManager::resolveConfigVersion(QJsonObject& config)
QString configVersion = generalConfig["configVersion"].toString();
QString previousVersion = generalConfig["previousVersion"].toString();
if ( !configVersion.isEmpty() )
if (!configVersion.isEmpty())
{
isValid = _configVersion.setVersion(configVersion.toStdString());
if (!isValid)
{
isValid = _configVersion.setVersion( fixVersion(configVersion).toStdString() );
isValid = _configVersion.setVersion(fixVersion(configVersion).toStdString());
if (isValid)
{
Info(_log, "Invalid config version [%s] fixed. Updated to [%s]", QSTRING_CSTR(configVersion), _configVersion.getVersion().c_str());
@@ -293,16 +314,15 @@ bool SettingsManager::resolveConfigVersion(QJsonObject& config)
}
else
{
_configVersion.setVersion(DEFAULT_VERSION);
isValid = true;
}
if ( !previousVersion.isEmpty() && isValid )
if (!previousVersion.isEmpty() && isValid)
{
isValid = _previousVersion.setVersion(previousVersion.toStdString());
if (!isValid)
{
isValid = _previousVersion.setVersion( fixVersion(previousVersion).toStdString() );
isValid = _previousVersion.setVersion(fixVersion(previousVersion).toStdString());
if (isValid)
{
Info(_log, "Invalid previous version [%s] fixed. Updated to [%s]", QSTRING_CSTR(previousVersion), _previousVersion.getVersion().c_str());
@@ -323,7 +343,7 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
bool migrated = false;
//Only migrate, if valid versions are available
if ( !resolveConfigVersion(config) )
if (!resolveConfigVersion(config))
{
Warning(_log, "Invalid version information found in configuration. No database migration executed.");
}
@@ -333,26 +353,26 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
if (_previousVersion < _configVersion)
{
//Migration steps for versions <= alpha 9
semver::version targetVersion {"2.0.0-alpha.9"};
if (_previousVersion <= targetVersion )
semver::version targetVersion{ "2.0.0-alpha.9" };
if (_previousVersion <= targetVersion)
{
Info(_log, "Instance [%u]: Migrate LED Layout from current version [%s] to version [%s] or later", _instance, _previousVersion.getVersion().c_str(), targetVersion.getVersion().c_str());
Info(_log, "Instance [%u]: Migrate from version [%s] to version [%s] or later", _instance, _previousVersion.getVersion().c_str(), targetVersion.getVersion().c_str());
// LED LAYOUT UPGRADE
// from { hscan: { minimum: 0.2, maximum: 0.3 }, vscan: { minimum: 0.2, maximum: 0.3 } }
// from { h: { min: 0.2, max: 0.3 }, v: { min: 0.2, max: 0.3 } }
// to { hmin: 0.2, hmax: 0.3, vmin: 0.2, vmax: 0.3}
if(config.contains("leds"))
if (config.contains("leds"))
{
const QJsonArray ledarr = config["leds"].toArray();
const QJsonObject led = ledarr[0].toObject();
if(led.contains("hscan") || led.contains("h"))
if (led.contains("hscan") || led.contains("h"))
{
const bool whscan = led.contains("hscan");
QJsonArray newLedarr;
for(const auto & entry : ledarr)
for (const auto& entry : ledarr)
{
const QJsonObject led = entry.toObject();
QJsonObject hscan;
@@ -363,7 +383,7 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
QJsonValue vmax;
QJsonObject nL;
if(whscan)
if (whscan)
{
hscan = led["hscan"].toObject();
vscan = led["vscan"].toObject();
@@ -391,27 +411,27 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
// replace
config["leds"] = newLedarr;
migrated = true;
Info(_log,"Instance [%u]: LED Layout migrated", _instance);
Info(_log, "Instance [%u]: LED Layout migrated", _instance);
}
}
if(config.contains("ledConfig"))
if (config.contains("ledConfig"))
{
QJsonObject oldLedConfig = config["ledConfig"].toObject();
if ( !oldLedConfig.contains("classic"))
if (!oldLedConfig.contains("classic"))
{
QJsonObject newLedConfig;
newLedConfig.insert("classic", oldLedConfig );
QJsonObject defaultMatrixConfig {{"ledshoriz", 1}
newLedConfig.insert("classic", oldLedConfig);
QJsonObject defaultMatrixConfig{ {"ledshoriz", 1}
,{"ledsvert", 1}
,{"cabling","snake"}
,{"start","top-left"}
};
newLedConfig.insert("matrix", defaultMatrixConfig );
newLedConfig.insert("matrix", defaultMatrixConfig);
config["ledConfig"] = newLedConfig;
migrated = true;
Info(_log,"Instance [%u]: LED-Config migrated", _instance);
Info(_log, "Instance [%u]: LED-Config migrated", _instance);
}
}
@@ -429,7 +449,7 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
const QJsonArray ledarr = config["leds"].toArray();
int layoutLedCount = ledarr.size();
if (hwLedcount < layoutLedCount )
if (hwLedcount < layoutLedCount)
{
Warning(_log, "Instance [%u]: HwLedCount/Layout mismatch! Setting Hardware LED count to number of LEDs configured via layout", _instance);
hwLedcount = layoutLedCount;
@@ -442,7 +462,7 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
if (newDeviceConfig.contains("type"))
{
QString type = newDeviceConfig["type"].toString();
if (type == "atmoorb" || type == "fadecandy" || type == "philipshue" )
if (type == "atmoorb" || type == "fadecandy" || type == "philipshue")
{
if (newDeviceConfig.contains("output"))
{
@@ -520,8 +540,150 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
Debug(_log, "Framegrabber records migrated");
}
}
//Migration steps for versions <= 2.0.12
_previousVersion = targetVersion;
targetVersion.setVersion("2.0.12");
if (_previousVersion <= targetVersion)
{
Info(_log, "Instance [%u]: Migrate from version [%s] to version [%s] or later", _instance, _previousVersion.getVersion().c_str(), targetVersion.getVersion().c_str());
// Have Hostname/IP-address separate from port for LED-Devices
if (config.contains("device"))
{
QJsonObject newDeviceConfig = config["device"].toObject();
if (newDeviceConfig.contains("host"))
{
QString oldHost = newDeviceConfig["host"].toString();
// Resolve hostname and port
QStringList addressparts = QStringUtils::split(oldHost, ":", QStringUtils::SplitBehavior::SkipEmptyParts);
newDeviceConfig["host"] = addressparts[0];
if (addressparts.size() > 1)
{
if (!newDeviceConfig.contains("port"))
{
newDeviceConfig["port"] = addressparts[1].toInt();
}
migrated = true;
}
if (migrated)
{
config["device"] = newDeviceConfig;
Debug(_log, "LED-Device records migrated");
}
}
}
// Have Hostname/IP-address separate from port for Forwarder
if (config.contains("forwarder"))
{
QJsonObject newForwarderConfig = config["forwarder"].toObject();
QJsonArray json;
if (newForwarderConfig.contains("json"))
{
QJsonArray oldJson = newForwarderConfig["json"].toArray();
QJsonObject newJsonConfig;
for (const QJsonValue& value : qAsConst(oldJson))
{
if (value.isString())
{
QString oldHost = value.toString();
// Resolve hostname and port
QStringList addressparts = QStringUtils::split(oldHost, ":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString host = addressparts[0];
if (host != "127.0.0.1")
{
newJsonConfig["host"] = host;
if (addressparts.size() > 1)
{
newJsonConfig["port"] = addressparts[1].toInt();
}
else
{
newJsonConfig["port"] = 19444;
}
json.append(newJsonConfig);
migrated = true;
}
}
}
if (!json.isEmpty())
{
newForwarderConfig["json"] = json;
}
else
{
newForwarderConfig.remove("json");
}
}
QJsonArray flatbuffer;
if (newForwarderConfig.contains("flat"))
{
QJsonArray oldFlatbuffer = newForwarderConfig["flat"].toArray();
QJsonObject newFlattbufferConfig;
for (const QJsonValue& value : qAsConst(oldFlatbuffer))
{
if (value.isString())
{
QString oldHost = value.toString();
// Resolve hostname and port
QStringList addressparts = QStringUtils::split(oldHost, ":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString host = addressparts[0];
if (host != "127.0.0.1")
{
newFlattbufferConfig["host"] = host;
if (addressparts.size() > 1)
{
newFlattbufferConfig["port"] = addressparts[1].toInt();
}
else
{
newFlattbufferConfig["port"] = 19400;
}
flatbuffer.append(newFlattbufferConfig);
migrated = true;
}
}
if (!flatbuffer.isEmpty())
{
newForwarderConfig["flat"] = flatbuffer;
}
else
{
newForwarderConfig.remove("flat");
}
}
}
if (json.isEmpty() && flatbuffer.isEmpty())
{
newForwarderConfig["enable"] = false;
}
if (migrated)
{
config["forwarder"] = newForwarderConfig;
Debug(_log, "Forwarder records migrated");
}
}
}
}
}
return migrated;
}

View File

@@ -2,40 +2,76 @@
"type" : "object",
"title" : "edt_conf_fw_heading_title",
"required" : true,
"properties" :
{
"enable" :
{
"type" : "boolean",
"title" : "edt_conf_general_enable_title",
"required" : true,
"default" : false,
"propertyOrder" : 1
"properties": {
"enable": {
"type": "boolean",
"title": "edt_conf_general_enable_title",
"required": true,
"default": false,
"propertyOrder": 1
},
"json" :
{
"type" : "array",
"title" : "edt_conf_fw_json_title",
"required" : true,
"default" : ["127.0.0.1:19446"],
"items" : {
"type": "string",
"title" : "edt_conf_fw_json_itemtitle"
},
"propertyOrder" : 2
"json": {
"type": "array",
"title": "edt_conf_fw_json_title",
"propertyOrder": 2,
"uniqueItems": true,
"items": {
"type": "object",
"title": "edt_conf_fw_json_itemtitle",
"required": true,
"properties": {
"host": {
"type": "string",
"format": "hostname_or_ip",
"minLength": 7,
"title": "edt_dev_spec_targetIpHost_title",
"required": true,
"propertyOrder": 1
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535,
"default": 19444,
"title": "edt_dev_spec_port_title",
"required": true,
"access": "expert",
"propertyOrder": 2
}
}
}
},
"flat" :
{
"type" : "array",
"title" : "edt_conf_fw_flat_title",
"required" : true,
"default" : ["127.0.0.1:19401"],
"items" : {
"type": "string",
"title" : "edt_conf_fw_flat_itemtitle"
},
"propertyOrder" : 3
"flat": {
"type": "array",
"title": "edt_conf_fw_flat_title",
"propertyOrder": 3,
"uniqueItems": true,
"items": {
"type": "object",
"title": "edt_conf_fw_flat_itemtitle",
"required": true,
"properties": {
"host": {
"type": "string",
"format": "hostname_or_ip",
"minLength": 7,
"title": "edt_dev_spec_targetIpHost_title",
"required": true,
"propertyOrder": 1
},
"port": {
"type": "integer",
"minimum": 1,
"maximum": 65535,
"default": 19400,
"title": "edt_dev_spec_port_title",
"required": true,
"access": "expert",
"propertyOrder": 2
}
}
}
}
},
"additionalProperties" : false
}
"additionalProperties": false
}

View File

@@ -27,6 +27,7 @@
"hidden": true
},
"required": true,
"default": "",
"comment": "The 'available_devices' settings are dynamically inserted into the WebUI under PropertyOrder '2'.",
"propertyOrder": 3
},

View File

@@ -19,7 +19,6 @@ const bool verbose3 = false;
// Configuration settings
const char CONFIG_ADDRESS[] = "host";
//const char CONFIG_PORT[] = "port";
const char CONFIG_AUTH_TOKEN[] = "token";
const char CONFIG_RESTORE_STATE[] = "restoreOriginalState";
const char CONFIG_BRIGHTNESS[] = "brightness";
@@ -182,8 +181,6 @@ bool LedDeviceNanoleaf::init(const QJsonObject& deviceConfig)
_startPos = deviceConfig[CONFIG_PANEL_START_POS].toInt(0);
// TODO: Allow to handle port dynamically
//Set hostname as per configuration and_defaultHost default port
_hostName = deviceConfig[CONFIG_ADDRESS].toString();
_apiPort = API_DEFAULT_PORT;
@@ -442,21 +439,7 @@ QJsonObject LedDeviceNanoleaf::getProperties(const QJsonObject& params)
QString authToken = params["token"].toString("");
QString filter = params["filter"].toString("");
// Resolve hostname and port (or use default API port)
QStringList addressparts = QStringUtils::split(hostName, ":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString apiHost = addressparts[0];
int apiPort;
if (addressparts.size() > 1)
{
apiPort = addressparts[1].toInt();
}
else
{
apiPort = API_DEFAULT_PORT;
}
initRestAPI(apiHost, apiPort, authToken);
initRestAPI(hostName, API_DEFAULT_PORT, authToken);
_restApi->setPath(filter);
// Perform request
@@ -482,21 +465,7 @@ void LedDeviceNanoleaf::identify(const QJsonObject& params)
{
QString authToken = params["token"].toString("");
// Resolve hostname and port (or use default API port)
QStringList addressparts = QStringUtils::split(hostName, ":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString apiHost = addressparts[0];
int apiPort;
if (addressparts.size() > 1)
{
apiPort = addressparts[1].toInt();
}
else
{
apiPort = API_DEFAULT_PORT;
}
initRestAPI(apiHost, apiPort, authToken);
initRestAPI(hostName, API_DEFAULT_PORT, authToken);
_restApi->setPath("identify");
// Perform request

View File

@@ -61,7 +61,7 @@ public:
/// Following parameters are required
/// @code
/// {
/// "host" : "hostname or IP [:port]",
/// "host" : "hostname or IP",
/// "token" : "authentication token",
/// "filter": "resource to query", root "/" is used, if empty
/// }
@@ -78,7 +78,7 @@ public:
/// Following parameters are required
/// @code
/// {
/// "host" : "hostname or IP [:port]",
/// "host" : "hostname or IP",
/// "token" : "authentication token",
/// }
///@endcode

View File

@@ -12,8 +12,8 @@ namespace {
bool verbose = false;
// Configuration settings
const char CONFIG_ADDRESS[] = "host";
//const char CONFIG_PORT[] = "port";
const char CONFIG_HOST[] = "host";
const char CONFIG_PORT[] = "port";
const char CONFIG_USERNAME[] = "username";
const char CONFIG_CLIENTKEY[] = "clientkey";
const char CONFIG_BRIGHTNESSFACTOR[] = "brightnessFactor";
@@ -282,31 +282,30 @@ bool LedDevicePhilipsHueBridge::init(const QJsonObject &deviceConfig)
log( "LatchTime", "%d", this->getLatchTime() );
//Set hostname as per configuration and_defaultHost default port
QString address = deviceConfig[ CONFIG_ADDRESS ].toString();
_hostname = deviceConfig[CONFIG_HOST].toString();
//If host not configured the init failed
if ( address.isEmpty() )
if (_hostname.isEmpty())
{
this->setInError("No target hostname nor IP defined");
this->setInError("No target hostname defined");
isInitOK = false;
}
else
{
QStringList addressparts = QStringUtils::split(address,":", QStringUtils::SplitBehavior::SkipEmptyParts);
_hostname = addressparts[0];
log( "Hostname/IP", "%s", QSTRING_CSTR( _hostname ) );
log("Hostname", "%s", QSTRING_CSTR(_hostname));
if ( addressparts.size() > 1 )
int _apiPort = deviceConfig[CONFIG_PORT].toInt();
if (_apiPort == 0)
{
_apiPort = addressparts[1].toInt();
log( "Port", "%u", _apiPort );
_apiPort = API_DEFAULT_PORT;
}
log("Port", "%d", _apiPort);
_username = deviceConfig[ CONFIG_USERNAME ].toString();
_username = deviceConfig[CONFIG_USERNAME].toString();
if ( initRestAPI( _hostname, _apiPort, _username ) )
if (initRestAPI(_hostname, _apiPort, _username))
{
if ( initMaps() )
if (initMaps())
{
isInitOK = ProviderUdpSSL::init(_devConfig);
}
@@ -1602,7 +1601,7 @@ QJsonObject LedDevicePhilipsHue::discover(const QJsonObject& /*params*/)
// Discover Devices
SSDPDiscover discover;
discover.skipDuplicateKeys(false);
discover.skipDuplicateKeys(true);
discover.setSearchFilter(SSDP_FILTER, SSDP_FILTER_HEADER);
QString searchTarget = SSDP_ID;
@@ -1619,37 +1618,39 @@ QJsonObject LedDevicePhilipsHue::discover(const QJsonObject& /*params*/)
QJsonObject LedDevicePhilipsHue::getProperties(const QJsonObject& params)
{
DebugIf(verbose, _log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData());
QJsonObject properties;
// Get Phillips-Bridge device properties
QString host = params["host"].toString("");
if ( !host.isEmpty() )
QString hostName = params[CONFIG_HOST].toString("");
if (!hostName.isEmpty())
{
QString username = params["user"].toString("");
QString filter = params["filter"].toString("");
// Resolve hostname and port (or use default API port)
QStringList addressparts = QStringUtils::split(host,":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString apiHost = addressparts[0];
int apiPort;
if ( addressparts.size() > 1 )
if (params[CONFIG_PORT].isString())
{
apiPort = addressparts[1].toInt();
apiPort = params[CONFIG_PORT].toString().toInt();
}
else
{
apiPort = params[CONFIG_PORT].toInt();
}
if (apiPort == 0)
{
apiPort = API_DEFAULT_PORT;
}
initRestAPI(apiHost, apiPort, username);
initRestAPI(hostName, apiPort, username);
_restApi->setPath(filter);
// Perform request
httpResponse response = _restApi->get();
if ( response.error() )
if (response.error())
{
Warning (_log, "%s get properties failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
Warning(_log, "%s get properties failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
}
// Perform request
@@ -1660,45 +1661,46 @@ QJsonObject LedDevicePhilipsHue::getProperties(const QJsonObject& params)
void LedDevicePhilipsHue::identify(const QJsonObject& params)
{
Debug(_log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData() );
DebugIf(verbose, _log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData());
QJsonObject properties;
// Identify Phillips-Bridge device
QString host = params["host"].toString("");
if ( !host.isEmpty() )
QString hostName = params[CONFIG_HOST].toString("");
if (!hostName.isEmpty())
{
QString username = params["user"].toString("");
int lightId = params["lightId"].toInt(0);
// Resolve hostname and port (or use default API port)
QStringList addressparts = QStringUtils::split(host,":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString apiHost = addressparts[0];
int apiPort;
if ( addressparts.size() > 1 )
if (params[CONFIG_PORT].isString())
{
apiPort = addressparts[1].toInt();
apiPort = params[CONFIG_PORT].toString().toInt();
}
else
{
apiPort = API_DEFAULT_PORT;
apiPort = params[CONFIG_PORT].toInt();
}
initRestAPI(apiHost, apiPort, username);
if (apiPort == 0)
{
apiPort = API_DEFAULT_PORT;
}
QString resource = QString("%1/%2/%3").arg( API_LIGHTS ).arg( lightId ).arg( API_STATE);
initRestAPI(hostName, apiPort, username);
QString resource = QString("%1/%2/%3").arg(API_LIGHTS).arg(lightId).arg(API_STATE);
_restApi->setPath(resource);
QString stateCmd;
stateCmd += QString("\"%1\":%2,").arg( API_STATE_ON, API_STATE_VALUE_TRUE );
stateCmd += QString("\"%1\":\"%2\"").arg( "alert", "select" );
stateCmd += QString("\"%1\":%2,").arg(API_STATE_ON, API_STATE_VALUE_TRUE);
stateCmd += QString("\"%1\":\"%2\"").arg("alert", "select");
stateCmd = "{" + stateCmd + "}";
// Perform request
httpResponse response = _restApi->put(stateCmd);
if ( response.error() )
if (response.error())
{
Warning (_log, "%s identification failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
Warning(_log, "%s identification failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
}
}
}

View File

@@ -376,7 +376,8 @@ public:
/// Following parameters are required
/// @code
/// {
/// "host" : "hostname or IP [:port]",
/// "host" : "hostname or IP
/// "port" : port
/// "user" : "username",
/// "filter": "resource to query", root "/" is used, if empty
/// }
@@ -390,7 +391,15 @@ public:
///
/// @brief Send an update to the device to identify it.
///
/// Used in context of a set of devices of the same type.
/// Following parameters are required
/// @code
/// {
/// "host" : "hostname or IP
/// "port" : port
/// "user" : "username",
/// "filter": "resource to query", root "/" is used, if empty
/// }
///@endcode
///
/// @param[in] params Parameters to address device
///

View File

@@ -47,7 +47,7 @@ public:
/// Following parameters are required
/// @code
/// {
/// "host" : "hostname or IP [:port]",
/// "host" : "hostname or IP",
/// "filter": "resource to query", root "/" is used, if empty
/// }
///@endcode
@@ -63,7 +63,7 @@ public:
/// Following parameters are required
/// @code
/// {
/// "host" : "hostname or IP [:port]",
/// "host" : "hostname or IP",
/// }
///@endcode
///

View File

@@ -1112,11 +1112,7 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig)
QString hostName = configuredYeelightLights[j].toObject().value("host").toString();
int port = configuredYeelightLights[j].toObject().value("port").toInt(API_DEFAULT_PORT);
QStringList addressparts = QStringUtils::split(hostName,":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString apiHost = addressparts[0];
int apiPort = port;
_lightsAddressList.append( {apiHost, apiPort} );
_lightsAddressList.append( { hostName, port} );
}
if ( updateLights(_lightsAddressList) )
@@ -1150,19 +1146,19 @@ bool LedDeviceYeelight::startMusicModeServer()
}
else
{
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
// use the first non-localhost IPv4 address
for (int i = 0; i < ipAddressesList.size(); ++i) {
if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
(ipAddressesList.at(i).toIPv4Address() != 0U))
// use the first non-localhost IPv4 address, IPv6 are not supported by Yeelight currently
for (const auto& address : QNetworkInterface::allAddresses())
{
// is valid when, no loopback, IPv4
if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol))
{
_musicModeServerAddress = ipAddressesList.at(i);
_musicModeServerAddress = address;
break;
}
}
if ( _musicModeServerAddress.isNull() )
if (_musicModeServerAddress.isNull())
{
Error( _log, "Failed to resolve IP for music mode server");
Error(_log, "Failed to resolve IP for music mode server");
}
}
}

View File

@@ -70,7 +70,7 @@ bool ProviderUdp::init(const QJsonObject& deviceConfig)
else
{
_port = static_cast<quint16>(config_port);
Debug(_log, "UDP socket will write to %s:%u", QSTRING_CSTR(_address.toString()), _port);
Debug(_log, "UDP socket will write to %s port: %u", QSTRING_CSTR(_address.toString()), _port);
_udpSocket = new QUdpSocket(this);

View File

@@ -74,9 +74,6 @@ bool ProviderUdpSSL::init(const QJsonObject &deviceConfig)
if( deviceConfig.contains("hs_attempts") ) _handshake_attempts = deviceConfig["hs_attempts"].toInt(5);
QString host = deviceConfig["host"].toString(_defaultHost);
//Split hostname from API-port in case given
QStringList addressparts = QStringUtils::split(host, ":", QStringUtils::SplitBehavior::SkipEmptyParts);
QString udpHost = addressparts[0];
QStringList debugLevels = QStringList() << "No Debug" << "Error" << "State Change" << "Informational" << "Verbose";
@@ -96,25 +93,24 @@ bool ProviderUdpSSL::init(const QJsonObject &deviceConfig)
configLog( "SSL Handshake Timeout max", "%d", _handshake_timeout_max );
configLog( "SSL Handshake attempts", "%d", _handshake_attempts );
if ( _address.setAddress(udpHost) )
if (_address.setAddress(host))
{
Debug( _log, "Successfully parsed %s as an ip address.", QSTRING_CSTR(udpHost) );
Debug(_log, "Successfully parsed %s as an IP-address.", QSTRING_CSTR(_address.toString()));
}
else
{
Debug( _log, "Failed to parse [%s] as an ip address.", QSTRING_CSTR(udpHost) );
QHostInfo info = QHostInfo::fromName(udpHost);
if ( info.addresses().isEmpty() )
QHostInfo hostInfo = QHostInfo::fromName(host);
if (hostInfo.error() == QHostInfo::NoError)
{
Debug( _log, "Failed to parse [%s] as a hostname.", QSTRING_CSTR(udpHost) );
QString errortext = QString("Invalid target address [%1]!").arg(host);
this->setInError( errortext );
isInitOK = false;
_address = hostInfo.addresses().first();
Debug(_log, "Successfully resolved IP-address (%s) for hostname (%s).", QSTRING_CSTR(_address.toString()), QSTRING_CSTR(host));
}
else
{
Debug( _log, "Successfully parsed %s as a hostname.", QSTRING_CSTR(udpHost) );
_address = info.addresses().first();
QString errortext = QString("Failed resolving IP-address for [%1], (%2) %3").arg(host).arg(hostInfo.error()).arg(hostInfo.errorString());
this->setInError(errortext);
isInitOK = false;
return isInitOK;
}
}
@@ -129,7 +125,7 @@ bool ProviderUdpSSL::init(const QJsonObject &deviceConfig)
else
{
_ssl_port = config_port;
Debug( _log, "UDP SSL using %s:%u", QSTRING_CSTR( _address.toString() ), _ssl_port );
Debug(_log, "UDP SSL will write to %s port: %u", QSTRING_CSTR(_address.toString()), _ssl_port);
isInitOK = true;
}
}
@@ -250,23 +246,26 @@ bool ProviderUdpSSL::initConnection()
bool ProviderUdpSSL::seedingRNG()
{
int ret = 0;
sslLog( "Seeding the random number generator..." );
sslLog("Seeding the random number generator...");
mbedtls_entropy_init(&entropy);
sslLog( "Set mbedtls_ctr_drbg_seed..." );
sslLog("Set mbedtls_ctr_drbg_seed...");
const char* custom = QSTRING_CSTR( _custom );
QByteArray customDataArray = _custom.toLocal8Bit();
const char* customData = customDataArray.constData();
if ((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, reinterpret_cast<const unsigned char *>(custom), strlen(custom))) != 0)
int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
&entropy, reinterpret_cast<const unsigned char*>(customData),
std::min(strlen(customData), (size_t)MBEDTLS_CTR_DRBG_MAX_SEED_INPUT));
if (ret != 0)
{
sslLog( QString("mbedtls_ctr_drbg_seed FAILED %1").arg( errorMsg( ret ) ), "error" );
sslLog(QString("mbedtls_ctr_drbg_seed FAILED %1").arg(errorMsg(ret)), "error");
return false;
}
sslLog( "Seeding the random number generator...ok" );
sslLog("Seeding the random number generator...ok");
return true;
}

View File

@@ -1,42 +1,43 @@
{
"type":"object",
"required":true,
"properties":{
"host" : {
"type": "string",
"title":"edt_dev_spec_targetIp_title",
"propertyOrder" : 1
},
"port" : {
"type": "integer",
"title":"edt_dev_spec_port_title",
"default": 6454,
"minimum": 0,
"maximum": 65535,
"propertyOrder" : 2
},
"universe": {
"type": "integer",
"title":"edt_dev_spec_universe_title",
"default": 1,
"propertyOrder" : 3
},
"channelsPerFixture": {
"type": "integer",
"title":"edt_dev_spec_chanperfixture_title",
"default": 3,
"propertyOrder" : 4
},
"latchTime": {
"type": "integer",
"title":"edt_dev_spec_latchtime_title",
"default": 0,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access" : "expert",
"propertyOrder" : 5
}
},
"additionalProperties": true
"type": "object",
"required": true,
"properties": {
"host": {
"type": "string",
"format": "hostname_or_ip",
"title": "edt_dev_spec_targetIpHost_title",
"propertyOrder": 1
},
"port": {
"type": "integer",
"title": "edt_dev_spec_port_title",
"default": 6454,
"minimum": 0,
"maximum": 65535,
"propertyOrder": 2
},
"universe": {
"type": "integer",
"title": "edt_dev_spec_universe_title",
"default": 1,
"propertyOrder": 3
},
"channelsPerFixture": {
"type": "integer",
"title": "edt_dev_spec_chanperfixture_title",
"default": 3,
"propertyOrder": 4
},
"latchTime": {
"type": "integer",
"title": "edt_dev_spec_latchtime_title",
"default": 0,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access": "expert",
"propertyOrder": 5
}
},
"additionalProperties": true
}

View File

@@ -18,6 +18,7 @@
},
"host": {
"type": "string",
"format": "ipv4",
"title": "edt_dev_spec_multicastGroup_title",
"default": "239.255.255.250",
"propertyOrder": 3

View File

@@ -15,6 +15,7 @@
},
"host": {
"type": "string",
"format": "hostname_or_ip4",
"title": "edt_dev_spec_targetIpHost_title",
"options": {
"infoText": "edt_dev_spec_targetIpHost_title_info"

View File

@@ -1,41 +1,42 @@
{
"type":"object",
"required":true,
"properties":{
"host" : {
"type": "string",
"title":"edt_dev_spec_targetIp_title",
"propertyOrder" : 1
},
"port" : {
"type": "integer",
"title":"edt_dev_spec_port_title",
"default": 5568,
"minimum" : 0,
"maximum" : 65535,
"propertyOrder" : 2
},
"universe": {
"type": "integer",
"title":"edt_dev_spec_universe_title",
"default": 1,
"propertyOrder" : 3
},
"latchTime": {
"type": "integer",
"title":"edt_dev_spec_latchtime_title",
"default": 0,
"append" : "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access" : "expert",
"propertyOrder" : 4
},
"cid": {
"type": "string",
"title":"edt_dev_spec_cid_title",
"propertyOrder" : 5
}
},
"additionalProperties": true
"type": "object",
"required": true,
"properties": {
"host": {
"type": "string",
"format": "hostname_or_ip",
"title": "edt_dev_spec_targetIpHost_title",
"propertyOrder": 1
},
"port": {
"type": "integer",
"title": "edt_dev_spec_port_title",
"default": 5568,
"minimum": 0,
"maximum": 65535,
"propertyOrder": 2
},
"universe": {
"type": "integer",
"title": "edt_dev_spec_universe_title",
"default": 1,
"propertyOrder": 3
},
"latchTime": {
"type": "integer",
"title": "edt_dev_spec_latchtime_title",
"default": 0,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access": "expert",
"propertyOrder": 4
},
"cid": {
"type": "string",
"title": "edt_dev_spec_cid_title",
"propertyOrder": 5
}
},
"additionalProperties": true
}

View File

@@ -1,113 +1,113 @@
{
"type":"object",
"required":true,
"properties": {
"host": {
"type": "string",
"title": "edt_dev_spec_targetIp_title",
"default": "127.0.0.1",
"propertyOrder": 1
},
"port": {
"type": "number",
"title": "edt_dev_spec_port_title",
"default": 7890,
"propertyOrder": 2
},
"latchTime": {
"type": "integer",
"title": "edt_dev_spec_latchtime_title",
"default": 0,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access": "expert",
"propertyOrder": 3
},
"setFcConfig": {
"type": "boolean",
"title": "edt_dev_spec_FCsetConfig_title",
"default": false,
"propertyOrder": 4
},
"manualLed": {
"type": "boolean",
"title": "edt_dev_spec_FCmanualControl_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 5
},
"ledOn": {
"type": "boolean",
"title": "edt_dev_spec_FCledToOn_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 6
},
"interpolation": {
"type": "boolean",
"title": "edt_dev_spec_interpolation_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 7
},
"dither": {
"type": "boolean",
"title": "edt_dev_spec_dithering_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 8
},
"gamma": {
"type": "number",
"title": "edt_dev_spec_gamma_title",
"default": 1.0,
"minimum": 0.1,
"maximum": 5.0,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 9
},
"whitepoint": {
"type": "array",
"title": "edt_dev_spec_whitepoint_title",
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 10,
"default": [ 255, 255, 255 ],
"maxItems": 3,
"minItems": 3,
"format": "colorpicker",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255,
"default": 255
}
}
},
"additionalProperties": true
"type": "object",
"required": true,
"properties": {
"host": {
"type": "string",
"format": "hostname_or_ip4",
"title": "edt_dev_spec_targetIpHost_title",
"default": "127.0.0.1",
"propertyOrder": 1
},
"port": {
"type": "number",
"title": "edt_dev_spec_port_title",
"default": 7890,
"propertyOrder": 2
},
"latchTime": {
"type": "integer",
"title": "edt_dev_spec_latchtime_title",
"default": 0,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access": "expert",
"propertyOrder": 3
},
"setFcConfig": {
"type": "boolean",
"title": "edt_dev_spec_FCsetConfig_title",
"default": false,
"propertyOrder": 4
},
"manualLed": {
"type": "boolean",
"title": "edt_dev_spec_FCmanualControl_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 5
},
"ledOn": {
"type": "boolean",
"title": "edt_dev_spec_FCledToOn_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 6
},
"interpolation": {
"type": "boolean",
"title": "edt_dev_spec_interpolation_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 7
},
"dither": {
"type": "boolean",
"title": "edt_dev_spec_dithering_title",
"default": false,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 8
},
"gamma": {
"type": "number",
"title": "edt_dev_spec_gamma_title",
"default": 1.0,
"minimum": 0.1,
"maximum": 5.0,
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 9
},
"whitepoint": {
"type": "array",
"title": "edt_dev_spec_whitepoint_title",
"options": {
"dependencies": {
"setFcConfig": true
}
},
"propertyOrder": 10,
"default": [ 255, 255, 255 ],
"maxItems": 3,
"minItems": 3,
"format": "colorpicker",
"items": {
"type": "integer",
"minimum": 0,
"maximum": 255,
"default": 255
}
}
},
"additionalProperties": true
}

View File

@@ -1,38 +1,39 @@
{
"type":"object",
"required":true,
"properties":{
"host" : {
"type": "string",
"title":"edt_dev_spec_targetIp_title",
"default": "255.255.255.255",
"propertyOrder" : 1
},
"port" : {
"type": "integer",
"title":"edt_dev_spec_port_title",
"default": 30977,
"propertyOrder" : 2
},
"lightIds": {
"type": "array",
"title":"edt_dev_spec_lightid_title",
"items" : {
"type" : "string",
"title" : "edt_dev_spec_lightid_itemtitle"
},
"propertyOrder" : 3
},
"latchTime": {
"type": "integer",
"title":"edt_dev_spec_latchtime_title",
"default": 10,
"append" : "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access" : "expert",
"propertyOrder" : 4
}
},
"additionalProperties": true
"type": "object",
"required": true,
"properties": {
"host": {
"type": "string",
"format": "ipv4",
"title": "edt_dev_spec_targetIp_title",
"default": "255.255.255.255",
"propertyOrder": 1
},
"port": {
"type": "integer",
"title": "edt_dev_spec_port_title",
"default": 30977,
"propertyOrder": 2
},
"lightIds": {
"type": "array",
"title": "edt_dev_spec_lightid_title",
"items": {
"type": "string",
"title": "edt_dev_spec_lightid_itemtitle"
},
"propertyOrder": 3
},
"latchTime": {
"type": "integer",
"title": "edt_dev_spec_latchtime_title",
"default": 10,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access": "expert",
"propertyOrder": 4
}
},
"additionalProperties": true
}

View File

@@ -15,6 +15,7 @@
},
"host": {
"type": "string",
"format": "hostname_or_ip",
"title": "edt_dev_spec_targetIpHost_title",
"options": {
"infoText": "edt_dev_spec_targetIpHost_title_info"

View File

@@ -4,15 +4,25 @@
"properties": {
"host": {
"type": "string",
"title": "edt_dev_spec_targetIp_title",
"format": "hostname_or_ip",
"title": "edt_dev_spec_targetIpHost_title",
"default": "",
"propertyOrder": 1
},
"port": {
"type": "integer",
"title": "edt_dev_spec_port_title",
"default": 0,
"minimum": 0,
"maximum": 65535,
"access": "expert",
"propertyOrder": 2
},
"username": {
"type": "string",
"title": "edt_dev_spec_username_title",
"default": "",
"propertyOrder": 2
"propertyOrder": 3
},
"clientkey": {
"type": "string",
@@ -23,13 +33,13 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 3
"propertyOrder": 4
},
"useEntertainmentAPI": {
"type": "boolean",
"title": "edt_dev_spec_useEntertainmentAPI_title",
"default": true,
"propertyOrder": 4
"propertyOrder": 5
},
"transitiontime": {
"type": "number",
@@ -41,19 +51,19 @@
"useEntertainmentAPI": false
}
},
"propertyOrder": 5
"propertyOrder": 6
},
"switchOffOnBlack": {
"type": "boolean",
"title": "edt_dev_spec_switchOffOnBlack_title",
"default": false,
"propertyOrder": 6
"propertyOrder": 7
},
"restoreOriginalState": {
"type": "boolean",
"title": "edt_dev_spec_restoreOriginalState_title",
"default": true,
"propertyOrder": 7
"propertyOrder": 8
},
"lightIds": {
"type": "array",
@@ -71,7 +81,7 @@
"useEntertainmentAPI": false
}
},
"propertyOrder": 8
"propertyOrder": 9
},
"groupId": {
"type": "number",
@@ -82,7 +92,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 9
"propertyOrder": 10
},
"blackLightsTimeout": {
"type": "number",
@@ -98,7 +108,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 10
"propertyOrder": 11
},
"brightnessThreshold": {
"type": "number",
@@ -113,7 +123,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 11
"propertyOrder": 12
},
"brightnessFactor": {
"type": "number",
@@ -123,7 +133,7 @@
"minimum": 0.5,
"maximum": 10.0,
"access": "advanced",
"propertyOrder": 12
"propertyOrder": 13
},
"brightnessMin": {
"type": "number",
@@ -138,7 +148,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 13
"propertyOrder": 14
},
"brightnessMax": {
"type": "number",
@@ -153,7 +163,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 14
"propertyOrder": 15
},
"sslReadTimeout": {
"type": "number",
@@ -169,7 +179,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 15
"propertyOrder": 16
},
"sslHSTimeoutMin": {
"type": "number",
@@ -185,7 +195,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 16
"propertyOrder": 17
},
"sslHSTimeoutMax": {
"type": "number",
@@ -201,14 +211,14 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 17
"propertyOrder": 18
},
"verbose": {
"type": "boolean",
"title": "edt_dev_spec_verbose_title",
"default": false,
"access": "expert",
"propertyOrder": 18
"propertyOrder": 19
},
"debugStreamer": {
"type": "boolean",
@@ -220,7 +230,7 @@
"useEntertainmentAPI": true
}
},
"propertyOrder": 19
"propertyOrder": 20
},
"debugLevel": {
"type": "string",
@@ -236,7 +246,7 @@
"minimum": 0,
"maximum": 4,
"access": "expert",
"propertyOrder": 20
"propertyOrder": 21
}
},
"additionalProperties": true

View File

@@ -2,11 +2,12 @@
"type":"object",
"required":true,
"properties":{
"output": {
"host": {
"type": "string",
"title":"edt_dev_spec_targetIp_title",
"default" : "127.0.0.1",
"propertyOrder" : 1
"format": "hostname_or_ip",
"title": "edt_dev_spec_targetIpHost_title",
"default": "127.0.0.1",
"propertyOrder": 1
},
"port": {
"type": "integer",

View File

@@ -1,37 +1,38 @@
{
"type":"object",
"required":true,
"properties":{
"host" : {
"type": "string",
"title":"edt_dev_spec_targetIpHost_title",
"propertyOrder" : 1
},
"port": {
"type": "integer",
"title":"edt_dev_spec_port_title",
"minimum" : 0,
"maximum" : 65535,
"default" : 50200,
"propertyOrder" : 2
},
"max-packet": {
"type": "integer",
"title":"edt_dev_spec_maxPacket_title",
"minimum" : 0,
"default" : 170,
"propertyOrder" : 3
},
"latchTime": {
"type": "integer",
"title":"edt_dev_spec_latchtime_title",
"default": 0,
"append" : "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access" : "expert",
"propertyOrder" : 4
}
},
"additionalProperties": true
"type": "object",
"required": true,
"properties": {
"host": {
"type": "string",
"format": "hostname_or_ip",
"title": "edt_dev_spec_targetIpHost_title",
"propertyOrder": 1
},
"port": {
"type": "integer",
"title": "edt_dev_spec_port_title",
"minimum": 0,
"maximum": 65535,
"default": 50200,
"propertyOrder": 2
},
"max-packet": {
"type": "integer",
"title": "edt_dev_spec_maxPacket_title",
"minimum": 0,
"default": 170,
"propertyOrder": 3
},
"latchTime": {
"type": "integer",
"title": "edt_dev_spec_latchtime_title",
"default": 0,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access": "expert",
"propertyOrder": 4
}
},
"additionalProperties": true
}

View File

@@ -1,30 +1,31 @@
{
"type":"object",
"required":true,
"properties":{
"host" : {
"type": "string",
"title":"edt_dev_spec_targetIp_title",
"propertyOrder" : 1
},
"port" : {
"type": "integer",
"title":"edt_dev_spec_port_title",
"default": 5568,
"minimum" : 0,
"maximum" : 65535,
"propertyOrder" : 2
},
"latchTime": {
"type": "integer",
"title":"edt_dev_spec_latchtime_title",
"default": 0,
"append" : "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access" : "expert",
"propertyOrder" : 3
}
},
"additionalProperties": true
"type": "object",
"required": true,
"properties": {
"host": {
"type": "string",
"title": "edt_dev_spec_targetIpHost_title",
"format": "hostname_or_ip",
"propertyOrder": 1
},
"port": {
"type": "integer",
"title": "edt_dev_spec_port_title",
"default": 5568,
"minimum": 0,
"maximum": 65535,
"propertyOrder": 2
},
"latchTime": {
"type": "integer",
"title": "edt_dev_spec_latchtime_title",
"default": 0,
"append": "edt_append_ms",
"minimum": 0,
"maximum": 1000,
"access": "expert",
"propertyOrder": 3
}
},
"additionalProperties": true
}

View File

@@ -16,6 +16,7 @@
},
"host": {
"type": "string",
"format": "hostname_or_ip4",
"title": "edt_dev_spec_targetIpHost_title",
"options": {
"infoText": "edt_dev_spec_targetIpHost_title_info"

View File

@@ -112,8 +112,9 @@
"properties": {
"host": {
"type": "string",
"format": "hostname_or_ip",
"minLength": 7,
"title": "edt_dev_spec_networkDeviceName_title",
"title": "edt_dev_spec_targetIpHost_title",
"required": true,
"propertyOrder": 1
},
@@ -122,7 +123,7 @@
"minimum": 0,
"maximum": 65535,
"default": 55443,
"title": "edt_dev_spec_networkDevicePort_title",
"title": "edt_dev_spec_port_title",
"required": false,
"access": "expert",
"propertyOrder": 2

View File

@@ -56,7 +56,8 @@ void WebServer::onServerStarted (quint16 port)
{
_inited = true;
Info(_log, "Started on port %d name '%s'", port ,_server->getServerName().toStdString().c_str());
Info(_log, "'%s' started on port %d",_server->getServerName().toStdString().c_str(), port);
#ifdef ENABLE_AVAHI
if(_serviceRegister == nullptr)
{