Adalight - HyperSerial Support (#1515)

* HyperSerial support

* Migrate Adalight records to new structure

* Serial Devices - Select baud rate and allow providing a custom one
This commit is contained in:
LordGrey
2022-09-30 17:02:40 +02:00
committed by GitHub
parent e8fc8a9855
commit 9df21b9ddd
12 changed files with 539 additions and 113 deletions

View File

@@ -699,6 +699,59 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
}
}
}
//Migration steps for versions <= 2.0.13
targetVersion.setVersion("2.0.13");
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("type"))
{
QString type = newDeviceConfig["type"].toString();
const QStringList serialDevices {"adalight", "dmx", "atmo", "sedu", "tpm2", "karate"};
if ( serialDevices.contains(type ))
{
if (!newDeviceConfig.contains("rateList"))
{
newDeviceConfig["rateList"] = "CUSTOM";
migrated = true;
}
}
if (type == "adalight")
{
if (newDeviceConfig.contains("lightberry_apa102_mode"))
{
bool lightberry_apa102_mode = newDeviceConfig["lightberry_apa102_mode"].toBool();
if (lightberry_apa102_mode)
{
newDeviceConfig["streamProtocol"] = "1";
}
else
{
newDeviceConfig["streamProtocol"] = "0";
}
newDeviceConfig.remove("lightberry_apa102_mode");
migrated = true;
}
}
}
if (migrated)
{
config["device"] = newDeviceConfig;
Debug(_log, "LED-Device records migrated");
}
}
}
}
}
return migrated;