aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java59
-rw-r--r--test/org/traccar/protocol/TotemProtocolDecoderTest.java3
2 files changed, 33 insertions, 29 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index 087416f18..e5096c675 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -92,35 +92,36 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
"\\p{XDigit}{4}" + // Checksum
"\r?\n?");
- private static final Pattern PATTERN3 = Pattern.compile(
- "\\$\\$" + // Header
- "\\p{XDigit}{2}" + // Length
- "(\\d+)\\|" + // IMEI
- "(..)" + // Alarm Type
- "(\\d{2})(\\d{2})(\\d{2})" + // Date (YYMMDD)
- "(\\d{2})(\\d{2})(\\d{2})" + // Time (HHMMSS)
- "(\\p{XDigit}{4})" + // IO Status
- "[01]" + // Charging
- "(\\d{2})" + // Battery
- "(\\d{2})" + // External Power
- "(\\d{4})" + // ADC 1
- "(\\d{4})" + // ADC 2
- "(\\d{3})" + // Temperature 1
- "(\\d{3})" + // Temperature 2
- "(\\p{XDigit}{8})" + // Location Code
- "([AV])" + // Validity
- "(\\d{2})" + // Satellites
- "(\\d{3})" + // Course
- "(\\d{3})" + // Speed
- "(\\d{2}\\.\\d)" + // PDOP
- "(\\d{7})" + // Odometer
- "(\\d{2})(\\d{2}\\.\\d{4})" + // Latitude (DDMM.MMMM)
- "([NS])" +
- "(\\d{3})(\\d{2}\\.\\d{4})" + // Longitude (DDDMM.MMMM)
- "([EW])" +
- "\\d{4}" + // Serial Number
- "\\p{XDigit}{4}" + // Checksum
- "\r?\n?");
+ private static final Pattern PATTERN3 = new PatternBuilder()
+ .txt("$$") // header
+ .num("xx") // length
+ .num("(d+)|") // imei
+ .xpr("(..)") // alarm type
+ .num("(dd)(dd)(dd)") // date (yymmdd)
+ .num("(dd)(dd)(dd)") // time (hhmmss)
+ .num("(xxxx)") // io status
+ .xpr("[01]") // charging
+ .num("(dd)") // battery
+ .num("(dd)") // external power
+ .num("(dddd)") // adc 1
+ .num("(dddd)") // adc 2
+ .num("(ddd)") // temperature 1
+ .num("(ddd)") // temperature 2
+ .num("(x{8})") // location code
+ .xpr("([AV])") // validity
+ .num("(dd)") // satellites
+ .num("(ddd)") // course
+ .num("(ddd)") // speed
+ .num("(dd.d)") // pdop
+ .num("(d{7})") // odometer
+ .num("(dd)(dd.dddd)") // latitude
+ .xpr("([NS])")
+ .num("(ddd)(dd.dddd)") // longitude
+ .xpr("([EW])")
+ .num("dddd") // serial number
+ .num("xxxx") // checksum
+ .any()
+ .compile();
@Override
protected Object decode(
diff --git a/test/org/traccar/protocol/TotemProtocolDecoderTest.java b/test/org/traccar/protocol/TotemProtocolDecoderTest.java
index fd08798e0..28b08b055 100644
--- a/test/org/traccar/protocol/TotemProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TotemProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class TotemProtocolDecoderTest extends ProtocolDecoderTest {
TotemProtocolDecoder decoder = new TotemProtocolDecoder(new TotemProtocol());
+ // $$0128AA867521029231005|1880100015101802314842140000000000000000000000001AB48366093127600000.900000000806.1947N09818.4795E080355
+ // $$0108AA864244026063437|1A0000001401010101014111000027BA0E57003100000000.000000000000.0000N00000.0000E048156
+
verify(decoder.decode(null, null,
"$$BE863771024392112|AA$GPRMC,044704.000,A,1439.3334,N,12059.1417,E,0.00,0.00,200815,,,A*67|01.7|00.8|01.4|000000000000|20150820044704|14291265|00000000|4EECBF8B31|0000|0.0000|0002|00000|56E7"));