diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-12-20 22:31:18 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-12-20 22:31:18 -0800 |
commit | fefa27140fcd7dca13a45f4186797420cb41604c (patch) | |
tree | edd8e6c7b68a3d7a8cd651d0789b2424b89ca1f1 /src/main/java | |
parent | ddd9a01c6e88e654f3fd377adcee36947e4e1e9d (diff) | |
download | trackermap-server-fefa27140fcd7dca13a45f4186797420cb41604c.tar.gz trackermap-server-fefa27140fcd7dca13a45f4186797420cb41604c.tar.bz2 trackermap-server-fefa27140fcd7dca13a45f4186797420cb41604c.zip |
Alternative location format
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java index 25a8f7090..167896386 100644 --- a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java @@ -55,9 +55,17 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder { if (topic.contains("gnss")) { position.setValid(true); - position.setTime(new Date(payload.getInt("time") * 1000L)); - position.setLatitude(payload.getJsonNumber("lat").doubleValue()); - position.setLongitude(payload.getJsonNumber("log").doubleValue()); + + if (payload.containsKey("time")) { + position.setTime(new Date(payload.getInt("time") * 1000L)); + position.setLatitude(payload.getJsonNumber("lat").doubleValue()); + position.setLongitude(payload.getJsonNumber("log").doubleValue()); + } else { + position.setTime(new Date(payload.getInt("gnss.ts") * 1000L)); + position.setLatitude(payload.getJsonNumber("gnss.latitude").doubleValue()); + position.setLongitude(payload.getJsonNumber("gnss.longitude").doubleValue()); + } + position.setAltitude(payload.getJsonNumber("gnss.altitude").doubleValue()); position.setSpeed(payload.getJsonNumber("gnss.speed").doubleValue()); position.setCourse(payload.getJsonNumber("gnss.heading").doubleValue()); @@ -81,6 +89,10 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_VIN, payload.getString("obd.vin")); } + } else if (topic.contains("cellular1")) { + + getLastLocation(position, new Date(payload.getInt("modem1.ts") * 1000L)); + } else { return null; |