Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 48 additions & 29 deletions assets/webconfig/js/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,24 +696,27 @@ function startWizardPhilipsHue(e) {
function checkHueBridge(cb, hueUser) {
var usr = (typeof hueUser != "undefined") ? hueUser : 'config';
if (usr == 'config') $('#wiz_hue_discovered').html("");
$.ajax({
url: 'http://' + hueIPs[hueIPsinc].internalipaddress + '/api/' + usr,
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);
}
},
timeout: 2500
}).fail(function () {
cb(false);
});

if (hueIPs[hueIPsinc]) {
$.ajax({
url: 'http://' + hueIPs[hueIPsinc].internalipaddress + '/api/' + usr,
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);
}
},
timeout: 2500
}).fail(function () {
cb(false);
});
}
}

function checkBridgeResult(reply, usr) {
Expand Down Expand Up @@ -788,25 +791,41 @@ function useGroupId(id) {
}

async function discover_hue_bridges() {
$('#wiz_hue_ipstate').html($.i18n('edt_dev_spec_devices_discovery_inprogress'));
$('#wiz_hue_discovered').html("")
const res = await requestLedDeviceDiscovery('philipshue');

// TODO: error case unhandled
// res can be: false (timeout) or res.error (not found)
if (res && !res.error) {
const r = res.info;

// Process devices returned by discovery
if (r.devices.length == 0)
if (r.devices.length == 0) {
$('#wiz_hue_ipstate').html($.i18n('wiz_hue_failure_ip'));
$('#wiz_hue_discovered').html("")
}
else {
for (const device of r.devices) {
console.log("Device:", device);
//console.log("Device:", device);
if (device && device.ip && device.port) {

var ip;
if (device.hostname && device.domain) {
ip = device.hostname + "." + device.domain + ":" + device.port;
} else {
ip = device.ip + ":" + device.port;
}

var ip = device.hostname + ":" + device.port;
console.log("Host:", ip);
if (ip) {

hueIPs.push({ internalipaddress: ip });
if (!hueIPs.some(item => item.internalipaddress === ip)) {
hueIPs.push({ internalipaddress: ip });
}
}
}
}

var usr = $('#user').val();
if (usr != "") {
checkHueBridge(checkUserResult, usr);
Expand Down Expand Up @@ -884,12 +903,12 @@ function beginWizardHue() {
}
}
//check if ip is empty/reachable/search for bridge
if (eV("output") == "") {
if (eV("host") == "") {
//getHueIPs();
discover_hue_bridges();
}
else {
var ip = eV("output");
var ip = eV("host");
$('#ip').val(ip);
hueIPs.unshift({ internalipaddress: ip });
if (usr != "") {
Expand Down Expand Up @@ -954,7 +973,7 @@ function beginWizardHue() {

//Start with a clean configuration
var d = {};
d.output = $('#ip').val();
d.host = $('#ip').val();
d.username = $('#user').val();
d.type = 'philipshue';
d.colorOrder = 'rgb';
Expand Down Expand Up @@ -1534,7 +1553,7 @@ function beginWizardAtmoOrb() {
configuredLights = configruedOrbIds.split(",").map(Number);
}

var multiCastGroup = conf_editor.getEditor("root.specificOptions.output").getValue();
var multiCastGroup = conf_editor.getEditor("root.specificOptions.host").getValue();
var multiCastPort = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());

discover_atmoorb_lights(multiCastGroup, multiCastPort);
Expand Down Expand Up @@ -1576,7 +1595,7 @@ function beginWizardAtmoOrb() {
d.orbIds = finalLights.toString();
d.useOrbSmoothing = (eV("useOrbSmoothing") == true);

d.output = conf_editor.getEditor("root.specificOptions.output").getValue();
d.host = conf_editor.getEditor("root.specificOptions.host").getValue();
d.port = parseInt(conf_editor.getEditor("root.specificOptions.port").getValue());
d.latchTime = parseInt(conf_editor.getEditor("root.specificOptions.latchTime").getValue());;

Expand Down
17 changes: 11 additions & 6 deletions libsrc/leddevice/dev_net/ProviderUdpSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

// Local Hyperion includes
#include "ProviderUdpSSL.h"
#include <utils/QStringUtils.h>

const int MAX_RETRY = 5;
const ushort MAX_PORT_SSL = 65535;
Expand Down Expand Up @@ -73,6 +74,10 @@ 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";

configLog( "SSL Streamer Debug", "%s", ( _debugStreamer ) ? "yes" : "no" );
Expand All @@ -91,24 +96,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(host) )
if ( _address.setAddress(udpHost) )
{
Debug( _log, "Successfully parsed %s as an ip address.", QSTRING_CSTR( host ) );
Debug( _log, "Successfully parsed %s as an ip address.", QSTRING_CSTR(udpHost) );
}
else
{
Debug( _log, "Failed to parse [%s] as an ip address.", QSTRING_CSTR( host ) );
QHostInfo info = QHostInfo::fromName(host);
Debug( _log, "Failed to parse [%s] as an ip address.", QSTRING_CSTR(udpHost) );
QHostInfo info = QHostInfo::fromName(udpHost);
if ( info.addresses().isEmpty() )
{
Debug( _log, "Failed to parse [%s] as a hostname.", QSTRING_CSTR( host ) );
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;
}
else
{
Debug( _log, "Successfully parsed %s as a hostname.", QSTRING_CSTR( host ) );
Debug( _log, "Successfully parsed %s as a hostname.", QSTRING_CSTR(udpHost) );
_address = info.addresses().first();
}
}
Expand Down