diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-12 11:29:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-09-12 11:29:01 -0700 |
commit | 50fb8ee8347481abec7aeb5431426ef12dfb0617 (patch) | |
tree | f3ee69a97de7c979ae2948e8a0defc6946a5fbaa /src/main/java/org/traccar | |
parent | dbcde8aee59ebaa488cf9730a0356817e282ee84 (diff) | |
download | trackermap-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')
-rw-r--r-- | src/main/java/org/traccar/protocol/Minifinder2ProtocolDecoder.java | 16 | ||||
-rw-r--r-- | src/main/java/org/traccar/protocol/RadarProtocolDecoder.java | 3 |
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()); |