Commit Graph

38 Commits

Author SHA1 Message Date
Jonas Bark
866c0164e7 feat(onboarding): device sub-flows and press-a-button-to-continue 2026-08-09 22:16:23 +02:00
Jonas Bark
0929cebfe3 fix(sram): prevent 3-minute idle disconnect with BLE keepalive
The SRAM rear derailleur drops idle connections after ~3 minutes.
Reverse-engineering the official SRAM AXS app revealed it requests
CONNECTION_PRIORITY_HIGH immediately after connecting. This fix adds
the same priority request, subscribes to the gear-state characteristic
for additional notification traffic, and reads it every 60s as a
fallback keepalive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-08-08 16:01:07 +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
5c44ca43f2 UI adjustments 2026-07-09 15:48:34 +02:00
Jonas Bark
0723272455 prepare release 2026-07-09 15:17:51 +02:00
Jonas Bark
c94b87f08a feat(sram): discrete-click gesture + "both levers" front-shift combo
A SRAM press is a single 0xFF edge on d9050054 — no release event, and (with
shifting disabled) no multishift burst. An --observe capture confirmed a HELD
lever emits exactly one edge, so a hold is indistinguishable from a tap and
long-press cannot be reconstructed. Replace the old instant-down+up-per-edge
guard with a small assembler that treats every press as a discrete CLICK and
reconstructs the one thing the base device can't get from the raw edges — "both
levers at once":

- a press is buffered for a short combo window; if the other lever's press lands
  inside it, both buttons are emitted together in ONE call so the base device's
  _maybeHandleFrontShiftCombo fires frontShift ({shiftUp,shiftDown}) and
  suppresses the rear shifts — the "left+right together" goal;
- otherwise the single button clicks (down+up). Single vs double click is left
  to the base device (two discrete taps in its double-click window);
- supportsLongPress is set false — it's not achievable on this hardware.

Buffer/timer reset on (re)connect and cancelled on disconnect. Single clicks now
land ~_comboWindow (90ms) after the press instead of waiting on a release that
never comes. Combo detection still needs a two-lever hardware check.

Tests: fakeAsync coverage for a single discrete click, both-levers-together one
click, a held (single-edge) lever as a single click, and two spaced taps as two
clicks.
2026-07-09 14:49:28 +02:00
Jonas Bark
2868ad39c0 some fixes 2026-07-09 09:47:29 +02:00
Jonas Bark
bd2f729981 logs 2026-07-09 09:20:36 +02:00
Jonas Bark
3778136411 fix(sram): differentiate left/right shifters and default one lever to shift down
Testers reported both AXS shifters doing the same thing and gears only ever
increasing, with presses logged as a generic "SRAM Paddle". Root cause: both
drop-bar paddles report button mask 1, so the mask alone can't tell them apart,
and every discovered button was hardcoded to InGameAction.shiftUp.

- Use the button event's controller device_type (prop SramPress.deviceType,
  field 2) to name and key buttons, so left and right become distinct keymap
  entries even in a plaintext (serial-less) session — the common case in the
  field. Names now resolve to "SRAM Left/Right Shifter" without needing an
  advert or the sparse d9050003 serial.
- Default the LEFT paddle to shift DOWN and everything else to shift UP so the
  shifters aren't identical out of the box ("one lever changes down") without
  hunting through the keymap. Every button stays freely remappable.
- Persist the device_type in the button record so a restart re-registers the
  same left/right name + default instead of a duplicate entry; two serial-less
  paddles that differ only by side stay separate, and a legacy side-less record
  upgrades in place once the side is known.
- Remember a shifter's side against its serial (preserving any known model) when
  both are seen, so its other buttons resolve the same name.
- Bump the prop submodule to the field-2 decode.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H48NvkfXYm2spiiwcTQsv8

# Conflicts:
#	prop
2026-07-09 09:20:12 +02:00
Jonas Bark
c3811410a1 refactor(sram): split setup-sheet UI out of the device file
sram_axs.dart had grown to ~990 lines by carrying the whole guided
setup/restore sheet. Extract it in two layers:

- lib/widgets/guided_operation_sheet.dart — reusable, feature-agnostic
  building blocks (StepRail, StageBadge, ProgressChecklist) any staged
  setup flow can compose.
- sram_setup_sheet.dart — the SRAM-specific composition, copy, palette
  and the AXS "press & hold" hero.

The device file (446 lines now) keeps only device/BLE logic and the
trimmed panel. No behaviour or pixels change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 09:19:22 +02:00
Jonas Bark
50c3b6de09 fix(sram): cap guided sheet width on wide displays
The setup/restore bottom sheet spans the full window width; on desktop
that stretched the content unpleasantly. Centre it and cap it at 480
(heightFactor: 1 keeps the sheet shrink-wrapped to its content height).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 09:19:22 +02:00
Jonas Bark
405dcf2362 refactor(sram): trim setup panel to status + action only
The panel duplicated the device card's own header and mappable-button
list. Reduce it to just the current status (intro + "Set up SRAM
control", or the "shifting off" strip + "Restore") since the card
already shows the device name and the discovered buttons. Removes the
now-dead _SramDeviceHeader/_SramStepChip/_SramControlRow widgets, the
debugSeedButton test hook, and 11 orphaned l10n keys. The guided bottom
sheet is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 09:19:22 +02:00
Jonas Bark
e7cc7d5441 feat(sram): redesign setup/restore UI from design-system handoff
UI-only reskin of _buildSetupPanel + _runGuidedOperation (BLE/decode logic and
the _SramSetupStage machine untouched): a two-state device panel (header + tile,
3-step diagram / status strip + mappable-controls list) and the guided flow
re-presented as a bottom sheet with a step rail, icon badge, progress checklist,
and the AXS press-and-hold hero. +20 localized strings (en/de/es/fr/it/pl);
reduced-motion honored; snapshot test renders the real sheet stages via a
@visibleForTesting builder.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 09:19:22 +02:00
Jonas Bark
bc3b6c7a7b i18n(sram): localize the SRAM setup/restore UI strings (en/de/es/fr/it/pl)
Externalize the panel + guided-dialog strings into intl_*.arb across all six
languages and wire sram_axs.dart to context.i18n. Button/log labels stay in
English (technical identifiers). Regenerated lib/gen is gitignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 18:51:49 +02:00
Jonas Bark
140f41e60c fix(sram): only treat the 1-byte 0xFF edge as a press (stop read-response loop)
The real cause of the runaway: handleTrigger reads d9050054 to decrypt the
button event, and on iOS/CoreBluetooth a read response is also delivered via
the notify callback — so the multi-byte read value re-entered processCharacteristic
and triggered another read, looping at BLE-read cadence (~120-180ms) from a
single click. Ignore anything that isn't the 0xFF edge (§6.1). The §7 multishift
guard from the previous commit stays as defense against genuine held-paddle bursts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 17:57:58 +02:00
Jonas Bark
9d4684922b fix(sram): suppress multishift bursts; only prompt authorize when a bond is needed
Add the protocol §7 multishift/hold guard: a held paddle makes the derailleur
emit a rapid burst of triggers — forward the first two (so a real double-click
still reaches the base device) and drop the 3rd+ rapid one, fixing a runaway
press loop. Also make the guided setup/restore dialog try the operation first
and only ask the user to press-and-hold the AXS button if a fresh bond is
actually required — no re-authorize prompt when already bonded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 17:51:00 +02:00
Jonas Bark
df1cebd326 fix(sram): exclude non-button components from pre-registration; stabilize names
sramShifterAdverts now gates on effectiveType (no model escape hatch), so a
front derailleur or dropper post no longer mints a phantom paddle button.
Persist each shifter's advertised type/model by serial so a button's §6.4 name
survives sessions where the shifter isn't advertising, instead of orphaning the
keymap mapping.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 17:34:52 +02:00
Jonas Bark
821ba2d0fe feat(sram): connect only to the rear derailleur; name buttons per shifter type
Filter scan results to the RD (device-type record in the 0xFE51 advertising
service data, §2), so we no longer create a controller for bare shifters. Name
buttons from the pressing shifter's advertised type/model (§6.4 — Left/Right
Shifter, Aux Top, Bonus, ...) and pre-register nearby shifters' buttons on
connect so they appear without a press; degrade to Shifter A/B when no advert.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 17:17:18 +02:00
Jonas Bark
086b127158 fix(sram): guided restore + drop vestigial re-run button
Restore now runs through the same staged dialog as setup, so when the session
key didn't survive a reconnect and a fresh bond is needed, it guides the
press-and-hold AXS authorize gesture and shows the error with a Retry instead
of only logging to the console. Remove the 'Re-run SRAM setup' button (a no-op
once shifting is disabled). Log once per connection when a press can't be
decoded, to make the key-not-active-this-session case visible.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 16:27:51 +02:00
Jonas Bark
2e59a71518 feat(sram): interactive setup dialog on the main card with visible errors
Move the setup/restore panel onto the main device card (showAdditionalInformation)
and make setup a guided dialog: instructions to press-and-hold the AXS button →
progress → success, or the actual error (e.g. bond authorization failure) with a
Retry, instead of only logging to the console. Restore surfaces a toast.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 16:04:27 +02:00
Jonas Bark
8204a41a8b fix(sram): never overwrite the saved backup on re-run; re-bond stale keys
setupControl captures the original config only once and never overwrites a
saved backup (a re-run reads the already-cleared device and would wipe it);
restore clears the backup so a later setup re-captures. Both flows verify the
session key via ensureBonded and persist any re-bond.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 15:09:13 +02:00
Jonas Bark
200ee36e1b refactor(sram): use BikeControl's built-in double-click, drop custom gesture layer
Each physical (shifter, button) now emits one press so the base device
handles single/double click from the keymap, like every other controller.
Removes the SRAM-specific tap-count timer and the double-click-window setting/UI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 14:47:13 +02:00
Jonas Bark
01ec230a2b feat(sram): guided setup / restore preferences panel
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 14:11:04 +02:00
Jonas Bark
e2475a9b76 feat(sram): decode presses into per-shifter/button model via prop logic
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 14:04:10 +02:00
Jonas Bark
c1ca003cf4 feat(sram): universal_ble transport implementation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 13:36:38 +02:00
Jonas Bark
5eefec6002 UI fixes 2026-04-28 08:39:48 +02:00
Jonas Bark
eabe519188 UI improvements 2026-04-25 22:36:25 +02:00
Jonas Bark
5492caa8fe new ui #18 2026-03-12 07:38:20 +01:00
Jonas Bark
97318ffa1c new ui #1 2026-03-10 12:35:36 +01:00
Jonas Bark
2317b27535 adjustments to sram + thinkrider 2026-02-25 20:17:26 +01:00
Jonas Bark
dd1dee3d6a supports long press for base device as field 2026-02-25 09:47:52 +01:00
Jonas Bark
173fa6f9f1 show a message in configuration when no buttons available for a device 2026-02-01 10:00:43 +01:00
Jonas Bark
565d14c3c0 group buttons by device, add new unlock mechanism 2026-01-23 15:27:32 +01:00
Jonas Bark
92a577f8ae axs info 2025-12-22 08:21:02 +01:00
Jonas Bark
9b7e5b91c5 bugfixes and clarifications 2025-12-20 10:01:37 +01:00
Jonas Bark
2f2a5ec0db sram fix 2025-12-19 21:06:13 +01:00
Jonas Bark
5bf75df016 SRAM AXS support 2025-12-19 20:41:27 +01:00