From 70c839eb3a3f869672af15992e883774d5497a00 Mon Sep 17 00:00:00 2001 From: Sean Moriarty Date: Thu, 28 Jun 2018 13:36:54 -0700 Subject: [PATCH] Check for valid PID_ADVANCED values --- src/js/backup_restore.js | 62 ++++++++++++++++++++++++++++++++++-- src/js/serial_backend.js | 2 ++ src/js/tabs/configuration.js | 1 + 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/src/js/backup_restore.js b/src/js/backup_restore.js index 59d2f56e..b76ed955 100644 --- a/src/js/backup_restore.js +++ b/src/js/backup_restore.js @@ -177,9 +177,65 @@ function configuration_backup(callback) { save(); } } + + if (GUI.configuration_loaded === true) { + return fetch_unique_data_item(); + } + var promises = [ getAdvancedConfig(), getSensorConfig(), getCraftName(), getBoardAlignmentConfig(), getMixerConfig(), getBeeperConfig() ]; + Promise.all(promises). + then(function () { + fetch_unique_data_item(); + }); + - // start fetching - fetch_unique_data_item(); + } + + function getAdvancedConfig() { + return new Promise(function (resolve, reject) { + MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, function() { + resolve(); + }); + }); + } + + function getSensorConfig() { + return new Promise(function (resolve, reject) { + MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, function() { + resolve(); + }); + }); + } + + function getCraftName() { + return new Promise(function (resolve, reject) { + MSP.send_message(MSPCodes.MSP_NAME, false, false, function() { + resolve(); + }); + }); + } + + function getBoardAlignmentConfig() { + return new Promise(function (resolve, reject) { + MSP.send_message(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG, false, false, function() { + resolve(); + }); + }); + } + + function getMixerConfig() { + return new Promise(function (resolve, reject) { + MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, function() { + resolve(); + }); + }); + } + + function getBeeperConfig() { + return new Promise(function (resolve, reject) { + MSP.send_message(MSPCodes.MSP_BEEPER_CONFIG, false, false, function() { + resolve(); + }); + }); } function save() { @@ -316,7 +372,7 @@ function configuration_restore(callback) { GUI.log(i18n.getMessage('backupFileUnmigratable')); return; } - if (typeof configuration.FEATURE_CONFIG != 'undefined' && configuration.FEATURE_CONFIG.features._featureMask) { + if (configuration.FEATURE_CONFIG.features._featureMask) { var features = new Features(CONFIG); features.setMask(configuration.FEATURE_CONFIG.features._featureMask); configuration.FEATURE_CONFIG.features = features; diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index e811c7ee..30128eb9 100755 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -43,6 +43,8 @@ function initializeSerialBackend() { thisElement.data("clicks", !clicks); }; + GUI.configuration_loaded = false; + var selected_baud = parseInt($('div#port-picker #baud').val()); var selected_port = $('div#port-picker #port option:selected').data().isManual ? $('#port-override').val() : diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index 6ca6cc23..7cc86354 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -10,6 +10,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { if (GUI.active_tab != 'configuration') { GUI.active_tab = 'configuration'; + GUI.configuration_loaded = true; } if (semver.lt(CONFIG.apiVersion, "1.36.0")) {