Skip to content

Add geofence validation, distance filtering, and debug mode#54

Merged
MrAlders0n merged 37 commits intomainfrom
dev
Dec 19, 2025
Merged

Add geofence validation, distance filtering, and debug mode#54
MrAlders0n merged 37 commits intomainfrom
dev

Conversation

@MrAlders0n
Copy link
Collaborator

Merge Notes: devmain

Here's a detailed breakdown of all changes in the dev branch that will be merged into main:


📄 .gitignore

Added temporary files directory to ignore list:

# Temporary files
tmp/

📄 README.md

Improved setup instructions for both Android and iOS:

  • Added explicit steps to join the #wardriving public hashtag channel in the MeshCore app before using the web app
  • Both platform instructions now include detailed sub-steps for adding the channel via the app's menu

📄 index.html

New UI element - Added a "Distance from last ping" display row in the GPS info table:

<tr>
  <td class="pr-3 text-slate-400 whitespace-nowrap align-top">Distance from last ping:</td>
  <td id="distanceInfo">-</td>
</tr>

📄 content/wardrive.js (Major changes)

This is the bulk of the update with significant feature additions and refactoring:

🔧 Debug System

  • Added URL parameter-based debug logging (?debug=true)
  • New debugLog(), debugWarn(), debugError() helper functions
  • Extensive debug logging throughout the codebase

🌍 Geofence Validation

  • Added Ottawa geofence (centered on Parliament Hill, 150km radius)
  • New validateGeofence() function using Haversine distance calculation
  • Pings outside the geofence are blocked with appropriate status messages

📏 Distance-Based Ping Filtering

  • Minimum 25m distance requirement between consecutive pings
  • New calculateHaversineDistance() function for accurate distance calculations
  • New validateMinimumDistance() function
  • Tracks lastSuccessfulPingLocation for distance comparisons
  • Real-time "Distance from last ping" UI updates every 3 seconds

⏱️ Countdown Timer Refactoring

  • Created generalized createCountdownTimer() factory function
  • Refactored auto-ping and API countdown timers to use the new system
  • Added pause/resume functionality for auto countdown when manual pings are sent during auto mode
  • New constants: MIN_PAUSE_THRESHOLD_MS (1s), MAX_REASONABLE_TIMER_MS (5min) for clock skew handling

🎨 Status Color System

  • New STATUS_COLORS constant object for consistent UI colors:
    • idle: slate-300
    • success: emerald-300
    • warning: amber-300
    • error: red-300
    • info: sky-300

📍 GPS Handling Improvements

  • New GPS_WATCH_MAX_AGE_MS constant (60s) for manual ping GPS data validation
  • Improved getGpsCoordinatesForPing() function with better handling of GPS watch data
  • New acquireFreshGpsPosition() helper function
  • Better fallback logic when GPS data is stale

🔄 Skip Reason Tracking

  • New state.skipReason property to track why pings were skipped
  • Countdown displays now show skip reasons (e.g., "outside geofence", "too close", "gps too old")

🧹 Code Organization

  • New cleanupAllTimers() function for comprehensive timer cleanup
  • Refactored scheduleApiPostAndMapRefresh() as a standalone function
  • New getDeviceIdentifier() helper function
  • New logPingToUI() helper function
  • Better separation of concerns throughout

🐛 Bug Fixes & Improvements

  • Fixed potential timer state issues during manual pings in auto mode
  • Added getRemainingCooldownSeconds() helper
  • Improved wake lock acquisition/release logging
  • Better error handling and user feedback

Summary of Key New Features

Feature Description
🌍 Geofence Pings restricted to 150km radius around Ottawa
📏 Min Distance 25m minimum between consecutive pings
🐛 Debug Mode Enable via ?debug=true URL parameter
📍 Distance UI Real-time distance from last ping display
⏸️ Timer Pause Auto countdown pauses during manual pings
📋 Setup Guide Improved README with channel setup instructions

Copilot AI and others added 30 commits December 18, 2025 16:54
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Refactor and optimize wardrive.js with comprehensive debug logging
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
…again

Fix manual ping timeout after stopping auto ping
- Manual ping now shows "GPS data too old, requesting fresh position" when requesting fresh GPS
- Manual ping shows "Error: could not get fresh GPS location" on timeout
- Auto ping validates GPS freshness before sending
- Auto ping shows "GPS data old, trying to refresh position" when refreshing
- Auto ping shows "GPS could not refresh position, skipping ping. Next attempt (Xs)" on failure
- Auto ping schedules next attempt when GPS refresh fails

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
- Created acquireFreshGpsPosition() helper to eliminate code duplication
- Reduces duplication between auto and manual GPS acquisition
- Improves code maintainability and readability

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
…dback

Add GPS status feedback and freshness validation for ping operations
- Add skipReason state to track when ping is skipped
- Update countdown timer to support color-coded messages
- Show "Ping skipped, gps too old. Waiting for next auto ping (Xs)" with live countdown
- Clear skip reason on auto ping start/stop and next ping attempt
- Display skip message in warning color to indicate issue

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Change from "Ping skipped, gps too old. Waiting for next auto ping (30s)"
to "Skipped (gps too old), next ping (30s)" for more compact display

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Extract applyCountdownStatus helper function to handle both string
and object return formats, reducing duplication in update() method

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Document applyCountdownStatus parameters and clarify skipReason
is an internal value for security review

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
…issue

Add live countdown for GPS skip in auto-ping mode
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
…nflict

Fix auto ping timer conflict during manual ping
Copilot AI and others added 7 commits December 18, 2025 20:06
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
…pings

Add GPS geofence and distance-based ping filtering for Ottawa region
@MrAlders0n MrAlders0n merged commit 1f13996 into main Dec 19, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants