Commit Graph

19 Commits

Author SHA1 Message Date
Jonas Bark
653dfbf461 feat(click-v2): hold discovered controllers for unlock-mode onboarding 2026-08-03 09:21:02 +02:00
Jonas Bark
1fed2971e5 fix: subscribe to all WHEELTOP notify slots; log reply slot + length
The +15 field log showed the probe auto-arming and the pod RESPONDING to
each candidate — but the response logged as empty. Cause: we subscribed
to 6e400002 only, so a reply on the second Nordic-UART slot (6e400003)
was never delivered, and the empty frames were artifacts on the write
slot. Subscribe to every notify/indicate characteristic (pressed-set
dedup absorbs any duplicated button event), and log each unexpected frame
with its slot and byte length so an empty artifact is distinguishable
from a real reply. Next field log will show which slot the pod answers on
and the actual bytes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 08:26:49 +02:00
Jonas Bark
4a7a301043 feat: WHEELTOP keepalive-reply prober (opt-in beta experiment)
TX pods drop the link after three unanswered 1 Hz status frames; the
derailleur's reply is unknown and undocumented anywhere public. When the
user opts in (device page > Preferences), each reconnect cycle writes
the next reply candidate (type-echo, ack, 3-byte XOR shapes, bare ACK —
on 6e400003 first, then other writable NUS slots) once after subscribe
and again per status frame, and logs the connection lifetime per
candidate. A lifetime past 5 s marks the likely answer; unexpected
frames are logged loudly as potential pod responses. Worst case per
attempt is the disconnect that already happens.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 09:38:50 +02:00
Jonas Bark
0cd08ab2a9 fix: silence backoff rounds, cancel cooldown timers, pin alert-once guarantee
Once a Wheeltop shifter gives up (backoff), each 90s cooldown round was
still emitting a "Connecting to:" toast and a "...disconnected" WARNING +
OS notification, defeating the "one clear alert, then quiet" goal. Add
Connection._isInBackoff and gate both the auto-connect queue's notify
toast and the connection-state listener's disconnected toast/OS
notification on it.

The cooldown timer scheduled by _recordConnectFailure was anonymous and
shared _suppressedAutoReconnect with the battery saver, so a stale timer
from an earlier round could lift a later (even unrelated) suppression
early. Track timers per device id, cancel-and-replace on each new round,
cancel on Retry, and cancel all on disconnectAll().

Also correct a comment in _connect's catch block that described only the
fake platform's failure ordering (throw before the disconnected event) —
real Android delivers the event before or after the exception depending
on the device, and both orderings depend on _connectionSubscriptions
staying attached.

Extend the "successful connect resets the failure counter" integration
test to also cover Retry clearing the counter and the give-up alert
firing only once per session across a second suppression round.
Post-threshold rounds no longer toast, so tests now count attempts via a
new FakePeripheral.connectAttempts platform-level counter where needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 17:32:22 +02:00
Jonas Bark
d9ee333648 test: fake-platform connect failures + Wheeltop EDS fixture
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 16:39:27 +02:00
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
e310adbceb Merge branch '6.2' into 6.3
Brings SRAM AXS shifter support, beta-access/Shorebird track, and the
battery-saver timeout fix into 6.3. Merged the prop submodule (83f4bf9) so the
SRAM parser/button-tables and the Climb protocol coexist. Resolved: CHANGELOG
(SRAM AXS folded into 6.3.0), the prop pointer, and repointed the SRAM
integration test to the fake-BLE harness that 6.3 promoted into lib/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 12:04:00 +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
Jonas Bark
15ce431098 fix(emulation): silence dangling doc-comment info with library directive 2026-07-02 09:36:03 +02:00
Jonas Bark
34c523eb58 feat(emulation): RoutingBlePlatform + real-platform factory 2026-07-02 09:28:32 +02:00
Jonas Bark
20ea804198 Reapply "refactor(emulation): promote fake BLE harness from test/ to lib/bluetooth/emulation"
This reverts commit 0346594c2e.
2026-07-02 09:14:48 +02:00
Jonas Bark
0346594c2e Revert "refactor(emulation): promote fake BLE harness from test/ to lib/bluetooth/emulation"
This reverts commit 45e987ef97.
2026-07-02 09:06:53 +02:00
Jonas Bark
45e987ef97 refactor(emulation): promote fake BLE harness from test/ to lib/bluetooth/emulation 2026-07-02 09:05:06 +02:00