From e94a83c5fdc8b48d5e8f3f537d8b6e3e15e26d51 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 16 Sep 2020 20:22:11 -0700 Subject: Ignore invalid data --- .../org/traccar/protocol/GlobalstarProtocolDecoder.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java index de23ea170..b742d0cac 100644 --- a/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java @@ -60,9 +60,9 @@ import java.util.List; public class GlobalstarProtocolDecoder extends BaseHttpProtocolDecoder { - private DocumentBuilder documentBuilder; - private XPath xPath; - private XPathExpression messageExpression; + private final DocumentBuilder documentBuilder; + private final XPath xPath; + private final XPathExpression messageExpression; public GlobalstarProtocolDecoder(Protocol protocol) { super(protocol); @@ -161,17 +161,20 @@ public class GlobalstarProtocolDecoder extends BaseHttpProtocolDecoder { position.setLongitude(position.getLongitude() - 360); } - position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); + int speed = buf.readUnsignedByte(); + position.setSpeed(UnitsConverter.knotsFromKph(speed)); position.set("batteryReplace", BitUtil.check(buf.readUnsignedByte(), 7)); - positions.add(position); + if (speed != 0xff) { + positions.add(position); + } } } sendResponse(channel, document.getFirstChild().getAttributes().getNamedItem("messageID").getNodeValue()); - return positions; + return !positions.isEmpty() ? positions : null; } } -- cgit v1.2.3