aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java40
-rw-r--r--src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java3
2 files changed, 41 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
index 3ff8eb2fb..b1deded3b 100644
--- a/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -20,6 +20,7 @@ import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.helper.BitUtil;
import org.traccar.session.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
@@ -229,7 +230,11 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
int header = buf.readUnsignedByte();
if (header == 0x01) {
- return decodePositions(channel, remoteAddress, buf);
+ if (buf.getUnsignedMedium(buf.readerIndex() + 2) == 0x01001c) {
+ return decodeIridiumPosition(channel, remoteAddress, buf);
+ } else {
+ return decodePositions(channel, remoteAddress, buf);
+ }
} else if (header == 0x07) {
return decodePhoto(channel, remoteAddress, buf);
}
@@ -237,7 +242,38 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private Object decodePositions(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
+ private Position decodeIridiumPosition(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
+
+ buf.readUnsignedShortLE(); // length
+
+ buf.skipBytes(3); // identification header
+ buf.readUnsignedIntLE(); // index
+
+ DeviceSession deviceSession = getDeviceSession(
+ channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII));
+ if (deviceSession == null) {
+ return null;
+ }
+
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+
+ buf.readUnsignedByte(); // session status
+ buf.skipBytes(4); // reserved
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
+
+ buf.skipBytes(3); // coordinates header
+ int flags = buf.readUnsignedByte();
+ double latitude = buf.readUnsignedByte() + buf.readUnsignedShortLE() / 60000.0;
+ double longitude = buf.readUnsignedByte() + buf.readUnsignedShortLE() / 60000.0;
+ position.setLatitude(BitUtil.check(flags, 1) ? -latitude : latitude);
+ position.setLongitude(BitUtil.check(flags, 0) ? -longitude : longitude);
+ position.setAccuracy(buf.readUnsignedIntLE());
+
+ return position;
+ }
+
+ private List<Position> decodePositions(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
int endIndex = (buf.readUnsignedShortLE() & 0x7fff) + buf.readerIndex();
diff --git a/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java
index f9bdd6b42..f676b1cc1 100644
--- a/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class GalileoProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new GalileoProtocolDecoder(null));
+ verifyNotNull(decoder, binary(
+ "01006501001c05cf1f8133303032333430363939303130313000004a000062d8f3ee03000b000f85402088970000000602003503333030323334303639393031303130100000207af3d862300cbe08ee00acfaf001330000760634b301350840090a416b2f42920e"));
+
verifyPositions(decoder, binary(
"011801018202130338363833343530333230343234323604640010a406207caa9f5b300c830a7901ca0ec802330000000034b802350540003e41703f422b1043234504004600e09000000000a000a100a200a300a400a500a600a700a800a900aa00ab00ac00ad00ae00af00b00000b10000b20000b30000b40000b50000b60000b70000b80000b90000c000000000c100000000c200000000c300000000c400c500c600c700c800c900ca00cb00cc00cd00ce00cf00d000d100d200d4d3140000d60000d70000d80000d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000f400000000f500000000f600000000f700000000f800000000f9000000008960"));