aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java16
-rw-r--r--src/main/java/org/traccar/protocol/RadarProtocolDecoder.java3
2 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java
index 7475ba4d9..5b04992ec 100644
--- a/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java
@@ -109,6 +109,8 @@ public class Minifinder2ProtocolDecoder extends BaseProtocolDecoder {
boolean hasLocation = false;
Position position = new Position(getProtocolName());
+ DeviceSession deviceSession = null;
+
while (buf.isReadable()) {
int endIndex = buf.readUnsignedByte() + buf.readerIndex();
int key = buf.readUnsignedByte();
@@ -126,11 +128,9 @@ public class Minifinder2ProtocolDecoder extends BaseProtocolDecoder {
switch (key) {
case 0x01:
- DeviceSession deviceSession = getDeviceSession(
+ deviceSession = getDeviceSession(
channel, remoteAddress, buf.readCharSequence(15, StandardCharsets.US_ASCII).toString());
- if (deviceSession == null) {
- return null;
- }
+
position.setDeviceId(deviceSession.getDeviceId());
break;
case 0x02:
@@ -211,6 +211,14 @@ public class Minifinder2ProtocolDecoder extends BaseProtocolDecoder {
}
positions.add(position);
+ if (deviceSession != null) {
+ for (Position p : positions) {
+ p.setDeviceId(deviceSession.getDeviceId());
+ }
+ } else {
+ return null;
+ }
+
return positions;
}
diff --git a/src/main/java/org/traccar/protocol/RadarProtocolDecoder.java b/src/main/java/org/traccar/protocol/RadarProtocolDecoder.java
index b56a081c7..d87f77b84 100644
--- a/src/main/java/org/traccar/protocol/RadarProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/RadarProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 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.
@@ -70,6 +70,7 @@ public class RadarProtocolDecoder extends BaseProtocolDecoder {
for (int index = 0; index < count; index++) {
Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
position.set(Position.KEY_EVENT, buf.readUnsignedShort());