Files
corescope-rx/src/gps.js
T
efitenandClaude Opus 4.8 db83810878 feat: scaffold corescope-rx capture app (BLE companion → MQTT coverage)
Protocol core implemented + unit-tested (meshpacket: path[last]/advert pubkey,
direct-only rule; frames: 0x88 snr/rssi/raw). Working skeleton for transport
(Web Bluetooth NUS), GPS, IndexedDB queue, MQTT.js publisher and field UI.
Remaining work in docs/plan.md (spikes + harden + verify).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-09 16:47:30 +02:00

20 lines
755 B
JavaScript

// Phone GPS. Each reception is tagged with the latest fix; no fix → no row
// (coverage without a position is useless).
export class Gps {
constructor() { this._last = null; this._watchId = null; }
start() {
if (!navigator.geolocation) throw new Error('geolocation unavailable');
this._watchId = navigator.geolocation.watchPosition(
(p) => { this._last = { lat: p.coords.latitude, lon: p.coords.longitude, acc_m: p.coords.accuracy }; },
() => {},
{ enableHighAccuracy: true, maximumAge: 5000, timeout: 15000 }
);
}
stop() { if (this._watchId != null) navigator.geolocation.clearWatch(this._watchId); this._watchId = null; }
// latest() returns the most recent fix or null.
latest() { return this._last; }
}