From 9308abd6d92c5ba632cb49eb6baed017ef1e4212 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 23:37:01 +0000 Subject: [PATCH 1/2] Initial plan From 845db0cd6ff2f0beee7f99206a4cfc7bf380bc09 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 23:39:56 +0000 Subject: [PATCH 2/2] Fix auto-ping timing: schedule next ping after current completes Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com> --- content/wardrive.js | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/content/wardrive.js b/content/wardrive.js index 86ee247..8617bdf 100644 --- a/content/wardrive.js +++ b/content/wardrive.js @@ -553,11 +553,10 @@ async function sendPing(manual = false) { // Set status to idle after map update if (state.connection) { - // If in auto mode, start countdown. Otherwise, set to idle + // If in auto mode, schedule next ping. Otherwise, set to idle if (state.running) { - // Restart the countdown for next auto ping - const intervalMs = getSelectedIntervalMs(); - startAutoCountdown(intervalMs); + // Schedule the next auto ping with countdown + scheduleNextAutoPing(); } else { setStatus("Idle", "text-slate-300"); } @@ -596,7 +595,7 @@ function stopAutoPing(stopGps = false) { } if (state.autoTimerId) { - clearInterval(state.autoTimerId); + clearTimeout(state.autoTimerId); state.autoTimerId = null; } stopAutoCountdown(); @@ -610,6 +609,22 @@ function stopAutoPing(stopGps = false) { updateAutoButton(); releaseWakeLock(); } +function scheduleNextAutoPing() { + if (!state.running) return; + + const intervalMs = getSelectedIntervalMs(); + + // Start countdown immediately + startAutoCountdown(intervalMs); + + // Schedule the next ping + state.autoTimerId = setTimeout(() => { + if (state.running) { + sendPing(false).catch(console.error); + } + }, intervalMs); +} + function startAutoPing() { if (!state.connection) { alert("Connect to a MeshCore device first."); @@ -626,7 +641,7 @@ function startAutoPing() { // Clean up any existing auto-ping timer (but keep GPS watch running) if (state.autoTimerId) { - clearInterval(state.autoTimerId); + clearTimeout(state.autoTimerId); state.autoTimerId = null; } stopAutoCountdown(); @@ -640,14 +655,8 @@ function startAutoPing() { // Acquire wake lock for auto mode acquireWakeLock().catch(console.error); - // First ping immediately, then at selected interval + // Send first ping immediately sendPing(false).catch(console.error); - const intervalMs = getSelectedIntervalMs(); - state.autoTimerId = setInterval(() => { - sendPing(false).catch(console.error); - }, intervalMs); - - // Countdown will be started after the first ping completes } // ---- BLE connect / disconnect ----