diff options
author | Leandro Silva Ferreira <leandrosilvaferreira@gmail.com> | 2012-08-15 22:15:59 -0400 |
---|---|---|
committer | Leandro Silva Ferreira <leandrosilvaferreira@gmail.com> | 2012-08-15 22:15:59 -0400 |
commit | 33cc8f56d87556a2233c174a39247048bb2e33fd (patch) | |
tree | 0c533ec982e95e2f6fc625bb82ed4613e1829f3d /src/org/traccar/protocol | |
parent | ba78f64d458bf03a3ffbac87369def5f79cbc8ae (diff) | |
download | traccar-server-33cc8f56d87556a2233c174a39247048bb2e33fd.tar.gz traccar-server-33cc8f56d87556a2233c174a39247048bb2e33fd.tar.bz2 traccar-server-33cc8f56d87556a2233c174a39247048bb2e33fd.zip |
Improvements on decoder to decode status, emergency and keep alive
messages from avl.
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/ST210ProtocolDecoder.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/org/traccar/protocol/ST210ProtocolDecoder.java b/src/org/traccar/protocol/ST210ProtocolDecoder.java index 983e9c6f4..2f9bcd863 100644 --- a/src/org/traccar/protocol/ST210ProtocolDecoder.java +++ b/src/org/traccar/protocol/ST210ProtocolDecoder.java @@ -23,8 +23,7 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { } private enum ST210FIELDS { - HDR_STATUS("SA200STT;", - "Status Report"), + HDR_STATUS("SA200STT;","Status Report"), HDR_EMERGENCY("SA200EMG;","Emergency Report"), HDR_EVENT("SA200EVT;", "Event Report"), HDR_ALERT("SA200ALT;","Alert Report"), @@ -44,8 +43,8 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { PWR_VOLT("(\\d+.\\d{2});","Voltage value of main power"), IO("(\\d+);","Current I/O status of inputs and outputs."), MODE("(\\d);","1 = Idle mode (Parking)\n" + "2 = Active Mode (Driving)"), - MSG_NUM("(\\d{4})","Message number - After 9999 is reported, message number returns to 0000"), - EMG_ID("(\\d)", "Emergency type"), + MSG_NUM("(\\d{4});","Message number - After 9999 is reported, message number returns to 0000"), + EMG_ID("(\\d);", "Emergency type"), EVT_ID("(\\d);", "Event type"), ALERT_ID("(\\d);", "Alert type"); @@ -488,6 +487,10 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { patternStr += field.getPattern(); } + if(patternStr.endsWith(";")){ + patternStr = patternStr.substring(0, patternStr.length()-1); + } + return Pattern.compile(patternStr); } @@ -631,6 +634,10 @@ public class ST210ProtocolDecoder extends GenericProtocolDecoder { throw new Exception("Pattern no match: " + protocolPattern.toString()); } + if(report.equals(ST210REPORTS.ALIVE)){ + return null; + } + // Create new position Position position = new Position(); |