You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Architecture: split the 1,500-line TeslaBleController and move the per-vehicle protocol state machine into core #118
TeslaBleController.kt is 1,483 lines. Its inner class VehicleLink (L608-L1442,`` about 840 lines) covers all of these, driven by android.os.Handler runnables:
transport lifecycle, reconnection and backoff;
session handshakes, the pending-request table and encrypted command I/O;
the pairing state machine and whitelist slot resolution;
polling cadence, history recording and logging.
The outer class adds scanning and discovery, vehicle persistence, selection and the UI state.
It is the most-changed file in the repo (touched by 50 of 250 non-merge commits) and has no tests. "Controller state-machine tests" is still open in the master plan.
detekt was fitted to the class instead of the other way round. LargeClass: 700 carries the comment "VehicleLink is one cohesive per-car state machine… splitting it would scatter that state", and TooManyFunctions.thresholdInClasses is set to 45 (config/detekt/detekt.yml).
It undercuts the library goal. The master plan says core becomes a reusable Tesla BLE library after v1. But what a library user needs lives in the Android app: per-domain handshakes, request/response correlation, anti-replay windows, re-handshake and resync, add-key with whitelist confirmation, and polling cadence. A published core would offer only primitives.
Add a platform-agnostic VehicleClient to core, one instance per car:
input: a transport interface (incoming: Flow<ByteArray>, send(ByteArray)), an injectable clock and an injectable CoroutineScope/dispatcher;
output: state: StateFlow<VehicleState> and suspend functions (handshake(domain), wake(), readCharge(), pair(key));
session and pairing logic written as explicit state machines.
Keep Android-specific parts in app: TeslaGattClient (the Android transport), scanning, the foreground service, persistence and UI mapping.
Unit-test the client against FakeCarProtocol, moved into a core test fixture, using kotlinx-coroutines-test virtual time. That covers retries, timeouts, faults and pairing without an emulator.
Once the class is split, restore detekt's default LargeClass and TooManyFunctions thresholds.
Progress: #215 moved the pairing state machine into core as PairingFlow, and #217 moved the session handshake into core as SessionHandshake. The rest of VehicleLink has not been split yet.
Activity
dzid26 commentedon Oct 15, 2026
Progress: #215 moved the pairing state machine into core as PairingFlow, and #217 moved the session handshake into core as SessionHandshake. The rest of VehicleLink has not been split yet.
Generated by Claude Code