aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-02-08 06:59:14 -0800
committerAnton Tananaev <anton@traccar.org>2024-02-08 06:59:14 -0800
commit3f55f474fde34c8110b48cb1ac472671ca5f80fc (patch)
tree6a8761c2ef1b7dc7504fe7d14d9f377e26988ed9 /src/main/java
parent9ca9c0c146125eaa9a6a3e875e5dd596b6fa228b (diff)
downloadtrackermap-server-3f55f474fde34c8110b48cb1ac472671ca5f80fc.tar.gz
trackermap-server-3f55f474fde34c8110b48cb1ac472671ca5f80fc.tar.bz2
trackermap-server-3f55f474fde34c8110b48cb1ac472671ca5f80fc.zip
Handle last FleetGuide position
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/protocol/FleetGuideProtocolDecoder.java34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/main/java/org/traccar/protocol/FleetGuideProtocolDecoder.java b/src/main/java/org/traccar/protocol/FleetGuideProtocolDecoder.java
index ba4d9cfae..b4593d843 100644
--- a/src/main/java/org/traccar/protocol/FleetGuideProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/FleetGuideProtocolDecoder.java
@@ -82,13 +82,15 @@ public class FleetGuideProtocolDecoder extends BaseProtocolDecoder {
index = null;
}
- Integer responseType;
- if (type == MSG_SYNC_REQ) {
- responseType = MSG_SYNC_ACK;
- } else {
- responseType = null;
+ if (type != MSG_DATA_N_ACK && type != MSG_REP_N_ACK) {
+ Integer responseType;
+ if (type == MSG_SYNC_REQ) {
+ responseType = MSG_SYNC_ACK;
+ } else {
+ responseType = null;
+ }
+ sendResponse(channel, remoteAddress, deviceId, responseType, index);
}
- sendResponse(channel, remoteAddress, deviceId, responseType, index);
if (BitUtil.check(options, 13)) {
buf.readUnsignedShortLE(); // acknowledgement
@@ -116,7 +118,7 @@ public class FleetGuideProtocolDecoder extends BaseProtocolDecoder {
int recordEndIndex = data.readerIndex() + recordLength;
if (recordTypes.contains(recordType)) {
- positions.add(processPosition(position));
+ processPosition(positions, position);
position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
recordTypes.clear();
@@ -159,19 +161,23 @@ public class FleetGuideProtocolDecoder extends BaseProtocolDecoder {
}
+ processPosition(positions, position);
+
data.release();
return positions.isEmpty() ? null : positions;
}
- private Position processPosition(Position position) {
- if (position.getFixTime() == null) {
- position.setTime(new Date());
- }
- if (!position.getAttributes().containsKey(Position.KEY_SATELLITES)) {
- getLastLocation(position, null);
+ private void processPosition(List<Position> positions, Position position) {
+ if (!position.getAttributes().isEmpty()) {
+ if (position.getFixTime() == null) {
+ position.setTime(new Date());
+ }
+ if (!position.getAttributes().containsKey(Position.KEY_SATELLITES)) {
+ getLastLocation(position, null);
+ }
+ positions.add(position);
}
- return position;
}