Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,18 @@
"message": "Set connection timeout to allow longer initialisation on device plugin or reboot",
"description": "Change timeout on auto-connect and reboot so the bus has more time to initialize after being detected by the system"
},
"developmentSettings": {
"message": "Development Settings",
"description": "Title for the development settings section"
},
"showAllSerialDevices": {
"message": "Show all serial devices (for manufacturers or development)",
"description": "Do not filter serial devices using VID/PID values (for manufacturers or development)"
},
"cliOnlyMode": {
"message": "Enable CLI only mode",
"description": "Text for the option to enable or disable CLI only mode"
},
"showManualMode": {
"message": "Enable manual connection mode",
"description": "Text for the option to enable or disable manual connection mode"
Expand Down
29 changes: 20 additions & 9 deletions src/js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const REBOOT_CONNECT_MAX_TIME_MS = 10000;
const REBOOT_GRACE_PERIOD_MS = 2000;
let rebootTimestamp = 0;

function isCliOnlyMode() {
return getConfig("cliOnlyMode")?.cliOnlyMode === true;
}

const toggleStatus = function () {
isConnected = !isConnected;
};
Expand All @@ -59,8 +63,10 @@ export function initializeSerialBackend() {
if (
!GUI.connected_to &&
!GUI.connecting_to &&
GUI.active_tab !== "firmware_flasher" &&
(PortHandler.portPicker.autoConnect || Date.now() - rebootTimestamp < REBOOT_CONNECT_MAX_TIME_MS)
!["cli", "firmware_flasher"].includes(GUI.active_tab) &&
PortHandler.portPicker.autoConnect &&
!isCliOnlyMode() &&
Date.now() - rebootTimestamp <= REBOOT_CONNECT_MAX_TIME_MS
) {
connectDisconnect();
}
Expand Down Expand Up @@ -587,6 +593,11 @@ function setRtc() {
function finishOpen() {
CONFIGURATOR.connectionValid = true;

if (isCliOnlyMode()) {
connectCli();
return;
}

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.CONFIG.buildOptions.length) {
GUI.allowedTabs = Array.from(GUI.defaultAllowedTabs);

Expand Down Expand Up @@ -652,7 +663,7 @@ function onConnect() {
})
.show();

if (FC.CONFIG.flightControllerVersion !== "") {
if (FC.CONFIG.flightControllerVersion !== "" && !isCliOnlyMode()) {
FC.FEATURE_CONFIG.features = new Features(FC.CONFIG);
FC.BEEPER_CONFIG.beepers = new Beepers(FC.CONFIG);
FC.BEEPER_CONFIG.dshotBeaconConditions = new Beepers(FC.CONFIG, ["RX_LOST", "RX_SET"]);
Expand All @@ -668,12 +679,12 @@ function onConnect() {
if (FC.CONFIG.boardType === 0 || FC.CONFIG.boardType === 2) {
startLiveDataRefreshTimer();
}

$("#sensor-status").show();
$("#dataflash_wrapper_global").show();
}

// header bar
$("#sensor-status").show();
$("#portsinput").hide();
$("#dataflash_wrapper_global").show();
}

function onClosed(result) {
Expand Down Expand Up @@ -798,9 +809,9 @@ export function reinitializeConnection() {
}
}

// Show reboot progress modal except for presets tab
if (GUI.active_tab === "presets") {
console.log("Rebooting in presets tab, skipping reboot dialog", GUI.active_tab);
// Show reboot progress modal except for cli and presets tab
if (["cli", "presets"].includes(GUI.active_tab)) {
console.log(`${logHead} Rebooting in ${GUI.active_tab} tab, skipping reboot dialog`);
gui_log(i18n.getMessage("deviceRebooting"));
gui_log(i18n.getMessage("deviceReady"));

Expand Down
12 changes: 12 additions & 0 deletions src/js/tabs/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ options.initialize = function (callback) {
TABS.options.initShowWarnings();
TABS.options.initMeteredConnection();
TABS.options.initBackupOnFlash();
TABS.options.initCLiOnlyMode();

GUI.content_ready(callback);
});
Expand Down Expand Up @@ -261,6 +262,17 @@ options.initUserLanguage = function () {
.trigger("change");
};

options.initCLiOnlyMode = function () {
const cliOnlyModeElement = $("div.cliOnlyMode input");
const result = getConfig("cliOnlyMode", false);
cliOnlyModeElement.prop("checked", !!result.cliOnlyMode).on("change", () => {
const checked = cliOnlyModeElement.is(":checked");
setConfig({ cliOnlyMode: checked });
});
// Trigger change to ensure the initial state is set correctly
cliOnlyModeElement.trigger("change");
};

// TODO: remove when modules are in place
TABS.options = options;
export { options };
29 changes: 23 additions & 6 deletions src/tabs/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
</div>
<span class="freelabel" i18n="cliAutoComplete"></span>
</div>
<div class="showAllSerialDevices margin-bottom">
<div>
<input type="checkbox" class="toggle" />
</div>
<span class="freelabel" i18n="showAllSerialDevices"></span>
</div>
<div class="showManualMode margin-bottom">
<div>
<input type="checkbox" class="toggle" />
Expand Down Expand Up @@ -94,6 +88,29 @@
</div>
</div>

<div class="gui_box">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="developmentSettings"></div>
</div>
<div class="spacer">
<div class="showAllSerialDevices margin-bottom">
<div>
<input type="checkbox" class="toggle" />
</div>
<span class="freelabel" i18n="showAllSerialDevices"></span>
</div>

<div class="developmentSettings margin-bottom">
<div class="cliOnlyMode margin-bottom">
<div>
<input type="checkbox" class="toggle" />
</div>
<span class="freelabel" i18n="cliOnlyMode"></span>
</div>
</div>
</div>
</div>

<div class="gui_box">
<div class="gui_box_titlebar">
<div class="spacer_box_title" i18n="warningSettings"></div>
Expand Down