Skip to content

fix(android): retry GATT subscribes dropped by GATT-busy races (1/4) - #210

Merged
wpmed92 merged 1 commit into
mainfrom
fix/gatt-subscribe-retry
Aug 27, 2026
Merged

fix(android): retry GATT subscribes dropped by GATT-busy races (1/4)#210
wpmed92 merged 1 commit into
mainfrom
fix/gatt-subscribe-retry

Conversation

@dkneeland

Copy link
Copy Markdown
Collaborator

Bottom layer of a 4-PR stacked series (the Android VIN / Tesla onboarding work above it builds on this). Also perfectly mergeable on its own.

Problem

Android's GATT client allows only one operation in flight. The CCCD (notification-enable) descriptor write that starts CAN notifications races other GATT operations during connection setup — and when it loses the race, Android silently refuses it. The old code ignored the write result entirely, so the app could sit connected with a subscribed-but-never-enabled characteristic: intermittent "connected but no dashboard data" until reconnect.

Fix

  • DashKitBleManager.subscribeWithRetry() — verifies the CCCD write was actually queued and retries up to 3× at 250 ms.
  • DashKitDataSource.onServicesReady() uses it instead of the fire-and-forget inline write.

The helper is deliberately generic ("CAN"/"Status" label params): the Tesla app-channel status subscription introduced later in this stack uses the same helper.

Scope discipline: 2 files, +42/−15. No behavior change beyond retry-on-refusal; no feature code.

Full testDebugUnitTest green against main @ b506147.

Stack context

Order Layer Base
1 this fix main
2 VIN CAN pipeline this branch
3 Tesla BLE core layer 2
4 VIN-driven enrollment UX layer 3

Supersedes parts of closed #201 / #206#208 (re-layered so this fix ships independently of feature review).

Android's GATT client allows one operation in flight; a CCCD write
that races another subscribe is silently refused, leaving CAN
notifications dead until reconnect. Replace the fire-and-forget
descriptor write in DashKitDataSource with DashKitBleManager
.subscribeWithRetry(), which verifies the write was queued and retries
(up to 3x, 250ms apart). The helper is shared and will also back the
Tesla status subscription.
@wpmed92
wpmed92 merged commit a04f728 into main Aug 27, 2026
2 checks passed
@wpmed92
wpmed92 deleted the fix/gatt-subscribe-retry branch August 27, 2026 07:51
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