aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-01-03 19:57:27 -0600
committerIván Ávalos <avalos@disroot.org>2023-01-03 19:57:27 -0600
commitc1f4af8cae325ee56fa2c57dc70c98ecffcd5a3a (patch)
tree4b8dd206a050d9284ac8be245edd5df195599c0f /shared/src/commonMain
parenta7b9e807d7f90b5c34d8c423806de90ceed0f065 (diff)
parent86b5601d7d9965bea7d57f04600b02f5432dc966 (diff)
downloadetbsa-trackermap-mobile-c1f4af8cae325ee56fa2c57dc70c98ecffcd5a3a.tar.gz
etbsa-trackermap-mobile-c1f4af8cae325ee56fa2c57dc70c98ecffcd5a3a.tar.bz2
etbsa-trackermap-mobile-c1f4af8cae325ee56fa2c57dc70c98ecffcd5a3a.zip
Merge branch 'main' of https://git.sr.ht/~avalos/trackermap-mobile
Diffstat (limited to 'shared/src/commonMain')
-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) {