aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-12 11:29:01 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-12 11:29:01 -0700
commit50fb8ee8347481abec7aeb5431426ef12dfb0617 (patch)
treef3ee69a97de7c979ae2948e8a0defc6946a5fbaa /src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java
parentdbcde8aee59ebaa488cf9730a0356817e282ee84 (diff)
downloadtrackermap-server-50fb8ee8347481abec7aeb5431426ef12dfb0617.tar.gz
trackermap-server-50fb8ee8347481abec7aeb5431426ef12dfb0617.tar.bz2
trackermap-server-50fb8ee8347481abec7aeb5431426ef12dfb0617.zip
Test for device id
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;
}