From 12b3d31f5c874bce6f80654c337f8d3832648795 Mon Sep 17 00:00:00 2001 From: Dennis Guse Date: Thu, 5 Jan 2023 20:46:16 +0100 Subject: [PATCH] Bugfix: BluetoothLE requires to trigger reconnect on either disconnect or never connected. Initial connection timeout seems to be 30s. Fixes #1442. --- .../sensors/BluetoothConnectionManager.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/sensors/BluetoothConnectionManager.java b/src/main/java/de/dennisguse/opentracks/sensors/BluetoothConnectionManager.java index dc1d55541..4fd4fa595 100644 --- a/src/main/java/de/dennisguse/opentracks/sensors/BluetoothConnectionManager.java +++ b/src/main/java/de/dennisguse/opentracks/sensors/BluetoothConnectionManager.java @@ -54,20 +54,23 @@ public abstract class BluetoothConnectionManager { public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) { switch (newState) { case BluetoothProfile.STATE_CONNECTING: - Log.d(TAG, "Connecting to sensor: " + gatt.getDevice()); + Log.i(TAG, "Connecting to sensor: " + gatt.getDevice()); break; case BluetoothProfile.STATE_CONNECTED: - Log.d(TAG, "Connected to sensor: " + gatt.getDevice()); + Log.i(TAG, "Connected to sensor: " + gatt.getDevice() + "; discovering services."); gatt.discoverServices(); break; case BluetoothProfile.STATE_DISCONNECTING: - Log.d(TAG, "Disconnecting from sensor: " + gatt.getDevice()); + Log.i(TAG, "Disconnecting from sensor: " + gatt.getDevice()); break; 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(); break; }