Skip to content

Commit c842b9d

Browse files
authored
Fix autoconnect (#4407)
* Fix autoconnect * Add constant
1 parent 75aa30a commit c842b9d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/js/serial_backend.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ let liveDataRefreshTimerId = false;
3636
let isConnected = false;
3737

3838
const REBOOT_CONNECT_MAX_TIME_MS = 10000;
39+
const REBOOT_GRACE_PERIOD_MS = 2000;
3940
let rebootTimestamp = 0;
4041

4142
const toggleStatus = function () {
@@ -109,6 +110,12 @@ function connectDisconnect() {
109110
return;
110111
}
111112

113+
// When rebooting, adhere to the auto-connect setting
114+
if (!PortHandler.portPicker.autoConnect && Date.now() - rebootTimestamp < REBOOT_GRACE_PERIOD_MS) {
115+
console.log(`${logHead} Rebooting, not connecting`);
116+
return;
117+
}
118+
112119
console.log(`${logHead} Connecting to: ${portName}`);
113120
GUI.connecting_to = portName;
114121

0 commit comments

Comments
 (0)