Skip to content

Handle already-connected BLE devices gracefully#928

Open
utkuvrs wants to merge 1 commit into
PhilipsHue:masterfrom
utkuvrs:master
Open

Handle already-connected BLE devices gracefully#928
utkuvrs wants to merge 1 commit into
PhilipsHue:masterfrom
utkuvrs:master

Conversation

@utkuvrs

@utkuvrs utkuvrs commented Apr 27, 2026

Copy link
Copy Markdown

Detect and surface a clear, actionable error when RxAndroidBle already holds a connection that the plugin does not track (e.g. after a hot restart).

  • ReactiveBleClient.establishConnection: if the underlying RxBleDevice is CONNECTED but no DeviceConnector is tracked, return an EstablishConnectionFailure Observable with a helpful message instead of triggering BleAlreadyConnectedException.
  • PluginController: map discover-services errors and return a "device_already_connected" code and detailed message when the underlying error indicates an already-connected device.
  • Tests: adjust connectionState stubbing and add a unit test verifying the actionable error is surfaced for untracked OS-level connections.

This avoids confusing BleAlreadyConnected exceptions and guides callers to disconnect the device (or restart Bluetooth) before retrying.

Detect and surface a clear, actionable error when RxAndroidBle already holds a connection that the plugin does not track (e.g. after a hot restart).

- ReactiveBleClient.establishConnection: if the underlying RxBleDevice is CONNECTED but no DeviceConnector is tracked, return an EstablishConnectionFailure Observable with a helpful message instead of triggering BleAlreadyConnectedException.
- PluginController: map discover-services errors and return a "device_already_connected" code and detailed message when the underlying error indicates an already-connected device.
- Tests: adjust connectionState stubbing and add a unit test verifying the actionable error is surfaced for untracked OS-level connections.

This avoids confusing BleAlreadyConnected exceptions and guides callers to disconnect the device (or restart Bluetooth) before retrying.
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