Skip to content

Reconnect when Bluetooth comes back on - #213

Merged
dzid26 merged 4 commits into
mainfrom
claude/project-thread-93m7qo
Oct 15, 2026
Merged

dzid26 merged 4 commits into
mainfrom
claude/project-thread-93m7qo

Conversation

@dzid26

@dzid26 dzid26 commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Requested by R

Summary

Before: turning Bluetooth off and on could leave a car disconnected for good, until tracking was turned off and on. On the owner's phone (2026-10-15) the first toggle recovered in 5 s; the second, with Bluetooth off for 6 s, never retried. The 5 s retry fired while Bluetooth was still off, connectGatt() returned no client and no callback ever came, so the link stayed CONNECTING, which every later retry and ensureConnected() skip. (Logcat shows no connect attempt after the drop; the null return is inferred from that and the code path.)

After: a connectGatt() that returns null fails the attempt, so the backoff carries on, and the tracking service listens for BluetoothAdapter.ACTION_STATE_CHANGED: when Bluetooth turns on, every car that is not connected retries at once with a fresh backoff.

Type

  • Bug fix
  • Feature
  • Protocol / crypto change
  • Docs / CI / tooling
  • Refactor (no behavior change)

Testing

  • ./gradlew :core:test (no core change)
  • ./gradlew :app:testDebugUnitTest
  • ./gradlew :app:lintDebug
  • Real car — not yet: toggle Bluetooth off for more than 5 s and back on; the car should reconnect within a couple of seconds of Bluetooth returning.

Also ran :app:assembleDebug and ktlintCheck. detekt is left to CI (local JDK 25).

Checklist

  • Protocol changes ship test vectors; expected.txt regenerated, not hand-edited (n/a)
  • No VINs, keys, or decrypted payloads in logs
  • Docs/master-plan updated where relevant (n/a)
  • New source files carry SPDX-License-Identifier: AGPL-3.0-only (n/a: no new files)

🤖 Generated with Claude Code

Turning Bluetooth off and on could leave a car disconnected for good. The
drop scheduled a retry 5 s later; when it fired with Bluetooth still off,
connectGatt() returned null, no callback ever came, and the link stayed
CONNECTING, which every later retry and ensureConnected() skip. Only
turning tracking off and on recovered it (owner's phone, 2026-10-15).

A null connectGatt() now fails the attempt so the backoff carries on, and
the tracking service listens for Bluetooth turning on and retries every
car that is not connected at once, with a fresh backoff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dzid26 dzid26 self-assigned this Oct 15, 2026
@github-actions

This comment has been minimized.

Keeps TeslaBleController under detekt's TooManyFunctions threshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

dzid26 and others added 2 commits October 15, 2026 13:39
The pill said Connecting only in the CONNECTING phase and fell back to
Disconnected while services were discovered, so it flashed Disconnected
just before the car connected while the status line read Connecting...

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dzid26
dzid26 merged commit 4f40e1b into main Oct 15, 2026
@dzid26
dzid26 deleted the claude/project-thread-93m7qo branch October 15, 2026 12:40
@github-actions

Copy link
Copy Markdown
Contributor

Snapshots

No visual change in the snapshots at 4921138 (vs 534f54c).

Full-screen emulator shots: Actions → PR screenshots → Run workflow, choosing the head branch of this PR.

Debug APK: still building in Android CI (GitHub sign-in needed)

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