From 2232e5fcba4bac4874aa656836152529efb79e40 Mon Sep 17 00:00:00 2001 From: Patrick Saxton Date: Wed, 20 May 2020 11:26:18 -0500 Subject: [PATCH] fix cadence sensor issue --- .../serializers/CyclingSpeedCadenceSerializer.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kotlinsensors/src/main/java/com/lexicalninja/kotlinsensors/serializers/CyclingSpeedCadenceSerializer.kt b/kotlinsensors/src/main/java/com/lexicalninja/kotlinsensors/serializers/CyclingSpeedCadenceSerializer.kt index 34eeec7..aa8ac69 100644 --- a/kotlinsensors/src/main/java/com/lexicalninja/kotlinsensors/serializers/CyclingSpeedCadenceSerializer.kt +++ b/kotlinsensors/src/main/java/com/lexicalninja/kotlinsensors/serializers/CyclingSpeedCadenceSerializer.kt @@ -48,8 +48,8 @@ class CyclingSpeedCadenceSerializer { fun readMeasurement(bytes: ByteArray): MeasurementData { val measurement = MeasurementData() var index = 0 - val rawFlags = bytes[index++] - if ((rawFlags.toInt() and MeasurementFlags.wheelRevolutionDataPresent) == MeasurementFlags.wheelRevolutionDataPresent) { + val rawFlags = FlagStruct(bytes[index++].toInt()) + if (rawFlags.contains(MeasurementFlags.wheelRevolutionDataPresent)) { measurement.cumulativeWheelRevolutions = (bytes[index++].toInt() and 0xFF) or ((bytes[index++].toInt() and 0xFF) shl 8) or @@ -58,7 +58,7 @@ class CyclingSpeedCadenceSerializer { measurement.lastWheelEventTime = ((bytes[index++].toInt() and 0xff) or ((bytes[index++].toInt() and 0xff) shl 8)).toShort() } - if ((rawFlags.toInt() and MeasurementFlags.crankRevolutionDataPresent) == MeasurementFlags.crankRevolutionDataPresent) { + if (rawFlags.contains(MeasurementFlags.crankRevolutionDataPresent)) { measurement.cumulativeCrankRevolutions = (bytes[index++].toInt() and 0xFF) or ((bytes[index++].toInt() and 0xFF) shl 8) measurement.lastCrankEventTime = (bytes[index++].toInt() and 0xFF) or