1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Fix isWeb usage and missing callback (#3758)

* Fix isWeb usage

* Add missing callback

* Fix reinitialize connection
This commit is contained in:
Mark Haslinghuis 2024-01-16 13:00:42 +01:00 committed by GitHub
parent 5d553bac38
commit dcda393f7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

View file

@ -308,7 +308,8 @@ const MSP = {
return bufferOut;
},
send_message(code, data, callback_sent, callback_msp, doCallbackOnError) {
const connected = isWeb ? serial.connected : serial.connectionId;
const connected = isWeb() ? serial.connected : serial.connectionId;
if (code === undefined || !connected || CONFIGURATOR.virtualMode) {
if (callback_msp) {
callback_msp();
@ -325,12 +326,6 @@ const MSP = {
}
}
if (isWeb() && (code === undefined || !serial.connectionInfo)) {
console.log('ERROR: code undefined or no connectionId');
return false;
}
const bufferOut = code <= 254 ? this.encode_message_v1(code, data) : this.encode_message_v2(code, data);
const obj = {

View file

@ -803,7 +803,7 @@ export function reinitializeConnection(callback) {
const reconnect = setInterval(waitforSerial, 100);
function waitforSerial() {
if (connectionTimestamp !== previousTimeStamp && CONFIGURATOR.connectionValid) {
if ((connectionTimestamp !== previousTimeStamp && CONFIGURATOR.connectionValid) || GUI.active_tab === 'firmware_flasher') {
console.log(`Serial connection available after ${attempts / 10} seconds`);
clearInterval(reconnect);
gui_log(i18n.getMessage('deviceReady'));

View file

@ -1241,7 +1241,7 @@ firmware_flasher.verifyBoard = function() {
const self = this;
if (!self.isSerialPortAvailable()) {
gui_log(i18n.getMessage('firmwareFlasherNoValidPort'));
// return silently as port-picker will trigger again when port becomes available
return;
}
@ -1474,6 +1474,9 @@ firmware_flasher.backupConfig = function (callback) {
clearInterval(disconnect);
// Allow auto-detect after CLI reset
self.allowBoardDetection = true;
if (callback) {
callback();
}
}
count++;
}, 100);