Commit Graph

21 Commits

Author SHA1 Message Date
Jonas Bark
40a114b913 test: housekeeping
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 20:23:17 +02:00
Jonas Bark
50ac4379ba fix(trainer): the bridge presents its own services and never waits on the trainer 2026-08-18 18:44:07 +02:00
Jonas Bark
4df41bdece fix(rouvy): keep the bridge connection stable 2026-08-16 14:13:09 +02:00
Jonas Bark
55d35b0add fix(rouvy): restore Virtual Shifting on the bridged trainer 2026-08-16 12:44:23 +02:00
Jonas Bark
27462b1c58 fix(rouvy): adjust the bridge's advertised services 2026-08-16 12:44:22 +02:00
jonas.bark@gmx.de
599e2e644d fix: let trainer apps on the network find BikeControl again
Retires the Windows IPv6 workaround instructions along with it — they no
longer apply.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 14:33:34 +02:00
Jonas Bark
2e63bf580a fix(dircon): derive a real mDNS serial-number for WiFi trainers
The advertised serial was sliced off the raw device id. WiFi trainer ids
are `dircon://<name>` and `dircon://` is itself exactly nine characters —
the same length as the reference serial the slice was sized against — so
every WiFi-proxied trainer advertised the identical, information-free
`serial-number=dircon://`.

Strip any `scheme://` prefix before slicing, and pad short ids instead of
letting substring throw. BLE device ids keep their existing derivation,
covered by a regression test.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 11:30:12 +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
c8776bd9bf Use 5W ERG steps for physical shifter buttons, matching on-screen controls
Physical remote/shifter buttons adjusted ERG target power in 10W jumps
while the on-screen and overlay +/- buttons use 5W. Align the button
action path to 5W and apply the same 0-500W clamp as the UI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 08:10:19 +02:00
Jonas Bark
42c246799d Merge feat/screen-recording into 6.2: screen recording action (Android + macOS) + changelog 2026-06-24 20:21:47 +02:00
Jonas Bark
81f5a433a6 feat: both-shifters combo (coincidence window) + BaseActions helpers
Add frontShiftComboEnabled getter, performInGameAction synthetic dispatch,
and a coincidence-window detector to BaseActions for two-device controllers
(e.g. Zwift Play) whose shifts arrive as separate performAction calls. When
the opposite rear shift lands within 120 ms, additively emit a frontShift
(the two rear shifts cancel; the front ring toggles). Reuses the existing
trainer-action/direct-connect routing rather than extracting a dispatcher.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:34:41 +02:00
Jonas Bark
e0cdd71e28 feat: route frontShift to FitnessBikeDefinition (direct path)
Add frontShift case to handleTrainerAction: ERG mode returns Ignored,
disabled returns Ignored, sim mode toggles front ring and returns
Success with large/small ring message. Add 3 ARB keys (6 locales) and
4 TDD tests in the consolidated test file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 15:52:00 +02:00
Jonas Bark
843f798537 cleanup 2026-06-18 16:30:01 +02:00
Jonas Bark
e9e7425c29 Integration tests: controller connections + virtual shifting through fake platform seams
Add test/integration with platform fakes installed at the plugin seams
(UniversalBle.setInstance, NsdPlatformInterface.instance); everything
above them — Connection, device classification, protocol parsers, press
state machine, keymaps, ProxyDevice — is the real code:

- controller_connection_test: scan→classification (Zwift Click/Ride via
  manufacturer data, Di2 via service UUID, FTMS trainer→ProxyDevice,
  ignored names/devices), connect lifecycle (device-info reads, battery,
  RideOn handshake, subscriptions), drops, dedupe, forget list.
- controller_button_chain_test: byte-accurate BLE notifications through
  the full reaction chain — single/double/long press, trigger remapping,
  duplicate-frame dedupe, unmapped-button error surfacing, multi-button
  Ride presses.
- virtual_shifting_connection_logic_test: retrofit-mode defaults (WiFi /
  BT-wins / proxy for power meters), auto-connect consent gating,
  in-place "No connection" disconnect + in-place reconnect, WiFi trainer
  discovery rules (found/lost/connected-survives-flap, self-exclusion),
  and an end-to-end Click-press → real action pipeline → gear shift.

Protocol-level coverage (DirCon over real TCP, BLE peripheral) lives in
the prop submodule's own tests — no prop internals in this repo.

Bug fix found by these tests: Connection.disconnect(keepInList: true)
was defeated — UniversalBle.disconnect resolves only after the platform
disconnect event, so the still-attached connectionStream listener
re-entered disconnect() without keepInList and dropped the device,
orphaning the object the open details page holds (the exact bug
0db8cf0c addressed). Guarded via _inPlaceDisconnects.

Also update stale tests to current behavior: sim-mode shifts return
Ignored since e0e4494d (handled by the bridge, not forwarded, logged
neutrally), ControllerButton.initials direction arrows, and skip the
third BC2 state-machine test consistently with its siblings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 18:59:14 +02:00
Jonas Bark
0db8cf0c31 Keep the device registered on in-place "No connection" disconnect
The "No connection" picker entry disconnects without leaving the details
page, but Connection.disconnect(forget: false) removed the ProxyDevice
from the registry (isResetting is false). The open page kept the now
orphaned object: rediscovery built a *new* ProxyDevice while the page
still pointed at the old one, so selecting Virtual Shifting again
reconnected a device absent from bluetoothDevices — its BLE notifications
were rejected ("Device not found") and the connection was force-dropped.

Add a keepInList flag to disconnect; the in-place "No connection" path
passes it so the same device object stays registered (and its scan
result is retained to avoid a churned duplicate) and remains
reconnectable on the same card. The Disconnect buttons, which pop the
page, keep the default removing behaviour.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 14:14:48 +02:00
Jonas Bark
60817dabee Smart Trainer card: stable keys, reconnect rebinding, awaited mDNS stop, No-connection UX
- ConnectionCard: "No connection" shows "Not connected" instead of the
  bridge connect instruction; switching modes keeps the bridge accordion
  mounted with inline progress (drops the "Connecting in ... mode"
  placeholder card).
- proxy_device_details: stable keys on ConnectionCard / LiveMetricsSection
  / MiniWorkoutCard. On (dis)connect, conditional siblings toggle both
  above (FTMS warning) and below (gear/settings/VS-notice) these widgets,
  trapping the unkeyed ones in Flutter's reconciliation middle and
  remounting them — which collapsed the accordion and rebuilt the page.
- ProxyDevice: re-establish the emulator-state bindings on every
  (re)connect (_rebindEmulatorState in startProxy). The in-place
  "No connection" disconnect detaches them on a reused ProxyDevice, so
  reconnecting Virtual Shifting left the UI stuck on "connecting" while
  the emulator was actually connected.
- ProxyDevice.disconnect/switchRetrofitMode/handleServices: await the
  emulator stops so mDNS/TCP is torn down before reporting disconnected,
  and log the previously swallowed detach errors.
- connection.dart: log the discovered device name instead of its runtime
  type.
- Bump prop for the awaited mDNS teardown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-10 14:06:12 +02:00
Jonas Bark
72d26000e1 warn when connecting smart trainer 2026-05-07 15:57:02 +02:00
Jonas Bark
77c09313fb Treat FE-C-only trainers as smart trainers + bump prop submodule
Widens ProxyDevice._isSmartTrainer to also return true when the scan
result advertises the ANT+ FE-C-over-BLE service (6e40fec1) so a
FE-C-only trainer like the ThinkRider X2Max routes into Virtual
Shifting via defaultRetrofitMode instead of falling through to Proxy.

Bumps the prop submodule which now carries the FE-C frame builder,
the FE-C write path in FitnessBikeDefinition, and CPS-derived cadence
for the sim recompute when no FTMS Indoor Bike Data is available.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 08:45:58 +02:00
Jonas Bark
67c970e5ba i18n: extract hardcoded strings in ProxyDevice
The 'Connect your <name> for:' header and its 5 feature bullets in
showInformation() now route through new ARB keys (proxyConnectFor,
proxyFeatureAddVirtualShifting, proxyFeatureAdjustGears,
proxyFeatureDirectControl{controller}, proxyFeatureMiniWorkout,
proxyFeatureWifiProxy).

handleTrainerAction's user-visible Success / Ignored messages
(ERG target updates, gear shift confirmations, mode switches,
intensity ±5%) are now localised via AppLocalizations.current —
matching the pattern in base_actions.dart since the dispatcher has
no BuildContext. The 'No active FitnessBikeDefinition' NotHandled
message stays English; it's an internal diagnostic, never surfaced
to the user.

DE/ES/FR/IT/PL translations added (15 keys each, tone in line with
the rest of the app — du / tú / tu / tu / ty).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 08:30:49 +02:00
Jonas Bark
5df12f908d UI adjustments 2026-04-26 09:44:56 +02:00
Jonas Bark
325c5ae464 feat(trainer-actions): consolidate shift/erg into mode-aware up/down + switchMode 2026-04-23 10:18:40 +02:00