aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/helper/PatternUtil.java26
-rw-r--r--src/org/traccar/protocol/ArknavX8ProtocolDecoder.java3
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java10
-rw-r--r--test/org/traccar/helper/PatternUtilTest.java2
-rw-r--r--test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/GoSafeProtocolDecoderTest.java9
6 files changed, 34 insertions, 22 deletions
diff --git a/src/org/traccar/helper/PatternUtil.java b/src/org/traccar/helper/PatternUtil.java
index 88c3f053b..f665eb30d 100644
--- a/src/org/traccar/helper/PatternUtil.java
+++ b/src/org/traccar/helper/PatternUtil.java
@@ -25,20 +25,13 @@ public final class PatternUtil {
}
public static class MatchResult {
- private String pattern;
- private String matched;
- private String remaining;
+ private String patternMatch;
+ private String patternTail;
+ private String stringMatch;
+ private String stringTail;
- public String getPattern() {
- return this.pattern;
- }
-
- public String getMatched() {
- return this.matched;
- }
-
- public String getRemaining() {
- return this.remaining;
+ public String getPatternMatch() {
+ return patternMatch;
}
}
@@ -50,9 +43,10 @@ public final class PatternUtil {
try {
Matcher matcher = Pattern.compile("(" + pattern.substring(0, i) + ").*").matcher(input);
if (matcher.matches()) {
- result.pattern = pattern.substring(0, i);
- result.matched = matcher.group(1);
- result.remaining = input.substring(matcher.group(1).length());
+ result.patternMatch = pattern.substring(0, i);
+ result.patternTail = pattern.substring(i);
+ result.stringMatch = matcher.group(1);
+ result.stringTail = input.substring(matcher.group(1).length());
}
} catch (PatternSyntaxException error) {
Log.warning(error);
diff --git a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
index 931cb1d14..c0a18311e 100644
--- a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
@@ -21,7 +21,6 @@ import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
-import org.traccar.helper.PatternUtil;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -57,8 +56,6 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- PatternUtil.MatchResult r = PatternUtil.checkPattern(PATTERN.pattern(), sentence);
-
Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 1a34a6bd8..363834f89 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -216,8 +216,14 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
String alarm = parser.next();
position.set(Position.KEY_ALARM, decodeAlarm(alarm));
- if (channel != null && alarm.equals("help me")) {
- channel.write("**,imei:" + imei + ",E;", remoteAddress);
+ if (alarm.equals("help me")) {
+ if (channel != null) {
+ channel.write("**,imei:" + imei + ",E;", remoteAddress);
+ }
+ } else if (alarm.equals("acc on")) {
+ position.set(Position.KEY_IGNITION, true);
+ } else if (alarm.equals("acc off")) {
+ position.set(Position.KEY_IGNITION, false);
}
DateBuilder dateBuilder = new DateBuilder()
diff --git a/test/org/traccar/helper/PatternUtilTest.java b/test/org/traccar/helper/PatternUtilTest.java
index bb1349363..b6b05e88c 100644
--- a/test/org/traccar/helper/PatternUtilTest.java
+++ b/test/org/traccar/helper/PatternUtilTest.java
@@ -9,7 +9,7 @@ public class PatternUtilTest {
@Test
public void testCheckPattern() {
- assertEquals("ab", PatternUtil.checkPattern("abc", "abd").getPattern());
+ assertEquals("ab", PatternUtil.checkPattern("abc", "abd").getPatternMatch());
}
diff --git a/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java b/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java
index a28e71c64..c5e99f60b 100644
--- a/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class ArknavX8ProtocolDecoderTest extends ProtocolTest {
ArknavX8ProtocolDecoder decoder = new ArknavX8ProtocolDecoder(new ArknavX8Protocol());
verifyNothing(decoder, text(
+ "351856045213782,241111"));
+
+ verifyNothing(decoder, text(
+ "2R,090214235955,00,,00.04,03.76,001892024.9"));
+
+ verifyNothing(decoder, text(
"351856040005407,240101"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java b/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java
index cc710def0..fb0dec4fb 100644
--- a/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GoSafeProtocolDecoderTest.java
@@ -10,6 +10,15 @@ public class GoSafeProtocolDecoderTest extends ProtocolTest {
GoSafeProtocolDecoder decoder = new GoSafeProtocolDecoder(new GoSafeProtocol());
+ verifyNotNull(decoder, text(
+ "*GS56,356449063230915,052339180916,,SYS:G7S;V1.08;V1.2,GPS:V;4;N24.730006;E46.637816;14;0;630,GSM:;;420;4;5655;507A;-70,COT:75242;2-8-17,ADC:13.22;0.08,DTT:23004;;0;0;0;1#"));
+
+ verifyNotNull(decoder, text(
+ "*GS56,356449063230915,052349180916,,SYS:G7S;V1.08;V1.2,GPS:V;6;N24.730384;E46.637620;47;56;607,GSM:;;420;4;5655;507A;-70,COT:75290;2-8-27,ADC:13.24;0.08,DTT:23004;;0;0;0;1#"));
+
+ verifyNotNull(decoder, text(
+ "*GS56,356449063230915,052444180916,,SYS:G7S;V1.08;V1.2,GPS:V;6;N24.730384;E46.637620;47;56;607,GSM:;;420;4;5655;F319;-102,COT:75290;2-9-27,ADC:13.00;0.08,DTT:23004;;0;0;0;1$052449180916,,SYS:G7S;V1.08;V1.2,GPS:V;6;N24.730384;E46.637620;47;56;607,GSM:;;420;4;5655;F319;-102,COT:75290;2-9-27,ADC:13.13;0.08,DTT:23004;;0;0;0;1#"));
+
verifyPositions(decoder, text(
"*GS16,356449062643845,141224290316,,SYS:G79;V1.13;V1.0.2,GPS:V;5;N24.694972;E46.680736;46;334;606;1.43,GSM:;;420;4;5655;4EB8;-57,COT:330034,ADC:13.31;3.83,DTT:27004;;0;0;0;1,OBD:064101000400000341057E04410304000341510104411001C203410F4B0341112904411F01AB0641010004000014490201FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF03410D21,FUL:28260"));