Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectRequest with autoConnect=true does not attempt to reconnect after timeout #33

Closed
ghost opened this issue Oct 4, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 4, 2018

Version: Beta5
Scenario
Attempt to connect to an offline device. After the connection attempt times out, switch the device on

bleManager.connect(bluetoothDevice)
      .useAutoConnect(true)
      .retry(3, 600)
      .enqueue();

Expected
The connection is attempted after the timeout

Got
The connection is never attempted after the timeout

Logs

13:58:41 BluetoothGatt: connect() - device: C0:4B:24:4B:11:A7, auto: false
13:58:41 BluetoothGatt: registerApp()
13:58:41 BluetoothGatt: registerApp() - UUID=1cc136ae-1d6f-4633-894a-5cf88ce20c60
13:58:41 BluetoothGatt: onClientRegistered() - status=0 clientIf=7

13:58:41 MyBleManagerCallback: onDeviceConnecting: C0:4B:24:4B:11:A7

13:59:12 BluetoothGatt: onClientConnectionState() - status=133 clientIf=7 device=C0:4B:24:4B:11:A7
13:59:12 BluetoothGatt: close()
13:59:12 BluetoothGatt: unregisterApp() - mClientIf=7

13:59:12 MyBleManagerCallback: onDeviceDisconnected: C0:4B:24:4B:11:A7
13:59:12 MyBleManagerCallback: onError: a BLE error has occurred message = Error on connection state change, code = 133

Related #31 (comment)

@philips77
Copy link
Member

But that's intended. As retry(...) method's docs says:

/**
* Sets an optional retry count. The BleManager will do that many attempts to connect to the
* device in case of an error. The library will NOT retry if the device is not reachable,
* that is when the 30 sec. timeout occurs. In that case the app should scan before
* connecting, to make sure the target is in range.
*
* @param count how many times should the BleManager retry to connect.
* @return The request.
* @see #retry(int, int)
*/
public ConnectRequest retry(final int count) {
this.retries = count;
this.delay = 0;
return this;
}

The correct way of solving this would be to scan before connecting to make sure the device is reachable. Check out #15 at the end.

@philips77
Copy link
Member

(I actually clarified the docs yesterday in here 8d3ddf4)

@ghost
Copy link
Author

ghost commented Oct 4, 2018

I'll close this then.

Thanks!

@ghost ghost closed this as completed Oct 4, 2018
This issue was closed.
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

No branches or pull requests

1 participant