Commit Graph

1245 Commits

Author SHA1 Message Date
Jonas Bark
45e987ef97 refactor(emulation): promote fake BLE harness from test/ to lib/bluetooth/emulation 2026-07-02 09:05:06 +02:00
Jonas Bark
69109184a7 feat(rizer): EliteRizer steering (calibration + PWM to steer actions)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 23:55:17 +02:00
Jonas Bark
6c478094d1 feat(rizer): EliteRizer incline device + name-based registration
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 23:51:21 +02:00
Jonas Bark
acedcd36df feat(rizer): Elite Rizer incline protocol + encoder
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 23:45:19 +02:00
Jonas Bark
fc83374306 refactor(incline): drive dispatch/sink-selection/UI off any incline device
- connection.dart: add inclineDevices getter (ManualInclineDevice) and
  generalize sinkProvider to pick any connected InclineSink, not just
  WahooKickrClimb; relay fallback unchanged
- base_actions.dart: dispatch incline actions to inclineDevices, not
  climbAccessories; error message now says "No incline device connected"
- button_edit.dart: gate incline card on inclineDevices, title uses
  inclineActions l10n key (generic "Incline")
- keymap.dart: hasActiveAction incline clause gates on inclineDevices
- incline_controller.dart: reset _lastWritten on manual hold so returning
  to auto re-asserts the grade even when grade equals last auto-written value
- incline_controller_test.dart: add re-asserts-after-manual-hold test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 23:40:41 +02:00
Jonas Bark
1b10dee7f1 refactor(incline): generic incline in-game actions + labels
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 23:34:57 +02:00
Jonas Bark
b2b63ea84a refactor(incline): extract ManualInclineDevice mixin shared by incline devices
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 23:30:48 +02:00
Jonas Bark
8bd23d7385 refactor(incline): rename Climb incline pipeline to device-agnostic Incline*
ClimbInclineSink → InclineSink, ClimbController → InclineController,
ClimbManualState → InclineManualState, ClimbMode → InclineMode.
Moves lib/bluetooth/climb/{climb_incline_sink,climb_manual_state,climb_controller}.dart
→ lib/bluetooth/incline/{incline_sink,incline_manual_state,incline_controller}.dart
and corresponding tests. Decouples InclineManualState from wahoo_climb.dart
constants (own kInclineManualMinGrade001/kInclineManualMaxGrade001, same values).
WahooKickrClimb and _ClimbRelaySink stay Climb-named; no behavior changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 23:27:58 +02:00
Jonas Bark
4a7637a815 feat(climb): ClimbController 1 Hz pipeline + Connection wiring
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 21:47:45 +02:00
Jonas Bark
8d99bf418b feat(climb): register KICKR Climb, generalize accessory exclusion, dispatch actions
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 21:28:50 +02:00
Jonas Bark
ae6dce0df2 feat(climb): WahooKickrClimb BLE device + ClimbInclineSink + Accessory marker
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 21:14:46 +02:00
Jonas Bark
2fdbf376c3 feat(climb): pure ClimbManualState (auto/manual/step/clamp)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 21:00:30 +02:00
Jonas Bark
dbea4e1f90 feat(phone-steering): expose live angle + calibration notifiers and recalibrate() 2026-06-30 10:31:00 +02:00
Jonas Bark
4612e62778 fix(battery-saver): extend local-method inactivity timeout to 60 min
When the local connection method (Keyboard/Touch/Media) is the only one
active, the battery saver disconnected idle controllers after 30 minutes
of no button activity. Riders on long steady efforts (e.g. Z2) with no
shifting got dropped mid-ride. Double the local-only sliding window to
60 minutes; the network method still never times out while connected.

The disconnect alert is parameterized off timeout.inMinutes, so it now
reads "60 minutes" with no string change.

Fixes #349

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 09:58:26 +02:00
Jonas Bark
782f60895e fix(obc): reset app-info reassembler on disconnect and bound the buffer
A half-received or corrupt app-info write was retained forever (cleared only
on a successful parse), poisoning every later parse so OpenBikeControl never
reported "Connected to app" again until app restart. Reset the reassembler on
disconnect and cap the buffer at 512 bytes so a stuck/corrupt stream recovers
and can't leak. Adds regression tests for reset and the bound.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 19:58:26 +02:00
Jonas Bark
2954deb1f2 test: full connection-card goldens (with action badges) for 8 controllers
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 18:14:08 +02:00
Jonas Bark
ff57b005d5 feat(shifting): show 2×N gear position when the front derailleur is active
With the virtual front derailleur on, the compact gear readout switches
from rear gear/total (14/25) to head-unit-style front×rear position
notation (small ring 1×N, large ring 2×N, e.g. 2×14) — matching how
Garmin/Wahoo display Di2/AXS gearing. With it off, it stays 14/25.

- Add tested formatGearReadout helper.
- Wire into the proxy card, debug menu, desktop second window + Android
  PiP/overlay (trainer_overlay_view), and the gear hero card (2× · 50T).
- Carry frontShiftEnabled + frontRingLarge through TrainerOverlayState
  (json, ==, hashCode, activity map) so the snapshot reaches the overlay
  and the iOS surfaces.
- iOS PiP + Live Activity: format 2×N centrally in GearSnapshot.
- Standardize the off-state readout to 14/25 across all surfaces.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 15:02:40 +02:00
Jonas Bark
b3960ba36c test(obc): cover app-info fragment reassembly; extract AppInfoReassembler
Extract the OpenBikeControl app-info fragment-stitching out of the BLE
emulator's write handler into a small, behavior-preserving AppInfoReassembler
so it can be unit-tested directly (the emulator's startServer() is otherwise
only reachable through the live peripheral platform).

Adds regression tests for the multi-packet app-info write (TrainingPeaks on
macOS), including the three-fragment case the previous single prior-fragment
buffer dropped — it kept only the first failed fragment, so a message split
across three packets never reassembled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:45:36 +02:00
Jonas Bark
1549c4c73c feat(proxy): show transport icon to disambiguate same-named trainers
When the same trainer is discovered over both WiFi (DirCon) and Bluetooth,
two proxy entries appear with an identical name (both already Beta). Add a
small WiFi/Bluetooth icon left of the Beta pill, shown only when a same-named
sibling exists, so the duplicates can be told apart.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:39:38 +02:00
Jonas Bark
0f81549740 refactor: share BLE advertising "already started" recovery via mixin
Extracts the recovery added for OpenBikeControl (abe636d4) into
PeripheralAdvertisingRecovery and applies it to ZwiftEmulator too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:08:18 +02:00
Jonas Bark
9a0e6262b7 Merge branch '6.1' into 6.2
# Conflicts:
#	prop
2026-06-25 08:31:52 +02:00
Jonas Bark
95b7a7ff06 fix(zwift): put Rouvy advertisement service UUIDs in the scan response
The Rouvy Zwift-BLE advertisement (Zwift fc82 + OBC 128-bit UUID + name
"BikeControl" = ~38 bytes) overflows Android's 31-byte primary packet, so
startAdvertising fails with "Data too large" — Rouvy users on 6.1 can't
connect (the bluetooth_low_energy -> universal_ble migration stopped
splitting service UUIDs into the scan response).

Bump universal_ble to the fork commit that adds
PeripheralAndroidOptions.addServicesInScanResponse, expose it through
PeripheralServer.startAdvertising, and enable it for the Rouvy branch of
the Zwift emulator. Primary packet becomes flags+name (~16B), scan
response carries the UUIDs (~22B); active scanners still see everything.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 08:27:39 +02:00
Jonas Bark
9413a1fc56 fix(obc): resolve "Address already in use" on the OpenBikeControl server
The OpenBikeControl mDNS emulator hit EADDRINUSE on its fixed port 36867
when "Connect directly over network" was toggled off then on: the
un-awaited stop() hadn't released the socket before start() rebound it.

- Bump prop submodule: ResilientTcpServer now supersedes a stale
  same-port instance before binding and defaults to walking ports
  (portAttempts: 5).
- OBC advertises the ACTUAL bound port via mDNS instead of a hardcoded
  36867, so it can walk to a free port and stay reachable (mirrors the
  DirCon emulator). Companion apps read the port from the SRV record.
- Reset isStarted on every start-failure path so a genuinely blocked
  port no longer leaves the feature showing as "running".
- Pin MyWhoosh Link to portAttempts: 1 (fixed-port contract preserved).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 07:34:47 +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
7c9ee4f747 feat: same-frame both-shifters combo → frontShift (Ride/Click)
Detect when a single BLE frame carries both the shiftUp-mapped and
shiftDown-mapped buttons (Zwift Ride / Click single-device controllers)
and emit a single frontShift, suppressing the two rear shifts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:43:33 +02:00
Jonas Bark
282841bd37 feat(zwift): forward frontShift as both-shifters combo frame
Intercept InGameAction.frontShift in ZwiftEmulator.sendAction and emit
the SHFT_UP_R|SHFT_UP_L combined buttonMap frame followed by the release
frame — the standard Zwift Ride gesture that triggers a front-chainring
shift in Zwift (SRAM) and a generic controller gesture in other apps.
No app-capability flag, no fallback, no toggle state.

UNVERIFIED: bitmask vs live Zwift SRAM — confirm on-device.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:24: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
e8d2599809 feat: seed chainring config into FitnessBikeDefinition
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 15:46:25 +02:00
Jonas Bark
abe636d40f fix OpenBikeControl failed to advertise: Advertising has already started 2026-06-24 14:23:35 +02:00
Jonas Bark
0008e173a2 feat: label OpenBikeControl TCP server; gate iOS local-network inference to iOS 2026-06-22 10:53:56 +02:00
Jonas Bark
a6f409f9ea misc fixes 2026-06-18 17:48:25 +02:00
Jonas Bark
3eaea1932d Stop battery-saver-disconnected controllers from auto-reconnecting
The inactivity disconnector parks idle controllers with
disconnect(forget: true, persistForget: false) so they stay off the
ignore list and the user can reconnect. But controllers auto-connect
unconditionally at the addDevices() choke point, so the controller
reconnected the instant it was rediscovered (scan result /
getSystemDevices / the disconnect listener's performScanning) — right
after being parked, defeating the battery saver.

Track parked controllers in a session-scoped _suppressedAutoReconnect
set, populated before each inactivity disconnect and filtered at the
addDevices() choke point. Clear it only on explicit intent — the alert's
Reconnect action and connectDevice() — and wholesale in disconnectAll().
Clearing on every successful _connect raced: a connect still in flight
when the timeout fires resolved afterwards and wiped the fresh
suppression, so the controller looped straight back.

disconnectAll() clears the set (BT off / full reset makes it moot), and
the integration harness reset routes through it so a parked controller
can't leak into the next test and block its connect.

Tests: a parked controller is not auto-reconnected on rediscovery, and
the Reconnect action lifts the suppression and brings it back.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 16:55:36 +02:00
Jonas Bark
843f798537 cleanup 2026-06-18 16:30:01 +02:00
Jonas Bark
786621a11b Localize TrainerConnection titles (re-evaluate per locale)
The connection titles ("Connect using Bluetooth", "Connect directly over
Network", "Connect using MyWhoosh Link", ...) were captured once at object
construction in English, so they didn't follow the active locale. Back the
title with a builder (String Function()) and expose it via a getter so it
re-localizes — fixing the English titles in the localized store screenshots.
Updated all 10 subclasses and the fake connection in the bridge-transport test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 11:47:43 +02:00
Jonas Bark
b201cb3e53 Generate localized store screenshots (golden_screenshot 11)
- Bump golden_screenshot 8.2.0 -> ^11.0.1 (drops the Yaru dependency, hence the
  linux plugin-registrant change).
- screenshot_test.dart now renders each scene for 6 locales (en/de/es/fr/it/pl)
  via a shoot() helper, writing screenshots/<locale>/<scene>-<device>.png.
  Marketing titles are translated per locale (de/es/fr/it/pl are drafts).
  - main.dart: screenshotLocale global drives the app locale in screenshot mode
    (was hardcoded to English).
  - v11 only loads fonts found in the rendered tree, so loadAssets() runs after
    the first pump.
- Virtual Shifting scene shows the gear UI instead of the "trainer doesn't
  advertise FTMS" warning: added ProxyDevice.debugAttachFitnessBike (test seam,
  no server side-effects) and hide the MyWhoosh gearing hint in screenshot mode.
- prepare_store_screenshots.sh maps each store locale from its language folder
  (de-DE <- screenshots/de, ...).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 11:22:56 +02:00
Jonas Bark
b5da4ac595 fix: persist the right-side-only keymap remap across restarts
The "use the right side only" button remapped the active keymap (+ shifts up,
B shifts down) in memory, but the change was lost on the next launch when the
active profile was a built-in app: those keymaps are code-defined templates
rebuilt on startup, and Settings.setKeyMap only persists key pairs for custom
profiles.

Mirror the button editor: if the active profile isn't already a custom one,
fork it into a "<App> (Copy)" custom profile (via KeymapManager.duplicateSync)
before applying the remap, then persist. The remap now runs before the left
side is disconnected so the forked copy keeps every connected controller's
existing mappings. Adds a regression test covering both the built-in-fork and
already-custom paths, including a reload from storage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-17 20:51:59 +02:00
Jonas Bark
f4023892cf fix: show "Use new unlock method" toggle only on the controller detail page
Move the new-unlock-method toggle from showAdditionalInformation (rendered on
both the compact overview card and the detail page) into buildPreferences,
which the controller detail page renders under "Preferences". The toggle now
appears only when the controller entry is opened, not on the overview card.
The Click V2 left side inherits this from ZwiftClickV2; the right side gets its
own override. Unlock-status warnings and the "use right side only" prompt are
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-17 20:40:36 +02:00
Jonas Bark
e37a9de61d increase Zwift Click recommended firmware to 1.2.0, cleanup 2026-06-17 20:38:59 +02:00
Jonas Bark
6778c1e45b feat: optimize Zwift Click V2 left/right experience
- Make the split left/right controllers available to everyone: replace the
  isPro gate in the device factory with a "Use new unlock method" setting
  (default on); off falls back to the legacy unified ZwiftClickV2.
- Add the "Use new unlock method" toggle to all three Click V2 settings panels;
  flipping it reconnects the Click as the new/legacy representation.
- Fix the "Unlock again" button placement: on narrow side-by-side cards the
  action now drops below the status text instead of squeezing it.
- Add "Use the right side only" to the right side when a left side is connected:
  ignores the left side (reversible via Ignored Devices) and remaps the active
  keymap so + shifts up and B shifts down.
- Localize new strings (de/es/fr/it/pl; en already present) and add
  factory/settings unit tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-17 19:50:08 +02:00
Jonas Bark
f29546f3c7 refactor: address review feedback on inactivity disconnect wiring 2026-06-17 19:50:08 +02:00
Jonas Bark
ad8501ac8b feat: wire activity-aware inactivity disconnect into Connection (#329)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 17:17:10 +02:00
Jonas Bark
ef87205156 refactor: address review feedback on InactivityDisconnector
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 17:10:48 +02:00
Jonas Bark
6b4e016511 feat: add InactivityDisconnector battery-saver state machine
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 17:01:35 +02:00
Jonas Bark
6e0861e556 Name the trainer app and show its transport in connection alerts
The "connected"/"disconnected" activity alerts fired when a trainer app
attaches to one of our emulators now name the app ("Connected to Zwift",
"Disconnected from Zwift") and tag the alert with the transport, so the
activity log shows a WiFi or Bluetooth icon depending on how the app is
connected instead of always Bluetooth.

- AlertNotification gains a connectionType field + a connection() factory
  that builds the localized, app-named message and tags the transport.
- All 6 emulator call sites (Zwift BLE, FTMS/Rouvy mDNS) route through it,
  passing their own type and core.settings.getTrainerApp()?.name.
- ConnectionMethodType.activityIcon maps network -> wifi, else -> bluetooth;
  overview threads connectionType through and uses it for the leading icon.
- Reuse existing connectedTo string; add disconnectedFrom (en/de/es/fr/it/pl).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-14 21:22:59 +02:00
Jonas Bark
c41683421e Merge remote-tracking branch 'origin/6.0.1' into custom-mdns-responder
# Conflicts:
#	.gitignore
#	lib/bluetooth/devices/openbikecontrol/obc_mdns_emulator.dart
#	prop
2026-06-12 12:03:37 +02:00
Jonas Bark
e736425331 Keep Zwift/Rouvy controller connection alive when idle (#367)
Zwift and Rouvy drop a wired LAN controller after ~30s without traffic. The Ftms/Rouvy mDNS emulators only emit on a button press, so an idle rider (pedalling, not shifting) goes silent and gets disconnected.

Add a ControllerKeepAlive timer that re-emits the neutral "released" controller frame every 5s while a client is connected, started/stopped from each emulator's isConnected listener. It's the same frame a key-up sends, so it resets the peer's inactivity watchdog without registering a phantom press.

Also drops an earlier keepalive attempt from OpenBikeControlMdnsEmulator — that path speaks the OpenBikeControl protocol, which Zwift doesn't use.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 11:03:42 +02:00
Jonas Bark
b2de1d56f0 OBC emulator: pick the advertised IPv4 via AdvertisedAddressPicker
Replaces 'first non-loopback IPv4', which on Android advertised the
phone-internal CLAT dummy address (192.0.0.8) when the 464XLAT
interface enumerated before wlan0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 10:42:11 +02:00
Jonas Bark
fb84ffbcf1 Merge remote-tracking branch 'origin/6.0.0' into custom-mdns-responder
# Conflicts:
#	lib/bluetooth/devices/openbikecontrol/obc_mdns_emulator.dart
2026-06-11 21:56:19 +02:00
Jonas Bark
44ed08070f Use the custom mDNS responder on desktop (TrainingPeaks IPv6 fix)
Switch the OBC/DirCon advertisement to prop's ServiceAdvertiser seam and
select the in-process responder backend on macOS/Windows/Linux at app
startup. The advertisement now carries a dedicated hostname with a
single A record, so Mono-based trainer apps (TrainingPeaks) no longer
pick a scope-less IPv6 link-local and fail with 'No route to host'.
iOS/Android keep the OS responder via nsd.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 20:46:19 +02:00
Jonas Bark
2f98f0c7fc Move OpenBikeControl + MyWhoosh Link servers onto ResilientTcpServer
Both had the fragile accept-loop copy: no teardown identity check (a
reconnecting app's old socket killed the new session), no onError
(abrupt resets became uncaught async errors), shared: true (a second
app instance silently stole connections). They keep their fixed
protocol ports (36867 / 21587) — no port fallback; a blocked port now
fails loudly instead of misbehaving.

Bumps prop with the shared ResilientTcpServer, its tests, and the
in-flight custom mDNS responder work.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 20:44:35 +02:00