aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-06-15 05:35:09 -0700
committerAnton Tananaev <anton@traccar.org>2023-06-15 05:35:09 -0700
commit03650fff8064b60ffcda75f9033fd44e66ef34b3 (patch)
tree456904d265c41369506b980d8fc92fd91b26465a
parent94fbc93f8b0a75fe17e529355c4e7758b81b4776 (diff)
downloadtrackermap-server-03650fff8064b60ffcda75f9033fd44e66ef34b3.tar.gz
trackermap-server-03650fff8064b60ffcda75f9033fd44e66ef34b3.tar.bz2
trackermap-server-03650fff8064b60ffcda75f9033fd44e66ef34b3.zip
Galileo Iridium frame decoding
-rw-r--r--src/main/java/org/traccar/protocol/GalileoFrameDecoder.java16
-rw-r--r--src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java4
2 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/GalileoFrameDecoder.java b/src/main/java/org/traccar/protocol/GalileoFrameDecoder.java
index c23d26c83..d90e48287 100644
--- a/src/main/java/org/traccar/protocol/GalileoFrameDecoder.java
+++ b/src/main/java/org/traccar/protocol/GalileoFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2018 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,7 +22,7 @@ import org.traccar.BaseFrameDecoder;
public class GalileoFrameDecoder extends BaseFrameDecoder {
- private static final int MESSAGE_MINIMUM_LENGTH = 5;
+ private static final int MESSAGE_MINIMUM_LENGTH = 6;
@Override
protected Object decode(
@@ -32,9 +32,15 @@ public class GalileoFrameDecoder extends BaseFrameDecoder {
return null;
}
- int length = buf.getUnsignedShortLE(buf.readerIndex() + 1) & 0x7fff;
- if (buf.readableBytes() >= (length + MESSAGE_MINIMUM_LENGTH)) {
- return buf.readRetainedSlice(length + MESSAGE_MINIMUM_LENGTH);
+ int length;
+ if (buf.getByte(buf.readerIndex()) == 0x01 && buf.getUnsignedMedium(buf.readerIndex() + 3) == 0x01001c) {
+ length = 3 + buf.getUnsignedShort(buf.readerIndex() + 1);
+ } else {
+ length = 5 + (buf.getUnsignedShortLE(buf.readerIndex() + 1) & 0x7fff);
+ }
+
+ if (buf.readableBytes() >= length) {
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java b/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java
index 256517460..530f0930e 100644
--- a/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java
@@ -13,6 +13,10 @@ public class GalileoFrameDecoderTest extends ProtocolTest {
var decoder = inject(new GalileoFrameDecoder());
assertEquals(
+ binary("01003f01001c475b166133303035333430363431383437393000001d000064897bb003000b0221c20512a60a0000000802000f209d7b8964300f2536fbfd103c1d01"),
+ decoder.decode(null, null, binary("01003f01001c475b166133303035333430363431383437393000001d000064897bb003000b0221c20512a60a0000000802000f209d7b8964300f2536fbfd103c1d01")));
+
+ assertEquals(
binary("011780011102e603383633353931303238393630323437043200801c"),
decoder.decode(null, null, binary("011780011102e603383633353931303238393630323437043200801c")));