Commit Graph

8 Commits

Author SHA1 Message Date
Jonas Bark
db5cc74a12 fix(erg,sram): shared ERG stepping with boundary guards; scope §7 guard to shifting-enabled; coalesce iOS echo presses
ERG (review findings on the ±5W change):
- New ErgPowerStepping extension is the single home for the 5W step and
  500W manual cap, replacing 7 inline copies (physical buttons, hero-card
  buttons/slider, three overlay controllers).
- Boundaries are guards, not clamps: up at >=500W is a no-op like the
  disabled UI button (a 600W FTMS target is no longer slashed to 500),
  down from >500W steps relative, and an unknown baseline (hub-commanded
  ERG reports no target) is a no-op with a new localized message instead
  of slamming the trainer to ~150W.
- ERG shift-up Success carries the button again so +5W presses show
  activity feedback (missed conversion from 843f7985).

SRAM gesture:
- Same-lever repeats inside the 90ms combo window coalesce as duplicates:
  a finger can't re-press in 90ms, but iOS re-delivers a colliding read
  response of the 0xFF edge through the notify callback — it must not
  actuate twice (nor break a combo when it misdecodes to the other lever).
- The §7 multishift guard only runs while shifting is enabled — the one
  state where a held paddle actually bursts (per c94b87f0's --observe
  capture). Bonded rapid tapping and both-lever combos are never
  throttled. Timer-driven instead of DateTime.now() (deterministic under
  fakeAsync) and cleared by _resetGesture on (re)connect.
- The "set up SRAM control" warning fires once per connection, not on
  every undecoded press.

Harness:
- EmulationSession.notify drops notifications for removed peripherals so
  delayed notifies (SRAM double-tap) can't land after teardown.
- The 0xFF press edge is SramAxsConstants.triggerEdge at all call sites;
  the emulation test waits on the named TRIGGER_UUID constant.
- New coverage: guard behavior through processCharacteristic in both
  states, burst suppression while unbonded, all-taps-delivered once
  bonded, ERG boundary/game-set-target cases.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 17:51:35 +02:00
Jonas Bark
39e9082e53 fix(sram): don't swallow same-lever repeats; restore §7 burst guard; fix failing tests
Gesture engine: a repeat of the SAME lever inside the 90ms combo window
can't be a combo, so flush the pending click instead of overwriting it —
rapid double-taps now deliver both shifts. The old press-swallowing was
accidentally doing multishift suppression, so bring back the explicit §7
guard (forward the first two rapid triggers, drop the 3rd+ within 350ms)
that the discrete-click rework removed.

Test fixes for the rest of the failing suite:
- review_prompt_service_test: derive seeds from sessionThreshold /
  snoozeSessions instead of hardcoding the old threshold of 3
- controller_settings_signal_change_test: persist a session key and run
  handleServices so the device is bonded and the Restore branch renders
- emulated SRAM AXS profile: send real 1-byte 0xFF edges (0x01 is now
  filtered as a read-response echo), expect the generic 'SRAM Button'
  name, and wait for the app's trigger subscription before tapping so
  the press can't land mid-connect and get wiped by the gesture reset

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 16:24:01 +02:00
Jonas Bark
34e60a498a fix(emulation): routing fallback for forgotten ids, capped write log, Di2 per-press baseline 2026-07-02 12:01:17 +02:00
Jonas Bark
9e2122445b feat(emulation): Cycplus, ThinkRider, SRAM AXS, OpenBikeControl and Di2 profiles
Adds the last emulation profile batch and finalizes allEmulationProfiles
(controllers, then steering, then accessories). Test assertions deviate from
the brief where verified behavior required it: Cycplus/ThinkRider buttons
compare by name (allowMultiple: true makes BluetoothDevice copy the static
button with a per-session sourceDeviceId, which ControllerButton equality
includes); the Di2 test sets a CustomApp so getOrAddButton actually registers
its dynamically-created channel buttons; setUp seeds packageInfoValue so
OpenBikeControlDevice's app-info write doesn't null-check crash.
2026-07-02 11:33:51 +02:00
Jonas Bark
35777d58e5 feat(emulation): Wahoo Kickr Bike Shift, Climb and Headwind profiles
Adds three emulation profiles for Task 9: Kickr Bike Shift (3-byte
button frames with rolling dedupe sequence), Kickr Climb (request-
control on connect + incline writes decoded/logged), and Headwind
(manual-mode + speed writes logged, status echo keeps the app's mode
tracking consistent with real hardware).
2026-07-02 11:12:38 +02:00
Jonas Bark
7b6ac4299c feat(emulation): Elite Sterzo, Square and Rizer profiles 2026-07-02 10:55:54 +02:00
Jonas Bark
54abf07ec8 feat(emulation): Zwift Play, Play FW2 and Click V2 profiles
Adds buildZwiftController + zwiftPlayNotification encoder plus five
new EmulationProfiles (Play L/R, Play FW2, Click V2 L/R) built on
Task 3's rideMaskInputs. Wires them into allEmulationProfiles.

TDD: emulation_zwift_profiles_test.dart written first (RED: profiles
undefined), then implemented to GREEN (5/5). The test's setUp also
initializes prop's global `propPrefs` directly — IntegrationEnv's
harness never wires it up (only production Settings.init() does),
and ZwiftClickV2's handleButtonsClicked reads it on every click, so
Click V2 side tests hit a LateInitializationError without it. This is
the first integration test to exercise a ZwiftClickV2 button press
end-to-end, which is why the gap wasn't hit before.
2026-07-02 10:30:06 +02:00
Jonas Bark
c95eb147c3 feat(emulation): EmulationManager, profiles model, Click/Ride profiles, debug platform install
Adds the EmulationProfile/EmulatedInput model, EmulationManager +
EmulationSession, removePeripheral on the fake BLE platform, the first two
device profiles (Zwift Click + Ride) with an allEmulationProfiles registry,
core.emulation, and the debug-only RoutingBlePlatform install in main().
2026-07-02 09:45:12 +02:00