aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-07-27 13:58:37 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-07-27 13:58:37 +1200
commit457bda5a0e8501dfae1d3dd4e0d39f778ee4d9da (patch)
treec8812385415ff405b70510be6c1b6fe72bc1f2ee
parent71c38dce9fe0ddae25e2e1192b90aa5d7fdd6118 (diff)
downloadtrackermap-server-457bda5a0e8501dfae1d3dd4e0d39f778ee4d9da.tar.gz
trackermap-server-457bda5a0e8501dfae1d3dd4e0d39f778ee4d9da.tar.bz2
trackermap-server-457bda5a0e8501dfae1d3dd4e0d39f778ee4d9da.zip
Update custom T55 protocol format
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java11
-rw-r--r--test/org/traccar/protocol/T55ProtocolDecoderTest.java2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index 34efc376f..1909d9bea 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -50,7 +50,9 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
.expression("[^,]+")
.number(",(d+)") // satellites
.number(",(d+)") // imei
- .number(",(d+)").optional(3)
+ .number(",([01])") // ignition
+ .number(",(d+)") // fuel
+ .number(",(d+)").optional(5) // battery
.any()
.compile();
@@ -123,13 +125,18 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt());
position.setTime(dateBuilder.getDate());
- if (parser.hasNext(3)) {
+ if (parser.hasNext(5)) {
position.set(Position.KEY_SATELLITES, parser.next());
+
deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;
}
position.setDeviceId(deviceSession.getDeviceId());
+
+ position.set(Position.KEY_IGNITION, parser.hasNext() && parser.next().equals("1"));
+ position.set(Position.KEY_FUEL, parser.nextInt());
+ position.set(Position.KEY_BATTERY, parser.nextInt());
}
if (deviceSession != null) {
diff --git a/test/org/traccar/protocol/T55ProtocolDecoderTest.java b/test/org/traccar/protocol/T55ProtocolDecoderTest.java
index 753b4f689..4cc5f549a 100644
--- a/test/org/traccar/protocol/T55ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/T55ProtocolDecoderTest.java
@@ -23,7 +23,7 @@ public class T55ProtocolDecoderTest extends ProtocolTest {
"4711/022789000688081/$GPRMC,133343,A,5308.56325,N,1029.12850,E,0.000000,0.000000,290316,,*2A"));
verifyPosition(decoder, text(
- "$GPRMC,073501.000,A,1255.5125,N,07738.2948,E,0.00,0.53,080316,,,D*73,12,865733027593268,10011"));
+ "$GPRMC,073446.000,A,1255.5125,N,07738.2948,E,0.00,0.53,080316,D*71,11,865733027593268,1,090,086"));
verifyNothing(decoder, text(
"$GPFID,ID123456ABC"));