aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java53
-rw-r--r--src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java3
2 files changed, 39 insertions, 17 deletions
diff --git a/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java
index 0781bd640..81a31e1d1 100644
--- a/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/EasyTrackProtocolDecoder.java
@@ -49,9 +49,18 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder {
.number("(x{8}),") // status
.number("(x+),") // signal
.number("(d+),") // power
- .number("(x{4}),") // oil
- .number("(x+),?") // odometer
- .number("(d+)?") // altitude
+ .number("(x+),") // fuel
+ .number("(x+)") // odometer
+ .groupBegin()
+ .number(",(x+)") // altitude
+ .groupBegin()
+ .number(",d+") // gps data
+ .number(",(d*)") // rfid
+ .number(",(x+)") // temperature
+ .number(",(d+.d+)") // adc
+ .number(",(d+)") // satellites
+ .groupEnd("?")
+ .groupEnd("?")
.any()
.compile();
@@ -102,37 +111,47 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder {
position.setValid(parser.next().equals("A"));
DateBuilder dateBuilder = new DateBuilder()
- .setDate(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0))
- .setTime(parser.nextHexInt(0), parser.nextHexInt(0), parser.nextHexInt(0));
+ .setDate(parser.nextHexInt(), parser.nextHexInt(), parser.nextHexInt())
+ .setTime(parser.nextHexInt(), parser.nextHexInt(), parser.nextHexInt());
position.setTime(dateBuilder.getDate());
- if (BitUtil.check(parser.nextHexInt(0), 3)) {
- position.setLatitude(-parser.nextHexInt(0) / 600000.0);
+ if (BitUtil.check(parser.nextHexInt(), 3)) {
+ position.setLatitude(-parser.nextHexInt() / 600000.0);
} else {
- position.setLatitude(parser.nextHexInt(0) / 600000.0);
+ position.setLatitude(parser.nextHexInt() / 600000.0);
}
- if (BitUtil.check(parser.nextHexInt(0), 3)) {
- position.setLongitude(-parser.nextHexInt(0) / 600000.0);
+ if (BitUtil.check(parser.nextHexInt(), 3)) {
+ position.setLongitude(-parser.nextHexInt() / 600000.0);
} else {
- position.setLongitude(parser.nextHexInt(0) / 600000.0);
+ position.setLongitude(parser.nextHexInt() / 600000.0);
}
- position.setSpeed(UnitsConverter.knotsFromKph(parser.nextHexInt(0) / 100.0));
- position.setCourse(parser.nextHexInt(0) / 100.0);
+ position.setSpeed(UnitsConverter.knotsFromKph(parser.nextHexInt() / 100.0));
+ double course = parser.nextHexInt() * 0.01;
+ if (course < 360) {
+ position.setCourse(course);
+ }
long status = parser.nextHexLong();
position.set(Position.KEY_ALARM, decodeAlarm(status));
position.set(Position.KEY_IGNITION, BitUtil.check(status, 23));
position.set(Position.KEY_STATUS, status);
- position.set("signal", parser.next());
- position.set(Position.KEY_POWER, parser.nextDouble(0));
- position.set("oil", parser.nextHexInt(0));
- position.set(Position.KEY_ODOMETER, parser.nextHexInt(0) * 100);
+ position.set(Position.KEY_RSSI, parser.nextHexInt());
+ position.set(Position.KEY_POWER, parser.nextDouble());
+ position.set(Position.KEY_FUEL_LEVEL, parser.nextHexInt());
+ position.set(Position.KEY_ODOMETER, parser.nextHexInt() * 100);
position.setAltitude(parser.nextDouble(0));
+ if (parser.hasNext(4)) {
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextHexInt() * 0.01);
+ position.set(Position.PREFIX_ADC + 1, parser.nextDouble());
+ position.set(Position.KEY_SATELLITES, parser.nextInt());
+ }
+
return position;
}
diff --git a/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java
index b26991ae7..1ea608b04 100644
--- a/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class EasyTrackProtocolDecoderTest extends ProtocolTest {
EasyTrackProtocolDecoder decoder = new EasyTrackProtocolDecoder(null);
verifyPosition(decoder, text(
+ "*ET,135790246811221,HB,A,050915,0C2A27,00CE5954,04132263,0000,F000,01000000,20,4,0000,00F123,100,4845423835,0091564212,0B45,10.00,9"));
+
+ verifyPosition(decoder, text(
"*ET,358155100054249,HB,A,100b06,053318,803a0b51,03d507c9,0017,0000,00400000,07,100,0000,1435,63"));
verifyNull(decoder, text(