forked from upstream-mirrors/OpenTracks
Bugfix: BluetoothLE requires to trigger reconnect on either disconnect or never connected.
Initial connection timeout seems to be 30s. Fixes #1442.
This commit is contained in:
@@ -54,20 +54,23 @@ public abstract class BluetoothConnectionManager<DataType> {
|
|||||||
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
|
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case BluetoothProfile.STATE_CONNECTING:
|
case BluetoothProfile.STATE_CONNECTING:
|
||||||
Log.d(TAG, "Connecting to sensor: " + gatt.getDevice());
|
Log.i(TAG, "Connecting to sensor: " + gatt.getDevice());
|
||||||
break;
|
break;
|
||||||
case BluetoothProfile.STATE_CONNECTED:
|
case BluetoothProfile.STATE_CONNECTED:
|
||||||
Log.d(TAG, "Connected to sensor: " + gatt.getDevice());
|
Log.i(TAG, "Connected to sensor: " + gatt.getDevice() + "; discovering services.");
|
||||||
|
|
||||||
gatt.discoverServices();
|
gatt.discoverServices();
|
||||||
break;
|
break;
|
||||||
case BluetoothProfile.STATE_DISCONNECTING:
|
case BluetoothProfile.STATE_DISCONNECTING:
|
||||||
Log.d(TAG, "Disconnecting from sensor: " + gatt.getDevice());
|
Log.i(TAG, "Disconnecting from sensor: " + gatt.getDevice());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BluetoothProfile.STATE_DISCONNECTED:
|
case BluetoothProfile.STATE_DISCONNECTED:
|
||||||
Log.d(TAG, "Disconnected from sensor: " + gatt.getDevice());
|
//This is also triggered, if no connection was established (ca. 30s)
|
||||||
|
Log.i(TAG, "Disconnected from sensor: " + gatt.getDevice() + "; trying to reconnect");
|
||||||
|
if (gatt.connect()) {
|
||||||
|
Log.e(TAG, "Could not trigger reconnect for sensor: " + gatt.getDevice());
|
||||||
|
}
|
||||||
clearData();
|
clearData();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user