aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-06-04 11:18:42 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-06-04 11:18:42 +1200
commit6396a2ec497fad786444be13884ad569526dafce (patch)
treeaf3c87da19c7c6cf0452e777d77709fc0e903e56
parent824a01c093700929ec3d2e581fef5e252f64e129 (diff)
downloadtraccar-server-6396a2ec497fad786444be13884ad569526dafce.tar.gz
traccar-server-6396a2ec497fad786444be13884ad569526dafce.tar.bz2
traccar-server-6396a2ec497fad786444be13884ad569526dafce.zip
Implement new Totem protocol format
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java16
-rw-r--r--test/org/traccar/protocol/TotemProtocolDecoderTest.java9
2 files changed, 23 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index bf24706c6..1e07e7ed5 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2013 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -136,6 +136,13 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
.number("(dd)") // battery
.number("(dd)") // external power
.number("(dddd)") // adc 1
+ .groupBegin()
+ .number("(dddd)") // adc 2
+ .number("(dddd)") // adc 3
+ .number("(dddd)") // adc 4
+ .number("(dddd)") // temperature 1
+ .number("(dddd)") // temperature 2
+ .groupEnd("?")
.number("(xxxx)") // lac
.number("(xxxx)") // cid
.number("(dd)") // satellites
@@ -271,7 +278,14 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, parser.nextDouble() / 10);
position.set(Position.KEY_POWER, parser.nextDouble());
+
position.set(Position.PREFIX_ADC + 1, parser.next());
+ position.set(Position.PREFIX_ADC + 2, parser.next());
+ position.set(Position.PREFIX_ADC + 3, parser.next());
+ position.set(Position.PREFIX_ADC + 4, parser.next());
+ position.set(Position.PREFIX_TEMP + 1, parser.next());
+ position.set(Position.PREFIX_TEMP + 2, parser.next());
+
position.set(Position.KEY_LAC, parser.nextInt(16));
position.set(Position.KEY_CID, parser.nextInt(16));
position.set(Position.KEY_SATELLITES, parser.nextInt());
diff --git a/test/org/traccar/protocol/TotemProtocolDecoderTest.java b/test/org/traccar/protocol/TotemProtocolDecoderTest.java
index 237e77612..8ff2e6f11 100644
--- a/test/org/traccar/protocol/TotemProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TotemProtocolDecoderTest.java
@@ -11,9 +11,16 @@ public class TotemProtocolDecoderTest extends ProtocolTest {
TotemProtocolDecoder decoder = new TotemProtocolDecoder(new TotemProtocol());
verifyPosition(decoder, text(
+ "$$0128AA864244026065291|18001800140916020524401100000000000000000000000027BA0E57063100000001.200000002237.8119N11403.5075E05202D"));
+
+ verifyPosition(decoder, text(
+ "$$0128AA867965024919124|10010800160223032415401203270321032103270189000027BA0E4E001800200001.000000002237.7581N11403.5088E000957"));
+
+ verifyPosition(decoder, text(
"$$0108AA863835024426319|18004000160216160756411100007DCD0000111000000000.800000000316.3519N10228.5086E126522"));
- // $$0128AA867521029231005|1880100015101802314842140000000000000000000000001AB48366093127600000.900000000806.1947N09818.4795E080355
+ verifyPosition(decoder, text(
+ "$$0128AA867521029231005|1880100015101802314842140000000000000000000000001AB48366093127600000.900000000806.1947N09818.4795E080355"));
verifyPosition(decoder, text(
"$$0108AA864244026063437|1A0000001401010101014111000027BA0E57003100000000.000000000000.0000N00000.0000E048156"));