aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt21
1 files changed, 10 insertions, 11 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt
index 1e23396..6afa350 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt
@@ -17,6 +17,7 @@
*/
package mx.trackermap.TrackerMap.client.models
+import kotlinx.serialization.json.boolean
import kotlinx.serialization.json.longOrNull
data class UnitInformation(
@@ -31,17 +32,15 @@ data class UnitInformation(
ON, OFF, UNKNOWN
}
- /**
- * Status is calculated from speed, because status based on
- * the actual connection to the server is useless for our clients.
- */
- fun getStatus() = position?.speed?.let {
- if (it >= 2) {
- Status.ONLINE
- } else {
- Status.OFFLINE
- }
- } ?: Status.UNKNOWN
+ fun getStatus() = when (device.status) {
+ "online" -> Status.ONLINE
+ "offline" -> Status.OFFLINE
+ else -> Status.UNKNOWN
+ }
+
+ fun getIgnition() = if (position?.attributes?.containsKey("ignition") == true) {
+ position.attributes["ignition"]?.boolean ?: false
+ } else false
/* Many GPS devices reserve pin 1 for engine stop */
fun getEngineStop() = if (position?.attributes?.containsKey("out1") == true) {