aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/protocol/Gt30ProtocolDecoder.java22
-rw-r--r--test/org/traccar/protocol/Gt30ProtocolDecoderTest.java12
2 files changed, 34 insertions, 0 deletions
diff --git a/src/org/traccar/protocol/Gt30ProtocolDecoder.java b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
index 19d964687..6c3f8c0a4 100644
--- a/src/org/traccar/protocol/Gt30ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
@@ -37,6 +37,7 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder {
.number("x{4}") // length
.expression("(.{14})") // device id
.number("x{4}") // type
+ .expression("(.)?") // alarm
.number("(dd)(dd)(dd).(d+),") // time
.expression("([AV]),") // validity
.number("(d+)(dd.d+),") // latitude
@@ -52,6 +53,23 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder {
.number("x{4}") // checksum
.compile();
+ private String decodeAlarm(int value) {
+ switch (value) {
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ return Position.ALARM_SOS;
+ case 0x10:
+ return Position.ALARM_LOW_BATTERY;
+ case 0x11:
+ return Position.ALARM_OVERSPEED;
+ case 0x12:
+ return Position.ALARM_GEOFENCE;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -70,6 +88,10 @@ public class Gt30ProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
+ if (parser.hasNext()) {
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.next().charAt(0)));
+ }
+
DateBuilder dateBuilder = new DateBuilder()
.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt(), parser.nextInt());
diff --git a/test/org/traccar/protocol/Gt30ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt30ProtocolDecoderTest.java
index f33875ce1..7b81b1ebe 100644
--- a/test/org/traccar/protocol/Gt30ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt30ProtocolDecoderTest.java
@@ -11,6 +11,18 @@ public class Gt30ProtocolDecoderTest extends ProtocolTest {
Gt30ProtocolDecoder decoder = new Gt30ProtocolDecoder(new Gt30Protocol());
verifyPosition(decoder, text(
+ "$$005D3037811014 9955102834.000,A,3802.8629,N,02349.7163,E,0.00,,060117,,*13|1.3|26225BD"));
+
+ verifyPosition(decoder, text(
+ "$$005E3037811014 9999\u0003121909.000,A,3802.9133,N,02349.9354,E,0.00,,060117,,*18|1.8|264518B"));
+
+ verifyPosition(decoder, text(
+ "$$00633037811014 9999\u0002121901.000,A,3802.9137,N,02349.9334,E,2.86,18.16,060117,,*3E|1.8|262D752"));
+
+ verifyPosition(decoder, text(
+ "$$005E3037811014 9999\u0001121849.000,A,3802.9094,N,02349.9384,E,0.00,,060117,,*1C|1.2|2683812"));
+
+ verifyPosition(decoder, text(
"$$005B3037811124 9955161049.000,A,3802.9474,N,02241.1897,E,0.00,,021115,,*15|2.9|5A639"));
}