aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-01-18 01:06:42 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-01-18 10:07:52 +1300
commit500d7361f023c15bd06cbe2836c5af1d12285583 (patch)
treedebd4ecfce4794e57aa55f6df288fd7c82258e4e
parenta1320c0d021df77f0a73f6663eddd9e286273634 (diff)
downloadtraccar-server-500d7361f023c15bd06cbe2836c5af1d12285583.tar.gz
traccar-server-500d7361f023c15bd06cbe2836c5af1d12285583.tar.bz2
traccar-server-500d7361f023c15bd06cbe2836c5af1d12285583.zip
Add location to Galileo responses
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java18
-rw-r--r--test/org/traccar/protocol/GalileoProtocolDecoderTest.java3
2 files changed, 12 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index 2e997a270..494111e2c 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -253,7 +253,6 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
while (buf.readerIndex() < length) {
- // Check if new message started
int tag = buf.readUnsignedByte();
if (tags.contains(tag)) {
if (hasLocation && position.getFixTime() != null) {
@@ -261,7 +260,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
}
tags.clear();
hasLocation = false;
- position = new Position();
+ position = new Position(); // new position starts
}
tags.add(tag);
@@ -279,13 +278,6 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
}
- if (hasLocation && position.getFixTime() != null) {
- positions.add(position);
- } else if (position.getAttributes().containsKey(Position.KEY_RESULT)) {
- getLastLocation(position, null);
- positions.add(position);
- }
-
if (deviceSession == null) {
deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
@@ -293,6 +285,14 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
}
}
+ if (hasLocation && position.getFixTime() != null) {
+ positions.add(position);
+ } else if (position.getAttributes().containsKey(Position.KEY_RESULT)) {
+ position.setDeviceId(deviceSession.getDeviceId());
+ getLastLocation(position, null);
+ positions.add(position);
+ }
+
sendReply(channel, buf.readUnsignedShort());
for (Position p : positions) {
diff --git a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
index e2e9f0ca3..6f2f1f90a 100644
--- a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
@@ -13,6 +13,9 @@ public class GalileoProtocolDecoderTest extends ProtocolTest {
GalileoProtocolDecoder decoder = new GalileoProtocolDecoder(new GalileoProtocol());
verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
+ "01560003383636303530303338343337353836044701e000000000e13c494e414c4c3a696e303d31313230362c696e313d302c696e323d302c696e333d302c696e343d302c696e353d302c4163633d3536363932343732353bfdef"));
+
+ verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
"012a0003383633353931303233353137333732046600e000000000e1104f555428332e2e3029203d2031313130bb29"));
verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,