feat(android): assemble vehicle VIN from DashKit CAN stream (2/4) - #211
Conversation
dd2da90 to
e15060c
Compare
|
Reworked per @wpmed92's review (force-pushed as a single commit; layers 3/4 rebased on top):
Validation: host assembler unit tests pass; decoder-integration check exercised updateFrame→assembler through the real VehicleDecoder; full :app:testDebugUnitTest\ green at every layer of the rebuilt stack. |
Move VIN assembly into the C++ layer (repo/bridge/car/vin_assembler.h), hooked into VehicleDecoder::updateFrame so it rides the existing decode path with no extra pass. The assembler reads raw frame bytes on purpose: VIN_B405/VIN_C405 are 56-bit signals, wider than double's 53-bit mantissa, so the normal Signal::getValue path would silently corrupt the top byte(s). VIN is surfaced next to CarState rather than inside it: CarState is a fixed DoubleArray across JNI that flows to dash apps, and the plan keeps the VIN out of dash-app data/persistence/logs. New JNI surface: nativeGetVin(handle) -> String? and nativeResetVin(handle); Kotlin side exposes them via CanFrameDecoder.getVin()/resetVin(). DashKitDataSource keeps its vinState StateFlow and teardown resets unchanged, so downstream layers need no changes. VehicleVinState stays in Kotlin as the flow's type; the pure-Kotlin assembler and its tests are deleted, CanPacketVinTest now covers packet parsing only, and host-run native unit tests cover the assembler (dashpilot-android/bridge/tests/vin_assembler_test.cpp, wired as a CMake/CTest target for non-Android builds).
e15060c to
87ee249
Compare
|
@dkneeland I updated with how I suggested, but I think maybe I didn't communicate it clearly. |
Part 2 of 4 of a stacked series that supersedes #201 (closed; work redistributed across this stack). Base is the GATT-subscribe-retry fix (layer 1), which this PR previously contained — extracted so the reliability fix ships independently.
What & why
Reads the vehicle VIN directly from DashKit's existing BLE CAN notification stream so Tesla enrollment can stop asking the user to type it. Purely additive — no existing behavior changes at this layer.
VehicleVinAssembler— pure-Kotlin assembler for the muxed VIN frames (bus 1, CAN id0x405, mux0x10/0x11/0x12). Accepts segments in any order, tolerates duplicates, rejects short frames / unknown mux / non-ASCII / illegal VIN chars, emits only when all 17 chars validate, resets on teardown. Raw ASCII bytes are joined directly — no 56-bit DBCDoubleround-trip.CanPacket— raw(bus, address, data)tuple parsing extracted fromparseAndEmit()so each frame feeds two consumers (dashboard decoder + assembler); firmwarebuild_ble_packetwire format documented alongside the parser.DashKitDataSourcefeeds the assembler per frame; exposesvinState.ConnectionViewModel.vehicleVin— dedicated replaying flow; deliberately not added toCarState(stays out of the dash-app data contract); reset during connection teardown.Inert until layer 4 consumes the flow.
Tests
Assembler unit tests (ordering, duplicates, special mux-A offsets, malformed input) and parser/data-source integration tests (single/multi-notification assembly, batching, truncated packets). Full
testDebugUnitTestgreen at carve time againstmain@b506147.Stack & merge order
mainMerge bottom-up after layer 1; the managed stack handles retarget/rebase automatically.