diff --git a/companion/src/firmwares/edgetx/edgetxinterface.cpp b/companion/src/firmwares/edgetx/edgetxinterface.cpp index 8c704ef92..3ca78fccc 100644 --- a/companion/src/firmwares/edgetx/edgetxinterface.cpp +++ b/companion/src/firmwares/edgetx/edgetxinterface.cpp @@ -94,6 +94,14 @@ bool loadRadioSettingsFromYaml(GeneralSettings& settings, const QByteArray& data try { YAML::Node node = loadYamlFromByteArray(data); node >> settings; + if (settings.version < CPN_CURRENT_SETTINGS_VERSION) { + qDebug() << "Older version of settings detected:" << settings.version; + } + else if (settings.version > CPN_CURRENT_SETTINGS_VERSION) { + qDebug() << "Newer version of settings detected:" << settings.version; + QMessageBox::critical(NULL, CPN_STR_APP_NAME, QCoreApplication::translate("EdgeTXInterface", "Companion does not support settings version %1!").arg(settings.version)); + return false; + } } catch (const std::runtime_error& e) { qDebug() << "YAML::ParserException: " << e.what(); return false; diff --git a/companion/src/firmwares/edgetx/edgetxinterface.h b/companion/src/firmwares/edgetx/edgetxinterface.h index e3743c829..e82771562 100644 --- a/companion/src/firmwares/edgetx/edgetxinterface.h +++ b/companion/src/firmwares/edgetx/edgetxinterface.h @@ -27,6 +27,8 @@ #include #include +constexpr unsigned int CPN_CURRENT_SETTINGS_VERSION = { 221 }; + typedef std::pair EtxModelfileCategoryPair; typedef std::list EtxModelfiles; diff --git a/companion/src/firmwares/edgetx/yaml_generalsettings.h b/companion/src/firmwares/edgetx/yaml_generalsettings.h index 2548d6b73..cd398631b 100644 --- a/companion/src/firmwares/edgetx/yaml_generalsettings.h +++ b/companion/src/firmwares/edgetx/yaml_generalsettings.h @@ -25,6 +25,7 @@ #include "generalsettings.h" #include "eeprominterface.h" +#include "edgetxinterface.h" extern const YamlLookupTable beeperModeLut; extern const YamlLookupTable backlightModeLut; @@ -41,8 +42,8 @@ namespace YAML { static YAML::Node encode(const GeneralSettings& rhs) { Node node; - - node["version"] = rhs.version; + + node["version"] = CPN_CURRENT_SETTINGS_VERSION; // Radio calib YamlCalibData calib(rhs.calibMid, rhs.calibSpanNeg, rhs.calibSpanPos); @@ -135,11 +136,11 @@ namespace YAML { static bool decode(const Node& node, GeneralSettings& rhs) { if (!node.IsMap()) return false; - + // for (const auto& n : node) { // qDebug() << QString::fromStdString(n.first.Scalar()); // } - + // TODO: check board string and fetch Board instance std::string board; node["board"] >> board; @@ -226,7 +227,7 @@ namespace YAML { YamlStickConfig stickConfig; node["sticksConfig"] >> stickConfig; stickConfig.copy(rhs.stickName); - + YamlSwitchConfig switchConfig; node["switchConfig"] >> switchConfig; switchConfig.copy(rhs.switchName, rhs.switchConfig); @@ -250,7 +251,7 @@ namespace YAML { // OneBit sampling (X9D only?) node["uartSampleMode"] >> rhs.uartSampleMode; - + return true; } }; diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 2ca769f35..e3e9761b5 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -254,7 +254,7 @@ unsigned long OpenTxEepromInterface::load(RadioData &radioData, const uint8_t * errors.set(HAS_WARNINGS); } else if (version_error == NOT_OPENTX) { - dbg << " not open9x"; + dbg << " not OpenTX"; errors.set(version_error); return errors.to_ulong(); } @@ -286,7 +286,7 @@ unsigned long OpenTxEepromInterface::load(RadioData &radioData, const uint8_t * uint8_t OpenTxEepromInterface::getLastDataVersion(Board::Type board) { - return 220; + return 220; // Note: this is the last bin format before the switch to YAML introduced in Companion version 2.6 } void OpenTxEepromInterface::showErrors(const QString & title, const QStringList & errors)