aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorLeo Sadovsky <lsadovski@oboz.com>2023-01-26 20:34:30 +0300
committerLeo Sadovsky <lsadovski@oboz.com>2023-01-26 20:34:30 +0300
commit2c4a87d08fd84be44f85ab58ae852b8128a48f8f (patch)
tree77be3092219bc3b3f42ace83bdbc3454bceea4d2 /src/main/java/org/traccar
parent1d0d5661ca921a08217f23d4889f530643327847 (diff)
parentc8425728d23805c7c653624354e9b46011c8b315 (diff)
downloadtrackermap-server-2c4a87d08fd84be44f85ab58ae852b8128a48f8f.tar.gz
trackermap-server-2c4a87d08fd84be44f85ab58ae852b8128a48f8f.tar.bz2
trackermap-server-2c4a87d08fd84be44f85ab58ae852b8128a48f8f.zip
Merge branch 'master' of github.com:Snowbridge/traccar
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
index d4bd45c4f..44baa94ea 100644
--- a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2023 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.
@@ -22,9 +22,11 @@ import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BitBuffer;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
+import org.traccar.helper.model.AttributeUtil;
import org.traccar.model.Position;
import org.traccar.session.DeviceSession;
@@ -47,6 +49,17 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
}
private ByteBuf photo;
+ private boolean compressed;
+
+ public void setCompressed(boolean compressed) {
+ this.compressed = compressed;
+ }
+
+ public boolean getCompressed(long deviceId) {
+ Boolean value = AttributeUtil.lookup(
+ getCacheManager(), Keys.PROTOCOL_EXTENDED.withPrefix(getProtocolName()), deviceId);
+ return value != null ? value : compressed;
+ }
private static final Map<Integer, Integer> TAG_LENGTH_MAP = new HashMap<>();
@@ -299,8 +312,34 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedInt(); // accuracy
buf.readUnsignedByte(); // data tag header
- // ByteBuf data = buf.readSlice(buf.readUnsignedShort());
- // decodeMinimalDataSet(position, data);
+ ByteBuf data = buf.readSlice(buf.readUnsignedShort());
+ if (getCompressed(deviceSession.getDeviceId())) {
+
+ decodeMinimalDataSet(position, data);
+
+ int[] tags = new int[BitUtil.to(data.readUnsignedByte(), 8)];
+ for (int i = 0; i < tags.length; i++) {
+ tags[i] = data.readUnsignedByte();
+ }
+
+ for (int tag : tags) {
+ decodeTag(position, data, tag);
+ }
+
+ } else {
+
+ while (data.isReadable()) {
+ int tag = data.readUnsignedByte();
+ if (tag == 0x30) {
+ position.setValid((data.readUnsignedByte() & 0xf0) == 0x00);
+ position.setLatitude(data.readIntLE() / 1000000.0);
+ position.setLongitude(data.readIntLE() / 1000000.0);
+ } else {
+ decodeTag(position, data, tag);
+ }
+ }
+
+ }
return position;
}