Bugfix: running sensor data total is distance is UINT_32.

This commit is contained in:
Dennis Guse
2021-11-11 20:20:43 +01:00
parent b1032f898a
commit c3d55127fe
2 changed files with 5 additions and 5 deletions
@@ -93,8 +93,8 @@ public class BluetoothUtilsTest {
@Test @Test
public void parseRunningSpeedAndCadence_with_distance() { public void parseRunningSpeedAndCadence_with_distance() {
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_SPEED_CADENCE_MEASUREMENT_CHAR_UUID, 0, 0); BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.RUNNING_RUNNING_SPEED_CADENCE_CHAR_UUID, 0, 0);
characteristic.setValue(new byte[]{2, 0, 5, 80, 12, 1}); characteristic.setValue(new byte[]{2, 0, 5, 80, (byte) 0xFF, (byte) 0xFF, 0, 1});
// when // when
SensorDataRunning sensor = BluetoothUtils.parseRunningSpeedAndCadence("address", "sensorName", characteristic); SensorDataRunning sensor = BluetoothUtils.parseRunningSpeedAndCadence("address", "sensorName", characteristic);
@@ -102,6 +102,6 @@ public class BluetoothUtilsTest {
// then // then
assertEquals(Speed.of(5), sensor.getSpeed()); assertEquals(Speed.of(5), sensor.getSpeed());
assertEquals(80, sensor.getCadence(), 0.01); assertEquals(80, sensor.getCadence(), 0.01);
assertEquals(Distance.of(26.8), sensor.getTotalDistance()); assertEquals(Distance.of(6553.5 + 1677721.6), sensor.getTotalDistance());
} }
} }
@@ -175,8 +175,8 @@ public class BluetoothUtils {
index += 2; index += 2;
} }
if (hasTotalDistance && valueLength - index >= 2) { if (hasTotalDistance && valueLength - index >= 4) {
totalDistance = Distance.ofDM(characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, index)); totalDistance = Distance.ofDM(characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, index));
} }
return new SensorDataRunning(address, sensorName, speed, cadence, totalDistance); return new SensorDataRunning(address, sensorName, speed, cadence, totalDistance);