diff --git a/assets/webconfig/js/content_index.js b/assets/webconfig/js/content_index.js
index 0aaa0819..9bb3fabb 100644
--- a/assets/webconfig/js/content_index.js
+++ b/assets/webconfig/js/content_index.js
@@ -22,6 +22,12 @@ $(document).ready( function() {
parsedServerInfoJSON = event.response;
currentVersion = parsedServerInfoJSON.info.hyperion[0].version;
cleanCurrentVersion = currentVersion.replace(/\./g, '');
+
+ // ToDo lock config menu and display appropriate message
+ if (! parsedServerInfoJSON.info.hyperion[0].config_writeable)
+ {
+ console.log("ATTENTION config is not writable");
+ }
if (parsedServerInfoJSON.info.hyperion[0].config_modified)
$("#hyperion_reload_notify").fadeIn("fast");
diff --git a/assets/webconfig/js/content_leds.js b/assets/webconfig/js/content_leds.js
index 457213bb..9c377fe9 100644
--- a/assets/webconfig/js/content_leds.js
+++ b/assets/webconfig/js/content_leds.js
@@ -472,11 +472,8 @@ $(document).ready(function() {
// ------------------------------------------------------------------
$("#leds_custom_save").off().on("click", function() {
- function createLedConfig(){
- var string = '{"leds" :'+$("#ledconfig").val()+'}';
- }
if (validateText())
- requestWriteConfig(JSON.parse(createLedConfig()));
+ requestWriteConfig(JSON.parse('{"leds" :'+$("#ledconfig").val()+'}'));
});
// ------------------------------------------------------------------
diff --git a/effects/candle.py b/effects/candle.py
index 1be744c3..f0eeaf6f 100644
--- a/effects/candle.py
+++ b/effects/candle.py
@@ -30,7 +30,7 @@ if (candles == "list") and (type(ledlist) is str):
if (i
+#include
#include
#include
#include
@@ -84,7 +85,7 @@ public:
///
void freeObjects();
- static Hyperion* initInstance(const QJsonObject& qjsonConfig, const std::string configFile);
+ static Hyperion* initInstance(const QJsonObject& qjsonConfig, const QString configFile);
static Hyperion* getInstance();
///
@@ -140,7 +141,7 @@ public:
/// get filename of configfile
/// @return the current config filename
- std::string getConfigFileName() { return _configFile; };
+ std::string getConfigFileName() { return _configFile.toStdString(); };
/// register a input source to a priority channel
/// @param name uniq name of input source
@@ -180,6 +181,8 @@ public:
bool configModified();
+ bool configWriteable();
+
public slots:
///
/// Writes a single color to all the leds for the given time and priority
@@ -314,7 +317,7 @@ private:
///
/// @param[in] qjsonConfig The Json configuration
///
- Hyperion(const QJsonObject& qjsonConfig, const std::string configFile);
+ Hyperion(const QJsonObject& qjsonConfig, const QString configFile);
/// The specifiation of the led frame construction and picture integration
LedString _ledString;
@@ -348,7 +351,7 @@ private:
const QJsonObject& _qjsonConfig;
// the name of config file
- std::string _configFile;
+ QString _configFile;
/// The timer for handling priority channel timeouts
QTimer _timer;
diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp
index 98fef676..f1bd9146 100644
--- a/libsrc/hyperion/Hyperion.cpp
+++ b/libsrc/hyperion/Hyperion.cpp
@@ -12,6 +12,7 @@
#include
#include
#include
+#include
// hyperion include
#include
@@ -32,7 +33,7 @@
Hyperion* Hyperion::_hyperion = nullptr;
-Hyperion* Hyperion::initInstance(const QJsonObject& qjsonConfig, const std::string configFile) // REMOVE jsonConfig variable when the conversion from jsonCPP to QtJSON is finished
+Hyperion* Hyperion::initInstance(const QJsonObject& qjsonConfig, const QString configFile) // REMOVE jsonConfig variable when the conversion from jsonCPP to QtJSON is finished
{
if ( Hyperion::_hyperion != nullptr )
throw std::runtime_error("Hyperion::initInstance can be called only one time");
@@ -514,7 +515,7 @@ MessageForwarder * Hyperion::getForwarder()
return _messageForwarder;
}
-Hyperion::Hyperion(const QJsonObject &qjsonConfig, const std::string configFile)
+Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
: _ledString(createLedString(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
, _ledStringClone(createLedStringClone(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
, _muxer(_ledString.leds().size())
@@ -582,6 +583,7 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const std::string configFile)
Debug(_log,"configured leds: %d hw leds: %d", getLedCount(), _hwLedCount);
WarningIf(hwLedCount < getLedCount(), _log, "more leds configured than available. check 'ledCount' in 'device' section");
+ WarningIf(!configWriteable(), _log, "Your config is not writeable - you won't be able to use the web ui for configuration.");
// initialize hash of current config
configModified();
@@ -618,7 +620,7 @@ unsigned Hyperion::getLedCount() const
bool Hyperion::configModified()
{
bool isModified = false;
- QFile f(_configFile.c_str());
+ QFile f(_configFile);
if (f.open(QFile::ReadOnly))
{
QCryptographicHash hash(QCryptographicHash::Sha1);
@@ -639,6 +641,14 @@ bool Hyperion::configModified()
return isModified;
}
+bool Hyperion::configWriteable()
+{
+ QFile file(_configFile);
+ QFileInfo fileInfo(file);
+ return fileInfo.isWritable() && fileInfo.isReadable();
+}
+
+
void Hyperion::registerPriority(const std::string name, const int priority)
{
Info(_log, "Register new input source named '%s' for priority channel '%d'", name.c_str(), priority );
diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json
index 656d5c83..e1ce0900 100644
--- a/libsrc/hyperion/hyperion.schema.json
+++ b/libsrc/hyperion/hyperion.schema.json
@@ -476,7 +476,8 @@
"priority" :
{
"type" : "integer",
- "minimum" : 0,
+ "minimum" : 2,
+ "maximum" : 2000000000,
"title" : "edt_conf_general_priority_title",
"default" : 900,
"propertyOrder" : 9
@@ -617,7 +618,8 @@
{
"type" : "integer",
"title" : "edt_conf_general_priority_title",
- "minimum" : 0,
+ "minimum" : 2,
+ "maximum" : 2000000000,
"default" : 890
},
"cropLeft" :
@@ -974,7 +976,8 @@
{
"type" : "integer",
"title" : "edt_conf_general_priority_title",
- "minimum" : 0,
+ "minimum" : 2,
+ "maximum" : 2000000000,
"default" : 800,
"propertyOrder" : 3
}
@@ -1014,7 +1017,8 @@
{
"type" : "integer",
"title" : "edt_conf_general_priority_title",
- "minimum" : 0,
+ "minimum" : 2,
+ "maximum" : 2000000000,
"default" : 800,
"propertyOrder" : 4
},
diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp
index b293c9fe..0709613d 100644
--- a/libsrc/jsonserver/JsonClientConnection.cpp
+++ b/libsrc/jsonserver/JsonClientConnection.cpp
@@ -841,6 +841,7 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
ver["build"] = QString(HYPERION_BUILD_ID);
ver["time"] = QString(__DATE__ " " __TIME__);
ver["config_modified"] = _hyperion->configModified();
+ ver["config_writeable"] = _hyperion->configWriteable();
hyperion.append(ver);
info["hyperion"] = hyperion;
diff --git a/libsrc/leddevice/LedDeviceAdalight.cpp b/libsrc/leddevice/LedDeviceAdalight.cpp
index f005770f..f25e884d 100644
--- a/libsrc/leddevice/LedDeviceAdalight.cpp
+++ b/libsrc/leddevice/LedDeviceAdalight.cpp
@@ -2,6 +2,7 @@
LedDeviceAdalight::LedDeviceAdalight(const QJsonObject &deviceConfig)
: ProviderRs232()
+ , _headerSize(6)
, _ligthBerryAPA102Mode(false)
{
_deviceReady = init(deviceConfig);
@@ -18,7 +19,6 @@ bool LedDeviceAdalight::init(const QJsonObject &deviceConfig)
_ligthBerryAPA102Mode = deviceConfig["lightberry_apa102_mode"].toBool(false);
// create ledBuffer
- unsigned int bufferSize = 6; // 6 bytes header
unsigned int totalLedCount = _ledCount;
if (_ligthBerryAPA102Mode)
@@ -26,25 +26,30 @@ bool LedDeviceAdalight::init(const QJsonObject &deviceConfig)
const unsigned int startFrameSize = 4;
const unsigned int bytesPerRGBLed = 4;
const unsigned int endFrameSize = std::max(((_ledCount + 15) / 16), bytesPerRGBLed);
- bufferSize += (_ledCount * bytesPerRGBLed) + startFrameSize + endFrameSize ;
+ _ledBuffer.resize(_headerSize + (_ledCount * bytesPerRGBLed) + startFrameSize + endFrameSize, 0x00);
+
+ // init constant data values
+ for (signed iLed=1; iLed<=_ledCount; iLed++)
+ {
+ _ledBuffer[iLed*4+_headerSize] = 0xFF;
+ }
+ Debug( _log, "Adalight driver with activated LightBerry APA102 mode");
}
else
{
totalLedCount -= 1;
- bufferSize += _ledRGBCount;
+ _ledBuffer.resize(_headerSize + _ledRGBCount, 0x00);
}
- _ledBuffer.resize(bufferSize, 0x00);
_ledBuffer[0] = 'A';
_ledBuffer[1] = 'd';
_ledBuffer[2] = 'a';
- _ledBuffer[3] = (((unsigned int)(totalLedCount)) >> 8) & 0xFF; // LED count high byte
- _ledBuffer[4] = ((unsigned int)(totalLedCount)) & 0xFF; // LED count low byte
+ _ledBuffer[3] = (totalLedCount >> 8) & 0xFF; // LED count high byte
+ _ledBuffer[4] = totalLedCount & 0xFF; // LED count low byte
_ledBuffer[5] = _ledBuffer[3] ^ _ledBuffer[4] ^ 0x55; // Checksum
Debug( _log, "Adalight header for %d leds: %c%c%c 0x%02x 0x%02x 0x%02x", _ledCount,
- _ledBuffer[0], _ledBuffer[1], _ledBuffer[2], _ledBuffer[3], _ledBuffer[4], _ledBuffer[5]
- );
+ _ledBuffer[0], _ledBuffer[1], _ledBuffer[2], _ledBuffer[3], _ledBuffer[4], _ledBuffer[5] );
return true;
}
@@ -56,15 +61,14 @@ int LedDeviceAdalight::write(const std::vector & ledValues)
for (signed iLed=1; iLed<=_ledCount; iLed++)
{
const ColorRgb& rgb = ledValues[iLed-1];
- _ledBuffer[iLed*4+6] = 0xFF;
- _ledBuffer[iLed*4+1+6] = rgb.red;
- _ledBuffer[iLed*4+2+6] = rgb.green;
- _ledBuffer[iLed*4+3+6] = rgb.blue;
+ _ledBuffer[iLed*4+7] = rgb.red;
+ _ledBuffer[iLed*4+8] = rgb.green;
+ _ledBuffer[iLed*4+9] = rgb.blue;
}
}
else
{
- memcpy(6 + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3);
+ memcpy(_headerSize + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3);
}
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
diff --git a/libsrc/leddevice/LedDeviceAdalight.h b/libsrc/leddevice/LedDeviceAdalight.h
index 3e5120e4..765f4586 100644
--- a/libsrc/leddevice/LedDeviceAdalight.h
+++ b/libsrc/leddevice/LedDeviceAdalight.h
@@ -31,6 +31,7 @@ private:
///
virtual int write(const std::vector & ledValues);
+ const short _headerSize;
bool _ligthBerryAPA102Mode;
};
diff --git a/libsrc/leddevice/LedDevicePhilipsHue.cpp b/libsrc/leddevice/LedDevicePhilipsHue.cpp
index 8f34d8e7..077d8d45 100755
--- a/libsrc/leddevice/LedDevicePhilipsHue.cpp
+++ b/libsrc/leddevice/LedDevicePhilipsHue.cpp
@@ -369,7 +369,9 @@ void LedDevicePhilipsHue::saveStates(unsigned int nLights)
if (error.error != QJsonParseError::NoError)
{
// Error occured, break loop.
- Error(_log, "saveStates(nLights=%d): got invalid response from light %s.", nLights, getUrl(getRoute(lightIds.at(i))).toStdString().c_str());
+ Error(_log, "saveStates(nLights=%d): got invalid response from light %s. (error:%s, offset:%d)",
+ nLights, getUrl(getRoute(lightIds.at(i))).toStdString().c_str(), error.errorString().toLocal8Bit().constData(), error.offset );
+
break;
}
diff --git a/libsrc/leddevice/LedDeviceTpm2.cpp b/libsrc/leddevice/LedDeviceTpm2.cpp
index abf6012c..24210089 100644
--- a/libsrc/leddevice/LedDeviceTpm2.cpp
+++ b/libsrc/leddevice/LedDeviceTpm2.cpp
@@ -16,11 +16,11 @@ bool LedDeviceTpm2::init(const QJsonObject &deviceConfig)
{
ProviderRs232::init(deviceConfig);
- _ledBuffer.resize(5 + 3*_ledCount);
+ _ledBuffer.resize(5 + _ledRGBCount);
_ledBuffer[0] = 0xC9; // block-start byte
_ledBuffer[1] = 0xDA; // DATA frame
- _ledBuffer[2] = ((3 * _ledCount) >> 8) & 0xFF; // frame size high byte
- _ledBuffer[3] = (3 * _ledCount) & 0xFF; // frame size low byte
+ _ledBuffer[2] = (_ledRGBCount >> 8) & 0xFF; // frame size high byte
+ _ledBuffer[3] = _ledRGBCount & 0xFF; // frame size low byte
_ledBuffer.back() = 0x36; // block-end byte
return true;
diff --git a/libsrc/leddevice/schemas/schema-adalight.json b/libsrc/leddevice/schemas/schema-adalight.json
index b5ff4526..19946533 100644
--- a/libsrc/leddevice/schemas/schema-adalight.json
+++ b/libsrc/leddevice/schemas/schema-adalight.json
@@ -17,7 +17,7 @@
"delayAfterConnect": {
"type": "integer",
"title":"edt_dev_spec_delayAfterConnect_title",
- "default": 250,
+ "default": 1500,
"append" : "ms",
"propertyOrder" : 3
},
diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp
index 577af4a4..04d931ef 100644
--- a/src/hyperiond/hyperiond.cpp
+++ b/src/hyperiond/hyperiond.cpp
@@ -69,12 +69,12 @@ HyperionDaemon::HyperionDaemon(QString configFile, QObject *parent)
}
else
{
- WarningIf(_qconfig.contains("logger"), Logger::getInstance("LOGGER"), "Logger settings overriden by command line argument");
+ WarningIf(_qconfig.contains("logger"), Logger::getInstance("LOGGER"), "Logger settings overridden by command line argument");
}
- _hyperion = Hyperion::initInstance(_qconfig, configFile.toStdString());
+ _hyperion = Hyperion::initInstance(_qconfig, configFile);
- Info(_log, "Hyperion initialised");
+ Info(_log, "Hyperion initialized");
}
HyperionDaemon::~HyperionDaemon()