Skip to content

Commit 95f958e

Browse files
committed
Prevent auto-connect (loop) in cli only mode
1 parent eb4a7b4 commit 95f958e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/js/serial_backend.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ const REBOOT_CONNECT_MAX_TIME_MS = 10000;
3939
const REBOOT_GRACE_PERIOD_MS = 2000;
4040
let rebootTimestamp = 0;
4141

42+
function isCliOnlyMode() {
43+
return getConfig("cliOnlyMode")?.cliOnlyMode === true;
44+
}
45+
4246
const toggleStatus = function () {
4347
isConnected = !isConnected;
4448
};
@@ -61,6 +65,7 @@ export function initializeSerialBackend() {
6165
!GUI.connecting_to &&
6266
!["cli", "firmware_flasher"].includes(GUI.active_tab) &&
6367
PortHandler.portPicker.autoConnect &&
68+
!isCliOnlyMode() &&
6469
Date.now() - rebootTimestamp <= REBOOT_CONNECT_MAX_TIME_MS
6570
) {
6671
connectDisconnect();
@@ -562,7 +567,7 @@ function setRtc() {
562567
function finishOpen() {
563568
CONFIGURATOR.connectionValid = true;
564569

565-
if (getConfig("cliOnlyMode")?.cliOnlyMode) {
570+
if (isCliOnlyMode()) {
566571
connectCli();
567572
return;
568573
}
@@ -632,10 +637,7 @@ function onConnect() {
632637
})
633638
.show();
634639

635-
const isCliOnlyMode =
636-
getConfig("cliOnlyMode")?.cliOnlyMode && GUI.allowedTabs.length === 1 && GUI.allowedTabs[0] === "cli";
637-
638-
if (FC.CONFIG.flightControllerVersion !== "" && !isCliOnlyMode) {
640+
if (FC.CONFIG.flightControllerVersion !== "" && !isCliOnlyMode()) {
639641
FC.FEATURE_CONFIG.features = new Features(FC.CONFIG);
640642
FC.BEEPER_CONFIG.beepers = new Beepers(FC.CONFIG);
641643
FC.BEEPER_CONFIG.dshotBeaconConditions = new Beepers(FC.CONFIG, ["RX_LOST", "RX_SET"]);

0 commit comments

Comments
 (0)