Skip to content

Commit 60d0261

Browse files
committed
Prevent auto-connect (loop) in cli only mode
1 parent ee52ba8 commit 60d0261

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();
@@ -588,7 +593,7 @@ function setRtc() {
588593
function finishOpen() {
589594
CONFIGURATOR.connectionValid = true;
590595

591-
if (getConfig("cliOnlyMode")?.cliOnlyMode) {
596+
if (isCliOnlyMode()) {
592597
connectCli();
593598
return;
594599
}
@@ -658,10 +663,7 @@ function onConnect() {
658663
})
659664
.show();
660665

661-
const isCliOnlyMode =
662-
getConfig("cliOnlyMode")?.cliOnlyMode && GUI.allowedTabs.length === 1 && GUI.allowedTabs[0] === "cli";
663-
664-
if (FC.CONFIG.flightControllerVersion !== "" && !isCliOnlyMode) {
666+
if (FC.CONFIG.flightControllerVersion !== "" && !isCliOnlyMode()) {
665667
FC.FEATURE_CONFIG.features = new Features(FC.CONFIG);
666668
FC.BEEPER_CONFIG.beepers = new Beepers(FC.CONFIG);
667669
FC.BEEPER_CONFIG.dshotBeaconConditions = new Beepers(FC.CONFIG, ["RX_LOST", "RX_SET"]);

0 commit comments

Comments
 (0)