[O] Make measurement for battery

This commit is contained in:
Azalea Gui
2023-01-23 22:17:18 -05:00
parent 41d9402516
commit 5c8e526930
2 changed files with 7 additions and 9 deletions
@@ -1,15 +1,16 @@
package org.hydev.wearsync.bles.decoders
import com.influxdb.annotations.Measurement
import com.welie.blessed.asUInt8
import java.util.*
class BatteryDecoder : IDecoder<UInt>
@Measurement(name = "wear-battery")
data class BatteryMeasurement(val percent: UInt)
class BatteryDecoder : IDecoder<BatteryMeasurement>
{
override val sid = UUID.fromString("0000180F-0000-1000-8000-00805f9b34fb")
override val cid = UUID.fromString("00002A19-0000-1000-8000-00805f9b34fb")
override fun decode(value: ByteArray): UInt
{
return value.asUInt8()!!
}
override fun decode(value: ByteArray) = BatteryMeasurement(value.asUInt8()!!)
}
@@ -8,8 +8,5 @@ class ModelDecoder : IDecoder<String>
override val sid = UUID.fromString("0000180A-0000-1000-8000-00805f9b34fb")
override val cid = UUID.fromString("00002A24-0000-1000-8000-00805f9b34fb")
override fun decode(value: ByteArray): String
{
return value.asString()
}
override fun decode(value: ByteArray) = value.asString()
}