The right puck switches itself off after a minute of not being used.
BikeControl now prevents that on its own, with no button to press. The
sequence lives in prop; this side supplies what only it knows and shows
the rider the one case they can fix.
- the gate reads raw adverts, not the device list: the sibling only has
to be nearby, and a left puck the rider ignored — every left puck in
right-side-only mode — still counts. Discovery is also the retrigger,
since an ignored puck never completes a handshake
- an optional step on the controller card, and a note on the right puck's
own card, when no left puck is in range. An offer, never a blocker
- drops the D-pad line from "use the right side only"
Fixes a related bug: the controller link counted every undone step,
optional or not, so an optional offer alone turned a working controller
amber and held back "Ready to ride". The other two links already
excluded optional steps.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
performScanning() arms a periodic 3s gamepad poll; stop() cancelled the BLE
scan and the wifi trainer scanner but not that. Worse, stop() clears
isScanning, so the next performScanning() sails past its early-return guard
and assigns a second periodic timer over the top of the first — one leaked
per stop/rescan cycle, and restoreLeftSides plus both Click V2 unlock-mode
choices all do exactly that.
Cancel it in stop(), symmetric with the method that arms it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Four things found riding the real app.
The offline note claimed "your changes apply the next time it connects",
which is simply untrue — button mappings live in the keymap, not on the
device, so nothing is queued up waiting for a reconnect. It now says what
is actually true: you can still change what its buttons do.
A smart trainer that had only just been discovered announced itself as
"Wahoo KICKR lost connection". That was mine, and the cause is worth
recording: _handleConnectionQueue calls _connect() on every queued device,
but ProxyDevice.connect() deliberately no-ops unless the rider has asked
for that trainer. Recording "connected this session" right after connect()
returned therefore marked a trainer that never connected as having
connected — and the chain then read the disconnected state as a break.
Recording now hangs off the actual connection signal, and a new
DevicePresence.discovered ("in range, never connected") maps to a grey
"Not connected" that, being optional, doesn't stop the rider being ready.
A trainer that genuinely drops is still red.
"More options" had picked up two things that don't belong in a settings
drawer: a scanner running a permanent searching animation, implying work
the app wasn't doing on anyone's behalf, and a Close row on desktop, where
SystemNavigator.pop() does nothing useful and the window's own close
button is the way out. Pairing lives in the controller card's setup sheet,
which is where the scanner already was.
The virtual-shifting takeover dialog is gone entirely — the widget, the
shouldAutoConnect gate, the settings accessors and the onboarding call
site. Tapping Connect once is the whole consent story. Two tests asserted
the old gate; one is rewritten around intent alone being sufficient, and
the widget test for the dialog's presence is dropped rather than inverted,
because showSmartTrainerConsentDialog no longer exists and bringing the
gate back could not compile.
Also removes twelve imports in overview.dart left orphaned by the chain
refactor. Verified against the untouched 6.4 baseline: analyze reports no
errors, and the suite's failures are unchanged pre-existing golden drift.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The home screen is being rebuilt as the setup chain: one card per link,
each carrying the same status light and the same tick-off checklist. This
lands the parts that decide *what* the screen says, ahead of the widgets
that draw it.
chain_state.dart is pure data with no Flutter, no BLE and no `core`, and
steps carry ids rather than sentences, so "which step is done or pending"
is unit-testable without a locale or a radio. chain_builder.dart turns a
plain ChainInputs snapshot into cards; deriveBanner reads the cards back,
so the banner can never contradict what is under it.
Remembered devices fix a real gap: a controller that is switched off or
out of range disappeared from the app entirely, so riders could not see
what they owned or edit a mapping away from the bike. We now store the
advertisement a device connected with — exactly the fields
BluetoothDevice.fromScanResult reads — and rebuild it into a real device
object of the right subclass, kept out of the connect queue. Trainers are
remembered as data only, since their card needs a name, not a contour.
Tracking which ids connected this session is what separates a red "lost
connection" from an amber "out of range"; a fresh launch with the
controller in a drawer must not paint the screen red.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fixes five review findings on the Click V2 onboarding branch:
1. "Set up again" now performs the same ClickLogic side effects
(setupHandshake / resetTimer) the connect-time flow does for an
already-connected left side, and refreshes UnlockToggle's state on
return instead of leaving it stale.
2. ClickV2OnboardingCard gained an onCompleted callback (wired to
DevicePage.onUpdate) so the device list refreshes even when no
connectionStream event fires after the onboarding page closes.
3. A connect failure in ClickV2Onboarding._connectPending() now also
surfaces a user-visible AlertNotification, not just a logged error.
New l10n key clickV2Onboarding_connectFailed added in all six
languages.
4. ClickV2OnboardingPage now builds its staggered-entrance
CurvedAnimations once in initState instead of one per row per
build, fixing an unbounded status-listener leak on _rows.
5. pendingDevices is intentionally left ungated on isPending (gating
it would break _connectPending, which needs it precisely because
isPending already flipped false) but is now correctly documented,
and _connectPending skips devices the battery saver suppressed via
the new Connection.isAutoReconnectSuppressed.
Also drops the redundant flutter/widgets.dart import from
click_v2_onboarding.dart (shadcn_flutter re-exports PageView/
PageController).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GcRAUvS3gwjmfi2qJipcc
From the +20 field log the pod replied 04 38 0f 4b to 04 11 15 and
09 01 00 00 to 01 (on 6e400003); add both as candidates (7 frames now).
Log every inbound frame and every outbound write verbatim while probing
(WHEELTOP PROBE rx/tx <slot> <hex>) so the support log is a full
transcript, not just unparseable frames. Suppress the connect-failure
give-up guidance while the experiment runs — the 147-timeout reconnect
churn is expected and is NOT rear-derailleur contention (fixed the
misleading 'claimed by the derailleur' alert the user saw with the RD
off).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The probe was only reachable via a device-page toggle, but TX pods drop
so fast the user can never open the page — the one field tester couldn't
enable it. Arm the probe automatically on the first 0x10 status frame
(the moment that proves a pod needs the reply), default on; the toggle
becomes an opt-out. Move probe creation out of handleServices into a
lazy arm on that frame.
When the experiment is off, count a connect that dies within
quickDropThreshold (5s) as a failure via the same backoff, so the
endless connect/connected/disconnected loop gives up after 3 and shows
the guidance instead of spamming forever. While the experiment is on the
device opts out (keepsReconnectingWhileDropping) so the loop keeps
cycling for the probe. Extract _engageBackoff shared by both paths.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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>
Adds per-device consecutive-failure tracking, suppression with a cooldown,
and a one-shot guidance alert (log-only on later rounds) when a device's
maxAutoConnectAttempts is exhausted. Also fixes Connection._connect's
failure path: it was cancelling the per-device connectionStream
subscription synchronously on a failed connect, before the platform's
disconnected event (delivered a radio-roundtrip later) could reach it —
silently breaking the rediscovery-driven retry loop for any failed first
connect, not just backoff-tracked devices.
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>
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>
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>
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>
The suppression that lets a controller power down was permanent, and the
controller's post-disconnect advertisement left a stale scan-dedup entry
that blocked every later advertisement from reaching addDevices — a woken
controller could not reconnect until an app restart. A cooldown timer now
lifts the suppression and purges the stale entry, so waking the controller
reconnects it automatically.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 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>
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>
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>
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>
After an in-place "No connection" disconnect, selecting Virtual Shifting
again reconnected the BLE upstream but the connect never completed:
device.isConnected stayed false and the card hung on "connecting".
The listener that flips isConnected (and drives the handshake to
completion) is created only in _connect(), which runs once via the
auto-connect queue at app start. The first manual connect reuses that
listener; disconnect cancels it (so a BLE drop doesn't fire
auto-reconnect); the second manual connect via startProxy() had no
listener and never re-ran _connect.
Route the in-place reconnect through a new Connection.connectDevice()
wrapper over _connect, re-attaching the action / connection-state
listeners — the same path the working auto-connect uses — instead of
calling ProxyDevice.startProxy() directly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
- 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>
Brings the BLE peripheral-mode migration to universal_ble 2.0.0 into the
WiFi DirCon trainer-discovery branch and bumps universal_ble to the latest
fork commit (ref: changes, 2.0.0).
Conflict resolutions:
- prop submodule: merged the universal_ble 2.0 transporter migration with
the WiFi DirCon TrainerTransport refactor; kept the '0x' short-UUID
normalisation on startAdvertising. Updated BleCharacteristic call sites
to the new 3-arg (uuid, properties, descriptors) constructor.
- obc_ble_emulator.dart: took the PeripheralServer / universal_ble 2.0
write-handler migration; kept the richer Error(button:) context on
sendAction (using _currentDeviceId, the migrated connection tracker).
- unlock.dart: kept the main.dart import.
- pubspec.yaml: kept version 6.0.0+135; took ref: changes for universal_ble.
Pre-existing prop test failures (composite/dircon/fitness serviceUUIDs) are
unchanged by this merge — they fail identically on the pre-merge branch.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Settings.trainerAppListenable fires from setTrainerApp.
- Connection.initialize listens and restarts ftmsEmulator + each
ProxyDevice's _proxyEmulator so the new advertisement name (e.g.
"Zwift Hub" for Rouvy) appears on the wire without reconnect.
- ProxyDevice.restartProxyEmulator no-ops in VS mode (ftmsEmulator
handles itself).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop bluetooth_low_energy. Move OBC BLE emulator, Zwift emulator, and
the remote mouse / keyboard pairing flows onto a new PeripheralServer
wrapper around UniversalBlePeripheral that routes per-characteristic
read/write handlers, so multiple peripheral instances coexist without
clobbering universal_ble's process-wide handlers.
Also: onValueChange callback gains a timestamp param (v1.0.0 breaking
change), PeripheralManager().showAppSettings() → openAppSettings(),
UUID.short(0x12) → literal UUID, and prop submodule bumped to the
matching universal_ble peripheral rewrite.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces hard-coded English strings in lib/bluetooth/connection.dart
with AppLocalizations accessors and adds the new keys to all six ARB
locales (en, de, es, fr, it, pl).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces hard-coded English strings in lib/bluetooth/connection.dart
with AppLocalizations accessors and adds the new keys to all six ARB
locales (en, de, es, fr, it, pl).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>