Skip to content

Bug fix: Auto connect not restarting if the initial connection fails when using with a non-bonded device#573

Merged
philips77 merged 1 commit intonordicsemi:mainfrom
muscardinus:fix-auto-connect-not-restarting-if-initial-connection-fails
Aug 16, 2024
Merged

Bug fix: Auto connect not restarting if the initial connection fails when using with a non-bonded device#573
philips77 merged 1 commit intonordicsemi:mainfrom
muscardinus:fix-auto-connect-not-restarting-if-initial-connection-fails

Conversation

@muscardinus
Copy link
Copy Markdown
Contributor

@muscardinus muscardinus commented Aug 12, 2024

If using useAutoConnect(true):

manager.connect(bluetoothDevice)
        .useAutoConnect(true)
        .suspend()

the initial connection will be a normal one (calling connectGatt() with autoConnect = false). If this fails (times out), the next connect is supposed to use auto connect (with bluetoothGatt.connect() or calling connectGatt() with autoConnect = true).

However, this does not work with a non-bonded device. As mentioned in the Javadoc of useAutoConnect(true), auto connect is still viable to use without a bond when the BLE device has a private static address.

This PR fixes the issue by removing the check for bond in the disconnected state handling.

I believe this is also the cause of this reported issue - #435

…connection fails without connecting first.

The assumption that the device should be bonded is incorrect as autoConnect = true can be used with non-bonded devices with static addresses as well.
@philips77
Copy link
Copy Markdown
Contributor

OK, I agree. Behavior will be more predictable.

@philips77 philips77 merged commit d12ef17 into nordicsemi:main Aug 16, 2024
@muscardinus muscardinus deleted the fix-auto-connect-not-restarting-if-initial-connection-fails branch August 19, 2024 07:59
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