aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-02-22 19:42:25 -0800
committerAnton Tananaev <anton@traccar.org>2022-02-22 19:42:33 -0800
commitde7a373eff79172f0848ca6fce968f99e45af41a (patch)
treedbfcbada74bbd4c6e7e96cd741de8222e9ac7547 /src
parent5363b99a75820661b5c5318bc633202be4c352d8 (diff)
downloadtrackermap-server-de7a373eff79172f0848ca6fce968f99e45af41a.tar.gz
trackermap-server-de7a373eff79172f0848ca6fce968f99e45af41a.tar.bz2
trackermap-server-de7a373eff79172f0848ca6fce968f99e45af41a.zip
Fix C2STek MT-20N decoding
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java8
-rw-r--r--src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java5
2 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java b/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java
index 83e62ff86..e735c67a1 100644
--- a/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/C2stekProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 - 2022 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.
@@ -50,7 +50,7 @@ public class C2stekProtocolDecoder extends BaseProtocolDecoder {
.number("(d+)#") // battery
.number("d+#") // geo area alarm
.number("(x+)#") // alarm
- .number("([01])") // armed
+ .number("([01])?") // armed
.number("([01])") // door
.number("([01])#") // ignition
.any()
@@ -111,7 +111,9 @@ public class C2stekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, parser.nextInt() * 0.001);
position.set(Position.KEY_ALARM, decodeAlarm(parser.nextHexInt()));
- position.set(Position.KEY_ARMED, parser.nextInt() > 0);
+ if (parser.hasNext()) {
+ position.set(Position.KEY_ARMED, parser.nextInt() > 0);
+ }
position.set(Position.KEY_DOOR, parser.nextInt() > 0);
position.set(Position.KEY_IGNITION, parser.nextInt() > 0);
diff --git a/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java
index d6831c1cf..6fb14b902 100644
--- a/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java
@@ -10,7 +10,10 @@ public class C2stekProtocolDecoderTest extends ProtocolTest {
var decoder = new C2stekProtocolDecoder(null);
- verifyNull(decoder, text(
+ verifyPosition(decoder, text(
+ "PA$867965024889327$D#220222#135059#0#+37.98995#+23.85141#0.00#69.2#0.0#0000#000#8#00#sz-w1001#B2600$AP"));
+
+ verifyPosition(decoder, text(
"PA$863083038046613$D#181123#162850#1#+37.92684#+23.75933#0.62#200.1#0.0#3768#000#9#00#sz-w1001#B0907839$AP"));
verifyPosition(decoder, text(