Sensor: adding Running Speed and Cadence.

Fixes #891.
This commit is contained in:
Dennis Guse
2021-07-21 22:26:57 +02:00
parent eba7a7fd89
commit 242147e491
16 changed files with 295 additions and 17 deletions
@@ -4,7 +4,10 @@ import android.bluetooth.BluetoothGattCharacteristic;
import org.junit.Test;
import de.dennisguse.opentracks.content.data.Distance;
import de.dennisguse.opentracks.content.data.Speed;
import de.dennisguse.opentracks.content.sensor.SensorDataCycling;
import de.dennisguse.opentracks.content.sensor.SensorDataRunning;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -87,4 +90,18 @@ public class BluetoothUtilsTest {
// then
assertEquals(40, power_w);
}
@Test
public void parseRunningSpeedAndCadence_with_distance() {
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_SPEED_CADENCE_MEASUREMENT_CHAR_UUID, 0, 0);
characteristic.setValue(new byte[]{2, 0, 5, 80, 12, 1});
// when
SensorDataRunning sensor = BluetoothUtils.parseRunningSpeedAndCadence("address", "sensorName", characteristic);
// then
assertEquals(Speed.of(5), sensor.getSpeed());
assertEquals(80, sensor.getCadence(), 0.01);
assertEquals(Distance.of(268), sensor.getTotalDistance());
}
}