Skip to content

Device: Fix AirPods showing up twice after opening the case#609

Merged
d4rken merged 1 commit into
mainfrom
worktree-issue-603-ble-prefix-guard
Jun 10, 2026
Merged

Device: Fix AirPods showing up twice after opening the case#609
d4rken merged 1 commit into
mainfrom
worktree-issue-603-ble-prefix-guard

Conversation

@d4rken

@d4rken d4rken commented Jun 10, 2026

Copy link
Copy Markdown
Member

What changed

Fixed AirPods appearing as two device cards for ~10–20 seconds when taking them out of the case. The duplicate showed wrong battery values and disappeared again on its own.

Closes #603

Technical Context

  • Root cause: on connect, AirPods Gen 4 emit a single proximity-pairing frame from their identity address whose payload prefix is 0x07 instead of 0x01. The model bytes happen to sit at the usual offset so it passed model matching, but the rest of the payload is not the plaintext status format (battery nibbles 13/14, invalid color) — it minted a fresh device tracker that matched the same profile and rendered as a second card until the 20 s stale timeout.
  • The guard sits at the decoder layer, before model dispatch, so every model — including the unknown-device catch-all — is protected; per-model validation would have left the catch-all exposed.
  • Safe for pairing mode and clones: every real-device capture in the test suite (all AirPods, Beats, and fake variants) uses prefix 0x01, and pairing/connection state is encoded in the payload suffix byte, not the prefix.
  • Dropped frames are still logged with their full hex payload at DEBUG, so unrecognized variants stay visible in user debug logs.

AirPods Gen4 emit a one-off type 0x07 frame from their identity address
on connect whose payload prefix is 0x07 instead of 0x01. Its bytes are
not the plaintext status format, but the model bytes happen to match,
so it minted a fresh device tracker and showed as a duplicate device
card until the stale timeout.

Every known plaintext status broadcast (including pairing mode) uses
prefix 0x01; pairing state lives in the suffix byte. Reject anything
else at the decoder, logging the dropped frame's hex.

Fixes #603
@d4rken d4rken added bug Something isn't working coms/BLE Uses Apple's Proximity Payloads, based on BLE broadcasted advertisements. labels Jun 10, 2026
@d4rken d4rken merged commit a1b9abd into main Jun 10, 2026
11 checks passed
@d4rken d4rken deleted the worktree-issue-603-ble-prefix-guard branch June 10, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working coms/BLE Uses Apple's Proximity Payloads, based on BLE broadcasted advertisements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BLE broadcasts only received during pairing on Xiaomi Redmi Note 13 5G

1 participant