diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/traccar/helper/PatternUtil.java | 26 | ||||
-rw-r--r-- | src/org/traccar/protocol/ArknavX8ProtocolDecoder.java | 3 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gps103ProtocolDecoder.java | 10 |
3 files changed, 18 insertions, 21 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() |