From 74c0b881c7276130b314ad87b3f8bc1819f88b75 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Fri, 3 May 2024 18:08:48 +0200 Subject: [PATCH] Fix virtual reboot --- src/js/fc.js | 2 +- src/js/serial_backend.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/js/fc.js b/src/js/fc.js index 86c2360a36..f337e1f9d7 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -630,7 +630,7 @@ const FC = { rcSmoothingAutoFactor: 0, usbCdcHidType: 0, rcSmoothingMode: 0, - elrsUid: 0, + elrsUid: [0, 0, 0, 0, 0, 0], }; this.FAILSAFE_CONFIG = { diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 87e933ce27..49c9c1a466 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -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; @@ -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);