Parse runtime from HID tracker

This commit is contained in:
sctanf
2025-12-13 19:04:44 -06:00
parent 3982249ebf
commit 7f536528d0
4 changed files with 14 additions and 1 deletions

View File

@@ -310,6 +310,9 @@ public class DataFeedBuilder {
HardwareStatus.addRssi(fbb, (short) tracker.getSignalStrength().floatValue());
}
if (tracker.getBatteryRemainingRuntime() != null) {
HardwareStatus.addBatteryRuntimeEstimate(fbb, tracker.getBatteryRemainingRuntime());
}
int hardwareDataOffset = HardwareStatus.endHardwareStatus(fbb);
int hardwareInfoOffset = DataFeedBuilder.createHardwareInfo(fbb, device);

View File

@@ -112,6 +112,7 @@ class Tracker @JvmOverloads constructor(
val trackerFlexHandler: TrackerFlexHandler = TrackerFlexHandler(this)
var batteryVoltage: Float? = null
var batteryLevel: Float? = null
var batteryRemainingRuntime: Long? = null
var ping: Int? = null
var signalStrength: Int? = null
var temperature: Float? = null

View File

@@ -138,6 +138,7 @@ class HIDCommon {
}
// Packet data
var runtime: Long? = null
var batt: Int? = null
var batt_v: Int? = null
var temp: Int? = null
@@ -221,6 +222,11 @@ class HIDCommon {
}
}
5 -> { // runtime
// ulong as little endian
runtime = (dataReceived[i + 9].toUByte().toLong() shl 56) or (dataReceived[i + 8].toUByte().toLong() shl 48) or (dataReceived[i + 7].toUByte().toLong() shl 40) or (dataReceived[i + 6].toUByte().toLong() shl 32) or (dataReceived[i + 5].toUByte().toLong() shl 24) or (dataReceived[i + 4].toUByte().toLong() shl 16) or (dataReceived[i + 3].toUByte().toLong() shl 8) or dataReceived[i + 2].toUByte().toLong()
}
6 -> { // data
button = dataReceived[i + 2].toUByte().toInt()
rssi = dataReceived[i + 15].toUByte().toInt()
@@ -248,6 +254,9 @@ class HIDCommon {
}
// Assign data
if (runtime != null) {
tracker.batteryRemainingRuntime = runtime
}
if (batt != null) {
tracker.batteryLevel = if (batt == 128) 1f else (batt and 127).toFloat()
}