mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-11-27 14:58:03 +00:00
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>
20 lines
755 B
JavaScript
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; }
|
|
}
|