This PR fixes that by checking the value of bluetoothGatt reference after internalConnect is called.
In case of null, that is when connectRequest.finished was true, the state is reset to disconnected.
Also, this PR adds another change. When the connection attempt fails, the onServicesInvalidated() is not called, as there were no services to invalidate in the first place. This MAY be breaking for some, but I hope not.
This PR fixes #524.
When the first connection attempt fails, and the library will start to retry connection, this code is invoked: https://github.com/NordicSemiconductor/Android-BLE-Library/blob/53e169ec7dec77923c50619967b895e8a91091aa/ble/src/main/java/no/nordicsemi/android/ble/BleManagerHandler.java#L639-L648 If the
ConnectRequest
times out, or gets cancelled when the thread is waiting 200 ms, the connection was cancelled, butconnectionState
was never set back toSTATE_DISCONNECTED
.This PR fixes that by checking the value of
bluetoothGatt
reference afterinternalConnect
is called. In case of null, that is whenconnectRequest.finished
was true, the state is reset to disconnected.Also, this PR adds another change. When the connection attempt fails, the
onServicesInvalidated()
is not called, as there were no services to invalidate in the first place. This MAY be breaking for some, but I hope not.