aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-16 20:22:11 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-16 20:22:11 -0700
commite94a83c5fdc8b48d5e8f3f537d8b6e3e15e26d51 (patch)
tree975aae0a5025162879c7079676bac396f07ff364 /src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java
parenta498a5584dc21d8ee3c1bdfe56dd158b789d463e (diff)
downloadtraccar-server-e94a83c5fdc8b48d5e8f3f537d8b6e3e15e26d51.tar.gz
traccar-server-e94a83c5fdc8b48d5e8f3f537d8b6e3e15e26d51.tar.bz2
traccar-server-e94a83c5fdc8b48d5e8f3f537d8b6e3e15e26d51.zip
Ignore invalid data
Diffstat (limited to 'src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/GlobalstarProtocolDecoder.java15
1 files changed, 9 insertions, 6 deletions
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;
}
}