mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
kjf
This commit is contained in:
@@ -4,6 +4,7 @@ const fs = require('fs');
|
||||
|
||||
const SCAN_TIMEOUT_MS = 8000;
|
||||
const RECONNECT_DELAY_MS = 5000;
|
||||
const IDLE_RETRY_MS = 1000;
|
||||
|
||||
function sanitizeLogText(value) {
|
||||
return String(value || '')
|
||||
@@ -111,6 +112,14 @@ function createLidarRuntime({ logger, host, port = 6053, key, logFile = '', shou
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function schedulePollRetry(delayMs = IDLE_RETRY_MS) {
|
||||
if (state.pollSoonTimer) return;
|
||||
state.pollSoonTimer = setTimeout(() => {
|
||||
state.pollSoonTimer = null;
|
||||
tickPoll();
|
||||
}, delayMs);
|
||||
}
|
||||
|
||||
function scheduleReconnect() {
|
||||
if (state.reconnectTimer) return;
|
||||
state.reconnectTimer = setTimeout(() => {
|
||||
@@ -330,8 +339,14 @@ function createLidarRuntime({ logger, host, port = 6053, key, logFile = '', shou
|
||||
}
|
||||
|
||||
async function tickPoll() {
|
||||
if (!state.connected) return;
|
||||
if (!shouldPoll?.()) return;
|
||||
if (!state.connected) {
|
||||
schedulePollRetry();
|
||||
return;
|
||||
}
|
||||
if (!shouldPoll?.()) {
|
||||
schedulePollRetry();
|
||||
return;
|
||||
}
|
||||
if (state.requestInFlight) return;
|
||||
state.requestInFlight = true;
|
||||
state.requestStartedAt = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user