chore(cpn): read/write semver in model and radio yml files (#1977)

Companion part of #1695, making it so companion is not removing written semver
This commit is contained in:
Neil Horne
2022-06-04 11:09:39 +10:00
committed by GitHub
parent d70828579e
commit 077abf719d
4 changed files with 13 additions and 4 deletions
@@ -27,6 +27,7 @@
#include "eeprominterface.h"
#include "edgetxinterface.h"
#include "version.h"
#include <QMessageBox>
@@ -143,11 +144,11 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
{
Node node;
node["semver"] = VERSION;
std::string board = getCurrentFirmware()->getFlavour().toStdString();
node["board"] = board;
node["version"] = CPN_CURRENT_SETTINGS_VERSION;
YamlCalibData calib(rhs.calibMid, rhs.calibSpanNeg, rhs.calibSpanPos);
node["calib"] = calib;
@@ -282,7 +283,8 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
// qDebug() << QString::fromStdString(n.first.Scalar());
// }
node["version"] >> rhs.version;
node["semver"] >> rhs.semver;
rhs.version = CPN_CURRENT_SETTINGS_VERSION; // depreciated in EdgeTX however data conversions use
// Decoding uses profile firmare therefore all conversions are performed on the fly
// So set board to firmware board
@@ -303,7 +305,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
auto fw = getCurrentFirmware();
qDebug() << "Settings version:" << rhs.version << "File flavour:" << flavour.c_str() << "Firmware flavour:" << fw->getFlavour();
qDebug() << "Settings version:" << rhs.semver << "File flavour:" << flavour.c_str() << "Firmware flavour:" << fw->getFlavour();
if (flavour.empty()) {
QString prmpt = QCoreApplication::translate("YamlGeneralSettings", "Warning: Radio settings file is missing the board entry!\n\nCurrent firmware profile board will be used.\n\nDo you wish to continue?");
@@ -33,6 +33,7 @@
#include "modeldata.h"
#include "output_data.h"
#include "eeprominterface.h"
#include "version.h"
#include <string>
@@ -741,6 +742,8 @@ Node convert<ModelData>::encode(const ModelData& rhs)
Node node;
auto board = getCurrentBoard();
node["semver"] = VERSION;
Node header;
header["name"] = rhs.name;
header["bitmap"] = rhs.bitmap;
@@ -980,6 +983,8 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
unsigned int modelIds[CPN_MAX_MODULES];
memset(modelIds, 0, sizeof(modelIds));
node["semver"] >> rhs.semver;
if (node["header"]) {
const auto& header = node["header"];
if (header.IsMap()) {
@@ -163,6 +163,7 @@ class GeneralSettings {
RawSource getDefaultSource(unsigned int channel) const;
int getDefaultChannel(unsigned int stick) const;
char semver[8 + 1];
unsigned int version;
unsigned int variant;
int calibMid[CPN_MAX_ANALOGS];
+1
View File
@@ -109,6 +109,7 @@ class ModelData {
QVector<const ExpoData *> expos(int input) const;
QVector<const MixData *> mixes(int channel) const;
char semver[8 + 1];
bool used;
int category;
char name[15+1];