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:
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "eeprominterface.h"
|
#include "eeprominterface.h"
|
||||||
#include "edgetxinterface.h"
|
#include "edgetxinterface.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
@@ -143,11 +144,11 @@ Node convert<GeneralSettings>::encode(const GeneralSettings& rhs)
|
|||||||
{
|
{
|
||||||
Node node;
|
Node node;
|
||||||
|
|
||||||
|
node["semver"] = VERSION;
|
||||||
|
|
||||||
std::string board = getCurrentFirmware()->getFlavour().toStdString();
|
std::string board = getCurrentFirmware()->getFlavour().toStdString();
|
||||||
node["board"] = board;
|
node["board"] = board;
|
||||||
|
|
||||||
node["version"] = CPN_CURRENT_SETTINGS_VERSION;
|
|
||||||
|
|
||||||
YamlCalibData calib(rhs.calibMid, rhs.calibSpanNeg, rhs.calibSpanPos);
|
YamlCalibData calib(rhs.calibMid, rhs.calibSpanNeg, rhs.calibSpanPos);
|
||||||
node["calib"] = calib;
|
node["calib"] = calib;
|
||||||
|
|
||||||
@@ -282,7 +283,8 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
|||||||
// qDebug() << QString::fromStdString(n.first.Scalar());
|
// 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
|
// Decoding uses profile firmare therefore all conversions are performed on the fly
|
||||||
// So set board to firmware board
|
// So set board to firmware board
|
||||||
@@ -303,7 +305,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
|
|||||||
|
|
||||||
auto fw = getCurrentFirmware();
|
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()) {
|
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?");
|
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 "modeldata.h"
|
||||||
#include "output_data.h"
|
#include "output_data.h"
|
||||||
#include "eeprominterface.h"
|
#include "eeprominterface.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -741,6 +742,8 @@ Node convert<ModelData>::encode(const ModelData& rhs)
|
|||||||
Node node;
|
Node node;
|
||||||
auto board = getCurrentBoard();
|
auto board = getCurrentBoard();
|
||||||
|
|
||||||
|
node["semver"] = VERSION;
|
||||||
|
|
||||||
Node header;
|
Node header;
|
||||||
header["name"] = rhs.name;
|
header["name"] = rhs.name;
|
||||||
header["bitmap"] = rhs.bitmap;
|
header["bitmap"] = rhs.bitmap;
|
||||||
@@ -980,6 +983,8 @@ bool convert<ModelData>::decode(const Node& node, ModelData& rhs)
|
|||||||
unsigned int modelIds[CPN_MAX_MODULES];
|
unsigned int modelIds[CPN_MAX_MODULES];
|
||||||
memset(modelIds, 0, sizeof(modelIds));
|
memset(modelIds, 0, sizeof(modelIds));
|
||||||
|
|
||||||
|
node["semver"] >> rhs.semver;
|
||||||
|
|
||||||
if (node["header"]) {
|
if (node["header"]) {
|
||||||
const auto& header = node["header"];
|
const auto& header = node["header"];
|
||||||
if (header.IsMap()) {
|
if (header.IsMap()) {
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ class GeneralSettings {
|
|||||||
RawSource getDefaultSource(unsigned int channel) const;
|
RawSource getDefaultSource(unsigned int channel) const;
|
||||||
int getDefaultChannel(unsigned int stick) const;
|
int getDefaultChannel(unsigned int stick) const;
|
||||||
|
|
||||||
|
char semver[8 + 1];
|
||||||
unsigned int version;
|
unsigned int version;
|
||||||
unsigned int variant;
|
unsigned int variant;
|
||||||
int calibMid[CPN_MAX_ANALOGS];
|
int calibMid[CPN_MAX_ANALOGS];
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ class ModelData {
|
|||||||
QVector<const ExpoData *> expos(int input) const;
|
QVector<const ExpoData *> expos(int input) const;
|
||||||
QVector<const MixData *> mixes(int channel) const;
|
QVector<const MixData *> mixes(int channel) const;
|
||||||
|
|
||||||
|
char semver[8 + 1];
|
||||||
bool used;
|
bool used;
|
||||||
int category;
|
int category;
|
||||||
char name[15+1];
|
char name[15+1];
|
||||||
|
|||||||
Reference in New Issue
Block a user