mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-17 21:35:33 +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.log(i18n.getMessage('eeprom_saved_ok'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code === undefined) {
|
if (code === undefined || !serial.connectionId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bufferOut;
|
let bufferOut;
|
||||||
if (code <= 254) {
|
if (code <= 254) {
|
||||||
bufferOut = this.encode_message_v1(code, data);
|
bufferOut = this.encode_message_v1(code, data);
|
||||||
|
|
|
@ -457,7 +457,7 @@ const serial = {
|
||||||
if (GUI.connected_to || GUI.connecting_to) {
|
if (GUI.connected_to || GUI.connecting_to) {
|
||||||
$('a.connect').trigger('click');
|
$('a.connect').trigger('click');
|
||||||
} else {
|
} else {
|
||||||
self.disconnect();
|
serial.disconnect();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
let mspHelper;
|
let mspHelper;
|
||||||
let connectionTimestamp;
|
let connectionTimestamp;
|
||||||
|
let clicks = false;
|
||||||
|
|
||||||
function initializeSerialBackend() {
|
function initializeSerialBackend() {
|
||||||
GUI.updateManualPortVisibility = function(){
|
GUI.updateManualPortVisibility = function(){
|
||||||
|
@ -43,11 +44,8 @@ function initializeSerialBackend() {
|
||||||
$('div.connect_controls a.connect').click(function () {
|
$('div.connect_controls a.connect').click(function () {
|
||||||
if (GUI.connect_lock != true) { // GUI control overrides the user control
|
if (GUI.connect_lock != true) { // GUI control overrides the user control
|
||||||
|
|
||||||
const thisElement = $(this);
|
|
||||||
const clicks = thisElement.data('clicks');
|
|
||||||
|
|
||||||
const toggleStatus = function() {
|
const toggleStatus = function() {
|
||||||
thisElement.data("clicks", !clicks);
|
clicks = !clicks;
|
||||||
};
|
};
|
||||||
|
|
||||||
GUI.configuration_loaded = false;
|
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);
|
$('div#port-picker #port, div#port-picker #baud, div#port-picker #delay').prop('disabled', false);
|
||||||
|
|
||||||
// reset data
|
// reset data
|
||||||
$('div#connectbutton a.connect').data("clicks", false);
|
clicks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processBoardInfo() {
|
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'));
|
GUI.log(i18n.getMessage('deviceRebooting'));
|
||||||
|
|
||||||
let connectionTimeout = 200;
|
let connectionTimeout = 200;
|
||||||
ConfigStorage.get('connectionTimeout', function (result) {
|
const result = ConfigStorage.get('connectionTimeout');
|
||||||
|
|
||||||
if (result.connectionTimeout) {
|
if (result.connectionTimeout) {
|
||||||
connectionTimeout = result.connectionTimeout;
|
connectionTimeout = result.connectionTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FC.boardHasVcp()) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
setTimeout(() => {
|
||||||
GUI.timeout_add('waiting_for_disconnect', function waiting_for_bootup() {
|
MSP.send_message(MSPCodes.MSP_STATUS, false, false, () => {
|
||||||
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() {
|
|
||||||
GUI.log(i18n.getMessage('deviceReady'));
|
GUI.log(i18n.getMessage('deviceReady'));
|
||||||
originatorTab.initialize(false, $('#content').scrollTop());
|
originatorTab.initialize(false, $('#content').scrollTop());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (callback) {
|
callback?.();
|
||||||
callback();
|
}, connectionTimeout);
|
||||||
}
|
|
||||||
|
|
||||||
}, connectionTimeout); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -462,7 +462,7 @@ TABS.cli.read = function (readInfo) {
|
||||||
CONFIGURATOR.cliActive = false;
|
CONFIGURATOR.cliActive = false;
|
||||||
CONFIGURATOR.cliValid = false;
|
CONFIGURATOR.cliValid = false;
|
||||||
GUI.log(i18n.getMessage('cliReboot'));
|
GUI.log(i18n.getMessage('cliReboot'));
|
||||||
reinitialiseConnection(self);
|
reinitializeConnection(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,8 +626,7 @@ TABS.configuration.initialize = function (callback) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||||
reinitialiseConnection(self);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,8 +413,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||||
reinitialiseConnection(self);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1117,7 +1117,7 @@ TABS.motors.initialize = function (callback) {
|
||||||
|
|
||||||
function reboot() {
|
function reboot() {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
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) {
|
function showDialogMixerReset(message) {
|
||||||
|
|
|
@ -48,8 +48,7 @@ TABS.onboard_logging.initialize = function (callback) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||||
reinitialiseConnection(self);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,8 +412,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||||
reinitialiseConnection(self);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,8 +486,7 @@ TABS.receiver.initialize = function (callback) {
|
||||||
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
GUI.log(i18n.getMessage('configurationEepromSaved'));
|
||||||
if (boot) {
|
if (boot) {
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(tab));
|
||||||
reinitialiseConnection(tab);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,8 +303,7 @@ TABS.transponder.initialize = function(callback, scrollPosition) {
|
||||||
GUI.log(i18n.getMessage('transponderEepromSaved'));
|
GUI.log(i18n.getMessage('transponderEepromSaved'));
|
||||||
if ( $(_this).hasClass('reboot') ) {
|
if ( $(_this).hasClass('reboot') ) {
|
||||||
GUI.tab_switch_cleanup(function() {
|
GUI.tab_switch_cleanup(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false);
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection(self));
|
||||||
reinitialiseConnection(self);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue