aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-11-06 06:38:30 -0800
committerAnton Tananaev <anton@traccar.org>2023-11-06 06:38:30 -0800
commit1b7802c639f8d40db141429f2c15b96e3b743a04 (patch)
treeb954fa7ce02aefdded9efb939d1934d6cbc0eb2d
parent3860e965c9feede1ac876261a47370b44181b5d7 (diff)
downloadtrackermap-server-1b7802c639f8d40db141429f2c15b96e3b743a04.tar.gz
trackermap-server-1b7802c639f8d40db141429f2c15b96e3b743a04.tar.bz2
trackermap-server-1b7802c639f8d40db141429f2c15b96e3b743a04.zip
Fix device id decoding
-rw-r--r--src/main/java/org/traccar/protocol/PositrexProtocolDecoder.java3
-rw-r--r--src/test/java/org/traccar/protocol/PositrexProtocolDecoderTest.java4
2 files changed, 2 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/PositrexProtocolDecoder.java b/src/main/java/org/traccar/protocol/PositrexProtocolDecoder.java
index 8726bc831..ff4825e8d 100644
--- a/src/main/java/org/traccar/protocol/PositrexProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PositrexProtocolDecoder.java
@@ -59,12 +59,11 @@ public class PositrexProtocolDecoder extends BaseProtocolDecoder {
ByteBuf buf = (ByteBuf) msg;
int first = buf.getUnsignedByte(buf.readerIndex());
- int second = buf.getUnsignedByte(buf.readerIndex() + 1);
long deviceId;
if (BitUtil.check(first, 7)) {
if (BitUtil.check(first, 6)) {
deviceId = 73000000 + BitUtil.to(buf.readUnsignedInt(), 30);
- } else if (second == 0) {
+ } else if (!BitUtil.check(first, 5) && !BitUtil.check(first, 4)) {
deviceId = 7590000 + BitUtil.to(buf.readUnsignedMedium(), 20);
} else {
deviceId = 70000000 + BitUtil.to(buf.readUnsignedMedium(), 20);
diff --git a/src/test/java/org/traccar/protocol/PositrexProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PositrexProtocolDecoderTest.java
index ff9d3ee1b..bf4f9c765 100644
--- a/src/test/java/org/traccar/protocol/PositrexProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/PositrexProtocolDecoderTest.java
@@ -1,19 +1,17 @@
package org.traccar.protocol;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.traccar.ProtocolTest;
public class PositrexProtocolDecoderTest extends ProtocolTest {
- @Disabled
@Test
public void testDecode() throws Exception {
var decoder = inject(new PositrexProtocolDecoder(null));
verifyPosition(decoder, binary(
- "TODO"));
+ "8280902e002b81c99fd607033905008b1c000003ae00003c9c000054ee00000079000000000d34d43f0fffffffda0000000000104fb80000204086464717807f8931082622128190980fffff862261047296590fffff"));
}