diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-12-10 19:23:38 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-12-10 19:23:38 -0800 |
commit | f020e0472d4544c7f968d8fb2504ad8e85174a49 (patch) | |
tree | 13686eb0b305e547b29554eb36e563b88b9e3f08 /src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java | |
parent | 21eab8d6d4ce37c1d6bf20e9dbb897fabf9a0eea (diff) | |
download | trackermap-server-f020e0472d4544c7f968d8fb2504ad8e85174a49.tar.gz trackermap-server-f020e0472d4544c7f968d8fb2504ad8e85174a49.tar.bz2 trackermap-server-f020e0472d4544c7f968d8fb2504ad8e85174a49.zip |
Handle missing attributes
Diffstat (limited to 'src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java index d2b3c6960..25a8f7090 100644 --- a/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FlexApiProtocolDecoder.java @@ -68,10 +68,18 @@ public class FlexApiProtocolDecoder extends BaseProtocolDecoder { getLastLocation(position, new Date(payload.getInt("obd.ts") * 1000L)); - position.set(Position.KEY_OBD_SPEED, payload.getJsonNumber("obd.speed").doubleValue()); - position.set(Position.KEY_OBD_ODOMETER, payload.getInt("obd.odo")); - position.set(Position.KEY_RPM, payload.getInt("obd.rpm")); - position.set(Position.KEY_VIN, payload.getString("obd.vin")); + if (payload.containsKey("obd.speed")) { + position.set(Position.KEY_OBD_SPEED, payload.getJsonNumber("obd.speed").doubleValue()); + } + if (payload.containsKey("obd.odo")) { + position.set(Position.KEY_OBD_ODOMETER, payload.getInt("obd.odo")); + } + if (payload.containsKey("obd.rpm")) { + position.set(Position.KEY_RPM, payload.getInt("obd.rpm")); + } + if (payload.containsKey("obd.vin")) { + position.set(Position.KEY_VIN, payload.getString("obd.vin")); + } } else { |