From fa270406f0a4729c7ae31c54782d8036b5ff9a70 Mon Sep 17 00:00:00 2001 From: elral <3263285+elral@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:24:27 +0100 Subject: [PATCH] Check FW capabilities against CoreVersion (#1870) * Firmware features are now checked against CoreVersion * add object clone() --- MobiFlight/MobiFlightModule.cs | 13 ++++++++++--- UI/Panels/Settings/MobiFlightPanel.cs | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/MobiFlight/MobiFlightModule.cs b/MobiFlight/MobiFlightModule.cs index abacfdbc..5c3c75ce 100644 --- a/MobiFlight/MobiFlightModule.cs +++ b/MobiFlight/MobiFlightModule.cs @@ -248,6 +248,13 @@ public MobiFlightModule(MobiFlightModuleInfo moduleInfo) HardwareId = moduleInfo.HardwareId; } + public object Clone() + { + var clone = new MobiFlightModule(this.ToMobiFlightModuleInfo()); + clone.CoreVersion = this.CoreVersion; + return clone; + } + public void Connect() { if (this.Connected) @@ -957,7 +964,7 @@ private static string FallbackCoreVersion(string version, Board board) // Official partner boards were only built with > 2.5.0 if (board?.PartnerLevel == BoardPartnerLevel.Partner) return "2.5.0"; - return null; + return version; } public bool SaveName() @@ -1281,7 +1288,7 @@ public void SetPowerSaveMode(bool mode) public bool GenerateNewSerial() { System.Version minVersion = new System.Version("1.3.0"); - System.Version currentVersion = new System.Version(Version != null ? Version : "0.0.0"); + System.Version currentVersion = new System.Version(CoreVersion != null ? CoreVersion : "0.0.0"); if (currentVersion.CompareTo(minVersion) < 0) { throw new FirmwareVersionTooLowException(minVersion, currentVersion); @@ -1297,7 +1304,7 @@ public bool HasFirmwareFeature(String FirmwareFeature) if (IsPullRequestBuild) return true; System.Version minVersion = new System.Version(FirmwareFeature); - System.Version currentVersion = new System.Version(Version != null ? Version : "0.0.0"); + System.Version currentVersion = new System.Version(CoreVersion != null ? CoreVersion : "0.0.0"); return (currentVersion.CompareTo(minVersion) >= 0); } diff --git a/UI/Panels/Settings/MobiFlightPanel.cs b/UI/Panels/Settings/MobiFlightPanel.cs index 032c3a92..aa81d853 100644 --- a/UI/Panels/Settings/MobiFlightPanel.cs +++ b/UI/Panels/Settings/MobiFlightPanel.cs @@ -1282,7 +1282,8 @@ private MobiFlightModule getVirtualModuleFromTree() TreeNode moduleNode = getModuleNode(); if (moduleNode == null) return null; - MobiFlightModule module = new MobiFlightModule((moduleNode.Tag as MobiFlightModule).ToMobiFlightModuleInfo()); + var module = (moduleNode.Tag as MobiFlightModule).Clone() as MobiFlightModule; + // Generate config MobiFlight.Config.Config newConfig = new MobiFlight.Config.Config(); foreach (TreeNode node in moduleNode.Nodes)