Skip to content

Commit

Permalink
fix cadence sensor issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lexicalninja committed May 20, 2020
1 parent 8604ce5 commit 2232e5f
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2232e5f

Please sign in to comment.