From 92c11394afae4d92032576bb73def080659b8aa5 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Thu, 15 Feb 2024 22:41:29 +0100 Subject: [PATCH] Prevent issues with corrupted firmware using outdated configurator (#3793) * Deny use of newer firmware not supported by configurator * Update dialog * Abort on dialog * Update message --- locales/en/messages.json | 6 +++--- src/js/serial_backend.js | 19 +++++++++++++++---- src/js/utils/checkForConfiguratorUpdates.js | 2 ++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/locales/en/messages.json b/locales/en/messages.json index 429911ed99..b3a33b23ad 100755 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -267,7 +267,7 @@ "message": "You are using an outdated version of the Betaflight Configurator.
$t(configuratorUpdateHelp.message)" }, "configuratorUpdateHelp": { - "message": "Using a newer version of the firmware with an outdated version of Configurator means that changing some settings will result in a corrupted firmware configuration and a non-working craft. Furthermore, some features of the firmware will only be configurable in CLI.
Betaflight Configurator version $1 is available for download online, please visit this page to download and install the latest version with fixes and improvements.
Please close the configurator window before updating." + "message": "Using a newer version of the firmware with an outdated version of Configurator means that changing some settings will result in a corrupted firmware configuration and a non-working craft.
Furthermore, some features of the firmware will only be configurable in CLI.

Betaflight Configurator version $1 is available for download online.
Download and install the latest version of configurator with fixes and improvements here
Configurator window needs to be closed before updating." }, "configuratorUpdateWebsite": { "message": "Go to Release Website" @@ -517,10 +517,10 @@ "message": "The following problems with your configuration were detected:" }, "reportProblemsDialogFooter": { - "message": "Please fix these problems before attempting to fly your craft." + "message": "You need to fix these problems before attempting to fly your craft." }, "reportProblemsDialogAPI_VERSION_MAX_SUPPORTED": { - "message": "the version of configurator that you are using ($3) is older than the firmware you are using ($4).
$t(configuratorUpdateHelp.message)" + "message": "The configurator version used ($3) does not support firmware $4.
$t(configuratorUpdateHelp.message)" }, "reportProblemsDialogMOTOR_PROTOCOL_DISABLED": { "message": "there is no motor output protocol selected.
Please select a motor output protocol appropriate for your ESCs in '$t(configurationEscFeatures.message)' on the '$t(tabMotorTesting.message)' tab.
$t(escProtocolDisabledMessage.message)" diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 3930535779..62ef4d79e5 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -487,18 +487,26 @@ function checkReportProblems() { problemDialogList.empty(); let problems = []; + let abort = false; if (semver.gt(FC.CONFIG.apiVersion, CONFIGURATOR.API_VERSION_MAX_SUPPORTED)) { const problemName = 'API_VERSION_MAX_SUPPORTED'; problems.push({ name: problemName, description: i18n.getMessage(`reportProblemsDialog${problemName}`, [CONFIGURATOR.latestVersion, CONFIGURATOR.latestVersionReleaseUrl, CONFIGURATOR.getDisplayVersion(), FC.CONFIG.flightControllerVersion])}); needsProblemReportingDialog = true; + + abort = true; + GUI.timeout_remove('connecting'); // kill connecting timer + $('div.connect_controls a.connect').click(); // disconnect } - needsProblemReportingDialog = checkReportProblem('MOTOR_PROTOCOL_DISABLED', problems) || needsProblemReportingDialog; + if (!abort) { + // only check for problems if we are not already aborting + needsProblemReportingDialog = checkReportProblem('MOTOR_PROTOCOL_DISABLED', problems) || needsProblemReportingDialog; - if (have_sensor(FC.CONFIG.activeSensors, 'acc')) { - needsProblemReportingDialog = checkReportProblem('ACC_NEEDS_CALIBRATION', problems) || needsProblemReportingDialog; + if (have_sensor(FC.CONFIG.activeSensors, 'acc')) { + needsProblemReportingDialog = checkReportProblem('ACC_NEEDS_CALIBRATION', problems) || needsProblemReportingDialog; + } } if (needsProblemReportingDialog) { @@ -519,7 +527,10 @@ function checkReportProblems() { $('#dialogReportProblems-closebtn').focus(); } - processUid(); + if (!abort) { + // if we are not aborting, we can continue + processUid(); + } }); } diff --git a/src/js/utils/checkForConfiguratorUpdates.js b/src/js/utils/checkForConfiguratorUpdates.js index d54cf7ab65..0703e1d67c 100644 --- a/src/js/utils/checkForConfiguratorUpdates.js +++ b/src/js/utils/checkForConfiguratorUpdates.js @@ -35,6 +35,8 @@ function notifyOutdatedVersion(data) { }); dialog.showModal(); + } else { + CONFIGURATOR.latestVersion = data.version; } }