fix: Companion will set critical radio general settings to profile defaults if mismatched boards (#1575)

* Do not import potentially conflicting radio settings

* Revert "Do not import potentially conflicting radio settings"

This reverts commit 06a19c04d6de341568362b87311264081aa3d38f.

* Override critical general settings to defaults when board mismatch
This commit is contained in:
Neil Horne
2022-03-08 11:49:34 +10:00
committed by GitHub
parent f764dfcc2e
commit 70a4f6c154
3 changed files with 22 additions and 6 deletions
@@ -264,6 +264,12 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
// If conversion should rename file with _converted suffix as done for bin
// Need to pass back messages and flags like converted so they can be handled in a more suitable section
// Note: This is part of an interim workaround to ensure critical settings are set to profile board defaults
// TODO: remove and let board conversion occur as for eeprom and profile
// this will require yaml import of general and model settings to be refactored to not use current firmware
bool needsConversion = false;
//
rhs.variant = Board::BOARD_UNKNOWN;
std::string flavour;
@@ -280,6 +286,7 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
return false;
}
flavour = fw->getFlavour().toStdString();
needsConversion = true;
}
else if (fw->getFlavour().toStdString() != flavour) {
auto msfw = Firmware::getFirmwareForFlavour(QString(flavour.c_str()));
@@ -290,8 +297,10 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
// TODO: this triggers an error in the calling code so we need a graceful way to handle
return false;
}
needsConversion = true;
}
// TODO: do not override here
rhs.variant = fw->getBoard();
YamlCalibData calib;
@@ -399,6 +408,11 @@ bool convert<GeneralSettings>::decode(const Node& node, GeneralSettings& rhs)
// OneBit sampling (X9D only?)
node["uartSampleMode"] >> rhs.uartSampleMode;
// override critical settings after import
// TODO: for consistency move up call stack to use existing eeprom and profile conversions
if (needsConversion)
rhs.init();
return true;
}
} // namespace YAML