mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-17 05:15:21 +03:00
fix_reboot
Fix clicks reinitializeConnection should be callback MSP fix
This commit is contained in:
parent
1c9ce766ba
commit
f5dab89965
12 changed files with 40 additions and 49 deletions
|
@ -911,7 +911,7 @@ function configuration_restore(callback) {
|
|||
GUI.log(i18n.getMessage('eeprom_saved_ok'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialiseConnection('setup', _callback));
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection('setup', _callback));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,9 +321,10 @@ const MSP = {
|
|||
return;
|
||||
}
|
||||
|
||||
if (code === undefined) {
|
||||
if (code === undefined || !serial.connectionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
let bufferOut;
|
||||
if (code <= 254) {
|
||||
bufferOut = this.encode_message_v1(code, data);
|
||||
|
|
|
@ -457,7 +457,7 @@ const serial = {
|
|||
if (GUI.connected_to || GUI.connecting_to) {
|
||||
$('a.connect').trigger('click');
|
||||
} else {
|
||||
self.disconnect();
|
||||
serial.disconnect();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
let mspHelper;
|
||||
let connectionTimestamp;
|
||||
let clicks = false;
|
||||
|
||||
function initializeSerialBackend() {
|
||||
GUI.updateManualPortVisibility = function(){
|
||||
|
@ -43,11 +44,8 @@ function initializeSerialBackend() {
|
|||
$('div.connect_controls a.connect').click(function () {
|
||||
if (GUI.connect_lock != true) { // GUI control overrides the user control
|
||||
|
||||
const thisElement = $(this);
|
||||
const clicks = thisElement.data('clicks');
|
||||
|
||||
const toggleStatus = function() {
|
||||
thisElement.data("clicks", !clicks);
|
||||
clicks = !clicks;
|
||||
};
|
||||
|
||||
GUI.configuration_loaded = false;
|
||||
|
@ -336,7 +334,7 @@ function abortConnect() {
|
|||
$('div#port-picker #port, div#port-picker #baud, div#port-picker #delay').prop('disabled', false);
|
||||
|
||||
// reset data
|
||||
$('div#connectbutton a.connect').data("clicks", false);
|
||||
clicks = false;
|
||||
}
|
||||
|
||||
function processBoardInfo() {
|
||||
|
@ -829,34 +827,32 @@ function update_dataflash_global() {
|
|||
}
|
||||
}
|
||||
|
||||
function reinitialiseConnection(originatorTab, callback) {
|
||||
function reinitializeConnection(originatorTab, callback) {
|
||||
|
||||
// Close connection gracefully if it still exists.
|
||||
if (serial.connectionId) {
|
||||
if (GUI.connected_to || GUI.connecting_to) {
|
||||
$('a.connect').trigger('click');
|
||||
} else {
|
||||
serial.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
||||
|
||||
let connectionTimeout = 200;
|
||||
ConfigStorage.get('connectionTimeout', function (result) {
|
||||
const result = ConfigStorage.get('connectionTimeout');
|
||||
|
||||
if (result.connectionTimeout) {
|
||||
connectionTimeout = result.connectionTimeout;
|
||||
}
|
||||
|
||||
if (FC.boardHasVcp()) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
||||
GUI.timeout_add('waiting_for_disconnect', function waiting_for_bootup() {
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}, connectionTimeout);
|
||||
//TODO: Need to work out how to do a proper reconnect here.
|
||||
// caveat: Timeouts set with `GUI.timeout_add()` are removed on disconnect.
|
||||
} else {
|
||||
GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() {
|
||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function() {
|
||||
setTimeout(() => {
|
||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false, () => {
|
||||
GUI.log(i18n.getMessage('deviceReady'));
|
||||
originatorTab.initialize(false, $('#content').scrollTop());
|
||||
});
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
|
||||
}, connectionTimeout); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
||||
}
|
||||
});
|
||||
callback?.();
|
||||
}, connectionTimeout);
|
||||
}
|
||||
|
|
|
@ -462,7 +462,7 @@ TABS.cli.read = function (readInfo) {
|
|||
CONFIGURATOR.cliActive = false;
|
||||
CONFIGURATOR.cliValid = false;
|
||||
GUI.log(i18n.getMessage('cliReboot'));
|
||||
reinitialiseConnection(self);
|
||||
reinitializeConnection(self);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -626,8 +626,7 @@ TABS.configuration.initialize = function (callback) {
|
|||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||
reinitialiseConnection(self);
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -413,8 +413,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
|
|||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||
reinitialiseConnection(self);
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1117,7 +1117,7 @@ TABS.motors.initialize = function (callback) {
|
|||
|
||||
function reboot() {
|
||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
MSP.promise(MSPCodes.MSP_SET_REBOOT, false, false).then(() => reinitialiseConnection());
|
||||
MSP.promise(MSPCodes.MSP_SET_REBOOT, false, false).then(() => reinitializeConnection(self));
|
||||
}
|
||||
|
||||
function showDialogMixerReset(message) {
|
||||
|
|
|
@ -48,8 +48,7 @@ TABS.onboard_logging.initialize = function (callback) {
|
|||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||
reinitialiseConnection(self);
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -412,8 +412,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
|
|||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||
reinitialiseConnection(self);
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -486,8 +486,7 @@ TABS.receiver.initialize = function (callback) {
|
|||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||
if (boot) {
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||
reinitialiseConnection(tab);
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(tab));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -303,8 +303,7 @@ TABS.transponder.initialize = function(callback, scrollPosition) {
|
|||
GUI.log(i18n.getMessage('transponderEepromSaved'));
|
||||
if ( $(_this).hasClass('reboot') ) {
|
||||
GUI.tab_switch_cleanup(function() {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
||||
reinitialiseConnection(self);
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue