Skip to content

Commit 7cd518e

Browse files
committed
Add CLI Only Mode as development option
1 parent 0c51874 commit 7cd518e

File tree

4 files changed

+62
-12
lines changed

4 files changed

+62
-12
lines changed

locales/en/messages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,18 @@
153153
"message": "Set connection timeout to allow longer initialisation on device plugin or reboot",
154154
"description": "Change timeout on auto-connect and reboot so the bus has more time to initialize after being detected by the system"
155155
},
156+
"developmentSettings": {
157+
"message": "Development Settings",
158+
"description": "Title for the development settings section"
159+
},
156160
"showAllSerialDevices": {
157161
"message": "Show all serial devices (for manufacturers or development)",
158162
"description": "Do not filter serial devices using VID/PID values (for manufacturers or development)"
159163
},
164+
"cliOnlyMode": {
165+
"message": "Enable CLI only mode",
166+
"description": "Text for the option to enable or disable CLI only mode"
167+
},
160168
"showManualMode": {
161169
"message": "Enable manual connection mode",
162170
"description": "Text for the option to enable or disable manual connection mode"

src/js/serial_backend.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async function sendConfigTracking() {
9292
flightControllerIdentifier: FC.CONFIG.flightControllerIdentifier,
9393
mcu: FC.CONFIG.targetName,
9494
deviceIdentifier: CryptoES.SHA1(FC.CONFIG.deviceIdentifier).toString(),
95-
});
95+
});
9696
}
9797

9898
function connectDisconnect() {
@@ -528,7 +528,7 @@ async function processUid() {
528528

529529
gui_log(i18n.getMessage("uniqueDeviceIdReceived", FC.CONFIG.deviceIdentifier));
530530

531-
await sendConfigTracking();
531+
await sendConfigTracking();
532532
await processBuildConfiguration();
533533
}
534534

@@ -561,6 +561,13 @@ function setRtc() {
561561
function finishOpen() {
562562
CONFIGURATOR.connectionValid = true;
563563

564+
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
565+
if (getConfig("cliOnlyMode")?.cliOnlyMode) {
566+
connectCli();
567+
return;
568+
}
569+
}
570+
564571
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.CONFIG.buildOptions.length) {
565572
GUI.allowedTabs = Array.from(GUI.defaultAllowedTabs);
566573

@@ -626,7 +633,13 @@ function onConnect() {
626633
})
627634
.show();
628635

629-
if (FC.CONFIG.flightControllerVersion !== "") {
636+
const isCliOnlyMode =
637+
semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47) &&
638+
getConfig("cliOnlyMode")?.cliOnlyMode &&
639+
GUI.allowedTabs.length === 1 &&
640+
GUI.allowedTabs[0] === "cli";
641+
642+
if (FC.CONFIG.flightControllerVersion !== "" && !isCliOnlyMode) {
630643
FC.FEATURE_CONFIG.features = new Features(FC.CONFIG);
631644
FC.BEEPER_CONFIG.beepers = new Beepers(FC.CONFIG);
632645
FC.BEEPER_CONFIG.dshotBeaconConditions = new Beepers(FC.CONFIG, ["RX_LOST", "RX_SET"]);
@@ -642,12 +655,12 @@ function onConnect() {
642655
if (FC.CONFIG.boardType === 0 || FC.CONFIG.boardType === 2) {
643656
startLiveDataRefreshTimer();
644657
}
658+
659+
$("#sensor-status").show();
660+
$("#dataflash_wrapper_global").show();
645661
}
646662

647-
// header bar
648-
$("#sensor-status").show();
649663
$("#portsinput").hide();
650-
$("#dataflash_wrapper_global").show();
651664
}
652665

653666
function onClosed(result) {

src/js/tabs/options.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ options.initialize = function (callback) {
3232
TABS.options.initShowWarnings();
3333
TABS.options.initMeteredConnection();
3434
TABS.options.initBackupOnFlash();
35+
TABS.options.initCLiOnlyMode();
3536

3637
GUI.content_ready(callback);
3738
});
@@ -261,6 +262,17 @@ options.initUserLanguage = function () {
261262
.trigger("change");
262263
};
263264

265+
options.initCLiOnlyMode = function () {
266+
const cliOnlyModeElement = $("div.cliOnlyMode input");
267+
const result = getConfig("cliOnlyMode", false);
268+
cliOnlyModeElement.prop("checked", !!result.cliOnlyMode).on("change", () => {
269+
const checked = cliOnlyModeElement.is(":checked");
270+
setConfig({ cliOnlyMode: checked });
271+
});
272+
// Trigger change to ensure the initial state is set correctly
273+
cliOnlyModeElement.trigger("change");
274+
};
275+
264276
// TODO: remove when modules are in place
265277
TABS.options = options;
266278
export { options };

src/tabs/options.html

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@
2929
</div>
3030
<span class="freelabel" i18n="cliAutoComplete"></span>
3131
</div>
32-
<div class="showAllSerialDevices margin-bottom">
33-
<div>
34-
<input type="checkbox" class="toggle" />
35-
</div>
36-
<span class="freelabel" i18n="showAllSerialDevices"></span>
37-
</div>
3832
<div class="showManualMode margin-bottom">
3933
<div>
4034
<input type="checkbox" class="toggle" />
@@ -94,6 +88,29 @@
9488
</div>
9589
</div>
9690

91+
<div class="gui_box">
92+
<div class="gui_box_titlebar">
93+
<div class="spacer_box_title" i18n="developmentSettings"></div>
94+
</div>
95+
<div class="spacer">
96+
<div class="showAllSerialDevices margin-bottom">
97+
<div>
98+
<input type="checkbox" class="toggle" />
99+
</div>
100+
<span class="freelabel" i18n="showAllSerialDevices"></span>
101+
</div>
102+
103+
<div class="developmentSettings margin-bottom">
104+
<div class="cliOnlyMode margin-bottom">
105+
<div>
106+
<input type="checkbox" class="toggle" />
107+
</div>
108+
<span class="freelabel" i18n="cliOnlyMode"></span>
109+
</div>
110+
</div>
111+
</div>
112+
</div>
113+
97114
<div class="gui_box">
98115
<div class="gui_box_titlebar">
99116
<div class="spacer_box_title" i18n="warningSettings"></div>

0 commit comments

Comments
 (0)