forked from upstream-mirrors/OpenTracks
Cleanup: removed DriverObserver0 and moved sensor drivers to separate package.
This commit is contained in:
+2
-2
@@ -66,8 +66,8 @@ import de.dennisguse.opentracks.data.models.TrackBuilder;
|
|||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
||||||
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingPower;
|
|
||||||
import de.dennisguse.opentracks.sensors.SensorManager;
|
import de.dennisguse.opentracks.sensors.SensorManager;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingPowerBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
||||||
@@ -663,7 +663,7 @@ public class ExportImportTest {
|
|||||||
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
SensorManager sensorManager = trackPointCreator.getSensorManager();
|
||||||
|
|
||||||
AggregatorCyclingPower cyclingPower = new AggregatorCyclingPower("", "");
|
AggregatorCyclingPower cyclingPower = new AggregatorCyclingPower("", "");
|
||||||
cyclingPower.add(trackPointCreator.getNow(), new BluetoothHandlerCyclingPower.Data(Power.of(power), null));
|
cyclingPower.add(trackPointCreator.getNow(), new CyclingPowerBluetooth.Data(Power.of(power), null));
|
||||||
sensorManager.add(cyclingPower);
|
sensorManager.add(cyclingPower);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -13,11 +13,11 @@ public class BluetoothHandlerBarometricPressureTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseEnvironmentalSensing_Pa() {
|
public void parseEnvironmentalSensing_Pa() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerBarometricPressure.BAROMETRIC_PRESSURE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BarometerBluetooth.BAROMETRIC_PRESSURE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{(byte) 0xB2, (byte) 0x48, (byte) 0x0F, (byte) 0x00});
|
characteristic.setValue(new byte[]{(byte) 0xB2, (byte) 0x48, (byte) 0x0F, (byte) 0x00});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
AtmosphericPressure pressure = BluetoothHandlerBarometricPressure.parseEnvironmentalSensing(characteristic);
|
AtmosphericPressure pressure = BarometerBluetooth.parseEnvironmentalSensing(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(AtmosphericPressure.ofHPA(1001.65f), pressure);
|
assertEquals(AtmosphericPressure.ofHPA(1001.65f), pressure);
|
||||||
+5
-5
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -13,11 +13,11 @@ public class BluetoothHandlerHeartRateTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseHeartRate_uint8() {
|
public void parseHeartRate_uint8() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(HeartRateBluetooth.HEARTRATE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x02, 0x3C});
|
characteristic.setValue(new byte[]{0x02, 0x3C});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
HeartRate heartRate = BluetoothHandlerHeartRate.parseHeartRate(characteristic);
|
HeartRate heartRate = HeartRateBluetooth.parseHeartRate(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(HeartRate.of(60), heartRate);
|
assertEquals(HeartRate.of(60), heartRate);
|
||||||
@@ -26,11 +26,11 @@ public class BluetoothHandlerHeartRateTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseHeartRate_uint16() {
|
public void parseHeartRate_uint16() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(HeartRateBluetooth.HEARTRATE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x01, 0x01, 0x01});
|
characteristic.setValue(new byte[]{0x01, 0x01, 0x01});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
HeartRate heartRate = BluetoothHandlerHeartRate.parseHeartRate(characteristic);
|
HeartRate heartRate = HeartRateBluetooth.parseHeartRate(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(HeartRate.of(257), heartRate);
|
assertEquals(HeartRate.of(257), heartRate);
|
||||||
+8
-8
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
@@ -8,14 +8,14 @@ import android.util.Pair;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BluetoothHandlerCyclingDistanceSpeedTest {
|
public class CyclingDistanceSpeedBluetoothTest {
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingSpeedCadence_crankOnly() {
|
public void parseCyclingSpeedCadence_crankOnly() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x02, (byte) 0xC8, 0x00, 0x00, 0x00, 0x06, (byte) 0x99});
|
characteristic.setValue(new byte[]{0x02, (byte) 0xC8, 0x00, 0x00, 0x00, 0x06, (byte) 0x99});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Pair<BluetoothHandlerCyclingDistanceSpeed.WheelData, BluetoothHandlerCyclingCadence.CrankData> sensor = BluetoothHandlerCyclingDistanceSpeed.parseCyclingCrankAndWheel("address", "sensorName", characteristic);
|
Pair<CyclingDistanceSpeedBluetooth.WheelData, CyclingCadenceBluetooth.CrankData> sensor = CyclingDistanceSpeedBluetooth.parseCyclingCrankAndWheel(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertNull(sensor.first);
|
assertNull(sensor.first);
|
||||||
@@ -24,11 +24,11 @@ public class BluetoothHandlerCyclingDistanceSpeedTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingSpeedCadence_wheelOnly() {
|
public void parseCyclingSpeedCadence_wheelOnly() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x01, (byte) 0xFF, (byte) 0xFF, 0, 1, 0x45, (byte) 0x99});
|
characteristic.setValue(new byte[]{0x01, (byte) 0xFF, (byte) 0xFF, 0, 1, 0x45, (byte) 0x99});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Pair<BluetoothHandlerCyclingDistanceSpeed.WheelData, BluetoothHandlerCyclingCadence.CrankData> sensor = BluetoothHandlerCyclingDistanceSpeed.parseCyclingCrankAndWheel("address", "sensorName", characteristic);
|
Pair<CyclingDistanceSpeedBluetooth.WheelData, CyclingCadenceBluetooth.CrankData> sensor = CyclingDistanceSpeedBluetooth.parseCyclingCrankAndWheel(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(65535 + 16777216, sensor.first.wheelRevolutionsCount());
|
assertEquals(65535 + 16777216, sensor.first.wheelRevolutionsCount());
|
||||||
@@ -37,11 +37,11 @@ public class BluetoothHandlerCyclingDistanceSpeedTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingSpeedCadence_crankWheel() {
|
public void parseCyclingSpeedCadence_crankWheel() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x03, (byte) 0xC8, 0x00, 0x00, 0x01, 0x06, (byte) 0x99, (byte) 0xE1, 0x00, 0x45, (byte) 0x99});
|
characteristic.setValue(new byte[]{0x03, (byte) 0xC8, 0x00, 0x00, 0x01, 0x06, (byte) 0x99, (byte) 0xE1, 0x00, 0x45, (byte) 0x99});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
Pair<BluetoothHandlerCyclingDistanceSpeed.WheelData, BluetoothHandlerCyclingCadence.CrankData> sensor = BluetoothHandlerCyclingDistanceSpeed.parseCyclingCrankAndWheel("address", "sensorName", characteristic);
|
Pair<CyclingDistanceSpeedBluetooth.WheelData, CyclingCadenceBluetooth.CrankData> sensor = CyclingDistanceSpeedBluetooth.parseCyclingCrankAndWheel(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(200 + 16777216, sensor.first.wheelRevolutionsCount());
|
assertEquals(200 + 16777216, sensor.first.wheelRevolutionsCount());
|
||||||
+6
-6
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -6,15 +6,15 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BluetoothHandlerCyclingPowerTest {
|
public class CyclingPowerBluetoothTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingPower_power() {
|
public void parseCyclingPower_power() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingPowerBluetooth.CYCLING_POWER.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0, 0, 40, 0});
|
characteristic.setValue(new byte[]{0, 0, 40, 0});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerCyclingPower.Data powerCadence = BluetoothHandlerCyclingPower.parseCyclingPower(characteristic);
|
CyclingPowerBluetooth.Data powerCadence = CyclingPowerBluetooth.parseCyclingPower(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(40, powerCadence.power().getW(), 0.01);
|
assertEquals(40, powerCadence.power().getW(), 0.01);
|
||||||
@@ -22,11 +22,11 @@ public class BluetoothHandlerCyclingPowerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingPower_power_with_cadence() {
|
public void parseCyclingPower_power_with_cadence() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(CyclingPowerBluetooth.CYCLING_POWER.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x2C, 0x00, 0x00, 0x00, (byte) 0x9F, 0x00, 0x0C, 0x00, (byte) 0xE5, 0x42});
|
characteristic.setValue(new byte[]{0x2C, 0x00, 0x00, 0x00, (byte) 0x9F, 0x00, 0x0C, 0x00, (byte) 0xE5, 0x42});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerCyclingPower.Data powerCadence = BluetoothHandlerCyclingPower.parseCyclingPower(characteristic);
|
CyclingPowerBluetooth.Data powerCadence = CyclingPowerBluetooth.parseCyclingPower(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(0, powerCadence.power().getW(), 0.01);
|
assertEquals(0, powerCadence.power().getW(), 0.01);
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@@ -10,15 +10,15 @@ import de.dennisguse.opentracks.data.models.Cadence;
|
|||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
|
|
||||||
public class BluetoothHandlerRunningSpeedAndCadenceTest {
|
public class RunningSpeedAndCadenceBluetoothTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseRunningSpeedAndCadence_with_distance() {
|
public void parseRunningSpeedAndCadence_with_distance() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerRunningSpeedAndCadence.RUNNING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(RunningSpeedAndCadenceBluetooth.RUNNING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{2, 0, 5, 80, (byte) 0xFF, (byte) 0xFF, 0, 1});
|
characteristic.setValue(new byte[]{2, 0, 5, 80, (byte) 0xFF, (byte) 0xFF, 0, 1});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerRunningSpeedAndCadence.Data sensor = BluetoothHandlerRunningSpeedAndCadence.parseRunningSpeedAndCadence("sensorName", characteristic);
|
RunningSpeedAndCadenceBluetooth.Data sensor = RunningSpeedAndCadenceBluetooth.parseRunningSpeedAndCadence("sensorName", characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(Speed.of(5), sensor.speed());
|
assertEquals(Speed.of(5), sensor.speed());
|
||||||
+18
-18
@@ -13,9 +13,9 @@ import java.time.Instant;
|
|||||||
import de.dennisguse.opentracks.data.models.Cadence;
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingCadence;
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingDistanceSpeed;
|
|
||||||
import de.dennisguse.opentracks.sensors.UintUtils;
|
import de.dennisguse.opentracks.sensors.UintUtils;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingCadenceBluetooth;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingDistanceSpeedBluetooth;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class SensorDataCyclingTest {
|
public class SensorDataCyclingTest {
|
||||||
@@ -25,8 +25,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 1024));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 2048));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 2048));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
||||||
@@ -37,8 +37,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 6184));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 6184));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 8016));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 8016));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(33.53, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
assertEquals(33.53, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
||||||
@@ -49,8 +49,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 1024));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 2048));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 2048));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(Cadence.of(0), current.getAggregatedValue(Instant.MIN));
|
assertEquals(Cadence.of(0), current.getAggregatedValue(Instant.MIN));
|
||||||
@@ -62,8 +62,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, 1024));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 1024));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 1024));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertFalse(current.hasReceivedData()); //TODO Cadence should be 0?
|
assertFalse(current.hasReceivedData()); //TODO Cadence should be 0?
|
||||||
@@ -74,8 +74,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, UintUtils.UINT16_MAX - 1024));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(1, UintUtils.UINT16_MAX - 1024));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 0));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(2, 0));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
|
||||||
@@ -87,8 +87,8 @@ public class SensorDataCyclingTest {
|
|||||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(UintUtils.UINT32_MAX - 1, 1024));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(UintUtils.UINT32_MAX - 1, 1024));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(0, 2048));
|
current.add(Instant.MIN, new CyclingCadenceBluetooth.CrankData(0, 2048));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// TODO See #953
|
// TODO See #953
|
||||||
@@ -102,8 +102,8 @@ public class SensorDataCyclingTest {
|
|||||||
current.setWheelCircumference(Distance.ofMM(2150));
|
current.setWheelCircumference(Distance.ofMM(2150));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(1, 6184));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(1, 6184));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(2, 8016));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(2, 8016));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(2.15, current.getAggregatedValue(Instant.MIN).distance().toM(), 0.01);
|
assertEquals(2.15, current.getAggregatedValue(Instant.MIN).distance().toM(), 0.01);
|
||||||
@@ -117,8 +117,8 @@ public class SensorDataCyclingTest {
|
|||||||
current.setWheelCircumference(Distance.ofMM(2000));
|
current.setWheelCircumference(Distance.ofMM(2000));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(UintUtils.UINT32_MAX - 1, 1024));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(UintUtils.UINT32_MAX - 1, 1024));
|
||||||
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(0, 2048));
|
current.add(Instant.MIN, new CyclingDistanceSpeedBluetooth.WheelData(0, 2048));
|
||||||
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|||||||
+6
-6
@@ -42,8 +42,8 @@ import de.dennisguse.opentracks.data.models.Statistics;
|
|||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.io.file.importer.TrackPointAssert;
|
import de.dennisguse.opentracks.io.file.importer.TrackPointAssert;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
|
|
||||||
import de.dennisguse.opentracks.sensors.SensorManager;
|
import de.dennisguse.opentracks.sensors.SensorManager;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.RunningSpeedAndCadenceBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
|
||||||
@@ -818,13 +818,13 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
String sensor1 = "2020-02-02T02:02:03Z";
|
String sensor1 = "2020-02-02T02:02:03Z";
|
||||||
trackPointCreator.setClock(sensor1);
|
trackPointCreator.setClock(sensor1);
|
||||||
//Should be ignored
|
//Should be ignored
|
||||||
aggregatorRunning.add(trackPointCreator.getNow(), new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(1), Distance.ZERO));
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(1), Distance.ZERO));
|
||||||
sensorManager.onChange();
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String sensor2 = "2020-02-02T02:02:04Z";
|
String sensor2 = "2020-02-02T02:02:04Z";
|
||||||
trackPointCreator.setClock(sensor2);
|
trackPointCreator.setClock(sensor2);
|
||||||
aggregatorRunning.add(trackPointCreator.getNow(), new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(2), Distance.of(2)));
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(2), Distance.of(2)));
|
||||||
sensorManager.onChange();
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@@ -834,14 +834,14 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
// when
|
// when
|
||||||
String sensor3 = "2020-02-02T02:02:06Z";
|
String sensor3 = "2020-02-02T02:02:06Z";
|
||||||
trackPointCreator.setClock(sensor3);
|
trackPointCreator.setClock(sensor3);
|
||||||
aggregatorRunning.add(trackPointCreator.getNow(), new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(3), Distance.of(12)));
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(3), Distance.of(12)));
|
||||||
sensorManager.onChange();
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String sensor4 = "2020-02-02T02:02:07Z";
|
String sensor4 = "2020-02-02T02:02:07Z";
|
||||||
trackPointCreator.setClock(sensor4);
|
trackPointCreator.setClock(sensor4);
|
||||||
//Should be ignored
|
//Should be ignored
|
||||||
aggregatorRunning.add(trackPointCreator.getNow(), new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(4), Distance.of(14)));
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(4), Distance.of(14)));
|
||||||
sensorManager.onChange();
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@@ -852,7 +852,7 @@ public class TrackRecordingServiceRecordingTest {
|
|||||||
String sensor5 = "2020-02-02T02:02:10Z";
|
String sensor5 = "2020-02-02T02:02:10Z";
|
||||||
trackPointCreator.setClock(sensor5);
|
trackPointCreator.setClock(sensor5);
|
||||||
//Should be ignored
|
//Should be ignored
|
||||||
aggregatorRunning.add(trackPointCreator.getNow(), new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(5), Distance.of(16)));
|
aggregatorRunning.add(trackPointCreator.getNow(), new RunningSpeedAndCadenceBluetooth.Data(Speed.of(5), Cadence.of(5), Distance.of(16)));
|
||||||
sensorManager.onChange();
|
sensorManager.onChange();
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.util.Pair;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
public class BluetoothHandlerCyclingCadence implements SensorHandlerInterface {
|
|
||||||
private static final String TAG = BluetoothHandlerCyclingCadence.class.getSimpleName();
|
|
||||||
|
|
||||||
public static final List<ServiceMeasurementUUID> CYCLING_CADENCE = List.of(
|
|
||||||
BluetoothHandlerCyclingPower.CYCLING_POWER,
|
|
||||||
BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ServiceMeasurementUUID> getServices() {
|
|
||||||
return CYCLING_CADENCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AggregatorCyclingCadence createEmptySensorData(String address, String name) {
|
|
||||||
return new AggregatorCyclingCadence(address, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePayload(DriverObserver0 observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
|
||||||
if (serviceMeasurementUUID.equals(BluetoothHandlerCyclingPower.CYCLING_POWER)) {
|
|
||||||
BluetoothHandlerCyclingPower.Data data = BluetoothHandlerCyclingPower.parseCyclingPower(characteristic);
|
|
||||||
if (data != null && data.crank() != null) {
|
|
||||||
observer.onChange(data.crank());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serviceMeasurementUUID.equals(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE)) {
|
|
||||||
Pair<BluetoothHandlerCyclingDistanceSpeed.WheelData, CrankData> data = BluetoothHandlerCyclingDistanceSpeed.parseCyclingCrankAndWheel(address, sensorName, characteristic);
|
|
||||||
|
|
||||||
if (data != null && data.second != null) {
|
|
||||||
observer.onChange(data.second);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.e(TAG, "Don't know how to decode this payload.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public record CrankData(
|
|
||||||
long crankRevolutionsCount, // UINT32
|
|
||||||
int crankRevolutionsTime // UINT16; 1/1024s
|
|
||||||
) {}
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
|
||||||
|
|
||||||
import static de.dennisguse.opentracks.sensors.BluetoothHandlerBarometricPressure.ENVIRONMENTAL_SENSING_SERVICE;
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Temperature;
|
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorTemperature;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
public class BluetoothHandlerTemperature implements SensorHandlerInterface {
|
|
||||||
public static final ServiceMeasurementUUID TEMPERATURE = new ServiceMeasurementUUID(
|
|
||||||
ENVIRONMENTAL_SENSING_SERVICE,
|
|
||||||
new UUID(0x2A6E00001000L, 0x800000805f9b34fbL)
|
|
||||||
);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ServiceMeasurementUUID> getServices() {
|
|
||||||
return List.of(TEMPERATURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Aggregator<?, ?> createEmptySensorData(String address, String name) {
|
|
||||||
return new AggregatorTemperature(address, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePayload(DriverObserver0 observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
|
||||||
Temperature value = parseEnvironmentalSensing(characteristic);
|
|
||||||
if (value == null) return;
|
|
||||||
|
|
||||||
observer.onChange(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decoding: org.bluetooth.characteristic.temperature.xml
|
|
||||||
*/
|
|
||||||
public static Temperature parseEnvironmentalSensing(BluetoothGattCharacteristic characteristic) {
|
|
||||||
byte[] raw = characteristic.getValue();
|
|
||||||
|
|
||||||
if (raw.length < 2) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer pressure = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, 0);
|
|
||||||
return Temperature.ofCentiCelsius(pressure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,12 +3,13 @@ package de.dennisguse.opentracks.sensors;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingCadenceBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.driver.Driver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
||||||
|
|
||||||
public class CyclingCadenceHandler extends SensorHandler<BluetoothHandlerCyclingCadence.CrankData> {
|
public class CyclingCadenceHandler extends SensorHandler<CyclingCadenceBluetooth.CrankData> {
|
||||||
|
|
||||||
protected CyclingCadenceHandler(SensorManager sensorManager) {
|
protected CyclingCadenceHandler(SensorManager sensorManager) {
|
||||||
super(sensorManager);
|
super(sensorManager);
|
||||||
@@ -17,36 +18,16 @@ public class CyclingCadenceHandler extends SensorHandler<BluetoothHandlerCycling
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Driver createDriverBluetooth(String address) {
|
protected Driver createDriverBluetooth(String address) {
|
||||||
return new BluetoothConnectionManager(
|
return new BluetoothDriver<>(
|
||||||
BluetoothUtils.getAdapter(getContext()),
|
BluetoothUtils.getAdapter(getContext()),
|
||||||
new DriverObserver0() {
|
driverObserver,
|
||||||
@Override
|
new CyclingCadenceBluetooth()
|
||||||
public void onConnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
driverObserver.onData((BluetoothHandlerCyclingCadence.CrankData) value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BluetoothHandlerCyclingCadence()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Aggregator<BluetoothHandlerCyclingCadence.CrankData, ?> createAggregator() {
|
protected Aggregator<CyclingCadenceBluetooth.CrankData, ?> createAggregator() {
|
||||||
return new AggregatorCyclingCadence("", null);
|
return new AggregatorCyclingCadence("", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package de.dennisguse.opentracks.sensors;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingDistanceSpeedBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.driver.Driver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpeed;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpeed;
|
||||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
|
||||||
|
|
||||||
public class CyclingDistanceSpeedHandler extends SensorHandler<BluetoothHandlerCyclingDistanceSpeed.WheelData> {
|
public class CyclingDistanceSpeedHandler extends SensorHandler<CyclingDistanceSpeedBluetooth.WheelData> {
|
||||||
|
|
||||||
protected CyclingDistanceSpeedHandler(SensorManager sensorManager) {
|
protected CyclingDistanceSpeedHandler(SensorManager sensorManager) {
|
||||||
super(sensorManager);
|
super(sensorManager);
|
||||||
@@ -18,31 +17,11 @@ public class CyclingDistanceSpeedHandler extends SensorHandler<BluetoothHandlerC
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Driver createDriverBluetooth(String address) {
|
protected Driver createDriverBluetooth(String address) {
|
||||||
return new BluetoothConnectionManager(
|
//TODO ((AggregatorCyclingDistanceSpeed) getAggregator()).setWheelCircumference(PreferencesUtils.getWheelCircumference()); //TODO Fetch once and then listen for changes.);
|
||||||
|
return new BluetoothDriver<>(
|
||||||
BluetoothUtils.getAdapter(getContext()),
|
BluetoothUtils.getAdapter(getContext()),
|
||||||
new DriverObserver0() {
|
driverObserver,
|
||||||
@Override
|
new CyclingDistanceSpeedBluetooth()
|
||||||
public void onConnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
((AggregatorCyclingDistanceSpeed) getAggregator()).setWheelCircumference(PreferencesUtils.getWheelCircumference()); //TODO Fetch once and then listen for changes.);
|
|
||||||
driverObserver.onData((BluetoothHandlerCyclingDistanceSpeed.WheelData) value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BluetoothHandlerCyclingDistanceSpeed()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package de.dennisguse.opentracks.sensors;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingPowerBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.driver.Driver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
|
||||||
|
|
||||||
public class CyclingPowerHandler extends SensorHandler<BluetoothHandlerCyclingPower.Data> {
|
public class CyclingPowerHandler extends SensorHandler<CyclingPowerBluetooth.Data> {
|
||||||
|
|
||||||
protected CyclingPowerHandler(SensorManager sensorManager) {
|
protected CyclingPowerHandler(SensorManager sensorManager) {
|
||||||
super(sensorManager);
|
super(sensorManager);
|
||||||
@@ -17,30 +17,10 @@ public class CyclingPowerHandler extends SensorHandler<BluetoothHandlerCyclingPo
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Driver createDriverBluetooth(String address) {
|
protected Driver createDriverBluetooth(String address) {
|
||||||
return new BluetoothConnectionManager(
|
return new BluetoothDriver<>(
|
||||||
BluetoothUtils.getAdapter(getContext()),
|
BluetoothUtils.getAdapter(getContext()),
|
||||||
new DriverObserver0() {
|
driverObserver,
|
||||||
@Override
|
new CyclingPowerBluetooth()
|
||||||
public void onConnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
driverObserver.onData((BluetoothHandlerCyclingPower.Data) value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BluetoothHandlerCyclingPower()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.data.models.AtmosphericPressure;
|
import de.dennisguse.opentracks.data.models.AtmosphericPressure;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BarometerBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.driver.BarometerInternal;
|
import de.dennisguse.opentracks.sensors.driver.BarometerInternal;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.driver.Driver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
||||||
|
|
||||||
@@ -34,30 +35,10 @@ public class GainManager extends SensorHandler<AtmosphericPressure> {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Driver createDriverBluetooth(String address) {
|
protected Driver createDriverBluetooth(String address) {
|
||||||
return new BluetoothConnectionManager(
|
return new BluetoothDriver<>(
|
||||||
BluetoothUtils.getAdapter(getContext()),
|
BluetoothUtils.getAdapter(getContext()),
|
||||||
new DriverObserver0() {
|
driverObserver,
|
||||||
@Override
|
new BarometerBluetooth()
|
||||||
public void onConnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
driverObserver.onData((AtmosphericPressure) value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BluetoothHandlerBarometricPressure()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.driver.Driver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.driver.HeartRateBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
||||||
|
|
||||||
@@ -18,30 +19,10 @@ public class HeartRateHandler extends SensorHandler<HeartRate> {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Driver createDriverBluetooth(String address) {
|
protected Driver createDriverBluetooth(String address) {
|
||||||
return new BluetoothConnectionManager(
|
return new BluetoothDriver<>(
|
||||||
BluetoothUtils.getAdapter(getContext()),
|
BluetoothUtils.getAdapter(getContext()),
|
||||||
new DriverObserver0() {
|
driverObserver,
|
||||||
@Override
|
new HeartRateBluetooth()
|
||||||
public void onConnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
driverObserver.onData((HeartRate) value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BluetoothHandlerHeartRate()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-26
@@ -3,12 +3,12 @@ package de.dennisguse.opentracks.sensors;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.driver.Driver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.driver.RunningSpeedAndCadenceBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
|
||||||
|
|
||||||
public class RunningSpeedCadenceDistanceHandler extends SensorHandler<BluetoothHandlerRunningSpeedAndCadence.Data> {
|
public class RunningSpeedCadenceDistanceHandler extends SensorHandler<RunningSpeedAndCadenceBluetooth.Data> {
|
||||||
|
|
||||||
protected RunningSpeedCadenceDistanceHandler(SensorManager sensorManager) {
|
protected RunningSpeedCadenceDistanceHandler(SensorManager sensorManager) {
|
||||||
super(sensorManager);
|
super(sensorManager);
|
||||||
@@ -17,30 +17,10 @@ public class RunningSpeedCadenceDistanceHandler extends SensorHandler<BluetoothH
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Driver createDriverBluetooth(String address) {
|
protected Driver createDriverBluetooth(String address) {
|
||||||
return new BluetoothConnectionManager(
|
return new BluetoothDriver<>(
|
||||||
BluetoothUtils.getAdapter(getContext()),
|
BluetoothUtils.getAdapter(getContext()),
|
||||||
new DriverObserver0() {
|
driverObserver,
|
||||||
@Override
|
new RunningSpeedAndCadenceBluetooth()
|
||||||
public void onConnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
driverObserver.onData((BluetoothHandlerRunningSpeedAndCadence.Data) value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BluetoothHandlerRunningSpeedAndCadence()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public abstract class SensorHandler<T> {
|
|||||||
|
|
||||||
private Aggregator<T, ?> aggregator;
|
private Aggregator<T, ?> aggregator;
|
||||||
|
|
||||||
protected final DriverObserver<T> driverObserver = new DriverObserver<T>() {
|
protected final DriverObserver<T> driverObserver = new DriverObserver<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnect() {
|
public void onConnect() {
|
||||||
SensorHandler.this.aggregator = createAggregator();
|
SensorHandler.this.aggregator = createAggregator();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import de.dennisguse.opentracks.data.models.Distance;
|
|||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.data.models.Position;
|
import de.dennisguse.opentracks.data.models.Position;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
||||||
@@ -34,8 +34,7 @@ import de.dennisguse.opentracks.settings.PreferencesUtils;
|
|||||||
import de.dennisguse.opentracks.util.SystemUtils;
|
import de.dennisguse.opentracks.util.SystemUtils;
|
||||||
|
|
||||||
//TODO provide context and handler for different Managers (not passing via start(), but similar to getNow()).
|
//TODO provide context and handler for different Managers (not passing via start(), but similar to getNow()).
|
||||||
//TODO Remove DriverObserver from SensorManager
|
public class SensorManager implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
public class SensorManager implements SharedPreferences.OnSharedPreferenceChangeListener, DriverObserver0 {
|
|
||||||
|
|
||||||
private static final String TAG = SensorManager.class.getSimpleName();
|
private static final String TAG = SensorManager.class.getSimpleName();
|
||||||
|
|
||||||
@@ -122,8 +121,6 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
|
|
||||||
context = null;
|
context = null;
|
||||||
handler = null;
|
handler = null;
|
||||||
|
|
||||||
clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
@@ -160,7 +157,7 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
this.altitudeSumManager = altitudeSumManager;
|
this.altitudeSumManager = altitudeSumManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void connect(BluetoothConnectionManager connectionManager, String address) {
|
private synchronized void connect(BluetoothDriver connectionManager, String address) {
|
||||||
connectionManager.connect(context, handler, address);
|
connectionManager.connect(context, handler, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,27 +196,6 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Inlined from SensorDataAggregator; Aggregators will be moved into Drivers.
|
|
||||||
@Deprecated
|
|
||||||
public void onConnect(Aggregator<?, ?> aggregator) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void onDisconnect(Aggregator<?, ?> aggregator) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void onRemove(Aggregator<?, ?> aggregator) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getNow() {
|
public Instant getNow() {
|
||||||
return observer.getNow();
|
return observer.getNow();
|
||||||
}
|
}
|
||||||
@@ -240,8 +216,8 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
return ((AggregatorCyclingCadence) cyclingCadenceHandler.getAggregator()).getAggregatedValueWithSensorName(now);
|
return ((AggregatorCyclingCadence) cyclingCadenceHandler.getAggregator()).getAggregatedValueWithSensorName(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runningSpeedCadenceDistanceHandler.getAggregator() != null && runningSpeedCadenceDistanceHandler.getAggregator().hasReceivedData() && ((AggregatorRunning)runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue(now).cadence() != null) {
|
if (runningSpeedCadenceDistanceHandler.getAggregator() != null && runningSpeedCadenceDistanceHandler.getAggregator().hasReceivedData() && ((AggregatorRunning) runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue(now).cadence() != null) {
|
||||||
return new SensorData<>(((AggregatorRunning)runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue().cadence(), runningSpeedCadenceDistanceHandler.getAggregator().getSensorNameOrAddress());
|
return new SensorData<>(((AggregatorRunning) runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue().cadence(), runningSpeedCadenceDistanceHandler.getAggregator().getSensorNameOrAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -253,7 +229,7 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (runningSpeedCadenceDistanceHandler.getAggregator() != null && runningSpeedCadenceDistanceHandler.getAggregator().hasReceivedData()) {
|
if (runningSpeedCadenceDistanceHandler.getAggregator() != null && runningSpeedCadenceDistanceHandler.getAggregator().hasReceivedData()) {
|
||||||
return new SensorData<>(((AggregatorRunning)runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue(now).distance(), runningSpeedCadenceDistanceHandler.getAggregator().getSensorNameOrAddress());
|
return new SensorData<>(((AggregatorRunning) runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue(now).distance(), runningSpeedCadenceDistanceHandler.getAggregator().getSensorNameOrAddress());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,8 +243,8 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
|||||||
return new SensorData<>(((AggregatorCyclingDistanceSpeed) cyclingDistanceSpeedHandler.getAggregator()).getAggregatedValue(now).speed(), cyclingDistanceSpeedHandler.getAggregator().getSensorNameOrAddress());
|
return new SensorData<>(((AggregatorCyclingDistanceSpeed) cyclingDistanceSpeedHandler.getAggregator()).getAggregatedValue(now).speed(), cyclingDistanceSpeedHandler.getAggregator().getSensorNameOrAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runningSpeedCadenceDistanceHandler.getAggregator() != null && runningSpeedCadenceDistanceHandler.getAggregator().hasReceivedData() && ((AggregatorRunning)runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue(now).speed() != null) {
|
if (runningSpeedCadenceDistanceHandler.getAggregator() != null && runningSpeedCadenceDistanceHandler.getAggregator().hasReceivedData() && ((AggregatorRunning) runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue(now).speed() != null) {
|
||||||
return new SensorData<>(((AggregatorRunning)runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue().speed(), runningSpeedCadenceDistanceHandler.getAggregator().getSensorNameOrAddress());
|
return new SensorData<>(((AggregatorRunning) runningSpeedCadenceDistanceHandler.getAggregator()).getAggregatedValue().speed(), runningSpeedCadenceDistanceHandler.getAggregator().getSensorNameOrAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.data.models.Temperature;
|
import de.dennisguse.opentracks.data.models.Temperature;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.BluetoothDriver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.driver.Driver;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.driver.TemperatureBluetooth;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorTemperature;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorTemperature;
|
||||||
|
|
||||||
@@ -18,30 +19,10 @@ public class TemperatureHandler extends SensorHandler<Temperature> {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
protected Driver createDriverBluetooth(String address) {
|
protected Driver createDriverBluetooth(String address) {
|
||||||
return new BluetoothConnectionManager(
|
return new BluetoothDriver<>(
|
||||||
BluetoothUtils.getAdapter(getContext()),
|
BluetoothUtils.getAdapter(getContext()),
|
||||||
new DriverObserver0() {
|
driverObserver,
|
||||||
@Override
|
new TemperatureBluetooth()
|
||||||
public void onConnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnect(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRemove(Aggregator<?, ?> emptySensorData) {
|
|
||||||
driverObserver.onRemove();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(Record value) {
|
|
||||||
driverObserver.onData((Temperature) value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new BluetoothHandlerTemperature()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-16
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
@@ -6,12 +6,9 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.AtmosphericPressure;
|
import de.dennisguse.opentracks.data.models.AtmosphericPressure;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
public class BluetoothHandlerBarometricPressure implements SensorHandlerInterface {
|
public class BarometerBluetooth implements BluetoothDriver.BluetoothParser<AtmosphericPressure> {
|
||||||
static final UUID ENVIRONMENTAL_SENSING_SERVICE = new UUID(0x181A00001000L, 0x800000805f9b34fbL);
|
static final UUID ENVIRONMENTAL_SENSING_SERVICE = new UUID(0x181A00001000L, 0x800000805f9b34fbL);
|
||||||
public static final ServiceMeasurementUUID BAROMETRIC_PRESSURE = new ServiceMeasurementUUID(
|
public static final ServiceMeasurementUUID BAROMETRIC_PRESSURE = new ServiceMeasurementUUID(
|
||||||
ENVIRONMENTAL_SENSING_SERVICE,
|
ENVIRONMENTAL_SENSING_SERVICE,
|
||||||
@@ -24,16 +21,8 @@ public class BluetoothHandlerBarometricPressure implements SensorHandlerInterfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Aggregator<?, ?> createEmptySensorData(String address, String name) {
|
public AtmosphericPressure parsePayload(ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic) {
|
||||||
return new AggregatorBarometer(address, name);
|
return parseEnvironmentalSensing(characteristic);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePayload(DriverObserver0 observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
|
||||||
AtmosphericPressure value = parseEnvironmentalSensing(characteristic);
|
|
||||||
if (value == null) return;
|
|
||||||
|
|
||||||
observer.onChange(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+24
-28
@@ -14,7 +14,7 @@
|
|||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
@@ -31,24 +31,24 @@ import android.util.Log;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.driver.Driver;
|
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages connection to a Bluetooth LE sensor and subscribes for onChange-notifications.
|
* Manages connection to a Bluetooth LE sensor and subscribes for onChange-notifications.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
public class BluetoothConnectionManager implements Driver {
|
public class BluetoothDriver<T> implements Driver {
|
||||||
|
|
||||||
private static final String TAG = BluetoothConnectionManager.class.getSimpleName();
|
private static final String TAG = BluetoothDriver.class.getSimpleName();
|
||||||
|
|
||||||
private final DriverObserver0 observer;
|
private final DriverObserver<T> observer;
|
||||||
|
|
||||||
private final SensorHandlerInterface sensorHandler;
|
private final BluetoothParser<T> sensorHandler;
|
||||||
|
|
||||||
private final BluetoothAdapter bluetoothAdapter;
|
private final BluetoothAdapter bluetoothAdapter;
|
||||||
private BluetoothGatt bluetoothGatt;
|
private BluetoothGatt bluetoothGatt;
|
||||||
@@ -128,11 +128,15 @@ public class BluetoothConnectionManager implements Driver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sensorHandler.handlePayload(observer, serviceMeasurementUUID.get(), gatt.getDevice().getName(), gatt.getDevice().getAddress(), characteristic);
|
T value = sensorHandler.parsePayload(serviceMeasurementUUID.get(), gatt.getDevice().getName(), characteristic);
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
observer.onData(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BluetoothConnectionManager(BluetoothAdapter bluetoothAdapter, DriverObserver0 observer, SensorHandlerInterface sensorHandler) {
|
public BluetoothDriver(BluetoothAdapter bluetoothAdapter, DriverObserver<T> observer, BluetoothParser<T> sensorHandler) {
|
||||||
this.bluetoothAdapter = bluetoothAdapter;
|
this.bluetoothAdapter = bluetoothAdapter;
|
||||||
this.observer = observer;
|
this.observer = observer;
|
||||||
this.sensorHandler = sensorHandler;
|
this.sensorHandler = sensorHandler;
|
||||||
@@ -145,26 +149,11 @@ public class BluetoothConnectionManager implements Driver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SensorType.NONE.getPreferenceValue().equals(address)) {
|
|
||||||
Log.w(TAG, "NONE: going to disconnect");
|
|
||||||
if (isConnected()) {
|
|
||||||
disconnect();
|
|
||||||
observer.onRemove(sensorHandler.createEmptySensorData(null, null));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
Log.w(TAG, "Already connected; ignoring.");
|
Log.e(TAG, "Already connected; ignoring.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSameBluetoothDevice(address)) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
BluetoothDevice device;
|
BluetoothDevice device;
|
||||||
try {
|
try {
|
||||||
device = bluetoothAdapter.getRemoteDevice(address);
|
device = bluetoothAdapter.getRemoteDevice(address);
|
||||||
@@ -177,11 +166,11 @@ public class BluetoothConnectionManager implements Driver {
|
|||||||
|
|
||||||
bluetoothGatt = device.connectGatt(context, false, connectCallback, BluetoothDevice.TRANSPORT_AUTO, 0, handler);
|
bluetoothGatt = device.connectGatt(context, false, connectCallback, BluetoothDevice.TRANSPORT_AUTO, 0, handler);
|
||||||
|
|
||||||
observer.onConnect(sensorHandler.createEmptySensorData(device.getAddress(), device.getName()));
|
observer.onConnect(); //TODO pass device.getAddress(), device.getName()
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void clearData() {
|
private synchronized void clearData() {
|
||||||
observer.onDisconnect(sensorHandler.createEmptySensorData(bluetoothGatt.getDevice().getAddress(), bluetoothGatt.getDevice().getName()));
|
observer.onDisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -215,4 +204,11 @@ public class BluetoothConnectionManager implements Driver {
|
|||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return bluetoothGatt != null;
|
return bluetoothGatt != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface BluetoothParser<T> {
|
||||||
|
|
||||||
|
List<ServiceMeasurementUUID> getServices();
|
||||||
|
|
||||||
|
T parsePayload(ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.Pair;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
|
|
||||||
|
public class CyclingCadenceBluetooth implements BluetoothDriver.BluetoothParser<CyclingCadenceBluetooth.CrankData> {
|
||||||
|
private static final String TAG = CyclingCadenceBluetooth.class.getSimpleName();
|
||||||
|
|
||||||
|
public static final List<ServiceMeasurementUUID> CYCLING_CADENCE = List.of(
|
||||||
|
CyclingPowerBluetooth.CYCLING_POWER,
|
||||||
|
CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ServiceMeasurementUUID> getServices() {
|
||||||
|
return CYCLING_CADENCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CrankData parsePayload(ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic) {
|
||||||
|
if (serviceMeasurementUUID.equals(CyclingPowerBluetooth.CYCLING_POWER)) {
|
||||||
|
CyclingPowerBluetooth.Data data = CyclingPowerBluetooth.parseCyclingPower(characteristic);
|
||||||
|
if (data != null && data.crank() != null) {
|
||||||
|
return data.crank();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceMeasurementUUID.equals(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE)) {
|
||||||
|
Pair<CyclingDistanceSpeedBluetooth.WheelData, CrankData> data = CyclingDistanceSpeedBluetooth.parseCyclingCrankAndWheel(characteristic);
|
||||||
|
|
||||||
|
if (data != null && data.second != null) {
|
||||||
|
return data.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.e(TAG, "Don't know how to decode this payload.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public record CrankData(
|
||||||
|
long crankRevolutionsCount, // UINT32
|
||||||
|
int crankRevolutionsTime // UINT16; 1/1024s
|
||||||
|
) {}
|
||||||
|
}
|
||||||
+12
-18
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@@ -9,11 +9,9 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpeed;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
public class BluetoothHandlerCyclingDistanceSpeed implements SensorHandlerInterface {
|
public class CyclingDistanceSpeedBluetooth implements BluetoothDriver.BluetoothParser<CyclingDistanceSpeedBluetooth.WheelData> {
|
||||||
|
|
||||||
public static final ServiceMeasurementUUID CYCLING_SPEED_CADENCE = new ServiceMeasurementUUID(
|
public static final ServiceMeasurementUUID CYCLING_SPEED_CADENCE = new ServiceMeasurementUUID(
|
||||||
new UUID(0x181600001000L, 0x800000805f9b34fbL),
|
new UUID(0x181600001000L, 0x800000805f9b34fbL),
|
||||||
@@ -26,22 +24,18 @@ public class BluetoothHandlerCyclingDistanceSpeed implements SensorHandlerInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AggregatorCyclingDistanceSpeed createEmptySensorData(String address, String name) {
|
public WheelData parsePayload(ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic) {
|
||||||
return new AggregatorCyclingDistanceSpeed(address, name);
|
Pair<WheelData, CyclingCadenceBluetooth.CrankData> data = parseCyclingCrankAndWheel(characteristic);
|
||||||
}
|
if (data != null && data.first != null) {
|
||||||
|
return data.first;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
return null;
|
||||||
public void handlePayload(DriverObserver0 observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
|
||||||
Pair<WheelData, BluetoothHandlerCyclingCadence.CrankData> data = parseCyclingCrankAndWheel(address, sensorName, characteristic);
|
|
||||||
if (data == null) return;
|
|
||||||
if (data.first == null) return;
|
|
||||||
|
|
||||||
observer.onChange(data.first);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
|
||||||
public static Pair<WheelData, BluetoothHandlerCyclingCadence.CrankData> parseCyclingCrankAndWheel(String address, String sensorName, @NonNull BluetoothGattCharacteristic characteristic) {
|
public static Pair<WheelData, CyclingCadenceBluetooth.CrankData> parseCyclingCrankAndWheel(@NonNull BluetoothGattCharacteristic characteristic) {
|
||||||
// DOCUMENTATION https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.csc_measurement.xml
|
// DOCUMENTATION https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.csc_measurement.xml
|
||||||
int valueLength = characteristic.getValue().length;
|
int valueLength = characteristic.getValue().length;
|
||||||
if (valueLength == 0) {
|
if (valueLength == 0) {
|
||||||
@@ -62,13 +56,13 @@ public class BluetoothHandlerCyclingDistanceSpeed implements SensorHandlerInterf
|
|||||||
index += 2;
|
index += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
BluetoothHandlerCyclingCadence.CrankData crankData = null;
|
CyclingCadenceBluetooth.CrankData crankData = null;
|
||||||
if (hasCrank && valueLength - index >= 4) {
|
if (hasCrank && valueLength - index >= 4) {
|
||||||
long crankCount = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index);
|
long crankCount = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index);
|
||||||
index += 2;
|
index += 2;
|
||||||
|
|
||||||
int crankTime = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index); // 1/1024s
|
int crankTime = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index); // 1/1024s
|
||||||
crankData = new BluetoothHandlerCyclingCadence.CrankData(crankCount, crankTime);
|
crankData = new CyclingCadenceBluetooth.CrankData(crankCount, crankTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pair<>(wheelData, crankData);
|
return new Pair<>(wheelData, crankData);
|
||||||
+12
-20
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
@@ -9,11 +9,9 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Power;
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
public class BluetoothHandlerCyclingPower implements SensorHandlerInterface {
|
public class CyclingPowerBluetooth implements BluetoothDriver.BluetoothParser<CyclingPowerBluetooth.Data> {
|
||||||
|
|
||||||
public static final ServiceMeasurementUUID CYCLING_POWER = new ServiceMeasurementUUID(
|
public static final ServiceMeasurementUUID CYCLING_POWER = new ServiceMeasurementUUID(
|
||||||
new UUID(0x181800001000L, 0x800000805f9b34fbL),
|
new UUID(0x181800001000L, 0x800000805f9b34fbL),
|
||||||
@@ -26,17 +24,8 @@ public class BluetoothHandlerCyclingPower implements SensorHandlerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AggregatorCyclingPower createEmptySensorData(String address, String name) {
|
public CyclingPowerBluetooth.Data parsePayload(@NonNull ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic) {
|
||||||
return new AggregatorCyclingPower(address, name);
|
return parseCyclingPower(characteristic);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePayload(DriverObserver0 observer, @NonNull ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
|
||||||
Data cyclingPower = parseCyclingPower(characteristic);
|
|
||||||
|
|
||||||
if (cyclingPower == null) return;
|
|
||||||
|
|
||||||
observer.onChange(cyclingPower);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -69,19 +58,22 @@ public class BluetoothHandlerCyclingPower implements SensorHandlerInterface {
|
|||||||
index += 2 + 2;
|
index += 2 + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
BluetoothHandlerCyclingCadence.CrankData crankData = null;
|
CyclingCadenceBluetooth.CrankData crankData = null;
|
||||||
if (hasCrank && valueLength - index >= 4) {
|
if (hasCrank && valueLength - index >= 4) {
|
||||||
long crankCount = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index);
|
long crankCount = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index);
|
||||||
index += 2;
|
index += 2;
|
||||||
|
|
||||||
int crankTime = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index); // 1/1024s
|
int crankTime = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index); // 1/1024s
|
||||||
|
|
||||||
crankData = new BluetoothHandlerCyclingCadence.CrankData(crankCount, crankTime);
|
crankData = new CyclingCadenceBluetooth.CrankData(crankCount, crankTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Data(Power.of(instantaneousPower), crankData);
|
return new Data(Power.of(instantaneousPower), crankData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Data(Power power, BluetoothHandlerCyclingCadence.CrankData crank) {}
|
public record Data(
|
||||||
|
Power power,
|
||||||
|
CyclingCadenceBluetooth.CrankData crank
|
||||||
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package de.dennisguse.opentracks.sensors.driver;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
|
||||||
|
|
||||||
@Deprecated //Use DriverObserver
|
|
||||||
public interface DriverObserver0 {
|
|
||||||
|
|
||||||
//TODO Pass SensorName as parameter only
|
|
||||||
void onConnect(Aggregator<?,?> emptySensorData);
|
|
||||||
|
|
||||||
//TODO Remove parameter
|
|
||||||
void onDisconnect(Aggregator<?,?> emptySensorData);
|
|
||||||
|
|
||||||
//TODO Remove parameter
|
|
||||||
void onRemove(Aggregator<?,?> emptySensorData);
|
|
||||||
|
|
||||||
void onChange(Record value);
|
|
||||||
|
|
||||||
}
|
|
||||||
+5
-16
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
@@ -9,11 +9,9 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
public class BluetoothHandlerHeartRate implements SensorHandlerInterface {
|
public class HeartRateBluetooth implements BluetoothDriver.BluetoothParser<HeartRate> {
|
||||||
|
|
||||||
public static final ServiceMeasurementUUID HEARTRATE = new ServiceMeasurementUUID(
|
public static final ServiceMeasurementUUID HEARTRATE = new ServiceMeasurementUUID(
|
||||||
new UUID(0x180D00001000L, 0x800000805f9b34fbL),
|
new UUID(0x180D00001000L, 0x800000805f9b34fbL),
|
||||||
@@ -36,17 +34,8 @@ public class BluetoothHandlerHeartRate implements SensorHandlerInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AggregatorHeartRate createEmptySensorData(String address, String name) {
|
public HeartRate parsePayload(@NonNull ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic) {
|
||||||
return new AggregatorHeartRate(address, name);
|
return parseHeartRate(characteristic);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePayload(DriverObserver0 observer, @NonNull ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
|
||||||
HeartRate heartRate = parseHeartRate(characteristic);
|
|
||||||
|
|
||||||
if (heartRate == null) return;
|
|
||||||
|
|
||||||
observer.onChange(heartRate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
+5
-15
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
@@ -11,11 +11,9 @@ import java.util.UUID;
|
|||||||
import de.dennisguse.opentracks.data.models.Cadence;
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
|
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
|
||||||
|
|
||||||
public class BluetoothHandlerRunningSpeedAndCadence implements SensorHandlerInterface {
|
public class RunningSpeedAndCadenceBluetooth implements BluetoothDriver.BluetoothParser<RunningSpeedAndCadenceBluetooth.Data> {
|
||||||
|
|
||||||
|
|
||||||
public static final ServiceMeasurementUUID RUNNING_SPEED_CADENCE = new ServiceMeasurementUUID(
|
public static final ServiceMeasurementUUID RUNNING_SPEED_CADENCE = new ServiceMeasurementUUID(
|
||||||
@@ -29,16 +27,8 @@ public class BluetoothHandlerRunningSpeedAndCadence implements SensorHandlerInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AggregatorRunning createEmptySensorData(String address, String name) {
|
public Data parsePayload(ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic) {
|
||||||
return new AggregatorRunning(address, name);
|
return parseRunningSpeedAndCadence(sensorName, characteristic);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handlePayload(DriverObserver0 observer, @NonNull ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
|
||||||
Data data = parseRunningSpeedAndCadence(sensorName, characteristic);
|
|
||||||
if (data == null) return;
|
|
||||||
|
|
||||||
observer.onChange(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package de.dennisguse.opentracks.sensors;
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
public enum SensorType {
|
public enum SensorType {
|
||||||
NONE("NONE"), //TODO Use R.string.sensor_type_value_none
|
NONE("NONE"), //TODO Use R.string.sensor_type_value_none
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package de.dennisguse.opentracks.sensors.driver;
|
||||||
|
|
||||||
|
import static de.dennisguse.opentracks.sensors.driver.BarometerBluetooth.ENVIRONMENTAL_SENSING_SERVICE;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import de.dennisguse.opentracks.data.models.Temperature;
|
||||||
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
|
|
||||||
|
public class TemperatureBluetooth implements BluetoothDriver.BluetoothParser<Temperature> {
|
||||||
|
public static final ServiceMeasurementUUID TEMPERATURE = new ServiceMeasurementUUID(
|
||||||
|
ENVIRONMENTAL_SENSING_SERVICE,
|
||||||
|
new UUID(0x2A6E00001000L, 0x800000805f9b34fbL)
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ServiceMeasurementUUID> getServices() {
|
||||||
|
return List.of(TEMPERATURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Temperature parsePayload(ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, BluetoothGattCharacteristic characteristic) {
|
||||||
|
return parseEnvironmentalSensing(characteristic);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decoding: org.bluetooth.characteristic.temperature.xml
|
||||||
|
*/
|
||||||
|
public static Temperature parseEnvironmentalSensing(BluetoothGattCharacteristic characteristic) {
|
||||||
|
byte[] raw = characteristic.getValue();
|
||||||
|
|
||||||
|
if (raw.length < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer pressure = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_SINT16, 0);
|
||||||
|
return Temperature.ofCentiCelsius(pressure);
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -7,10 +7,10 @@ import androidx.annotation.NonNull;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Cadence;
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingCadence;
|
|
||||||
import de.dennisguse.opentracks.sensors.UintUtils;
|
import de.dennisguse.opentracks.sensors.UintUtils;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingCadenceBluetooth;
|
||||||
|
|
||||||
public class AggregatorCyclingCadence extends Aggregator<BluetoothHandlerCyclingCadence.CrankData, Cadence> {
|
public class AggregatorCyclingCadence extends Aggregator<CyclingCadenceBluetooth.CrankData, Cadence> {
|
||||||
|
|
||||||
private final String TAG = AggregatorCyclingCadence.class.getSimpleName();
|
private final String TAG = AggregatorCyclingCadence.class.getSimpleName();
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ public class AggregatorCyclingCadence extends Aggregator<BluetoothHandlerCycling
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void computeValue(Raw<BluetoothHandlerCyclingCadence.CrankData> current) {
|
protected void computeValue(Raw<CyclingCadenceBluetooth.CrankData> current) {
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -8,10 +8,10 @@ import java.time.Duration;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingDistanceSpeed;
|
|
||||||
import de.dennisguse.opentracks.sensors.UintUtils;
|
import de.dennisguse.opentracks.sensors.UintUtils;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.CyclingDistanceSpeedBluetooth;
|
||||||
|
|
||||||
public class AggregatorCyclingDistanceSpeed extends Aggregator<BluetoothHandlerCyclingDistanceSpeed.WheelData, AggregatorCyclingDistanceSpeed.Data> {
|
public class AggregatorCyclingDistanceSpeed extends Aggregator<CyclingDistanceSpeedBluetooth.WheelData, AggregatorCyclingDistanceSpeed.Data> {
|
||||||
|
|
||||||
private final String TAG = AggregatorCyclingDistanceSpeed.class.getSimpleName();
|
private final String TAG = AggregatorCyclingDistanceSpeed.class.getSimpleName();
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ public class AggregatorCyclingDistanceSpeed extends Aggregator<BluetoothHandlerC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void computeValue(Raw<BluetoothHandlerCyclingDistanceSpeed.WheelData> current) {
|
protected void computeValue(Raw<CyclingDistanceSpeedBluetooth.WheelData> current) {
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -3,16 +3,16 @@ package de.dennisguse.opentracks.sensors.sensorData;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Power;
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingPower;
|
import de.dennisguse.opentracks.sensors.driver.CyclingPowerBluetooth;
|
||||||
|
|
||||||
public class AggregatorCyclingPower extends Aggregator<BluetoothHandlerCyclingPower.Data, Power> {
|
public class AggregatorCyclingPower extends Aggregator<CyclingPowerBluetooth.Data, Power> {
|
||||||
|
|
||||||
public AggregatorCyclingPower(String name, String address) {
|
public AggregatorCyclingPower(String name, String address) {
|
||||||
super(name, address);
|
super(name, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void computeValue(Raw<BluetoothHandlerCyclingPower.Data> current) {
|
public void computeValue(Raw<CyclingPowerBluetooth.Data> current) {
|
||||||
this.aggregatedValue = current.value().power();
|
this.aggregatedValue = current.value().power();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import androidx.annotation.NonNull;
|
|||||||
import de.dennisguse.opentracks.data.models.Cadence;
|
import de.dennisguse.opentracks.data.models.Cadence;
|
||||||
import de.dennisguse.opentracks.data.models.Distance;
|
import de.dennisguse.opentracks.data.models.Distance;
|
||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
|
import de.dennisguse.opentracks.sensors.driver.RunningSpeedAndCadenceBluetooth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides cadence in rpm and speed in milliseconds from Bluetooth LE Running Speed and Cadence sensors.
|
* Provides cadence in rpm and speed in milliseconds from Bluetooth LE Running Speed and Cadence sensors.
|
||||||
*/
|
*/
|
||||||
public final class AggregatorRunning extends Aggregator<BluetoothHandlerRunningSpeedAndCadence.Data, AggregatorRunning.Data> {
|
public final class AggregatorRunning extends Aggregator<RunningSpeedAndCadenceBluetooth.Data, AggregatorRunning.Data> {
|
||||||
|
|
||||||
private static final String TAG = AggregatorRunning.class.getSimpleName();
|
private static final String TAG = AggregatorRunning.class.getSimpleName();
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ public final class AggregatorRunning extends Aggregator<BluetoothHandlerRunningS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void computeValue(Raw<BluetoothHandlerRunningSpeedAndCadence.Data> current) {
|
public void computeValue(Raw<RunningSpeedAndCadenceBluetooth.Data> current) {
|
||||||
if (previous == null) {
|
if (previous == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package de.dennisguse.opentracks.sensors.sensorData;
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
|
||||||
import de.dennisguse.opentracks.sensors.driver.DriverObserver0;
|
|
||||||
|
|
||||||
public interface SensorHandlerInterface {
|
|
||||||
|
|
||||||
List<ServiceMeasurementUUID> getServices();
|
|
||||||
|
|
||||||
Aggregator<?, ?> createEmptySensorData(String address, String name);
|
|
||||||
|
|
||||||
void handlePayload(DriverObserver0 observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic);
|
|
||||||
}
|
|
||||||
@@ -48,7 +48,7 @@ import de.dennisguse.opentracks.data.models.HeartRateZones;
|
|||||||
import de.dennisguse.opentracks.data.models.Track;
|
import de.dennisguse.opentracks.data.models.Track;
|
||||||
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
||||||
import de.dennisguse.opentracks.io.file.TrackFilenameGenerator;
|
import de.dennisguse.opentracks.io.file.TrackFilenameGenerator;
|
||||||
import de.dennisguse.opentracks.sensors.SensorType;
|
import de.dennisguse.opentracks.sensors.driver.SensorType;
|
||||||
import de.dennisguse.opentracks.ui.customRecordingLayout.DataField;
|
import de.dennisguse.opentracks.ui.customRecordingLayout.DataField;
|
||||||
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayout;
|
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayout;
|
||||||
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayoutIO;
|
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayoutIO;
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@ import android.util.AttributeSet;
|
|||||||
|
|
||||||
import androidx.preference.PreferenceDialogFragmentCompat;
|
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingCadence;
|
import de.dennisguse.opentracks.sensors.driver.CyclingCadenceBluetooth;
|
||||||
|
|
||||||
public class BluetoothLeCyclingCadencePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeCyclingCadencePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -27,6 +27,6 @@ public class BluetoothLeCyclingCadencePreference extends BluetoothLeSensorPrefer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothHandlerCyclingCadence.CYCLING_CADENCE);
|
return BluetoothLeSensorPreferenceDialog.newInstance(getKey(), CyclingCadenceBluetooth.CYCLING_CADENCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ import androidx.preference.PreferenceDialogFragmentCompat;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingPower;
|
import de.dennisguse.opentracks.sensors.driver.CyclingPowerBluetooth;
|
||||||
|
|
||||||
public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -29,6 +29,6 @@ public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreferen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(BluetoothHandlerCyclingPower.CYCLING_POWER));
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(CyclingPowerBluetooth.CYCLING_POWER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -7,7 +7,7 @@ import androidx.preference.PreferenceDialogFragmentCompat;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingDistanceSpeed;
|
import de.dennisguse.opentracks.sensors.driver.CyclingDistanceSpeedBluetooth;
|
||||||
|
|
||||||
public class BluetoothLeCyclingSpeedPreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeCyclingSpeedPreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -29,6 +29,6 @@ public class BluetoothLeCyclingSpeedPreference extends BluetoothLeSensorPreferen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE));
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(CyclingDistanceSpeedBluetooth.CYCLING_SPEED_CADENCE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@ import android.util.AttributeSet;
|
|||||||
|
|
||||||
import androidx.preference.PreferenceDialogFragmentCompat;
|
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerHeartRate;
|
import de.dennisguse.opentracks.sensors.driver.HeartRateBluetooth;
|
||||||
|
|
||||||
public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -27,6 +27,6 @@ public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothHandlerHeartRate.HEART_RATE_SUPPORTING_DEVICES);
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), HeartRateBluetooth.HEART_RATE_SUPPORTING_DEVICES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -9,7 +9,7 @@ import androidx.preference.PreferenceDialogFragmentCompat;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerBarometricPressure;
|
import de.dennisguse.opentracks.sensors.driver.BarometerBluetooth;
|
||||||
|
|
||||||
public class BluetoothLePressurePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLePressurePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -36,6 +36,6 @@ public class BluetoothLePressurePreference extends BluetoothLeSensorPreference {
|
|||||||
boolean hasInternalSensor = pressureSensor != null;
|
boolean hasInternalSensor = pressureSensor != null;
|
||||||
|
|
||||||
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog
|
||||||
.newInstance(getKey(), List.of(BluetoothHandlerBarometricPressure.BAROMETRIC_PRESSURE), hasInternalSensor);
|
.newInstance(getKey(), List.of(BarometerBluetooth.BAROMETRIC_PRESSURE), hasInternalSensor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -7,7 +7,7 @@ import androidx.preference.PreferenceDialogFragmentCompat;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
|
import de.dennisguse.opentracks.sensors.driver.RunningSpeedAndCadenceBluetooth;
|
||||||
|
|
||||||
public class BluetoothLeRunningSpeedAndCadencePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeRunningSpeedAndCadencePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -29,6 +29,6 @@ public class BluetoothLeRunningSpeedAndCadencePreference extends BluetoothLeSens
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(BluetoothHandlerRunningSpeedAndCadence.RUNNING_SPEED_CADENCE));
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(RunningSpeedAndCadenceBluetooth.RUNNING_SPEED_CADENCE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -28,8 +28,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
||||||
import de.dennisguse.opentracks.sensors.SensorType;
|
|
||||||
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
import de.dennisguse.opentracks.sensors.ServiceMeasurementUUID;
|
||||||
|
import de.dennisguse.opentracks.sensors.driver.SensorType;
|
||||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||||
import de.dennisguse.opentracks.util.PermissionRequester;
|
import de.dennisguse.opentracks.util.PermissionRequester;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ import androidx.preference.PreferenceDialogFragmentCompat;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerTemperature;
|
import de.dennisguse.opentracks.sensors.driver.TemperatureBluetooth;
|
||||||
|
|
||||||
public class BluetoothLeTemperaturePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeTemperaturePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -30,6 +30,6 @@ public class BluetoothLeTemperaturePreference extends BluetoothLeSensorPreferenc
|
|||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreferenceDialog
|
return BluetoothLeSensorPreferenceDialog
|
||||||
.newInstance(getKey(), List.of(BluetoothHandlerTemperature.TEMPERATURE));
|
.newInstance(getKey(), List.of(TemperatureBluetooth.TEMPERATURE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user