aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-16 14:16:40 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-16 14:16:40 +0500
commit96f0143b2cbbb93f1c325e1df7c66a2fc3d55b7e (patch)
tree3e1336a0597ca649f54e2b271a96df4b37273c9b
parent87a8bf3f5cff9b2e537594d0a13371ed8f06fcea (diff)
downloadtrackermap-server-96f0143b2cbbb93f1c325e1df7c66a2fc3d55b7e.tar.gz
trackermap-server-96f0143b2cbbb93f1c325e1df7c66a2fc3d55b7e.tar.bz2
trackermap-server-96f0143b2cbbb93f1c325e1df7c66a2fc3d55b7e.zip
GT06 Added alarm decoder for status packets
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java27
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java3
2 files changed, 28 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index d69f425ab..c0b475b1e 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -154,14 +154,37 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private void decodeStatus(Position position, ChannelBuffer buf) {
- position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
-
int flags = buf.readUnsignedByte();
position.set(Position.KEY_IGNITION, BitUtil.check(flags, 1));
position.set(Position.KEY_STATUS, flags);
position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
position.set(Position.KEY_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
+ }
+
+ private String decodeAlarm(short value) {
+ switch (value) {
+ case 0x01:
+ return Position.ALARM_SOS;
+ case 0x03:
+ case 0x09:
+ return Position.ALARM_VIBRATION;
+ case 0x04:
+ return Position.ALARM_GEOFENCE_ENTER;
+ case 0x05:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 0x06:
+ return Position.ALARM_OVERSPEED;
+ case 0x0E:
+ case 0x0F:
+ return Position.ALARM_LOW_BATTERY;
+ case 0x11:
+ return Position.ALARM_LOW_BATTERY;
+ default:
+ break;
+ }
+ return null;
}
@Override
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 3343f72e2..8b6b65b8c 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -43,6 +43,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, binary(
"78780a13440604000201baaf540d0a"));
+ verifyAttributes(decoder, binary(
+ "787825160F0C1D0A2B21C8027AC8040C46581000146F0901CC00287D001F714804040301001C84CF0D0A"));
+
verifyPosition(decoder, binary(
"78781f120f0a140e150bc505e51e780293a9e800540000f601006e0055da00035f240d0a"),
position("2015-10-20 14:21:11.000", true, 54.94535, 24.01762));