Skip to content

Commit

Permalink
Fix virtual reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed May 3, 2024
1 parent 9e25c16 commit 74c0b88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ const FC = {
rcSmoothingAutoFactor: 0,
usbCdcHidType: 0,
rcSmoothingMode: 0,
elrsUid: 0,
elrsUid: [0, 0, 0, 0, 0, 0],
};

this.FAILSAFE_CONFIG = {
Expand Down
16 changes: 15 additions & 1 deletion src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,9 @@ function startLiveDataRefreshTimer() {
}

export function reinitializeConnection(callback) {
const isVirtual = CONFIGURATOR.virtualMode && GUI.connected_to === 'virtual' && CONFIGURATOR.connectionValid && serial.connectionId === 'virtual';

gui_log(i18n.getMessage('deviceRebooting'));

// Close connection gracefully if it still exists.
const previousTimeStamp = connectionTimestamp;
Expand All @@ -829,8 +832,19 @@ export function reinitializeConnection(callback) {
}
}

gui_log(i18n.getMessage('deviceRebooting'));
// In virtual mode reconnect when autoconnect is enabled
if (isVirtual) {
return setTimeout(() => {
if (GUI.auto_connect) {
$('a.connect').trigger('click');
}
if (typeof callback === 'function') {
callback();
}
}, 500);
}

// Wait for serial or tcp connection to be available
let attempts = 0;
const reconnect = setInterval(waitforSerial, 100);

Expand Down

0 comments on commit 74c0b88

Please sign in to comment.