diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java b/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java index 7405fb6ef..0a0d04db0 100644 --- a/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2020 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,6 +64,7 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder { } Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + position.setValid(true); decodePosition(message, position); positions.add(position); } @@ -125,8 +126,11 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder { return true; case "din": case "dout": - position.set(name.equals("din") ? Position.KEY_INPUT : Position.KEY_OUTPUT, - ((JsonNumber) value).intValue()); + if (name.equals("din")) { + position.set(Position.KEY_INPUT, ((JsonNumber) value).intValue()); + } else { + position.set(Position.KEY_OUTPUT, ((JsonNumber) value).intValue()); + } return true; case "gps.vehicle.mileage": position.set(Position.KEY_ODOMETER, ((JsonNumber) value).doubleValue()); @@ -146,7 +150,7 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder { position.set(Position.KEY_RPM, ((JsonNumber) value).doubleValue()); return true; case "can.engine.temperature": - position.set(Position.PREFIX_TEMP + (index > 0 ? index : 0), ((JsonNumber) value).doubleValue()); + position.set(Position.PREFIX_TEMP + Math.max(index, 0), ((JsonNumber) value).doubleValue()); return true; case "engine.ignition.status": position.set(Position.KEY_IGNITION, value == JsonValue.TRUE); |