Skip to content

feat(android): Tesla BLE core - client, status source, VIN-matched scanner (3/4) - #212

Merged
wpmed92 merged 2 commits into
mainfrom
feat/tesla-ble-core
Aug 27, 2026
Merged

feat(android): Tesla BLE core - client, status source, VIN-matched scanner (3/4)#212
wpmed92 merged 2 commits into
mainfrom
feat/tesla-ble-core

Conversation

@dkneeland

Copy link
Copy Markdown
Collaborator

Part 3 of 4 of a stacked series that supersedes #201 (closed; work redistributed across this stack). Base is the VIN CAN pipeline (layer 2).

What & why

The Tesla app-channel BLE layer, hardened per the post-review audit of #201:

  • TeslaClient — commands incl. CMD_PROVISION. Payload built only after validating all 17 VIN chars and the complete MAC (length + hex + separators); preserves the required reversed NimBLE MAC byte order; the full VIN is never logged (generic rejection message instead).
  • Acknowledgement semantics: a successful GATT write is treated as dispatch only; TeslaLinkState.Staged is the provisioning acknowledgement.
  • TeslaStatus / TeslaStatusSource — notification parsing plus requestReset() plumbing with resetPending cleared on NeverEnrolled/Staged.
  • TeslaVehicleScanner — matches only advertisements derived from the supplied VIN: legacy S + first 8 bytes of SHA1(VIN) hex + every supported role suffix, and modern Tesla + 4-, 5-, and 6-char VIN tails. No generic "any Tesla name" discovery path.

No UI yet — Home/Settings are untouched until Part 3 wires the enrollment flow.

Tests

Provision payload byte-layout (opcode, ASCII VIN, address type, reversed MAC), invalid VIN/MAC rejection, legacy/modern name matching incl. all suffix/tail lengths, TeslaStatus parsing. Full testDebugUnitTest green at carve time.

Stack & merge order

Merge third in the stack (after layers 1-2); GitHub's managed stack handles retarget/rebase automatically.

…anner


Introduce the Tesla app-channel BLE layer:

- TeslaClient commands incl. CMD_PROVISION with full 17-char VIN and
  MAC validation, reversed NimBLE byte order, and no full-VIN logging
- a GATT write is treated as dispatch only; Staged status is the
  provisioning acknowledgement
- TeslaStatus / TeslaStatusSource parsing with reset-request plumbing
- TeslaVehicleScanner matches only advertisements derived from the
  supplied VIN (legacy SHA-1 prefix with all role suffixes, modern
  4/5/6-char tails)

Unit coverage for payload bytes, invalid inputs, name matching.
@wpmed92
wpmed92 force-pushed the feat/tesla-ble-core branch from 2063430 to 980ccf7 Compare August 27, 2026 09:08
…internals

- Extract DashKitBleManager.writeCommand() and route both VehicleControl.send
  and the TeslaClient app-channel writes through it, removing the duplicated
  gatt/service/characteristic resolution and API-33 write branch.
- Validate MACs with a regex and parse octets via split(":"), replacing the
  hand-rolled index-modulo loop and substring arithmetic (payload bytes
  unchanged, pinned by TeslaClientProvisionTest).
- Drop TeslaStatusSource.statusChar: onDescriptorWrite already receives the
  characteristic via descriptor.characteristic.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YHug6438BcFaMQ2hwPdtCY
@wpmed92
wpmed92 merged commit 957835d into main Aug 27, 2026
2 checks passed
@wpmed92
wpmed92 deleted the feat/tesla-ble-core branch August 27, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants