diff options
author | Anton Tananaev <anton@traccar.org> | 2023-01-26 07:55:48 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-01-26 07:55:48 -0800 |
commit | d0874767e27a021ee898201f8f5e27192e0da64b (patch) | |
tree | 1c6ca14add96c14b46796e8dcd7adf53d960ae92 | |
parent | 5d572a11870b16668d2803481a2a687d3625abe0 (diff) | |
download | trackermap-server-d0874767e27a021ee898201f8f5e27192e0da64b.tar.gz trackermap-server-d0874767e27a021ee898201f8f5e27192e0da64b.tar.bz2 trackermap-server-d0874767e27a021ee898201f8f5e27192e0da64b.zip |
Iridium without compression
-rw-r--r-- | src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java | 45 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java | 23 |
2 files changed, 59 insertions, 9 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; } diff --git a/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java index df7f37903..7addc8e75 100644 --- a/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java @@ -10,12 +10,6 @@ public class GalileoProtocolDecoderTest extends ProtocolTest { var decoder = inject(new GalileoProtocolDecoder(null)); - verifyPosition(decoder, binary( - "01004e01001c0747ea59333030323334303639363034353930000012000063c85e6903000b0321a8f846aba50000000202001e205f5ec863300c4643fdfdbbe6c8fb330000000034e7013505d400000000")); - - verifyNotNull(decoder, binary( - "01006501001c05cf1f8133303032333430363939303130313000004a000062d8f3ee03000b000f85402088970000000602003503333030323334303639393031303130100000207af3d862300cbe08ee00acfaf001330000760634b301350840090a416b2f42920e")); - verifyPositions(decoder, binary( "011801018202130338363833343530333230343234323604640010a406207caa9f5b300c830a7901ca0ec802330000000034b802350540003e41703f422b1043234504004600e09000000000a000a100a200a300a400a500a600a700a800a900aa00ab00ac00ad00ae00af00b00000b10000b20000b30000b40000b50000b60000b70000b80000b90000c000000000c100000000c200000000c300000000c400c500c600c700c800c900ca00cb00cc00cd00ce00cf00d000d100d200d4d3140000d60000d70000d80000d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000f400000000f500000000f600000000f700000000f800000000f9000000008960")); @@ -51,4 +45,21 @@ public class GalileoProtocolDecoderTest extends ProtocolTest { } + @Test + public void testDecodeIridium() throws Exception { + + var decoder = inject(new GalileoProtocolDecoder(null)); + + decoder.setCompressed(false); + + verifyPosition(decoder, binary( + "01004e01001c0747ea59333030323334303639363034353930000012000063c85e6903000b0321a8f846aba50000000202001e205f5ec863300c4643fdfdbbe6c8fb330000000034e7013505d400000000")); + + /*decoder.setCompressed(true); + + verifyPosition(decoder, binary( + "01003a01001c07553e40333030323334303639363034353930020021000063d1921c03000b0321ac2c4545b20000009f02000ac200000000db00000000"));*/ + + } + } |