mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
add EnvironmentMetrics to NodeInfo
This commit is contained in:
parent
75af1ed197
commit
d2140b13cb
2 changed files with 40 additions and 4 deletions
|
|
@ -107,6 +107,37 @@ data class DeviceMetrics(
|
|||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@Parcelize
|
||||
data class EnvironmentMetrics(
|
||||
val time: Int = currentTime(), // default to current time in secs (NOT MILLISECONDS!)
|
||||
val temperature: Float,
|
||||
val relativeHumidity: Float,
|
||||
val barometricPressure: Float,
|
||||
val gasResistance: Float,
|
||||
val voltage: Float,
|
||||
val current: Float,
|
||||
) : Parcelable {
|
||||
companion object {
|
||||
fun currentTime() = (System.currentTimeMillis() / 1000).toInt()
|
||||
}
|
||||
|
||||
/** Create our model object from a protobuf.
|
||||
*/
|
||||
constructor(t: TelemetryProtos.EnvironmentMetrics, telemetryTime: Int = currentTime()) : this(
|
||||
telemetryTime,
|
||||
t.temperature,
|
||||
t.relativeHumidity,
|
||||
t.barometricPressure,
|
||||
t.gasResistance,
|
||||
t.voltage,
|
||||
t.current
|
||||
)
|
||||
|
||||
override fun toString(): String {
|
||||
return "EnvironmentMetrics(time=${time}, temperature=${temperature}, humidity=${relativeHumidity}, pressure=${barometricPressure}), resistance=${gasResistance}, voltage=${voltage}, current=${current}"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@Parcelize
|
||||
|
|
@ -117,7 +148,8 @@ data class NodeInfo(
|
|||
var snr: Float = Float.MAX_VALUE,
|
||||
var rssi: Int = Int.MAX_VALUE,
|
||||
var lastHeard: Int = 0, // the last time we've seen this node in secs since 1970
|
||||
var deviceMetrics: DeviceMetrics? = null
|
||||
var deviceMetrics: DeviceMetrics? = null,
|
||||
var environmentMetrics: EnvironmentMetrics? = null,
|
||||
) : Parcelable {
|
||||
|
||||
val batteryLevel get() = deviceMetrics?.batteryLevel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue