|
|
|
@@ -21,7 +21,7 @@ public class BluetoothUtilsTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void parseHeartRate_uint8() {
|
|
|
|
|
// given
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.HEARTRATE.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.HEARTRATE.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{0x02, 0x3C});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
@@ -34,7 +34,7 @@ public class BluetoothUtilsTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void parseHeartRate_uint16() {
|
|
|
|
|
// given
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.HEARTRATE.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.HEARTRATE.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{0x01, 0x01, 0x01});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
@@ -47,7 +47,7 @@ public class BluetoothUtilsTest {
|
|
|
|
|
@Test
|
|
|
|
|
public void parseEnvironmentalSensing_Pa() {
|
|
|
|
|
// given
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.BAROMETRIC_PRESSURE.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.BAROMETRIC_PRESSURE.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{(byte) 0xB2, (byte) 0x48, (byte) 0x0F, (byte) 0x00});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
@@ -59,7 +59,7 @@ public class BluetoothUtilsTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void parseCyclingSpeedCadence_crankOnly() {
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_SPEED_CADENCE.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{0x02, (byte) 0xC8, 0x00, 0x00, 0x00, 0x06, (byte) 0x99});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
@@ -72,7 +72,7 @@ public class BluetoothUtilsTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void parseCyclingSpeedCadence_wheelOnly() {
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_SPEED_CADENCE.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{0x01, (byte) 0xFF, (byte) 0xFF, 0, 1, 0x45, (byte) 0x99});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
@@ -85,7 +85,7 @@ public class BluetoothUtilsTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void parseCyclingSpeedCadence_crankWheel() {
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_SPEED_CADENCE.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.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});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
@@ -98,34 +98,34 @@ public class BluetoothUtilsTest {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void parseCyclingPower_power() {
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_POWER.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_POWER.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{0, 0, 40, 0});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
|
SensorDataCyclingPower.Data powerCadence = BluetoothUtils.parseCyclingPower("", "", characteristic);
|
|
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
assertEquals(40, powerCadence.getPower().getValue().getW(), 0.01);
|
|
|
|
|
assertEquals(40, powerCadence.power().getValue().getW(), 0.01);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void parseCyclingPower_power_with_cadence() {
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_POWER.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.CYCLING_POWER.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{0x2C, 0x00, 0x00, 0x00, (byte) 0x9F, 0x00, 0x0C, 0x00, (byte) 0xE5, 0x42});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
|
SensorDataCyclingPower.Data powerCadence = BluetoothUtils.parseCyclingPower("", "", characteristic);
|
|
|
|
|
|
|
|
|
|
// then
|
|
|
|
|
assertEquals(0, powerCadence.getPower().getValue().getW(), 0.01);
|
|
|
|
|
assertEquals(0, powerCadence.power().getValue().getW(), 0.01);
|
|
|
|
|
|
|
|
|
|
assertEquals(12, powerCadence.getCadence().getCrankRevolutionsCount());
|
|
|
|
|
assertEquals(17125, powerCadence.getCadence().getCrankRevolutionsTime());
|
|
|
|
|
assertEquals(12, powerCadence.cadence().getCrankRevolutionsCount());
|
|
|
|
|
assertEquals(17125, powerCadence.cadence().getCrankRevolutionsTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void parseRunningSpeedAndCadence_with_distance() {
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.RUNNING_SPEED_CADENCE.getServiceUUID(), 0, 0);
|
|
|
|
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothUtils.RUNNING_SPEED_CADENCE.serviceUUID(), 0, 0);
|
|
|
|
|
characteristic.setValue(new byte[]{2, 0, 5, 80, (byte) 0xFF, (byte) 0xFF, 0, 1});
|
|
|
|
|
|
|
|
|
|
// when
|
|
|
|
|