mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
+8
-2
@@ -69,6 +69,8 @@ public abstract class BluetoothConnectionManager<DataType> {
|
||||
|
||||
case BluetoothProfile.STATE_DISCONNECTED:
|
||||
Log.d(TAG, "Disconnected from sensor: " + gatt.getDevice());
|
||||
|
||||
clearData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -130,14 +132,18 @@ public abstract class BluetoothConnectionManager<DataType> {
|
||||
observer.onChanged(sensorData);
|
||||
}
|
||||
|
||||
private synchronized void clearData() {
|
||||
observer.onDisconnecting(createEmptySensorData(bluetoothGatt.getDevice().getAddress()));
|
||||
}
|
||||
|
||||
|
||||
synchronized void disconnect() {
|
||||
if (bluetoothGatt == null) {
|
||||
Log.w(TAG, "Cannot disconnect if not connected.");
|
||||
return;
|
||||
}
|
||||
bluetoothGatt.close();
|
||||
observer.onDisconnecting(createEmptySensorData(bluetoothGatt.getDevice().getAddress()));
|
||||
|
||||
clearData();
|
||||
bluetoothGatt = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user