Skip to content

fix: detect and close connections on physical device disconnect - #5

Merged
almasumdev merged 2 commits into
almasumdev:mainfrom
abbiyuarsyah:fix/disconnect-stream-listener
Jul 25, 2026
Merged

fix: detect and close connections on physical device disconnect#5
almasumdev merged 2 commits into
almasumdev:mainfrom
abbiyuarsyah:fix/disconnect-stream-listener

Conversation

@abbiyuarsyah

Copy link
Copy Markdown
Contributor

If a Bluetooth device you're connected to suddenly goes away, say the printer gets switched off, an accessory is unplugged, or you walk out of range, the app doesn't realize it. From the app's point of view the connection still looks fine, so it keeps trying to send data and only finds out something is wrong.

This PR updates the plugin to notice these disconnections the moment they happen (both on Android and iOS), clean up the dead connection, and tell the app about it right away, so the UI can react, and reconnect logic can kick in, instead of the app being stuck thinking everything is okay.

It's has been tested by multiple android and ios devices with one bluetooth printer.

@almasumdev
almasumdev merged commit 1244871 into almasumdev:main Jul 25, 2026
5 checks passed
almasumdev added a commit that referenced this pull request Jul 25, 2026
- Android/iOS: close every connection to a device on ACL/accessory
  disconnect, not just the first match (a dropped physical link kills
  all connections to that address).
- iOS: emit terminal "disconnected" exactly once, guarding against the
  stream delegate and accessory-disconnect notification both firing.
- iOS: remove the EAAccessoryDidDisconnect observer on teardown.
- Add 0.1.5 CHANGELOG covering physical-disconnect detection (#5) and
  these robustness fixes.

Co-Authored-By: Claude Opus 4.8 (1M context) <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.

2 participants