Skip to content

Commit 188961b

Browse files
committed
Enhance GPS failure handling and status messages in wardrive.js and STATUS_MESSAGES.md
1 parent 911514a commit 188961b

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

‎content/wardrive.js‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ const state = {
545545
lastFix: null, // { lat, lon, accM, tsMs }
546546
bluefyLockEnabled: false,
547547
gpsState: "idle", // "idle", "acquiring", "acquired", "error"
548+
lastGpsFailureReason: null, // "inaccurate", "stale", "error", or null
548549
gpsAgeUpdateTimer: null, // Timer for updating GPS age display
549550
meshMapperTimer: null, // Timer for delayed MeshMapper API call
550551
cooldownEndTime: null, // Timestamp when cooldown period ends
@@ -2316,6 +2317,7 @@ async function getValidGpsForZoneCheck(maxRetries = 3, retryDelayMs = 5000) {
23162317
await new Promise(resolve => setTimeout(resolve, retryDelayMs));
23172318
continue;
23182319
}
2320+
state.lastGpsFailureReason = "stale";
23192321
return null;
23202322
}
23212323

@@ -2327,10 +2329,12 @@ async function getValidGpsForZoneCheck(maxRetries = 3, retryDelayMs = 5000) {
23272329
await new Promise(resolve => setTimeout(resolve, retryDelayMs));
23282330
continue;
23292331
}
2332+
state.lastGpsFailureReason = "inaccurate";
23302333
return null;
23312334
}
23322335

23332336
debugLog(`[GPS] [GEO AUTH] Valid GPS acquired: lat=${lat.toFixed(6)}, lon=${lng.toFixed(6)}, accuracy=${accuracy_m.toFixed(1)}m, age=${ageMs}ms`);
2337+
state.lastGpsFailureReason = null; // Clear any previous failure reason on success
23342338
return { lat, lon: lng, accuracy_m, timestamp };
23352339

23362340
} catch (error) {
@@ -2343,6 +2347,10 @@ async function getValidGpsForZoneCheck(maxRetries = 3, retryDelayMs = 5000) {
23432347
}
23442348

23452349
debugError(`[GPS] [GEO AUTH] GPS acquisition failed after ${maxRetries} attempts`);
2350+
// If no specific reason was set, mark as general error
2351+
if (!state.lastGpsFailureReason) {
2352+
state.lastGpsFailureReason = "error";
2353+
}
23462354
return null;
23472355
}
23482356

@@ -6406,8 +6414,17 @@ function updateConnectButtonState() {
64066414
debugLog("[UI] External antenna not selected - showing message in status bar");
64076415
setDynamicStatus("Select external antenna to connect", STATUS_COLORS.warning);
64086416
} else if (!inValidZone) {
6409-
debugLog("[UI] Not in valid zone - showing waiting for location status");
6410-
setDynamicStatus("Waiting for location...", STATUS_COLORS.info);
6417+
// Show more informative message based on GPS failure reason
6418+
let gpsStatusMsg = "Waiting for location...";
6419+
if (state.lastGpsFailureReason === "inaccurate") {
6420+
gpsStatusMsg = "GPS too inaccurate (max 50m)";
6421+
} else if (state.lastGpsFailureReason === "stale") {
6422+
gpsStatusMsg = "GPS too stale, acquiring...";
6423+
} else if (state.lastGpsFailureReason === "error") {
6424+
gpsStatusMsg = "GPS unavailable";
6425+
}
6426+
debugLog(`[UI] Not in valid zone - showing status: ${gpsStatusMsg}`);
6427+
setDynamicStatus(gpsStatusMsg, STATUS_COLORS.info);
64116428
} else {
64126429
debugLog("[UI] External antenna selected and in valid zone - ready to connect");
64136430
// Only set Idle if not showing a disconnect error

‎docs/STATUS_MESSAGES.md‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,35 @@ These messages use a hybrid approach: **first display respects 500ms minimum**,
574574
##### Waiting for location...
575575
- **Message**: `"Waiting for location..."`
576576
- **Color**: Blue (info)
577-
- **When**: External antenna is selected but zone check is still in progress (location display shows "Checking...")
577+
- **When**: External antenna is selected but zone check is still in progress with no specific GPS failure
578578
- **Terminal State**: Yes (persists until zone check completes)
579579
- **Notes**: Displayed in Dynamic Status Bar to inform user that the app is waiting for GPS location and zone validation before allowing connection. Once zone check passes, status changes to "Idle" and Connect button becomes enabled.
580580
- **Source**: `content/wardrive.js:updateConnectButtonState()`
581581

582+
##### GPS too inaccurate (max 50m)
583+
- **Message**: `"GPS too inaccurate (max 50m)"`
584+
- **Color**: Blue (info)
585+
- **When**: External antenna is selected but GPS accuracy exceeds 50m threshold after all retries
586+
- **Terminal State**: Yes (persists until GPS improves or zone check passes)
587+
- **Notes**: More specific message explaining why zone check failed. User should move to area with better GPS reception (outdoors, away from buildings). 30s slot refresh timer will auto-retry zone check.
588+
- **Source**: `content/wardrive.js:updateConnectButtonState()`
589+
590+
##### GPS too stale, acquiring...
591+
- **Message**: `"GPS too stale, acquiring..."`
592+
- **Color**: Blue (info)
593+
- **When**: External antenna is selected but GPS data is older than 60 seconds after all retries
594+
- **Terminal State**: Yes (persists until fresh GPS is acquired or zone check passes)
595+
- **Notes**: More specific message explaining why zone check failed. User should wait for fresh GPS fix. 30s slot refresh timer will auto-retry zone check.
596+
- **Source**: `content/wardrive.js:updateConnectButtonState()`
597+
598+
##### GPS unavailable
599+
- **Message**: `"GPS unavailable"`
600+
- **Color**: Blue (info)
601+
- **When**: External antenna is selected but GPS acquisition failed due to error (permissions, hardware, etc.)
602+
- **Terminal State**: Yes (persists until GPS becomes available or zone check passes)
603+
- **Notes**: Generic GPS error message when acquisition fails completely. User should check GPS permissions and hardware.
604+
- **Source**: `content/wardrive.js:updateConnectButtonState()`
605+
582606
##### Select radio power to connect
583607
- **Message**: `"Select radio power to connect"`
584608
- **Color**: Amber (warning)

0 commit comments

Comments
 (0)