mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
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:
parent
b33466d392
commit
ad293b2fb6
11
CHANGELOG.md
11
CHANGELOG.md
@ -10,10 +10,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- hyperion-remote & standalone grabbers: IPv6 support
|
||||
|
||||
### Changed
|
||||
|
||||
- LED-Devices: Removed IPv6 limitations
|
||||
- Philips-Hue Wizard optimizations
|
||||
- JSON/Flatbuffer forwarder: Removed IPv6 limitations
|
||||
- Allow to import configurations from previous versions
|
||||
|
||||
Note: Existing configurations are migrated to new structures automatically
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed hyperion-remote when sending multiple Hex-Colors with "Set Color" option
|
||||
|
||||
### Removed
|
||||
|
||||
## [2.0.0-alpha.11](https://github.com/hyperion-project/hyperion.ng/releases/tag/2.0.0-alpha.11) - 2021-10-06
|
||||
|
@ -46,7 +46,7 @@
|
||||
"conf_general_intro": "Basic settings around Hyperion and WebUI that don't fit into another category.",
|
||||
"conf_general_label_title": "General settings",
|
||||
"conf_grabber_fg_intro": "Screen capture is your local system capture as input source, Hyperion is installed on.",
|
||||
"conf_grabber_inst_grabber_config_info": "Configure your capturing hardware devices to be used by the instance in advance",
|
||||
"conf_grabber_inst_grabber_config_info": "Configure your capturing hardware devices to be used by the instance in advance",
|
||||
"conf_grabber_v4l_intro": "USB capture is a (capture) device connected via USB which is used to input source pictures for processing.",
|
||||
"conf_helptable_expl": "Explanation",
|
||||
"conf_helptable_option": "Option",
|
||||
@ -581,9 +581,9 @@
|
||||
"edt_dev_spec_switchOffOnBlack_title": "Switch off on black",
|
||||
"edt_dev_spec_switchOffOnbelowMinBrightness_title": "Switch-off, below minimum",
|
||||
"edt_dev_spec_syncOverwrite_title": "Disable synchronisation",
|
||||
"edt_dev_spec_targetIpHost_title": "Target Hostname/IP-address",
|
||||
"edt_dev_spec_targetIpHost_title": "Hostname/IP-address",
|
||||
"edt_dev_spec_targetIpHost_title_info": "The device's hostname or IP-address",
|
||||
"edt_dev_spec_targetIp_title": "Target IP-address",
|
||||
"edt_dev_spec_targetIp_title": "IP-address",
|
||||
"edt_dev_spec_transeffect_title": "Transition effect",
|
||||
"edt_dev_spec_transistionTimeExtra_title": "Extra time darkness",
|
||||
"edt_dev_spec_transistionTime_title": "Transition time",
|
||||
@ -654,7 +654,7 @@
|
||||
"edt_eff_image_source_url": "URL",
|
||||
"edt_eff_image": "Image file",
|
||||
"edt_eff_url": "Image adress",
|
||||
"edt_eff_initial_blink" : "Flash for attention",
|
||||
"edt_eff_initial_blink": "Flash for attention",
|
||||
"edt_eff_interval": "Interval",
|
||||
"edt_eff_knightrider_header": "Knight Rider",
|
||||
"edt_eff_knightrider_header_desc": "K.I.T.T is back! The front-scanner of the well known car, this time not just in red.",
|
||||
@ -692,7 +692,7 @@
|
||||
"edt_eff_reversedirection": "Reverse direction",
|
||||
"edt_eff_rotationtime": "Rotation time",
|
||||
"edt_eff_saturation": "Saturation",
|
||||
"edt_eff_set_post_color" : "Set post color after alam",
|
||||
"edt_eff_set_post_color": "Set post color after alam",
|
||||
"edt_eff_showseconds": "Show seconds",
|
||||
"edt_eff_sleeptime": "Sleep time",
|
||||
"edt_eff_smooth_custom": "Enable smoothing",
|
||||
@ -735,6 +735,10 @@
|
||||
"edt_msg_error_disallow": "Value must not be of type $1",
|
||||
"edt_msg_error_disallow_union": "Value must not be one of the provided disallowed types",
|
||||
"edt_msg_error_enum": "Value must be one of the enumerated values",
|
||||
"edt_msg_error_hostname": "The hostname has the wrong format",
|
||||
"edt_msg_error_invalid_epoch": "Date must be greater than 1 January 1970",
|
||||
"edt_msg_error_ipv4": "Value must be a valid IPv4 address in the form of 4 numbers between 0 and 255, separated by dots",
|
||||
"edt_msg_error_ipv6": "Value must be a valid IPv6 address",
|
||||
"edt_msg_error_maxItems": "Value must have at most $1 items",
|
||||
"edt_msg_error_maxLength": "Value must be at most $1 characters long",
|
||||
"edt_msg_error_maxProperties": "Object must have at most $1 properties",
|
||||
@ -755,6 +759,8 @@
|
||||
"edt_msg_error_type": "Value must be of type $1",
|
||||
"edt_msg_error_type_union": "Value must be one of the provided types",
|
||||
"edt_msg_error_uniqueItems": "Array must have unique items",
|
||||
"edt_msgcust_error_hostname_ip": "Not a valid Hostname nor IPv4 nor IPv6",
|
||||
"edt_msgcust_error_hostname_ip4": "Not a valid Hostname nor IPv4",
|
||||
"effectsconfigurator_button_conttest": "Continuous test",
|
||||
"effectsconfigurator_button_deleffect": "Delete Effect",
|
||||
"effectsconfigurator_button_editeffect": "Load Effect",
|
||||
@ -979,15 +985,15 @@
|
||||
"wiz_cololight_title": "Cololight Wizard",
|
||||
"wiz_guideyou": "The $1 will guide you through the settings. Just press the button!",
|
||||
"wiz_hue_blinkblue": "Let ID $1 light up blue",
|
||||
"wiz_hue_clientkey": "Clientkey:",
|
||||
"wiz_hue_clientkey": "Clientkey",
|
||||
"wiz_hue_create_user": "Create new User",
|
||||
"wiz_hue_desc1": "It searches automatically for a Hue-Bridge, in case it can't find one you need to provide the IP-address and push the reload button on the right. Now you need a user ID, if you don't have one create a new one.",
|
||||
"wiz_hue_desc2": "Now choose which lamps should be added. The position assigns the lamp to a specific position on your \"picture\". Disabled lamps won't be added. To identify single lamps press the button on the right.",
|
||||
"wiz_hue_desc1": "1. Hyperion searches automatically for a Hue-Bridge, in case it cannot find one you need to provide the hostname or IP-address and push the reload button. <br> 2. Provide a user ID, if you do not have one create a new one.",
|
||||
"wiz_hue_desc2": "3. Now choose which lamps should be added. The position assigns the lamp to a specific position on your \"picture\". Disabled lamps won't be added. To identify single lamps press the button on the right.",
|
||||
"wiz_hue_e_clientkey_needed": "A clientkey that matches the username is required to use the entertainment API. Please enter an existing one or use the button below to create a new one.",
|
||||
"wiz_hue_e_create_user": "Create new User and clientkey",
|
||||
"wiz_hue_e_desc1": "It searches automatically for a hue bridge, in case it can't find one you need to provide the ip address and push the reload button on the right. Now you need a user id and the clientkey, if you don't have both, create a new one.",
|
||||
"wiz_hue_e_desc2": "Now choose your entertainment group, which has all your lights inside for use with Hyperion.",
|
||||
"wiz_hue_e_desc3": "Now you can choose in which position the respective lamp should be \"in the picture\". A preselection of the position was made based on the configured positions of the lights in the entertainment group. This is just a recommendation and can be customized as desired. You can therefore highlight them briefly by clicking on the right button to improve the selection.",
|
||||
"wiz_hue_e_desc1": "1. Hyperion searches automatically for a Hue-Bridge, in case it cannot find one you need to provide the hostname or IP-address and push the reload button. <br> 2. Provide a user id and the clientkey, if you do not have both, create new ones.",
|
||||
"wiz_hue_e_desc2": "3. Choose your entertainment group, which has all your lights inside for use with Hyperion.",
|
||||
"wiz_hue_e_desc3": "4. Choose in which position the respective lamp should be \"in the picture\". A preselection of the position was made based on the configured positions of the lights in the entertainment group. This is just a recommendation and can be customized as desired. You can therefore highlight them briefly by clicking on the right button to improve the selection.",
|
||||
"wiz_hue_e_intro1": "This wizards configures Hyperion for the well known Philips Hue Entertainment system. Features are: Hue Bridge auto detection, user and clientkey creation, entertainment group selection, setting group lights to a specific position on your picture and optimise the Hyperion settings automatically! So in short: All you need are some clicks and you are done!",
|
||||
"wiz_hue_e_noapisupport": "The Wizard has disabled entertainment API support and will continue in classic mode.",
|
||||
"wiz_hue_e_noapisupport_hint": "The option \"<b>Use Hue Entertainment API</b>\" was unchecked.",
|
||||
@ -997,15 +1003,15 @@
|
||||
"wiz_hue_e_use_group": "Use group",
|
||||
"wiz_hue_e_use_groupid": "Use group ID $1",
|
||||
"wiz_hue_failure_connection": "Timeout: Please press the bridge button within the period of 30 seconds",
|
||||
"wiz_hue_failure_ip": "No Bridge found, please type in a valid IP-Address",
|
||||
"wiz_hue_failure_ip": "No Bridge found, please provide a valid hostname or IP-address",
|
||||
"wiz_hue_failure_user": "User not found, create a new one with the button below or input a valid user id and press the \"reload\" symbol.",
|
||||
"wiz_hue_intro1": "This wizards configures Hyperion for the well known Philips Hue system. Features are Hue Bridge auto detection, user creation, set each hue light to a specific position on your picture or disable it and tune the Hyperion settings automatically! So in short: All you need are some clicks and you are done!",
|
||||
"wiz_hue_ip": "Hue Bridge IP:",
|
||||
"wiz_hue_ip": "Hostname or IP",
|
||||
"wiz_hue_noids": "This Hue bridge has no bulbs/stripes, please pair them before with the Hue Apps",
|
||||
"wiz_hue_press_link": "Please press link button on the Hue Bridge.",
|
||||
"wiz_hue_searchb": "Searching for bridge...",
|
||||
"wiz_hue_title": "Philips Hue Wizard",
|
||||
"wiz_hue_username": "User ID:",
|
||||
"wiz_hue_username": "User ID",
|
||||
"wiz_identify": "Identify",
|
||||
"wiz_identify_tip": "Identify configured device by lighting it up",
|
||||
"wiz_identify_light": "Identify $1",
|
||||
@ -1021,6 +1027,7 @@
|
||||
"wiz_rgb_qrend": "...red?",
|
||||
"wiz_rgb_switchevery": "Switch color every...",
|
||||
"wiz_rgb_title": "RGB Byte Order Wizard",
|
||||
"wiz_cc_try_connect": "Connecting...",
|
||||
"wiz_wizavail": "Wizard available",
|
||||
"wiz_yeelight_desc2": "Now choose which lamps should be added. The position assigns the lamp to a specific position on your \"picture\". Disabled lamps won't be added. To identify single lamps press the button on the right.",
|
||||
"wiz_yeelight_intro1": "This wizards configures Hyperion for the Yeelight system. Features are the Yeelighs' auto detection, setting each light to a specific position on your picture or disable it and tune the Hyperion settings automatically! So in short: All you need are some clicks and you are done!",
|
||||
|
@ -144,7 +144,7 @@ $(document).ready(function () {
|
||||
showInfoDialog('import', $.i18n('infoDialog_import_confirm_title'), $.i18n('infoDialog_import_confirm_text', confName));
|
||||
|
||||
$('#id_btn_import').off().on('click', function () {
|
||||
requestWriteConfig(importedConf, true);
|
||||
requestRestoreConfig(importedConf);
|
||||
setTimeout(initRestart, 100);
|
||||
});
|
||||
});
|
||||
|
@ -641,6 +641,8 @@ $(document).ready(function () {
|
||||
// External properties properties, 2-dimensional arry of [ledType][key]
|
||||
devicesProperties = {};
|
||||
|
||||
addJsonEditorHostValidation();
|
||||
|
||||
$("#leddevices").off().on("change", function () {
|
||||
var generalOptions = window.serverSchema.properties.device;
|
||||
|
||||
@ -1092,7 +1094,7 @@ $(document).ready(function () {
|
||||
hwLedCount.setValue(lights.length);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Handle Hardware Led Count constraint list
|
||||
conf_editor.watch('root.generalOptions.hardwareLedCountList', () => {
|
||||
var hwLedCountSelected = conf_editor.getEditor("root.generalOptions.hardwareLedCountList").getValue();
|
||||
@ -1629,9 +1631,8 @@ function updateElements(ledType, key) {
|
||||
if (ledProperties && ledProperties.leds && ledProperties.maxLedCount) {
|
||||
hardwareLedCount = ledProperties.leds.count;
|
||||
var maxLedCount = ledProperties.maxLedCount
|
||||
if (hardwareLedCount > maxLedCount)
|
||||
{
|
||||
showInfoDialog('warning', $.i18n("conf_leds_config_warning"), $.i18n('conf_leds_error_hwled_gt_maxled', hardwareLedCount, maxLedCount, maxLedCount));
|
||||
if (hardwareLedCount > maxLedCount) {
|
||||
showInfoDialog('warning', $.i18n("conf_leds_config_warning"), $.i18n('conf_leds_error_hwled_gt_maxled', hardwareLedCount, maxLedCount, maxLedCount));
|
||||
hardwareLedCount = maxLedCount;
|
||||
}
|
||||
}
|
||||
@ -1661,8 +1662,7 @@ function updateElements(ledType, key) {
|
||||
if (ledProperties && ledProperties.maxLedCount) {
|
||||
hardwareLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue();
|
||||
var maxLedCount = ledProperties.maxLedCount
|
||||
if (hardwareLedCount > maxLedCount)
|
||||
{
|
||||
if (hardwareLedCount > maxLedCount) {
|
||||
showInfoDialog('warning', $.i18n("conf_leds_config_warning"), $.i18n('conf_leds_error_hwled_gt_maxled', hardwareLedCount, maxLedCount, maxLedCount));
|
||||
hardwareLedCount = maxLedCount;
|
||||
}
|
||||
@ -1678,8 +1678,8 @@ function updateElements(ledType, key) {
|
||||
if (ledProperties.ledCount.length > 0) {
|
||||
var configuredLedCount = window.serverConfig.device.hardwareLedCount;
|
||||
showInputOptionForItem(conf_editor, 'generalOptions', "hardwareLedCount", false);
|
||||
updateJsonEditorSelection(conf_editor, 'root.generalOptions', "hardwareLedCountList", {"title": "edt_dev_general_hardwareLedCount_title"},
|
||||
ledProperties.ledCount.map(String), [], configuredLedCount);
|
||||
updateJsonEditorSelection(conf_editor, 'root.generalOptions', "hardwareLedCountList", { "title": "edt_dev_general_hardwareLedCount_title" },
|
||||
ledProperties.ledCount.map(String), [], configuredLedCount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -10,6 +10,8 @@ $(document).ready(function () {
|
||||
var conf_editor_bobl = null;
|
||||
var conf_editor_forw = null;
|
||||
|
||||
addJsonEditorHostValidation();
|
||||
|
||||
if (window.showOptHelp) {
|
||||
//network
|
||||
$('#conf_cont').append(createRow('conf_cont_net'))
|
||||
|
@ -410,6 +410,10 @@ function requestWriteConfig(config, full)
|
||||
sendToHyperion("config","setconfig", '"config":'+JSON.stringify(window.serverConfig));
|
||||
}
|
||||
|
||||
function requestRestoreConfig(config) {
|
||||
sendToHyperion("config", "restoreconfig", '"config":' + JSON.stringify(config));
|
||||
}
|
||||
|
||||
function requestWriteEffect(effectName,effectPy,effectArgs,data)
|
||||
{
|
||||
var cutArgs = effectArgs.slice(1, -1);
|
||||
|
@ -88,7 +88,7 @@ function loadContent(event, forceRefresh) {
|
||||
var tag;
|
||||
|
||||
var lastSelectedInstance = getStorage('lastSelectedInstance', false);
|
||||
|
||||
|
||||
if (lastSelectedInstance && (lastSelectedInstance != window.currentHyperionInstance)) {
|
||||
if (window.serverInfo.instance[lastSelectedInstance] && window.serverInfo.instance[lastSelectedInstance].running) {
|
||||
instanceSwitch(lastSelectedInstance);
|
||||
@ -681,6 +681,68 @@ function updateJsonEditorRange(rootEditor, path, key, minimum, maximum, defaultV
|
||||
rootEditor.getEditor(path + "." + key).setValue(currentValue);
|
||||
}
|
||||
|
||||
function addJsonEditorHostValidation() {
|
||||
|
||||
JSONEditor.defaults.custom_validators.push(function (schema, value, path) {
|
||||
var errors = [];
|
||||
|
||||
if (!jQuery.isEmptyObject(value)) {
|
||||
switch (schema.format) {
|
||||
case "hostname_or_ip":
|
||||
if (!isValidHostnameOrIP(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msgcust_error_hostname_ip')
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "hostname_or_ip4":
|
||||
if (!isValidHostnameOrIP4(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msgcust_error_hostname_ip4')
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
//Remove, when new json-editor 2.x is used
|
||||
case "ipv4":
|
||||
if (!isValidIPv4(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msg_error_ipv4')
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "ipv6":
|
||||
if (!isValidIPv6(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msg_error_ipv6')
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "hostname":
|
||||
if (!isValidHostname(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msg_error_hostname')
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
});
|
||||
}
|
||||
|
||||
function buildWL(link, linkt, cl) {
|
||||
var baseLink = "https://docs.hyperion-project.org/";
|
||||
var lang;
|
||||
@ -1246,3 +1308,42 @@ function showInputOptionsForKey(editor, item, showForKeys, state) {
|
||||
function encodeHTML(s) {
|
||||
return s.replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function isValidIPv4(value) {
|
||||
const parts = value.split('.')
|
||||
if (parts.length !== 4) {
|
||||
return false;
|
||||
}
|
||||
for (let part of parts) {
|
||||
if (isNaN(part) || part < 0 || part > 255) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isValidIPv6(value) {
|
||||
if (value.match(
|
||||
'^(?:(?:(?:[a-fA-F0-9]{1,4}:){6}|(?=(?:[a-fA-F0-9]{0,4}:){2,6}(?:[0-9]{1,3}.){3}[0-9]{1,3}$)(([0-9a-fA-F]{1,4}:){1,5}|:)((:[0-9a-fA-F]{1,4}){1,5}:|:)|::(?:[a-fA-F0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}|(?=(?:[a-fA-F0-9]{0,4}:){0,7}[a-fA-F0-9]{0,4}$)(([0-9a-fA-F]{1,4}:){1,7}|:)((:[0-9a-fA-F]{1,4}){1,7}|:)|(?:[a-fA-F0-9]{1,4}:){7}:|:(:[a-fA-F0-9]{1,4}){7})$'
|
||||
))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function isValidHostname(value) {
|
||||
if (value.match(
|
||||
'(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9].)+[a-zA-Z]{2,63}$)'
|
||||
))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function isValidHostnameOrIP4(value) {
|
||||
return (isValidHostname(value) || isValidIPv4(value));
|
||||
}
|
||||
|
||||
function isValidHostnameOrIP(value) {
|
||||
return (isValidHostnameOrIP4(value) || isValidIPv6(value));
|
||||
}
|
||||
|
@ -5,6 +5,10 @@ $(window.hyperion).one("ready", function (event) {
|
||||
setStorage("wizardactive", false);
|
||||
if (getStorage("kodiAddress") != null) {
|
||||
kodiAddress = getStorage("kodiAddress");
|
||||
|
||||
if (getStorage("kodiPort") != null) {
|
||||
kodiPort = getStorage("kodiPort");
|
||||
}
|
||||
sendToKodi("stop");
|
||||
}
|
||||
}
|
||||
@ -156,9 +160,14 @@ $('#btn_wizard_byteorder').off().on('click', startWizardRGB);
|
||||
|
||||
//color calibration wizard
|
||||
|
||||
var kodiHost = document.location.hostname;
|
||||
var kodiPort = 9090;
|
||||
var kodiAddress = kodiHost;
|
||||
const defaultKodiPort = 9090;
|
||||
|
||||
var kodiAddress = document.location.hostname;
|
||||
var kodiPort = defaultKodiPort;
|
||||
|
||||
var kodiUrl = new URL("ws://" + kodiAddress);
|
||||
kodiUrl.port = kodiPort;
|
||||
kodiUrl.pathname = "/jsonrpc/websocket";
|
||||
|
||||
var wiz_editor;
|
||||
var colorLength;
|
||||
@ -175,14 +184,12 @@ var availVideos = ["Sweet_Cocoon", "Caminandes_2_GranDillama", "Caminandes_3_Lla
|
||||
if (getStorage("kodiAddress") != null) {
|
||||
|
||||
kodiAddress = getStorage("kodiAddress");
|
||||
[kodiHost, kodiPort] = kodiAddress.split(":", 2);
|
||||
kodiUrl.host = kodiAddress;
|
||||
}
|
||||
|
||||
// Ensure that Kodi's default REST-API port is not used, as now the Web-Socket port is used
|
||||
if (kodiPort === "8080") {
|
||||
kodiAddress = kodiHost;
|
||||
kodiPort = undefined;
|
||||
setStorage("kodiAddress", kodiAddress);
|
||||
}
|
||||
if (getStorage("kodiPort") != null) {
|
||||
kodiPort = getStorage("kodiPort");
|
||||
kodiUrl.port = kodiPort;
|
||||
}
|
||||
|
||||
function switchPicture(pictures) {
|
||||
@ -221,12 +228,11 @@ function sendToKodi(type, content, cb) {
|
||||
}
|
||||
|
||||
if ("WebSocket" in window) {
|
||||
//Add kodi default web-socket port, in case port has been explicitly provided
|
||||
if (kodiPort == undefined) {
|
||||
kodiPort = 9090;
|
||||
}
|
||||
|
||||
var ws = new WebSocket("ws://" + kodiHost + ":" + kodiPort + "/jsonrpc/websocket");
|
||||
if (kodiUrl.port === '') {
|
||||
kodiUrl.port = defaultKodiPort;
|
||||
}
|
||||
var ws = new WebSocket(kodiUrl);
|
||||
|
||||
ws.onopen = function () {
|
||||
ws.send(JSON.stringify(command));
|
||||
@ -234,13 +240,18 @@ function sendToKodi(type, content, cb) {
|
||||
|
||||
ws.onmessage = function (evt) {
|
||||
var response = JSON.parse(evt.data);
|
||||
|
||||
if (cb != undefined) {
|
||||
if (response.result != undefined) {
|
||||
if (response.result === "OK") {
|
||||
cb("success");
|
||||
} else {
|
||||
cb("error");
|
||||
if (response.method === "System.OnQuit") {
|
||||
ws.close();
|
||||
} else {
|
||||
if (cb != undefined) {
|
||||
if (response.result != undefined) {
|
||||
if (response.result === "OK") {
|
||||
cb("success");
|
||||
ws.close();
|
||||
} else {
|
||||
cb("error");
|
||||
ws.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -249,8 +260,13 @@ function sendToKodi(type, content, cb) {
|
||||
ws.onerror = function (evt) {
|
||||
if (cb != undefined) {
|
||||
cb("error");
|
||||
ws.close();
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = function (evt) {
|
||||
};
|
||||
|
||||
}
|
||||
else {
|
||||
console.log("Kodi Access: WebSocket NOT supported by this browser");
|
||||
@ -419,18 +435,24 @@ function updateWEditor(el, all) {
|
||||
|
||||
function startWizardCC() {
|
||||
|
||||
// Ensure that Kodi's default REST-API port is not used, as now the Web-Socket port is used
|
||||
[kodiHost, kodiPort] = kodiAddress.split(":", 2);
|
||||
if (kodiPort === "8080") {
|
||||
kodiAddress = kodiHost;
|
||||
kodiPort = undefined;
|
||||
}
|
||||
//create html
|
||||
$('#wiz_header').html('<i class="fa fa-magic fa-fw"></i>' + $.i18n('wiz_cc_title'));
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('wiz_cc_title') + '</h4><p>' + $.i18n('wiz_cc_intro1') + '</p><label>' + $.i18n('wiz_cc_kwebs') + '</label><input class="form-control" style="width:170px;margin:auto" id="wiz_cc_kodiip" type="text" placeholder="' + kodiAddress + '" value="' + kodiAddress + '" /><span id="kodi_status"></span><span id="multi_cali"></span>');
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont" disabled="disabled"><i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_continue') + '</button><button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
$('#wizp2_body').html('<div id="wiz_cc_desc" style="font-weight:bold"></div><div id="editor_container_wiz"></div>');
|
||||
$('#wizp2_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_back"><i class="fa fa-fw fa-chevron-left"></i>' + $.i18n('general_btn_back') + '</button><button type="button" class="btn btn-primary" id="btn_wiz_next">' + $.i18n('general_btn_next') + '<i style="margin-left:4px;"class="fa fa-fw fa-chevron-right"></i></button><button type="button" class="btn btn-warning" id="btn_wiz_save" style="display:none"><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_save') + '</button><button type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n('wiz_cc_title') + '</h4>' +
|
||||
'<p>' + $.i18n('wiz_cc_intro1') + '</p>' +
|
||||
'<label>' + $.i18n('wiz_cc_kwebs') + '</label>' +
|
||||
'<input class="form-control" style="width:280px;margin:auto" id="wiz_cc_kodiip" type="text" placeholder="' + kodiAddress + '" value="' + kodiAddress + '" />' +
|
||||
'<span id="kodi_status"></span><span id="multi_cali"></span>'
|
||||
);
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont" disabled="disabled">' + '<i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_continue') + '</button>' +
|
||||
'<button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>'
|
||||
);
|
||||
$('#wizp2_body').html('<div id="wiz_cc_desc" style="font-weight:bold"></div><div id="editor_container_wiz"></div>'
|
||||
);
|
||||
$('#wizp2_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_back">' + '<i class="fa fa-fw fa-chevron-left"></i>' + $.i18n('general_btn_back') + '</button>' +
|
||||
'<button type="button" class="btn btn-primary" id="btn_wiz_next">' + $.i18n('general_btn_next') + '<i style="margin-left:4px;"class="fa fa-fw fa-chevron-right"></i>' + '</button>' +
|
||||
'<button type="button" class="btn btn-warning" id="btn_wiz_save" style="display:none"><i class="fa fa-fw fa-save"></i>' + $.i18n('general_btn_save') + '</button>' +
|
||||
'<button type="button" class="btn btn-danger" id="btn_wiz_abort"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>'
|
||||
);
|
||||
|
||||
if (getStorage("darkMode", false) == "on")
|
||||
$('#wizard_logo').attr("src", 'img/hyperion/logo_negativ.png');
|
||||
@ -443,32 +465,44 @@ function startWizardCC() {
|
||||
});
|
||||
|
||||
$('#wiz_cc_kodiip').off().on('change', function () {
|
||||
|
||||
kodiAddress = $(this).val().trim();
|
||||
$('#wizp1_body').find("kodiAddress").val(kodiAddress);
|
||||
|
||||
$('#kodi_status').html('');
|
||||
|
||||
// Remove Kodi's default Web-Socket port (9090) from display and ensure Kodi's default REST-API port (8080) is mapped to web-socket port to ease migration
|
||||
if (kodiAddress !== "") {
|
||||
[kodiHost, kodiPort] = kodiAddress.split(":", 2);
|
||||
if (kodiPort === "9090" || kodiPort === "8080") {
|
||||
kodiAddress = kodiHost;
|
||||
kodiPort = undefined;
|
||||
|
||||
if (!isValidHostnameOrIP(kodiAddress)) {
|
||||
|
||||
$('#kodi_status').html('<p style="color:red;font-weight:bold;margin-top:5px">' + $.i18n('edt_msgcust_error_hostname_ip') + '</p>');
|
||||
withKodi = false;
|
||||
|
||||
} else {
|
||||
|
||||
if (isValidIPv6(kodiAddress)) {
|
||||
kodiUrl.hostname = "[" + kodiAddress + "]";
|
||||
} else {
|
||||
kodiUrl.hostname = kodiAddress;
|
||||
}
|
||||
|
||||
$('#kodi_status').html('<p style="font-weight:bold;margin-top:5px">' + $.i18n('wiz_cc_try_connect') + '</p>');
|
||||
$('#btn_wiz_cont').attr('disabled', true);
|
||||
|
||||
sendToKodi("msg", $.i18n('wiz_cc_kodimsg_start'), function (cb) {
|
||||
if (cb == "error") {
|
||||
$('#kodi_status').html('<p style="color:red;font-weight:bold;margin-top:5px">' + $.i18n('wiz_cc_kodidiscon') + '</p><p>' + $.i18n('wiz_cc_kodidisconlink') + ' <a href="https://sourceforge.net/projects/hyperion-project/files/resources/Hyperion_calibration_pictures.zip/download" target="_blank">' + $.i18n('wiz_cc_link') + '</p>');
|
||||
withKodi = false;
|
||||
}
|
||||
else {
|
||||
setStorage("kodiAddress", kodiAddress);
|
||||
setStorage("kodiPort", defaultKodiPort);
|
||||
|
||||
$('#kodi_status').html('<p style="color:green;font-weight:bold;margin-top:5px">' + $.i18n('wiz_cc_kodicon') + '</p>');
|
||||
withKodi = true;
|
||||
}
|
||||
|
||||
$('#btn_wiz_cont').attr('disabled', false);
|
||||
});
|
||||
}
|
||||
sendToKodi("msg", $.i18n('wiz_cc_kodimsg_start'), function (cb) {
|
||||
if (cb == "error") {
|
||||
$('#kodi_status').html('<p style="color:red;font-weight:bold;margin-top:5px">' + $.i18n('wiz_cc_kodidiscon') + '</p><p>' + $.i18n('wiz_cc_kodidisconlink') + ' <a href="https://sourceforge.net/projects/hyperion-project/files/resources/Hyperion_calibration_pictures.zip/download" target="_blank">' + $.i18n('wiz_cc_link') + '</p>');
|
||||
withKodi = false;
|
||||
}
|
||||
else {
|
||||
setStorage("kodiAddress", kodiAddress);
|
||||
|
||||
$('#kodi_status').html('<p style="color:green;font-weight:bold;margin-top:5px">' + $.i18n('wiz_cc_kodicon') + '</p>');
|
||||
withKodi = true;
|
||||
}
|
||||
|
||||
$('#btn_wiz_cont').attr('disabled', false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -632,6 +666,8 @@ var groupLights = [];
|
||||
var groupLightsLocations = [];
|
||||
var hueType = "philipshue";
|
||||
|
||||
let hueUrl = new URL('http://dummy');
|
||||
|
||||
function startWizardPhilipsHue(e) {
|
||||
if (typeof e.data.type != "undefined") hueType = e.data.type;
|
||||
|
||||
@ -651,24 +687,52 @@ function startWizardPhilipsHue(e) {
|
||||
$('#wizp1_body').html('<h4 style="font-weight:bold;text-transform:uppercase;">' + $.i18n(hue_title) + '</h4><p>' + $.i18n(hue_intro1) + '</p>');
|
||||
$('#wizp1_footer').html('<button type="button" class="btn btn-primary" id="btn_wiz_cont"><i class="fa fa-fw fa-check"></i>' + $.i18n('general_btn_continue') + '</button><button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-fw fa-close"></i>' + $.i18n('general_btn_cancel') + '</button>');
|
||||
$('#wizp2_body').html('<div id="wh_topcontainer"></div>');
|
||||
$('#wh_topcontainer').append('<p style="font-weight:bold">' + $.i18n(hue_desc1) + '</p><div class="form-group"><label>' + $.i18n('wiz_hue_ip') + '</label><div class="input-group" style="width:175px"><input type="text" class="input-group form-control" id="ip"><span class="input-group-addon" id="retry_bridge" style="cursor:pointer"><i class="fa fa-refresh"></i></span></div></div><span style="font-weight:bold;color:red" id="wiz_hue_ipstate"></span><span style="font-weight:bold;" class="component-on" id="wiz_hue_discovered"></span>');
|
||||
|
||||
var hidePort = "hidden-lg";
|
||||
if (storedAccess === 'expert') {
|
||||
hidePort = "";
|
||||
}
|
||||
|
||||
$('#wh_topcontainer').append('<p class="text-left" style="font-weight:bold">' + $.i18n(hue_desc1) + '</p>' +
|
||||
'<div class="row">' +
|
||||
'<div class="col-md-2">' +
|
||||
' <p class="text-left">' + $.i18n('wiz_hue_ip') + '</p></div>' +
|
||||
' <div class="col-md-7"><div class="input-group">' +
|
||||
' <span class="input-group-addon" id="retry_bridge" style="cursor:pointer"><i class="fa fa-refresh"></i></span>' +
|
||||
' <input type="text" class="input-group form-control" id="host" placeholder="' + $.i18n('wiz_hue_ip') + '"></div></div>' +
|
||||
' <div class="col-md-3 ' + hidePort + '"><div class="input-group">' +
|
||||
' <span class="input-group-addon">:</span>' +
|
||||
' <input type="text" class="input-group form-control" id="port" placeholder="' + $.i18n('edt_conf_general_port_title') + '"></div></div>' +
|
||||
'</div><p><span style="font-weight:bold;color:red" id="wiz_hue_ipstate"></span><span style="font-weight:bold;" id="wiz_hue_discovered"></span></p>'
|
||||
);
|
||||
$('#wh_topcontainer').append();
|
||||
$('#wh_topcontainer').append('<div class="form-group" id="usrcont" style="display:none"></div>');
|
||||
if (hueType == 'philipshue') {
|
||||
$('#usrcont').append('<label>' + $.i18n('wiz_hue_username') + '</label><div class="input-group" style="width:250px"><input type="text" class="form-control" id="user"><span class="input-group-addon" id="retry_usr" style="cursor:pointer"><i class="fa fa-refresh"></i></span></div>');
|
||||
}
|
||||
|
||||
$('#usrcont').append('<div class="row"><div class="col-md-2"><p class="text-left">' + $.i18n('wiz_hue_username') + '</p ></div>' +
|
||||
'<div class="col-md-7">' +
|
||||
'<div class="input-group">' +
|
||||
' <span class="input-group-addon" id="retry_usr" style="cursor:pointer"><i class="fa fa-refresh"></i></span>' +
|
||||
' <input type="text" class="input-group form-control" id="user">' +
|
||||
'</div></div></div><br>' +
|
||||
'</div><input type="hidden" id="groupId">'
|
||||
);
|
||||
|
||||
if (hueType == 'philipshueentertainment') {
|
||||
$('#usrcont').append('<label>' + $.i18n('wiz_hue_username') + '</label><div class="input-group" style="width:250px"><input type="text" class="form-control" id="user"></div><label>' + $.i18n('wiz_hue_clientkey') + '</label><div class="input-group" style="width:250px"><input type="text" class="form-control" id="clientkey"><span class="input-group-addon" id="retry_usr" style="cursor:pointer"><i class="fa fa-refresh"></i></span></div><input type="hidden" id="groupId">');
|
||||
$('#usrcont').append('<div class="row"><div class="col-md-2"><p class="text-left">' + $.i18n('wiz_hue_clientkey') +
|
||||
'</p></div><div class="col-md-7"><input class="form-control" id="clientkey" type="text"></div></div><br>');
|
||||
}
|
||||
$('#usrcont').append('<span style="font-weight:bold;color:red" id="wiz_hue_usrstate"></span><br><button type="button" class="btn btn-primary" style="display:none" id="wiz_hue_create_user"> <i class="fa fa-fw fa-plus"></i>' + $.i18n(hue_create_user) + '</button>');
|
||||
|
||||
$('#usrcont').append('<p><span style="font-weight:bold;color:red" id="wiz_hue_usrstate"></span><\p>' +
|
||||
'<button type="button" class="btn btn-primary" style="display:none" id="wiz_hue_create_user"> <i class="fa fa-fw fa-plus"></i>' + $.i18n(hue_create_user) + '</button>');
|
||||
|
||||
if (hueType == 'philipshueentertainment') {
|
||||
$('#wizp2_body').append('<div id="hue_grp_ids_t" style="display:none"><p style="font-weight:bold">' + $.i18n('wiz_hue_e_desc2') + '</p></div>');
|
||||
$('#wizp2_body').append('<div id="hue_grp_ids_t" style="display:none"><p class="text-left" style="font-weight:bold">' + $.i18n('wiz_hue_e_desc2') + '</p></div>');
|
||||
createTable("gidsh", "gidsb", "hue_grp_ids_t");
|
||||
$('.gidsh').append(createTableRow([$.i18n('edt_dev_spec_groupId_title'), $.i18n('wiz_hue_e_use_group')], true));
|
||||
$('#wizp2_body').append('<div id="hue_ids_t" style="display:none"><p style="font-weight:bold" id="hue_id_headline">' + $.i18n('wiz_hue_e_desc3') + '</p></div>');
|
||||
$('#wizp2_body').append('<div id="hue_ids_t" style="display:none"><p class="text-left" style="font-weight:bold" id="hue_id_headline">' + $.i18n('wiz_hue_e_desc3') + '</p></div>');
|
||||
}
|
||||
else {
|
||||
$('#wizp2_body').append('<div id="hue_ids_t" style="display:none"><p style="font-weight:bold" id="hue_id_headline">' + $.i18n('wiz_hue_desc2') + '</p></div>');
|
||||
$('#wizp2_body').append('<div id="hue_ids_t" style="display:none"><p class="text-left" style="font-weight:bold" id="hue_id_headline">' + $.i18n('wiz_hue_desc2') + '</p></div>');
|
||||
}
|
||||
createTable("lidsh", "lidsb", "hue_ids_t");
|
||||
$('.lidsh').append(createTableRow([$.i18n('edt_dev_spec_lightid_title'), $.i18n('wiz_pos'), $.i18n('wiz_identify')], true));
|
||||
@ -698,18 +762,36 @@ function checkHueBridge(cb, hueUser) {
|
||||
if (usr == 'config') $('#wiz_hue_discovered').html("");
|
||||
|
||||
if (hueIPs[hueIPsinc]) {
|
||||
|
||||
hueUrl.hostname = "dummy";
|
||||
var host = hueIPs[hueIPsinc].host;
|
||||
|
||||
if (isValidIPv6(host)) {
|
||||
hueUrl.hostname = "[" + host + "]";
|
||||
} else {
|
||||
hueUrl.hostname = host;
|
||||
}
|
||||
|
||||
var port = hueIPs[hueIPsinc].port;
|
||||
if (port > 0) {
|
||||
hueUrl.port = port;
|
||||
}
|
||||
|
||||
hueUrl.pathname = '/api/' + usr;
|
||||
$.ajax({
|
||||
url: 'http://' + hueIPs[hueIPsinc].internalipaddress + '/api/' + usr,
|
||||
url: hueUrl,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
if (json.config) {
|
||||
cb(true, usr);
|
||||
} else if (json.name && json.bridgeid && json.modelid) {
|
||||
$('#wiz_hue_discovered').html("Bridge: " + json.name + ", Modelid: " + json.modelid + ", API-Version: " + json.apiversion);
|
||||
cb(true);
|
||||
} else {
|
||||
cb(false);
|
||||
if (json.name && json.bridgeid && json.modelid) {
|
||||
$('#wiz_hue_discovered').html("Bridge: " + json.name + ", Modelid: " + json.modelid + ", API-Version: " + json.apiversion);
|
||||
cb(true);
|
||||
} else {
|
||||
cb(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
timeout: 2500
|
||||
@ -723,7 +805,8 @@ function checkBridgeResult(reply, usr) {
|
||||
if (reply) {
|
||||
//abort checking, first reachable result is used
|
||||
$('#wiz_hue_ipstate').html("");
|
||||
$('#ip').val(hueIPs[hueIPsinc].internalipaddress)
|
||||
$('#host').val(hueIPs[hueIPsinc].host)
|
||||
$('#port').val(hueIPs[hueIPsinc].port)
|
||||
|
||||
//now check hue user on this bridge
|
||||
$('#usrcont').toggle(true);
|
||||
@ -743,10 +826,11 @@ function checkBridgeResult(reply, usr) {
|
||||
};
|
||||
|
||||
function checkUserResult(reply, usr) {
|
||||
$('#usrcont').toggle(true);
|
||||
if (reply) {
|
||||
$('#user').val(usr);
|
||||
if (hueType == 'philipshueentertainment' && $('#clientkey').val() == "") {
|
||||
$('#usrcont').toggle(true);
|
||||
|
||||
$('#wiz_hue_usrstate').html($.i18n('wiz_hue_e_clientkey_needed'));
|
||||
$('#wiz_hue_create_user').toggle(true);
|
||||
} else {
|
||||
@ -761,6 +845,7 @@ function checkUserResult(reply, usr) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
//abort checking, first reachable result is used
|
||||
$('#wiz_hue_usrstate').html($.i18n('wiz_hue_failure_user'));
|
||||
$('#wiz_hue_create_user').toggle(true);
|
||||
}
|
||||
@ -775,8 +860,9 @@ function identHueId(id, off, oState) {
|
||||
var put_data = '{"on":' + oState.on + ',"bri":' + oState.bri + ',"hue":' + oState.hue + ',"sat":' + oState.sat + '}';
|
||||
}
|
||||
|
||||
hueUrl.pathname = '/api/' + $('#user').val() + '/lights/' + id + '/state',
|
||||
$.ajax({
|
||||
url: 'http://' + $('#ip').val() + '/api/' + $('#user').val() + '/lights/' + id + '/state',
|
||||
url: hueUrl,
|
||||
type: 'PUT',
|
||||
timeout: 2000,
|
||||
data: put_data
|
||||
@ -806,25 +892,32 @@ async function discover_hue_bridges() {
|
||||
$('#wiz_hue_discovered').html("")
|
||||
}
|
||||
else {
|
||||
for (const device of r.devices) {
|
||||
//console.log("Device:", device);
|
||||
if (device && device.ip && device.port) {
|
||||
hueIPs = [];
|
||||
hueIPsinc = 0;
|
||||
|
||||
var ip;
|
||||
for (const device of r.devices) {
|
||||
if (device && device.ip && device.port) {
|
||||
var host;
|
||||
var port;
|
||||
if (device.hostname && device.domain) {
|
||||
ip = device.hostname + "." + device.domain + ":" + device.port;
|
||||
host = device.hostname + "." + device.domain;
|
||||
port = device.port;
|
||||
} else {
|
||||
ip = device.ip + ":" + device.port;
|
||||
host = device.ip;
|
||||
port = device.port;
|
||||
}
|
||||
|
||||
if (ip) {
|
||||
if (host) {
|
||||
|
||||
if (!hueIPs.some(item => item.internalipaddress === ip)) {
|
||||
hueIPs.push({ internalipaddress: ip });
|
||||
if (!hueIPs.some(item => item.host === host)) {
|
||||
hueIPs.push({ host: host, port: port });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$('#wiz_hue_ipstate').html("");
|
||||
$('#host').val(hueIPs[hueIPsinc].host)
|
||||
$('#port').val(hueIPs[hueIPsinc].port)
|
||||
|
||||
var usr = $('#user').val();
|
||||
if (usr != "") {
|
||||
@ -836,8 +929,11 @@ async function discover_hue_bridges() {
|
||||
}
|
||||
}
|
||||
|
||||
async function getProperties_hue_bridge(hostAddress, username, resourceFilter) {
|
||||
async function getProperties_hue_bridge(hostAddress, port, username, resourceFilter) {
|
||||
let params = { host: hostAddress, user: username, filter: resourceFilter };
|
||||
if (port !== 'undefined') {
|
||||
params.port = port;
|
||||
}
|
||||
|
||||
const res = await requestLedDeviceProperties('philipshue', params);
|
||||
|
||||
@ -851,12 +947,15 @@ async function getProperties_hue_bridge(hostAddress, username, resourceFilter) {
|
||||
}
|
||||
}
|
||||
|
||||
async function identify_hue_device(hostAddress, username, id) {
|
||||
async function identify_hue_device(hostAddress, port, username, id) {
|
||||
|
||||
// Take care that new record cannot be save during background process
|
||||
$('#btn_wiz_save').attr('disabled', true);
|
||||
|
||||
let params = { host: hostAddress, user: username, lightId: id };
|
||||
if (port !== 'undefined') {
|
||||
params.port = port;
|
||||
}
|
||||
await requestLedDeviceIdentification('philipshue', params);
|
||||
|
||||
if (!window.readOnlyMode) {
|
||||
@ -866,6 +965,7 @@ async function identify_hue_device(hostAddress, username, id) {
|
||||
|
||||
function getHueIPs() {
|
||||
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_searchb'));
|
||||
|
||||
$.ajax({
|
||||
url: 'https://discovery.meethue.com',
|
||||
crossDomain: true,
|
||||
@ -902,15 +1002,28 @@ function beginWizardHue() {
|
||||
$('#clientkey').val(clkey);
|
||||
}
|
||||
}
|
||||
//check if ip is empty/reachable/search for bridge
|
||||
|
||||
//check if host is empty/reachable/search for bridge
|
||||
if (eV("host") == "") {
|
||||
hueIPs = [];
|
||||
hueIPsinc = 0;
|
||||
|
||||
//getHueIPs();
|
||||
discover_hue_bridges();
|
||||
}
|
||||
else {
|
||||
var ip = eV("host");
|
||||
$('#ip').val(ip);
|
||||
hueIPs.unshift({ internalipaddress: ip });
|
||||
var host = eV("host");
|
||||
$('#host').val(host);
|
||||
|
||||
var port = eV("port");
|
||||
if (port > 0) {
|
||||
$('#port').val(port);
|
||||
}
|
||||
else {
|
||||
$('#port').val('');
|
||||
}
|
||||
hueIPs.unshift({ host: host, port: port });
|
||||
|
||||
if (usr != "") {
|
||||
checkHueBridge(checkUserResult, usr);
|
||||
} else {
|
||||
@ -919,11 +1032,16 @@ function beginWizardHue() {
|
||||
}
|
||||
|
||||
$('#retry_bridge').off().on('click', function () {
|
||||
if ($('#ip').val() != "") {
|
||||
hueIPs.unshift({ internalipaddress: $('#ip').val() })
|
||||
|
||||
if ($('#host').val() != "") {
|
||||
|
||||
hueIPs = [];
|
||||
hueIPsinc = 0;
|
||||
hueIPs.push({ host: $('#host').val(), port: $('#port').val() });
|
||||
}
|
||||
else {
|
||||
discover_hue_bridges();
|
||||
}
|
||||
else discover_hue_bridges();
|
||||
|
||||
var usr = $('#user').val();
|
||||
if (usr != "") {
|
||||
@ -938,7 +1056,9 @@ function beginWizardHue() {
|
||||
});
|
||||
|
||||
$('#wiz_hue_create_user').off().on('click', function () {
|
||||
if ($('#ip').val() != "") hueIPs.unshift({ internalipaddress: $('#ip').val() });
|
||||
if ($('#host').val() != "") {
|
||||
hueIPs.unshift({ host: $('#host').val(), port: $('#port').val() });
|
||||
}
|
||||
createHueUser();
|
||||
});
|
||||
|
||||
@ -973,12 +1093,12 @@ function beginWizardHue() {
|
||||
|
||||
//Start with a clean configuration
|
||||
var d = {};
|
||||
d.host = $('#ip').val();
|
||||
d.host = $('#host').val();
|
||||
d.port = parseInt($('#port').val());
|
||||
d.username = $('#user').val();
|
||||
d.type = 'philipshue';
|
||||
d.colorOrder = 'rgb';
|
||||
d.lightIds = finalLightIds;
|
||||
d.latchTime = 0;
|
||||
d.transitiontime = parseInt(eV("transitiontime"));
|
||||
d.restoreOriginalState = (eV("restoreOriginalState") == true);
|
||||
d.switchOffOnBlack = (eV("switchOffOnBlack") == true);
|
||||
@ -1000,7 +1120,6 @@ function beginWizardHue() {
|
||||
if (hueType == 'philipshue') {
|
||||
d.useEntertainmentAPI = false;
|
||||
d.hardwareLedCount = finalLightIds.length;
|
||||
d.rewriteTime = 0;
|
||||
d.verbose = false;
|
||||
//smoothing off
|
||||
sc.smoothing.enable = false;
|
||||
@ -1030,9 +1149,11 @@ function createHueUser() {
|
||||
data = { "devicetype": "hyperion#" + Date.now(), "generateclientkey": true }
|
||||
}
|
||||
var UserInterval = setInterval(function () {
|
||||
|
||||
hueUrl.pathname = '/api/';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: 'http://' + $("#ip").val() + '/api',
|
||||
url: hueUrl,
|
||||
processData: false,
|
||||
timeout: 1000,
|
||||
contentType: 'application/json',
|
||||
@ -1081,9 +1202,10 @@ function createHueUser() {
|
||||
}
|
||||
|
||||
function get_hue_groups() {
|
||||
hueUrl.pathname = '/api/' + $("#user").val() + '/groups';
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'http://' + $("#ip").val() + '/api/' + $("#user").val() + '/groups',
|
||||
url: hueUrl,
|
||||
processData: false,
|
||||
contentType: 'application/json',
|
||||
success: function (r) {
|
||||
@ -1125,9 +1247,10 @@ function noAPISupport(txt) {
|
||||
}
|
||||
|
||||
function get_light_state(id) {
|
||||
hueUrl.pathname = '/api/' + $("#user").val() + '/lights/' + id;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'http://' + $("#ip").val() + '/api/' + $("#user").val() + '/lights/' + id,
|
||||
url: hueUrl,
|
||||
processData: false,
|
||||
contentType: 'application/json',
|
||||
success: function (r) {
|
||||
@ -1139,9 +1262,10 @@ function get_light_state(id) {
|
||||
}
|
||||
|
||||
function get_hue_lights() {
|
||||
hueUrl.pathname = '/api/' + $("#user").val() + '/lights';
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'http://' + $("#ip").val() + '/api/' + $("#user").val() + '/lights',
|
||||
url: hueUrl,
|
||||
processData: false,
|
||||
contentType: 'application/json',
|
||||
success: function (r) {
|
||||
@ -1199,7 +1323,7 @@ function get_hue_lights() {
|
||||
}
|
||||
$('.lidsb').append(createTableRow([lightid + ' (' + r[lightid].name + ')', '<select id="hue_' + lightid + '" class="hue_sel_watch form-control">'
|
||||
+ options
|
||||
+ '</select>', '<button class="btn btn-sm btn-primary" onClick=identify_hue_device("' + $("#ip").val() + '","' + $("#user").val() + '",' + lightid + ')>' + $.i18n('wiz_hue_blinkblue', lightid) + '</button>']));
|
||||
+ '</select>', '<button class="btn btn-sm btn-primary" onClick=identify_hue_device("' + $("#host").val() + '","' + $("#port").val() + '","' + $("#user").val() + '",' + lightid + ')>' + $.i18n('wiz_hue_blinkblue', lightid) + '</button>']));
|
||||
}
|
||||
|
||||
if (hueType != 'philipshueentertainment') {
|
||||
@ -1356,8 +1480,6 @@ async function discover_yeelight_lights() {
|
||||
|
||||
// Process devices returned by discovery
|
||||
for (const device of r.devices) {
|
||||
//console.log("Device:", device);
|
||||
|
||||
if (device.hostname !== "") {
|
||||
if (getHostInLights(device.hostname).length === 0) {
|
||||
var light = {};
|
||||
@ -1381,7 +1503,7 @@ async function discover_yeelight_lights() {
|
||||
|
||||
// Add additional items from configuration
|
||||
for (var keyConfig in configuredLights) {
|
||||
var [host, port] = configuredLights[keyConfig].host.split(":", 2);
|
||||
var host = configuredLights[keyConfig].host;
|
||||
|
||||
//In case port has been explicitly provided, overwrite port given as part of hostname
|
||||
if (configuredLights[keyConfig].port !== 0)
|
||||
|
@ -139,8 +139,8 @@
|
||||
"forwarder" :
|
||||
{
|
||||
"enable" : false,
|
||||
"json" : ["127.0.0.1:19446"],
|
||||
"flat" : ["127.0.0.1:19401"]
|
||||
"json" : [],
|
||||
"flat" : []
|
||||
},
|
||||
|
||||
"jsonServer" :
|
||||
|
@ -233,6 +233,12 @@ protected:
|
||||
///
|
||||
bool saveSettings(const QJsonObject &data);
|
||||
|
||||
///
|
||||
/// @brief Restore settings object. Requires ADMIN ACCESS
|
||||
/// @param data The data object
|
||||
///
|
||||
bool restoreSettings(const QJsonObject &data);
|
||||
|
||||
///
|
||||
/// @brief Test if we are authorized to use the interface
|
||||
/// @return The result
|
||||
|
@ -229,6 +229,12 @@ private:
|
||||
///
|
||||
void handleConfigSetCommand(const QJsonObject &message, const QString &command, int tan);
|
||||
|
||||
/// Handle an incoming JSON RestoreConfig message from handleConfigCommand()
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleConfigRestoreCommand(const QJsonObject &message, const QString &command, int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Component State message
|
||||
///
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <QTcpSocket>
|
||||
#include <QTimer>
|
||||
#include <QMap>
|
||||
#include <QHostAddress>
|
||||
|
||||
// hyperion util
|
||||
#include <utils/Image.h>
|
||||
@ -16,6 +17,8 @@
|
||||
|
||||
#include <flatbuffers/flatbuffers.h>
|
||||
|
||||
const int FLATBUFFER_DEFAULT_PORT = 19400;
|
||||
|
||||
namespace hyperionnet
|
||||
{
|
||||
struct Reply;
|
||||
@ -32,10 +35,11 @@ class FlatBufferConnection : public QObject
|
||||
public:
|
||||
///
|
||||
/// @brief Constructor
|
||||
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
|
||||
/// @param host The hostname or IP-address of the Hyperion Flatbuffer server (for example "192.168.0.32")
|
||||
/// @param port The port of the Hyperion Flatpuffer server (default is 19400)
|
||||
/// @param skipReply If true skip reply
|
||||
///
|
||||
FlatBufferConnection(const QString& origin, const QString & address, int priority, bool skipReply);
|
||||
FlatBufferConnection(const QString& origin, const QString& host, int priority, bool skipReply, quint16 port = FLATBUFFER_DEFAULT_PORT);
|
||||
|
||||
///
|
||||
/// @brief Destructor
|
||||
|
@ -324,6 +324,14 @@ public slots:
|
||||
///
|
||||
bool saveSettings(const QJsonObject& config, bool correct = false);
|
||||
|
||||
///
|
||||
/// @brief Restore a complete json config
|
||||
/// @param config The entire config object
|
||||
/// @param correct If true will correct json against schema before save
|
||||
/// @return True on success else false
|
||||
///
|
||||
bool restoreSettings(const QJsonObject& config, bool correct = false);
|
||||
|
||||
/// ############
|
||||
/// COMPONENTREGISTER
|
||||
///
|
||||
|
@ -36,8 +36,8 @@ public:
|
||||
MessageForwarder(Hyperion* hyperion);
|
||||
~MessageForwarder() override;
|
||||
|
||||
void addJsonSlave(const QString& slave);
|
||||
void addFlatbufferSlave(const QString& slave);
|
||||
void addJsonTarget(const QJsonObject& targetConfig);
|
||||
void addFlatbufferTarget(const QJsonObject& targetConfig);
|
||||
|
||||
private slots:
|
||||
///
|
||||
@ -61,25 +61,36 @@ private slots:
|
||||
void handlePriorityChanges(quint8 priority);
|
||||
|
||||
///
|
||||
/// @brief Forward message to all json slaves
|
||||
/// @brief Forward message to all json target hosts
|
||||
/// @param message The JSON message to send
|
||||
///
|
||||
void forwardJsonMessage(const QJsonObject &message);
|
||||
|
||||
///
|
||||
/// @brief Forward image to all flatbuffer slaves
|
||||
/// @brief Forward image to all flatbuffer target hosts
|
||||
/// @param image The flatbuffer image to send
|
||||
///
|
||||
void forwardFlatbufferMessage(const QString& name, const Image<ColorRgb> &image);
|
||||
|
||||
///
|
||||
/// @brief Forward message to a single json slave
|
||||
/// @brief Forward message to a single json target host
|
||||
/// @param message The JSON message to send
|
||||
/// @param socket The TCP-Socket with the connection to the slave
|
||||
/// @param socket The TCP-Socket with the connection to the target host
|
||||
///
|
||||
void sendJsonMessage(const QJsonObject &message, QTcpSocket *socket);
|
||||
|
||||
private:
|
||||
|
||||
struct TargetHost {
|
||||
QHostAddress host;
|
||||
quint16 port;
|
||||
|
||||
bool operator == (TargetHost const& a) const
|
||||
{
|
||||
return ((host == a.host) && (port == a.port));
|
||||
}
|
||||
};
|
||||
|
||||
/// Hyperion instance
|
||||
Hyperion *_hyperion;
|
||||
|
||||
@ -89,11 +100,11 @@ private:
|
||||
/// Muxer instance
|
||||
PriorityMuxer *_muxer;
|
||||
|
||||
// JSON connection for forwarding
|
||||
QStringList _jsonSlaves;
|
||||
// JSON connections for forwarding
|
||||
QList<TargetHost> _jsonTargets;
|
||||
|
||||
/// Proto connection for forwarding
|
||||
QStringList _flatSlaves;
|
||||
/// Flatbuffer connection for forwarding
|
||||
QList<TargetHost> _flatbufferTargets;
|
||||
QList<FlatBufferConnection*> _forwardClients;
|
||||
|
||||
/// Flag if forwarder is enabled
|
||||
|
@ -36,6 +36,14 @@ public:
|
||||
///
|
||||
bool saveSettings(QJsonObject config, bool correct = false);
|
||||
|
||||
///
|
||||
/// @brief Restore a complete json configuration
|
||||
/// @param config The entire config object
|
||||
/// @param correct If true will correct json against schema before save
|
||||
/// @return True on success else false
|
||||
///
|
||||
bool restoreSettings(QJsonObject config, bool correct = false);
|
||||
|
||||
///
|
||||
/// @brief get a single setting json from configuration
|
||||
/// @param type The settings::type from enum
|
||||
|
@ -3,15 +3,21 @@
|
||||
#include <utils/Logger.h>
|
||||
|
||||
#include <QTcpServer>
|
||||
#include <QUrl>
|
||||
#include <QHostAddress>
|
||||
#include <QHostInfo>
|
||||
|
||||
namespace NetUtils {
|
||||
|
||||
const int MAX_PORT = 65535;
|
||||
|
||||
///
|
||||
/// @brief Check if the port is available for listening
|
||||
/// @param[in/out] port The port to test, will be incremented if port is in use
|
||||
/// @param log The logger of the caller to print
|
||||
/// @return True on success else false
|
||||
///
|
||||
static bool portAvailable(quint16& port, Logger* log)
|
||||
inline bool portAvailable(quint16& port, Logger* log)
|
||||
{
|
||||
const quint16 prevPort = port;
|
||||
QTcpServer server;
|
||||
@ -29,4 +35,89 @@ namespace NetUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
/// @brief Check if the port is in the valid range
|
||||
/// @param log The logger of the caller to print///
|
||||
/// @param[in] port The port to be tested
|
||||
/// @param[in] host A hostname/IP-address to make reference to during logging
|
||||
/// @return True on success else false
|
||||
///
|
||||
inline bool isValidPort(Logger* log, int port, const QString& host)
|
||||
{
|
||||
if (port <= 0 || port > MAX_PORT)
|
||||
{
|
||||
Error(log, "Invalid port [%d] for host: %s!", port, QSTRING_CSTR(host));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
/// @brief Get host and port from an host address
|
||||
/// @param[in] address Hostname or IP-address with or without port (e.g. 192.168.1.100:4711, 2003:e4:c73a:8e00:d5bb:dc3c:50cb:c76e, hyperion.fritz.box)
|
||||
/// @param[in/out] host The resolved hostname or IP-address
|
||||
/// @param[in/out] port The resolved port, if available.
|
||||
/// @return True on success else false
|
||||
///
|
||||
inline bool resolveHostPort(const QString& address, QString& host, quint16& port)
|
||||
{
|
||||
QString testUrl;
|
||||
if (address.at(0) != '[' && address.count(':') > 1)
|
||||
{
|
||||
testUrl = QString("http://[%1]").arg(address);
|
||||
}
|
||||
else
|
||||
{
|
||||
testUrl = QString("http://%1").arg(address);
|
||||
}
|
||||
|
||||
QUrl url(testUrl);
|
||||
if (!url.isValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
host = url.host();
|
||||
if (url.port() != -1)
|
||||
{
|
||||
port = url.port();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
/// @brief Check if the port is in the valid range
|
||||
/// @param log The logger of the caller to print
|
||||
/// @param[in] address The port to be tested
|
||||
/// @param[out] hostAddress A hostname to make reference to during logging
|
||||
/// @return True on success else false
|
||||
///
|
||||
|
||||
inline bool resolveHostAddress(Logger* log, const QString& address, QHostAddress& hostAddress)
|
||||
{
|
||||
bool isHostAddressOK{ false };
|
||||
|
||||
if (hostAddress.setAddress(address))
|
||||
{
|
||||
Debug(log, "Successfully parsed %s as an IP-address.", QSTRING_CSTR(hostAddress.toString()));
|
||||
isHostAddressOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QHostInfo hostInfo = QHostInfo::fromName(address);
|
||||
if (hostInfo.error() == QHostInfo::NoError)
|
||||
{
|
||||
hostAddress = hostInfo.addresses().first();
|
||||
Debug(log, "Successfully resolved IP-address (%s) for hostname (%s).", QSTRING_CSTR(hostAddress.toString()), QSTRING_CSTR(address));
|
||||
isHostAddressOK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString errortext = QString("Failed resolving IP-address for [%1], (%2) %3").arg(address).arg(hostInfo.error()).arg(hostInfo.errorString());
|
||||
Error(log, "%s", QSTRING_CSTR(errortext));
|
||||
isHostAddressOK = false;
|
||||
}
|
||||
}
|
||||
return isHostAddressOK;
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -10,7 +10,7 @@
|
||||
"subcommand": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["setconfig","getconfig","getschema","reload"]
|
||||
"enum" : ["getconfig","getschema","setconfig","restoreconfig","reload"]
|
||||
},
|
||||
"tan" : {
|
||||
"type" : "integer"
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
///
|
||||
|
@ -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
|
||||
///
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
},
|
||||
"host": {
|
||||
"type": "string",
|
||||
"format": "ipv4",
|
||||
"title": "edt_dev_spec_multicastGroup_title",
|
||||
"default": "239.255.255.250",
|
||||
"propertyOrder": 3
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
@ -53,7 +54,7 @@ int main(int argc, char ** argv)
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -122,8 +123,17 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("AML Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
FlatBufferConnection flatbuf("AML Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&amlWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
@ -54,7 +55,7 @@ int main(int argc, char ** argv)
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -124,8 +125,18 @@ int main(int argc, char ** argv)
|
||||
address = argAddress.value(parser);
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("Dispmanx Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
FlatBufferConnection flatbuf("Dispmanx Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&dispmanxWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
@ -55,7 +56,7 @@ int main(int argc, char ** argv)
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -125,8 +126,17 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("Framebuffer Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
FlatBufferConnection flatbuf("Framebuffer Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&fbWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
@ -49,7 +50,7 @@ int main(int argc, char ** argv)
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -119,8 +120,17 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("OSX Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
FlatBufferConnection flatbuf("OSX Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&osxWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
@ -56,7 +57,7 @@ int main(int argc, char ** argv)
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -126,8 +127,17 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port { FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if ( !NetUtils::resolveHostPort(address, host, port) )
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("Qt Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
FlatBufferConnection flatbuf("Qt Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&qtWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QHostInfo>
|
||||
#include <QUrl>
|
||||
|
||||
// hyperion-remote includes
|
||||
#include "JsonConnection.h"
|
||||
@ -17,31 +18,17 @@
|
||||
// util includes
|
||||
#include <utils/JsonUtils.h>
|
||||
|
||||
JsonConnection::JsonConnection(const QString & address, bool printJson)
|
||||
JsonConnection::JsonConnection(const QString & host, bool printJson , quint16 port)
|
||||
: _printJson(printJson)
|
||||
, _log(Logger::getInstance("REMOTE"))
|
||||
, _socket()
|
||||
{
|
||||
QStringList parts = address.split(":");
|
||||
if (parts.size() != 2)
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
bool ok;
|
||||
uint16_t port = parts[1].toUShort(&ok);
|
||||
if (!ok)
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: Unable to parse the port number (%1)").arg(parts[1]).toStdString());
|
||||
}
|
||||
|
||||
_socket.connectToHost(parts[0], port);
|
||||
_socket.connectToHost(host, port);
|
||||
if (!_socket.waitForConnected())
|
||||
{
|
||||
throw std::runtime_error("Unable to connect to host");
|
||||
throw std::runtime_error(QString("Unable to connect to host (%1), port (%2)").arg(host).arg(port).toStdString());
|
||||
}
|
||||
|
||||
qDebug() << "Connected to:" << address;
|
||||
Debug(_log, "Connected to: %s, port: %u", QSTRING_CSTR(host), port);
|
||||
}
|
||||
|
||||
JsonConnection::~JsonConnection()
|
||||
@ -51,7 +38,7 @@ JsonConnection::~JsonConnection()
|
||||
|
||||
void JsonConnection::setColor(std::vector<QColor> colors, int priority, int duration)
|
||||
{
|
||||
qDebug() << "Set color to " << colors[0].red() << " " << colors[0].green() << " " << colors[0].blue() << (colors.size() > 1 ? " + ..." : "");
|
||||
Debug(_log, "Set color to [%d,%d,%d] %s", colors[0].red(), colors[0].green(), colors[0].blue(), (colors.size() > 1 ? " + ..." : ""));
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
@ -81,7 +68,7 @@ void JsonConnection::setColor(std::vector<QColor> colors, int priority, int dura
|
||||
|
||||
void JsonConnection::setImage(QImage &image, int priority, int duration)
|
||||
{
|
||||
qDebug() << "Set image has size: " << image.width() << "x" << image.height();
|
||||
Debug(_log, "Set image has size: %dx%d", image.width(), image.height());
|
||||
|
||||
// ensure the image has RGB888 format
|
||||
image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
@ -121,7 +108,7 @@ void JsonConnection::setImage(QImage &image, int priority, int duration)
|
||||
|
||||
void JsonConnection::setEffect(const QString &effectName, const QString & effectArgs, int priority, int duration)
|
||||
{
|
||||
qDebug() << "Start effect " << effectName;
|
||||
Debug(_log, "Start effect: %s", QSTRING_CSTR(effectName));
|
||||
|
||||
// create command
|
||||
QJsonObject command, effect;
|
||||
@ -157,7 +144,7 @@ void JsonConnection::setEffect(const QString &effectName, const QString & effect
|
||||
|
||||
void JsonConnection::createEffect(const QString &effectName, const QString &effectScript, const QString & effectArgs)
|
||||
{
|
||||
qDebug() << "Create effect " << effectName;
|
||||
Debug(_log, "Create effect: %s", QSTRING_CSTR(effectName));
|
||||
|
||||
// create command
|
||||
QJsonObject effect;
|
||||
@ -185,7 +172,7 @@ void JsonConnection::createEffect(const QString &effectName, const QString &effe
|
||||
|
||||
void JsonConnection::deleteEffect(const QString &effectName)
|
||||
{
|
||||
qDebug() << "Delete effect configuration" << effectName;
|
||||
Debug(_log, "Delete effect configuration: %s", QSTRING_CSTR(effectName));
|
||||
|
||||
// create command
|
||||
QJsonObject effect;
|
||||
@ -208,7 +195,7 @@ QString JsonConnection::getServerInfoString()
|
||||
|
||||
QJsonObject JsonConnection::getServerInfo()
|
||||
{
|
||||
qDebug() << "Get server info";
|
||||
Debug(_log, "Get server info");
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
@ -233,7 +220,7 @@ QJsonObject JsonConnection::getServerInfo()
|
||||
|
||||
QString JsonConnection::getSysInfo()
|
||||
{
|
||||
qDebug() << "Get system info";
|
||||
Debug(_log, "Get system info");
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
@ -260,7 +247,7 @@ QString JsonConnection::getSysInfo()
|
||||
|
||||
void JsonConnection::clear(int priority)
|
||||
{
|
||||
qDebug() << "Clear priority channel " << priority;
|
||||
Debug(_log, "Clear priority channel [%d]", priority);
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
@ -276,7 +263,7 @@ void JsonConnection::clear(int priority)
|
||||
|
||||
void JsonConnection::clearAll()
|
||||
{
|
||||
qDebug() << "Clear all priority channels";
|
||||
Debug(_log, "Clear all priority channels");
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
@ -292,7 +279,7 @@ void JsonConnection::clearAll()
|
||||
|
||||
void JsonConnection::setComponentState(const QString & component, bool state)
|
||||
{
|
||||
qDebug() << (state ? "Enable" : "Disable") << "Component" << component;
|
||||
Debug(_log, "%s Component: %s", (state ? "Enable" : "Disable"), QSTRING_CSTR(component));
|
||||
|
||||
// create command
|
||||
QJsonObject command, parameter;
|
||||
@ -339,7 +326,7 @@ void JsonConnection::setSourceAutoSelect()
|
||||
QString JsonConnection::getConfig(std::string type)
|
||||
{
|
||||
assert( type == "schema" || type == "config" );
|
||||
qDebug() << "Get configuration file from Hyperion Server";
|
||||
Debug(_log, "Get configuration file from Hyperion Server");
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
@ -408,7 +395,7 @@ void JsonConnection::setAdjustment(
|
||||
int *brightness,
|
||||
int *brightnessC)
|
||||
{
|
||||
qDebug() << "Set color adjustments";
|
||||
Debug(_log, "Set color adjustments");
|
||||
|
||||
// create command
|
||||
QJsonObject command, adjust;
|
||||
|
@ -9,6 +9,8 @@
|
||||
//forward class decl
|
||||
class Logger;
|
||||
|
||||
const int JSON_DEFAULT_PORT = 19444;
|
||||
|
||||
///
|
||||
/// Connection class to setup an connection to the hyperion server and execute commands
|
||||
///
|
||||
@ -18,10 +20,11 @@ public:
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
|
||||
/// @param address The hostname or IP-address of the Hyperion JSON-server (for example "192.168.0.32")
|
||||
/// @param address The port of the Hyperion JSON-server (default port = 19444)
|
||||
/// @param printJson Boolean indicating if the sent and received json is written to stdout
|
||||
///
|
||||
JsonConnection(const QString & address, bool printJson);
|
||||
JsonConnection(const QString& host, bool printJson, quint16 port = JSON_DEFAULT_PORT);
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
|
@ -9,14 +9,16 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QLocale>
|
||||
|
||||
#include "HyperionConfig.h"
|
||||
#include <commandline/Parser.h>
|
||||
|
||||
// hyperion-remote include
|
||||
#include "JsonConnection.h"
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
#include "HyperionConfig.h"
|
||||
#include <commandline/Parser.h>
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
using namespace commandline;
|
||||
@ -66,6 +68,10 @@ int main(int argc, char * argv[])
|
||||
#ifndef _WIN32
|
||||
setenv("AVAHI_COMPAT_NOWARN", "1", 1);
|
||||
#endif
|
||||
|
||||
Logger* log = Logger::getInstance("REMOTE");
|
||||
Logger::setLogLevel(Logger::INFO);
|
||||
|
||||
std::cout
|
||||
<< "hyperion-remote:" << std::endl
|
||||
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
|
||||
@ -87,8 +93,8 @@ int main(int argc, char * argv[])
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// art variable definition append art to Parser short-, long option description, optional default value //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Option & argAddress = parser.add<Option> ('a', "address" , "Set the address of the hyperion server [default: %1]", "127.0.0.1:19444");
|
||||
Option & argToken = parser.add<Option> ('t', "token " , "If authorization tokens are required, this token is used");
|
||||
Option & argAddress = parser.add<Option> ('a', "address" , "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
Option & argToken = parser.add<Option> ('t', "token" , "If authorization tokens are required, this token is used");
|
||||
Option & argInstance = parser.add<Option> ('I', "instance" , "Select a specific target instance by name for your command. By default it uses always the first instance");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority" , "Used to the provided priority channel (suggested 2-99) [default: %1]", "50");
|
||||
IntOption & argDuration = parser.add<IntOption> ('d', "duration" , "Specify how long the LEDs should be switched on in milliseconds [default: infinity]");
|
||||
@ -111,8 +117,6 @@ int main(int argc, char * argv[])
|
||||
IntOption & argBacklightThreshold = parser.add<IntOption> ('n', "backlightThreshold" , "threshold for activating backlight (minimum brightness)");
|
||||
IntOption & argBacklightColored = parser.add<IntOption> (0x0, "backlightColored" , "0 = white backlight; 1 = colored backlight");
|
||||
DoubleOption & argGamma = parser.add<DoubleOption> ('g', "gamma" , "Set the overall gamma of the LEDs");
|
||||
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print" , "Print the JSON input and output messages on stdout");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help" , "Show this help message and exit");
|
||||
ColorOption & argRAdjust = parser.add<ColorOption> ('R', "redAdjustment" , "Set the adjustment of the red color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argGAdjust = parser.add<ColorOption> ('G', "greenAdjustment" , "Set the adjustment of the green color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argBAdjust = parser.add<ColorOption> ('B', "blueAdjustment" , "Set the adjustment of the blue color (requires colors in hex format as RRGGBB)");
|
||||
@ -131,9 +135,19 @@ int main(int argc, char * argv[])
|
||||
BooleanOption & argSchemaGet = parser.add<BooleanOption>(0x0, "schemaGet" , "Print the JSON schema for Hyperion configuration");
|
||||
Option & argConfigSet = parser.add<Option> (0x0, "configSet" , "Write to the actual loaded configuration file. Should be a JSON object string.");
|
||||
|
||||
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print", "Print the JSON input and output messages on stdout");
|
||||
BooleanOption & argDebug = parser.add<BooleanOption>(0x0, "debug", "Enable debug logging");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help", "Show this help message and exit");
|
||||
|
||||
// parse all _options
|
||||
parser.process(app);
|
||||
|
||||
// check if debug logging is required
|
||||
if (parser.isSet(argDebug))
|
||||
{
|
||||
Logger::setLogLevel(Logger::DEBUG);
|
||||
}
|
||||
|
||||
// check if we need to display the usage. exit if we do.
|
||||
if (parser.isSet(argHelp))
|
||||
{
|
||||
@ -196,8 +210,17 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ JSON_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// create the connection to the hyperion server
|
||||
JsonConnection connection(address, parser.isSet(argPrint));
|
||||
JsonConnection connection(host, parser.isSet(argPrint), port);
|
||||
|
||||
// authorization token specified. Use it first
|
||||
if (parser.isSet(argToken))
|
||||
@ -323,7 +346,7 @@ int main(int argc, char * argv[])
|
||||
catch (const std::runtime_error & e)
|
||||
{
|
||||
// An error occurred. Display error and quit
|
||||
std::cerr << e.what() << std::endl;
|
||||
Error(log, "%s", e.what());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
#include <utils/DefaultSignalHandler.h>
|
||||
|
||||
@ -81,7 +82,7 @@ int main(int argc, char** argv)
|
||||
DoubleOption & argSignalHorizontalMax = parser.add<DoubleOption> (0x0, "signal-horizontal-max", "area for signal detection - horizontal maximum offset value. Values between 0.0 and 1.0");
|
||||
DoubleOption & argSignalVerticalMax = parser.add<DoubleOption> (0x0, "signal-vertical-max" , "area for signal detection - vertical maximum offset value. Values between 0.0 and 1.0");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -241,8 +242,17 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the Flatbuf-connection
|
||||
FlatBufferConnection flatbuf("V4L2 Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("V4L2 Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&grabber, SIGNAL(newFrame(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
@ -52,7 +53,7 @@ int main(int argc, char ** argv)
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -121,8 +122,18 @@ int main(int argc, char ** argv)
|
||||
address = argAddress.value(parser);
|
||||
}
|
||||
}
|
||||
// Create the Flatbuf-connection
|
||||
FlatBufferConnection flatbuf("X11 Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("X11 Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&x11Wrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
// ssdp discover
|
||||
#include <ssdp/SSDPDiscover.h>
|
||||
#include <utils/NetUtils.h>
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
@ -52,7 +53,7 @@ int main(int argc, char ** argv)
|
||||
BooleanOption & arg3DSBS = parser.add<BooleanOption>(0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
|
||||
BooleanOption & arg3DTAB = parser.add<BooleanOption>(0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "Set the address of the hyperion server [default: %1]", "127.0.0.1:19400");
|
||||
Option & argAddress = parser.add<Option> ('a', "address", "The hostname or IP-address (IPv4 or IPv6) of the hyperion server.\nDefault port: 19444.\nSample addresses:\nHost : hyperion.fritz.box\nIPv4 : 127.0.0.1:19444\nIPv6 : [2001:1:2:3:4:5:6:7]");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority", "Use the provided priority channel (suggested 100-199) [default: %1]", "150");
|
||||
BooleanOption & argSkipReply = parser.add<BooleanOption>(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
|
||||
|
||||
@ -121,8 +122,18 @@ int main(int argc, char ** argv)
|
||||
address = argAddress.value(parser);
|
||||
}
|
||||
}
|
||||
// Create the Flatbuf-connection
|
||||
FlatBufferConnection flatbuf("XCB Standalone", address, argPriority.getInt(parser), parser.isSet(argSkipReply));
|
||||
|
||||
// Resolve hostname and port (or use default port)
|
||||
QString host;
|
||||
quint16 port{ FLATBUFFER_DEFAULT_PORT };
|
||||
|
||||
if (!NetUtils::resolveHostPort(address, host, port))
|
||||
{
|
||||
throw std::runtime_error(QString("Wrong address: unable to parse address (%1)").arg(address).toStdString());
|
||||
}
|
||||
|
||||
// Create the Flabuf-connection
|
||||
FlatBufferConnection flatbuf("XCB Standalone", host, argPriority.getInt(parser), parser.isSet(argSkipReply), port);
|
||||
|
||||
// Connect the screen capturing to flatbuf connection processing
|
||||
QObject::connect(&xcbWrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &flatbuf, SLOT(setImage(Image<ColorRgb>)));
|
||||
|
@ -181,6 +181,7 @@ if (WIN32)
|
||||
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
|
||||
get_filename_component(QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
|
||||
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
|
||||
|
||||
if (NOT WINDEPLOYQT_EXECUTABLE)
|
||||
find_program(WINDEPLOYQT_EXECUTABLE windeployqt)
|
||||
endif()
|
||||
@ -190,6 +191,37 @@ if (WIN32)
|
||||
message(STATUS "Found windeployqt: ${WINDEPLOYQT_EXECUTABLE} PATH_HINT:${QT_BIN_DIR}")
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} ${WINDEPLOYQT_PARAMS_RUNTIME} "$<TARGET_FILE:${PROJECT_NAME}>")
|
||||
endif()
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
if (OPENSSL_FOUND)
|
||||
string(REGEX MATCHALL "[0-9]+" openssl_versions "${OPENSSL_VERSION}")
|
||||
list(GET openssl_versions 0 openssl_version_major)
|
||||
list(GET openssl_versions 1 openssl_version_minor)
|
||||
|
||||
set(library_suffix "-${openssl_version_major}_${openssl_version_minor}")
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
string(APPEND library_suffix "-x64")
|
||||
endif()
|
||||
|
||||
find_file(OPENSSL_SSL
|
||||
NAMES "libssl${library_suffix}.dll"
|
||||
PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
find_file(OPENSSL_CRYPTO
|
||||
NAMES "libcrypto${library_suffix}.dll"
|
||||
PATHS ${OPENSSL_INCLUDE_DIR}/.. ${OPENSSL_INCLUDE_DIR}/../bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${OPENSSL_SSL} ${OPENSSL_CRYPTO}
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
)
|
||||
endif(OPENSSL_FOUND)
|
||||
endif(WIN32)
|
||||
|
||||
if(ENABLE_DEPLOY_DEPENDENCIES)
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QNetworkInterface>
|
||||
#include <QHostInfo>
|
||||
|
||||
#include "HyperionConfig.h"
|
||||
|
||||
@ -47,7 +49,7 @@
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
#define PERM0664 QFileDevice::ReadOwner | QFileDevice::ReadGroup | QFileDevice::ReadOther | QFileDevice::WriteOwner | QFileDevice::WriteGroup
|
||||
#define PERM0664 (QFileDevice::ReadOwner | QFileDevice::ReadGroup | QFileDevice::ReadOther | QFileDevice::WriteOwner | QFileDevice::WriteGroup)
|
||||
|
||||
#ifndef _WIN32
|
||||
void signal_handler(int signum)
|
||||
@ -59,7 +61,6 @@ void signal_handler(int signum)
|
||||
{
|
||||
// only quit when a registered child process is gone
|
||||
// currently this feature is not active ...
|
||||
return;
|
||||
}
|
||||
else if (signum == SIGUSR1)
|
||||
{
|
||||
@ -67,7 +68,6 @@ void signal_handler(int signum)
|
||||
{
|
||||
_hyperion->toggleStateAllInstances(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (signum == SIGUSR2)
|
||||
{
|
||||
@ -75,7 +75,6 @@ void signal_handler(int signum)
|
||||
{
|
||||
_hyperion->toggleStateAllInstances(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -106,8 +105,8 @@ QCoreApplication* createApplication(int &argc, char *argv[])
|
||||
{
|
||||
// if x11, then test if xserver is available
|
||||
#if defined(ENABLE_X11)
|
||||
Display* dpy = XOpenDisplay(NULL);
|
||||
if (dpy != NULL)
|
||||
Display* dpy = XOpenDisplay(nullptr);
|
||||
if (dpy != nullptr)
|
||||
{
|
||||
XCloseDisplay(dpy);
|
||||
isGuiApp = true;
|
||||
@ -165,7 +164,7 @@ int main(int argc, char** argv)
|
||||
// Initialising QCoreApplication
|
||||
QScopedPointer<QCoreApplication> app(createApplication(argc, argv));
|
||||
|
||||
bool isGuiApp = (qobject_cast<QApplication *>(app.data()) != 0 && QSystemTrayIcon::isSystemTrayAvailable());
|
||||
bool isGuiApp = (qobject_cast<QApplication *>(app.data()) != nullptr && QSystemTrayIcon::isSystemTrayAvailable());
|
||||
|
||||
DefaultSignalHandler::install();
|
||||
|
||||
@ -200,6 +199,13 @@ int main(int argc, char** argv)
|
||||
|
||||
parser.process(*qApp);
|
||||
|
||||
#ifdef WIN32
|
||||
if (parser.isSet(consoleOption))
|
||||
{
|
||||
CreateConsole();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (parser.isSet(versionOption))
|
||||
{
|
||||
std::cout
|
||||
@ -215,6 +221,24 @@ int main(int argc, char** argv)
|
||||
if (getProcessIdsByProcessName(processName).size() > 1)
|
||||
{
|
||||
Error(log, "The Hyperion Daemon is already running, abort start");
|
||||
|
||||
// use the first non-localhost IPv4 address, IPv6 are not supported by Yeelight currently
|
||||
for (const auto& address : QNetworkInterface::allAddresses())
|
||||
{
|
||||
if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol))
|
||||
{
|
||||
std::cout << "Access the Hyperion User-Interface for configuration and control via:" << std::endl;
|
||||
std::cout << "http:://" << address.toString().toStdString() << ":8090" << std::endl;
|
||||
|
||||
QHostInfo hostInfo = QHostInfo::fromName(address.toString());
|
||||
if (hostInfo.error() == QHostInfo::NoError)
|
||||
{
|
||||
QString hostname = hostInfo.hostName();
|
||||
std::cout << "http:://" << hostname.toStdString() << ":8090" << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -226,13 +250,6 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
if (parser.isSet(consoleOption))
|
||||
{
|
||||
CreateConsole();
|
||||
}
|
||||
#endif
|
||||
|
||||
int logLevelCheck = 0;
|
||||
if (parser.isSet(silentOption))
|
||||
{
|
||||
@ -268,11 +285,13 @@ int main(int argc, char** argv)
|
||||
std::cout << "Extract to folder: " << destDir.absolutePath().toStdString() << std::endl;
|
||||
QStringList filenames = directory.entryList(QStringList() << "*", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
||||
QString destFileName;
|
||||
for (const QString & filename : filenames)
|
||||
for (const QString & filename : qAsConst(filenames))
|
||||
{
|
||||
destFileName = destDir.dirName()+"/"+filename;
|
||||
if (QFile::exists(destFileName))
|
||||
{
|
||||
QFile::remove(destFileName);
|
||||
}
|
||||
|
||||
std::cout << "Extract: " << filename.toStdString() << " ... ";
|
||||
if (QFile::copy(QString(":/effects/")+filename, destFileName))
|
||||
@ -303,20 +322,16 @@ int main(int argc, char** argv)
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
if (dbFile.exists())
|
||||
{
|
||||
if (!dbFile.isReadable())
|
||||
{
|
||||
throw std::runtime_error("Configuration database '" + dbFile.absoluteFilePath().toStdString() + "' is not readable. Please setup permissions correctly!");
|
||||
}
|
||||
else
|
||||
|
||||
if (!dbFile.isWritable())
|
||||
{
|
||||
if (!dbFile.isWritable())
|
||||
{
|
||||
readonlyMode = true;
|
||||
}
|
||||
readonlyMode = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -338,18 +353,16 @@ int main(int argc, char** argv)
|
||||
Error(log,"Password reset is not possible. The user data path '%s' is not writeable.", QSTRING_CSTR(userDataDirectory.absolutePath()));
|
||||
throw std::runtime_error("Password reset failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthTable* table = new AuthTable(userDataDirectory.absolutePath());
|
||||
if(table->resetHyperionUser()){
|
||||
Info(log,"Password reset successful");
|
||||
delete table;
|
||||
exit(0);
|
||||
} else {
|
||||
Error(log,"Failed to reset password!");
|
||||
delete table;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
AuthTable* table = new AuthTable(userDataDirectory.absolutePath());
|
||||
if(table->resetHyperionUser()){
|
||||
Info(log,"Password reset successful");
|
||||
delete table;
|
||||
exit(0);
|
||||
} else {
|
||||
Error(log,"Failed to reset password!");
|
||||
delete table;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,25 +374,23 @@ int main(int argc, char** argv)
|
||||
Error(log,"Deleting the configuration database is not possible. The user data path '%s' is not writeable.", QSTRING_CSTR(dbFile.absolutePath()));
|
||||
throw std::runtime_error("Deleting the configuration database failed");
|
||||
}
|
||||
else
|
||||
|
||||
if (QFile::exists(dbFile.absoluteFilePath()))
|
||||
{
|
||||
if (QFile::exists(dbFile.absoluteFilePath()))
|
||||
if (!QFile::remove(dbFile.absoluteFilePath()))
|
||||
{
|
||||
if (!QFile::remove(dbFile.absoluteFilePath()))
|
||||
{
|
||||
Info(log,"Failed to delete Database!");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(log,"Configuration database deleted successfully.");
|
||||
}
|
||||
Info(log,"Failed to delete Database!");
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(log,"Configuration database [%s] does not exist!", QSTRING_CSTR(dbFile.absoluteFilePath()));
|
||||
Info(log,"Configuration database deleted successfully.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(log,"Configuration database [%s] does not exist!", QSTRING_CSTR(dbFile.absoluteFilePath()));
|
||||
}
|
||||
}
|
||||
|
||||
Info(log,"Starting Hyperion - %s, %s, built: %s:%s", HYPERION_VERSION, HYPERION_BUILD_ID, __DATE__, __TIME__);
|
||||
|
Loading…
Reference in New Issue
Block a user