mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-19 06:15:13 +03:00
Auto merged - #2475 at Sat, 26 Jun 2021 00:51:14 GMT
Make connection timeout user-configurable
This commit is contained in:
commit
1d296d5af4
6 changed files with 63 additions and 22 deletions
|
@ -92,6 +92,10 @@
|
||||||
"analyticsOptOut": {
|
"analyticsOptOut": {
|
||||||
"message": "Opt out of the anonymised collection of statistics data"
|
"message": "Opt out of the anonymised collection of statistics data"
|
||||||
},
|
},
|
||||||
|
"connectionTimeout": {
|
||||||
|
"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"
|
||||||
|
},
|
||||||
"cordovaForceComputerUI": {
|
"cordovaForceComputerUI": {
|
||||||
"message": "Use computers interface instead of phones interface"
|
"message": "Use computers interface instead of phones interface"
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,4 +13,5 @@
|
||||||
color: var(--defaultText);
|
color: var(--defaultText);
|
||||||
border: 1px solid var(--subtleAccent);
|
border: 1px solid var(--subtleAccent);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
width: fit-content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,9 +179,15 @@ PortHandler.detectPort = function(currentPorts) {
|
||||||
if (GUI.auto_connect && !GUI.connecting_to && !GUI.connected_to) {
|
if (GUI.auto_connect && !GUI.connecting_to && !GUI.connected_to) {
|
||||||
// start connect procedure. We need firmware flasher protection over here
|
// start connect procedure. We need firmware flasher protection over here
|
||||||
if (GUI.active_tab !== 'firmware_flasher') {
|
if (GUI.active_tab !== 'firmware_flasher') {
|
||||||
|
let connectionTimeout = 100;
|
||||||
|
ConfigStorage.get('connectionTimeout', function (result) {
|
||||||
|
if (result.connectionTimeout) {
|
||||||
|
connectionTimeout = result.connectionTimeout;
|
||||||
|
}
|
||||||
GUI.timeout_add('auto-connect_timeout', function () {
|
GUI.timeout_add('auto-connect_timeout', function () {
|
||||||
$('div#header_btns a.connect').click();
|
$('div#header_btns a.connect').click();
|
||||||
}, 100); // timeout so bus have time to initialize after being detected by the system
|
}, connectionTimeout); // timeout so bus have time to initialize after being detected by the system
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// trigger callbacks
|
// trigger callbacks
|
||||||
|
|
|
@ -828,13 +828,18 @@ function update_dataflash_global() {
|
||||||
|
|
||||||
function reinitialiseConnection(originatorTab, callback) {
|
function reinitialiseConnection(originatorTab, callback) {
|
||||||
GUI.log(i18n.getMessage('deviceRebooting'));
|
GUI.log(i18n.getMessage('deviceRebooting'));
|
||||||
|
let connectionTimeout = 200;
|
||||||
|
ConfigStorage.get('connectionTimeout', function (result) {
|
||||||
|
if (result.connectionTimeout) {
|
||||||
|
connectionTimeout = result.connectionTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
if (FC.boardHasVcp()) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
if (FC.boardHasVcp()) { // VCP-based flight controls may crash old drivers, we catch and reconnect
|
||||||
GUI.timeout_add('waiting_for_disconnect', function waiting_for_bootup() {
|
GUI.timeout_add('waiting_for_disconnect', function waiting_for_bootup() {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}, 200);
|
}, connectionTimeout);
|
||||||
//TODO: Need to work out how to do a proper reconnect here.
|
//TODO: Need to work out how to do a proper reconnect here.
|
||||||
// caveat: Timeouts set with `GUI.timeout_add()` are removed on disconnect.
|
// caveat: Timeouts set with `GUI.timeout_add()` are removed on disconnect.
|
||||||
} else {
|
} else {
|
||||||
|
@ -848,6 +853,7 @@ function reinitialiseConnection(originatorTab, callback) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
}, connectionTimeout); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ options.initialize = function (callback) {
|
||||||
TABS.options.initCheckForConfiguratorUnstableVersions();
|
TABS.options.initCheckForConfiguratorUnstableVersions();
|
||||||
TABS.options.initAnalyticsOptOut();
|
TABS.options.initAnalyticsOptOut();
|
||||||
TABS.options.initCliAutoComplete();
|
TABS.options.initCliAutoComplete();
|
||||||
|
TABS.options.initAutoConnectConnectionTimeout();
|
||||||
TABS.options.initCordovaForceComputerUI();
|
TABS.options.initCordovaForceComputerUI();
|
||||||
TABS.options.initDarkTheme();
|
TABS.options.initDarkTheme();
|
||||||
|
|
||||||
|
@ -105,6 +106,18 @@ options.initCliAutoComplete = function () {
|
||||||
}).change();
|
}).change();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options.initAutoConnectConnectionTimeout = function () {
|
||||||
|
ConfigStorage.get('connectionTimeout', function (result) {
|
||||||
|
if (result.connectionTimeout) {
|
||||||
|
$('#connectionTimeoutSelect').val(result.connectionTimeout);
|
||||||
|
}
|
||||||
|
$('#connectionTimeoutSelect').on('change', function () {
|
||||||
|
const value = parseInt($(this).val());
|
||||||
|
ConfigStorage.set({'connectionTimeout': value});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
options.initCordovaForceComputerUI = function () {
|
options.initCordovaForceComputerUI = function () {
|
||||||
if (GUI.isCordova() && cordovaUI.canChangeUI) {
|
if (GUI.isCordova() && cordovaUI.canChangeUI) {
|
||||||
ConfigStorage.get('cordovaForceComputerUI', function (result) {
|
ConfigStorage.get('cordovaForceComputerUI', function (result) {
|
||||||
|
|
|
@ -35,6 +35,17 @@
|
||||||
</div>
|
</div>
|
||||||
<span class="freelabel" i18n="cliAutoComplete"></span>
|
<span class="freelabel" i18n="cliAutoComplete"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="connectionTimeout margin-bottom">
|
||||||
|
<select id="connectionTimeoutSelect">
|
||||||
|
<option value="100">100</option>
|
||||||
|
<option value="500">500</option>
|
||||||
|
<option value="1000">1000</option>
|
||||||
|
<option value="1500">1500</option>
|
||||||
|
<option value="2500">2500</option>
|
||||||
|
<option value="5000">5000</option>
|
||||||
|
</select>
|
||||||
|
<span i18n="connectionTimeout"></span>
|
||||||
|
</div>
|
||||||
<div class="cordovaForceComputerUI margin-bottom">
|
<div class="cordovaForceComputerUI margin-bottom">
|
||||||
<div>
|
<div>
|
||||||
<input type="checkbox" class="toggle" />
|
<input type="checkbox" class="toggle" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue