mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 00:35:26 +03:00
Fix intermittent connect failure (#3515)
This commit is contained in:
parent
664e6722a8
commit
edd34a1624
3 changed files with 7 additions and 13 deletions
|
@ -761,7 +761,7 @@ export function reinitializeConnection(callback) {
|
||||||
clearInterval(reconnect);
|
clearInterval(reconnect);
|
||||||
gui_log(i18n.getMessage('deviceReady'));
|
gui_log(i18n.getMessage('deviceReady'));
|
||||||
|
|
||||||
if (callback === typeof('function')) {
|
if (typeof callback === 'function') {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import FC from '../fc';
|
||||||
import MSP from '../msp';
|
import MSP from '../msp';
|
||||||
import MSPCodes from '../msp/MSPCodes';
|
import MSPCodes from '../msp/MSPCodes';
|
||||||
import PortHandler, { usbDevices } from '../port_handler';
|
import PortHandler, { usbDevices } from '../port_handler';
|
||||||
import CONFIGURATOR, { API_VERSION_1_39, API_VERSION_1_45 } from '../data_storage';
|
import { API_VERSION_1_39, API_VERSION_1_45 } from '../data_storage';
|
||||||
import serial from '../serial';
|
import serial from '../serial';
|
||||||
import STM32DFU from '../protocols/stm32usbdfu';
|
import STM32DFU from '../protocols/stm32usbdfu';
|
||||||
import { gui_log } from '../gui_log';
|
import { gui_log } from '../gui_log';
|
||||||
|
@ -581,6 +581,7 @@ firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
function onFinishClose() {
|
function onFinishClose() {
|
||||||
MSP.clearListeners();
|
MSP.clearListeners();
|
||||||
|
MSP.disconnect_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClose(success) {
|
function onClose(success) {
|
||||||
|
@ -589,7 +590,6 @@ firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
serial.disconnect(onFinishClose);
|
serial.disconnect(onFinishClose);
|
||||||
MSP.disconnect_cleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFinish() {
|
function onFinish() {
|
||||||
|
@ -646,6 +646,7 @@ firmware_flasher.initialize = function (callback) {
|
||||||
console.log(`Requesting board information`);
|
console.log(`Requesting board information`);
|
||||||
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, () => {
|
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, () => {
|
||||||
gui_log(i18n.getMessage('apiVersionReceived', FC.CONFIG.apiVersion));
|
gui_log(i18n.getMessage('apiVersionReceived', FC.CONFIG.apiVersion));
|
||||||
|
|
||||||
if (FC.CONFIG.apiVersion.includes('null')) {
|
if (FC.CONFIG.apiVersion.includes('null')) {
|
||||||
onClose(false); // not supported
|
onClose(false); // not supported
|
||||||
} else if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
|
} else if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
|
||||||
|
@ -684,8 +685,7 @@ firmware_flasher.initialize = function (callback) {
|
||||||
if (!(serial.connected || serial.connectionId)) {
|
if (!(serial.connected || serial.connectionId)) {
|
||||||
serial.connect(port, {bitrate: baud}, onConnect);
|
serial.connect(port, {bitrate: baud}, onConnect);
|
||||||
} else {
|
} else {
|
||||||
console.warn('Attempting to connect while there still is a connection', serial.connected, serial.connectionId);
|
console.warn('Attempting to connect while there still is a connection', serial.connected, serial.connectionId, serial.openCanceled);
|
||||||
serial.disconnect();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('Releases not loaded yet');
|
console.log('Releases not loaded yet');
|
||||||
|
|
|
@ -2,7 +2,6 @@ import semver from 'semver';
|
||||||
import { i18n } from "../localization";
|
import { i18n } from "../localization";
|
||||||
import GUI, { TABS } from '../gui';
|
import GUI, { TABS } from '../gui';
|
||||||
import { tracking } from "../Analytics";
|
import { tracking } from "../Analytics";
|
||||||
import { reinitializeConnection } from '../serial_backend';
|
|
||||||
import { mspHelper } from '../msp/MSPHelper';
|
import { mspHelper } from '../msp/MSPHelper';
|
||||||
import FC from '../fc';
|
import FC from '../fc';
|
||||||
import MSP from '../msp';
|
import MSP from '../msp';
|
||||||
|
@ -296,8 +295,7 @@ ports.initialize = function (callback) {
|
||||||
|
|
||||||
const pheripheralsSelectElement = $('select[name="function-peripherals"]');
|
const pheripheralsSelectElement = $('select[name="function-peripherals"]');
|
||||||
pheripheralsSelectElement.on('change', function() {
|
pheripheralsSelectElement.on('change', function() {
|
||||||
let vtxControlSelected = undefined;
|
let vtxControlSelected, mspControlSelected;
|
||||||
let mspControlSelected = undefined;
|
|
||||||
|
|
||||||
pheripheralsSelectElement.each(function(index, element) {
|
pheripheralsSelectElement.each(function(index, element) {
|
||||||
const value = $(element).val();
|
const value = $(element).val();
|
||||||
|
@ -476,11 +474,7 @@ ports.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_to_eeprom() {
|
function save_to_eeprom() {
|
||||||
mspHelper.writeConfiguration(function() {
|
mspHelper.writeConfiguration(true);
|
||||||
GUI.tab_switch_cleanup(function() {
|
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitializeConnection);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue