Temporary PKJS watchPosition() speed feed #13

Closed
opened 2026-08-31 17:14:38 +02:00 by robert · 1 comment
robert commented 2026-08-31 17:14:38 +02:00 (Migrated from git.butzei.de)

Goal

Give the watchapp real speed immediately, so it is genuinely useful before any Android work exists.

Acceptance criteria

  • PKJS navigator.geolocation.watchPosition() with enableHighAccuracy: true, maximumAge: 0
  • Error handler and timeout present on every geolocation call
  • Speed and position forwarded to the watch using the shared message keys
  • Distance and average accumulated on the JS side for now
  • Known limitations documented (background reliability, no BLE sensors)

Files

  • watchapp/src/pkjs/index.js

Notes

This is scaffolding, replaced by the companion app in Phase 2 and kept only behind a fallback flag.

## Goal Give the watchapp real speed immediately, so it is genuinely useful before any Android work exists. ## Acceptance criteria - [ ] PKJS `navigator.geolocation.watchPosition()` with `enableHighAccuracy: true`, `maximumAge: 0` - [ ] Error handler and timeout present on every geolocation call - [ ] Speed and position forwarded to the watch using the shared message keys - [ ] Distance and average accumulated on the JS side for now - [ ] Known limitations documented (background reliability, no BLE sensors) ## Files - `watchapp/src/pkjs/index.js` ## Notes This is scaffolding, replaced by the companion app in Phase 2 and kept only behind a fallback flag.
Owner

Closed by PR #110 (merged). Plain-ES5 PKJS speed feed using watchPosition() with enableHighAccuracy/maximumAge:0/a real 15s timeout, both error and success paths handled (all three W3C PositionError codes send the SPEED_MMS sentinel rather than a stale/fake value). SPEED_MMS/AVG_SPEED_MMS/DISTANCE_M come from PROTOCOL.md section 2.2, hand-copied into package.json's messageKeys since tools/gen_message_keys.py (#7) has no JS output target yet -- flagged as a real, undetected second copy of those three integers, and extending the generator to a JS target is a reasonable follow-up. Deliberately does NOT port SpeedPipeline/StopDetector's real machinery (GPS-quality gating, wraparound, dwell/hysteresis) -- reuses only the 0.8 m/s stopped-speed number, not the class, since this file is scaffolding #21 will delete. Fallback flag: localStorage['pkjsSpeedFeedEnabled'], default enabled since Phase 1 has no other speed source yet.

Real end-to-end verification, a first for a PKJS feature in this repo: pebble build clean on all three platforms, then a live emery emulator run confirmed watchPosition() getting a genuine fix through pypkjs's actual IP-geolocation path, the resulting AppMessage arriving at the watch's C inbox handler, and the ack returning to PKJS -- via pebble logs, not just compiled. Honestly unverified: multi-fix accumulation (pypkjs's watchPosition() fires its success callback only once, an emulator limitation) and the error/timeout path (network never failed in this sandbox) -- both verified by reading the logic instead, stated as such rather than claimed.

Closed by PR #110 (merged). Plain-ES5 PKJS speed feed using watchPosition() with enableHighAccuracy/maximumAge:0/a real 15s timeout, both error and success paths handled (all three W3C PositionError codes send the SPEED_MMS sentinel rather than a stale/fake value). SPEED_MMS/AVG_SPEED_MMS/DISTANCE_M come from PROTOCOL.md section 2.2, hand-copied into package.json's messageKeys since tools/gen_message_keys.py (#7) has no JS output target yet -- flagged as a real, undetected second copy of those three integers, and extending the generator to a JS target is a reasonable follow-up. Deliberately does NOT port SpeedPipeline/StopDetector's real machinery (GPS-quality gating, wraparound, dwell/hysteresis) -- reuses only the 0.8 m/s stopped-speed number, not the class, since this file is scaffolding #21 will delete. Fallback flag: localStorage['pkjsSpeedFeedEnabled'], default enabled since Phase 1 has no other speed source yet. **Real end-to-end verification, a first for a PKJS feature in this repo**: pebble build clean on all three platforms, then a live emery emulator run confirmed watchPosition() getting a genuine fix through pypkjs's actual IP-geolocation path, the resulting AppMessage arriving at the watch's C inbox handler, and the ack returning to PKJS -- via pebble logs, not just compiled. Honestly unverified: multi-fix accumulation (pypkjs's watchPosition() fires its success callback only once, an emulator limitation) and the error/timeout path (network never failed in this sandbox) -- both verified by reading the logic instead, stated as such rather than claimed.
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
robert/PedalPebble#13
No description provided.