Skip to content

android: queue DashKit command writes, one GATT operation at a time - #289

Open
ehoeve786 wants to merge 1 commit into
softwiredtech:mainfrom
ehoeve786:fix/android-gatt-write-queue
Open

ehoeve786 wants to merge 1 commit into
softwiredtech:mainfrom
ehoeve786:fix/android-gatt-write-queue

Conversation

@ehoeve786

Copy link
Copy Markdown
Collaborator

Android allows a single GATT operation in flight and refuses a write issued while another is pending. The resync burst on connect, pings, controls and Tesla commands could overlap, so writes were silently dropped. Commands now go through a queue that sends one at a time, retries while the stack is busy and gives up on a write whose completion never arrives.

writeCommand now returns true once queued. Because a queued write can still be lost (link drop, stack keeps refusing it, the DashKit rejects it or never answers), callers can pass onDropped, which runs on the main thread. The battery preheat, charge port, mirror fold and rear fan toggles use it to show the previous state again.

Testing

  • An earlier version ran in a combined Android test build (Samsung S23) with a DashKit in a legacy Model Y. The current version (onDropped restores the toggles) has not been run on a device yet.
  • Android builds and the unit tests pass.

Note: #282 also adds a MAX_WRITE_ATTEMPTS constant in DashKitBleManager; whichever merges second needs a one-line fix.

🤖 Generated with Claude Code

Android allows a single GATT operation in flight and refuses a write
issued while another is pending. The resync burst on connect, pings,
controls and Tesla commands could overlap, so writes were silently
dropped. Commands now go through a queue that sends one at a time,
retries while the stack is busy and gives up on a write whose
completion never arrives.

writeCommand now returns true once queued. Because a queued write can
still be lost (link drop, stack keeps refusing it, the DashKit rejects
it or never answers), callers can pass onDropped, which runs on the
main thread. The battery preheat, charge port, mirror fold and rear fan
toggles use it to show the previous state again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

1 participant