aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-05-15 02:23:14 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-05-15 02:23:14 +1200
commitbb0d6eef1870454673cffbcd9b27d0381aaf21ff (patch)
tree79278278e486cde4845d07db233ce6995f7857ad
parent849cfa52a907666241b58d988c9a3b324ac67ba0 (diff)
downloadtrackermap-server-bb0d6eef1870454673cffbcd9b27d0381aaf21ff.tar.gz
trackermap-server-bb0d6eef1870454673cffbcd9b27d0381aaf21ff.tar.bz2
trackermap-server-bb0d6eef1870454673cffbcd9b27d0381aaf21ff.zip
Decode additional GPS103 data
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java28
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java6
2 files changed, 23 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index f32d22c00..ceb0c5748 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -65,14 +65,14 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
.expression("([EW]),").optional()
.number("(d+)(dd.d+),") // longitude (dddmm.mmmm)
.expression("([EW])?,").optional()
- .number("(d+.?d*)?,?") // speed
- .number("(d+.?d*)?,?") // course
- .number("(d+.?d*)?,?") // altitude
- .expression("([^,;]+)?,?")
- .expression("([^,;]+)?,?")
- .expression("([^,;]+)?,?")
- .expression("([^,;]+)?,?")
- .expression("([^,;]+)?,?")
+ .number("(d+.?d*)?,").optional() // speed
+ .number("(d+.?d*)?,").optional() // course
+ .number("(d+.?d*)?,").optional() // altitude
+ .number("([01])?,").optional() // ignition
+ .number("([01])?,").optional() // door
+ .number("(?:(d+.d+)%)?,").optional() // fuel 1
+ .number("(?:(d+.d+)%)?,").optional() // fuel 2
+ .number("(-?d+)?") // temperature
.groupEnd()
.any()
.compile();
@@ -168,7 +168,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
} else if (alarm.startsWith("T:")) {
position.set(Position.PREFIX_TEMP + 1, alarm.substring(2));
} else if (alarm.startsWith("oil ")) {
- position.set("oil", alarm.substring(4));
+ position.set(Position.KEY_FUEL_LEVEL, Double.parseDouble(alarm.substring(4)));
} else if (!position.getAttributes().containsKey(Position.KEY_ALARM) && !alarm.equals("tracker")) {
position.set(Position.KEY_EVENT, alarm);
}
@@ -218,9 +218,15 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble(0));
position.setAltitude(parser.nextDouble(0));
- for (int i = 1; i <= 5; i++) {
- position.set(Position.PREFIX_IO + i, parser.next());
+ if (parser.hasNext()) {
+ position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
}
+ if (parser.hasNext()) {
+ position.set(Position.KEY_DOOR, parser.nextInt() == 1);
+ }
+ position.set("fuel1", parser.nextDouble());
+ position.set("fuel2", parser.nextDouble());
+ position.set(Position.PREFIX_TEMP + 1, parser.nextInt());
}
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index 17ed8da56..cf111f687 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -10,6 +10,12 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest {
Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(new Gps103Protocol());
+ verifyPosition(decoder, text(
+ "imei:353451044508750,001,0809231929,13554900601,F,055403.000,A,2233.1870,N,11354.3067,E,0.00,30.1,65.43,1,0,10.5%,0.0%,28;"));
+
+ verifyPosition(decoder, text(
+ "imei:864180036029895,acc on,180508145653,,F,065645.000,A,4729.1497,N,01904.2342,E,0.00,0,,1,,0.00%,,;"));
+
verifyNotNull(decoder, text(
"imei:864895030279986,ac alarm,180404174252,,L,,,296a,,51f7,,,"));