aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java16
1 files changed, 12 insertions, 4 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;
}