The keymap ('app') and the trainer app ('trainer_app') are independent
prefs. When the keymap one is missing while a trainer app is selected,
actionHandler.supportedApp stays null — every button press then threw
"Null check operator used on a null value" and the device registered no
buttons at all, so the SRAM edit screen came up empty.
- RemoteActions/DesktopActions/AndroidActions no longer dereference
supportedApp (or getKeyPair) with `!`; they return the same
noKeymapSet / noActionAssigned Error BaseActions already produces.
- Fall back to the selected trainer app when the keymap pref can't be
resolved (initializeActions, Settings.init, deleteCustomAppProfile).
- BaseDevice.getOrAddButton keeps the created button in availableButtons
even without a keymap, so the device still renders its buttons.
- The OBC BLE/mDNS emulators evaluated connectedApp.value! before the
null guard that follows, making the guard dead code — reordered.
- handleButtonsClicked now forwards through recordError, which is why
this never showed up in crash reporting.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Running BikeControl on a second device made the one next to the trainer app
unreachable. Each install now advertises its own identity.
Because that identity changes, an app that was already paired will ask to
pair once more.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Replaces the copy-pasted "first non-loopback IPv4" interface selection
with prop's AdvertisedAddressPicker (prefers the real LAN interface over
VPN tunnels, virtualization bridges and link-local adapters) and bumps
the prop submodule with the DirCon TCP/mDNS hardening: reconnect
supersede, socket onError handling, port-bind fallback with
actually-bound-port advertising, dual-stack listener.
Co-Authored-By: Claude Fable 5 <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>
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>