Skip to content

fix(ble): only report disconnects the device starts as unexpected - #350

Merged
donavanbecker merged 1 commit into
beta-6.0.0from
fix/ble-disconnect-logging-6
Oct 25, 2026
Merged

donavanbecker merged 1 commit into
beta-6.0.0from
fix/ble-disconnect-logging-6

Conversation

@donavanbecker

Copy link
Copy Markdown
Contributor

Carries #349 into beta-6.0.0.

#349 fixes the Unexpected disconnect warning that follows every BLE command, and handles disconnects the device starts: it drops the dead link so the next command reconnects.

On this branch the shared cleanup also clears the encrypted session (encryptedSessions), so an encrypted device that drops the link re-runs the 0x570f2103 session init on reconnect instead of reusing a stale IV.

The beta-6.0.0 branch has the encrypted-session state and the pending-reply rejection, so one conflict was resolved: the pending reply is rejected with the disconnect reason.

435 tests pass. Build and lint pass.


Generated by Claude Code

BLEConnection logged "Unexpected disconnect" for every disconnect it started
itself (the idle timer after each command, disconnectAll, a failed
connection), because nothing marked them as expected. Meanwhile a disconnect
started by the device (out of range, powered off) was never noticed: the dead
peripheral stayed in the connection map and the next command reused it.

- disconnect() is always intentional: it logs at debug level.
- A 'disconnect' listener on the peripheral drops the connection state
  (characteristics, encryption, pending reply) and warns only when the device
  dropped the link; markExpectedDisconnect() silences that warning.
- The characteristic-discovery failure path uses disconnect().

Supersedes #348.

Co-authored-by: dnicolson <dnicolson@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TYWa2RXoWsaUTWh76oNv8s
@donavanbecker
donavanbecker merged commit 9e3aaff into beta-6.0.0 Oct 25, 2026
2 checks passed
@donavanbecker
donavanbecker deleted the fix/ble-disconnect-logging-6 branch October 25, 2026 00: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