aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorPankaj Nakhat <pnakhat@gmail.com>2014-12-06 22:31:20 +0000
committerPankaj Nakhat <pnakhat@gmail.com>2014-12-06 22:31:20 +0000
commit0bf064dd0e69e009f7213ac70ef034d682a617be (patch)
treef919c8e77937d9e292fac884baa913ed14a3375c /src/org/traccar
parentdad236c8944ba4fac7e7c341b59b796e43898c1d (diff)
downloadtraccar-server-0bf064dd0e69e009f7213ac70ef034d682a617be.tar.gz
traccar-server-0bf064dd0e69e009f7213ac70ef034d682a617be.tar.bz2
traccar-server-0bf064dd0e69e009f7213ac70ef034d682a617be.zip
Support for alarm packet 0x27 and parsing of alarm flags
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java55
1 files changed, 34 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index fae284e22..e7fe9453b 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -15,16 +15,10 @@
*/
package org.traccar.protocol;
-import java.util.Calendar;
-import java.util.Properties;
-import java.util.Properties;
-import java.util.TimeZone;
-
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
-
import org.traccar.BaseProtocolDecoder;
import org.traccar.database.DataManager;
import org.traccar.helper.Crc;
@@ -32,6 +26,10 @@ import org.traccar.helper.Log;
import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
+import java.util.Calendar;
+import java.util.Properties;
+import java.util.TimeZone;
+
public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private Long deviceId;
@@ -70,6 +68,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private static final int MSG_STRING = 0x15;
private static final int MSG_GPS_LBS_STATUS_1 = 0x16;
private static final int MSG_GPS_LBS_STATUS_2 = 0x26;
+ private static final int MSG_GPS_LBS_STATUS_3 = 0x27;
private static final int MSG_LBS_PHONE = 0x17;
private static final int MSG_LBS_EXTEND = 0x18;
private static final int MSG_LBS_STATUS = 0x19;
@@ -132,16 +131,15 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
Log.warning("Unknown device - " + imei);
}
- }
-
- else if (deviceId != null && (
- type == MSG_GPS ||
- type == MSG_GPS_LBS_1 ||
- type == MSG_GPS_LBS_2 ||
- type == MSG_GPS_LBS_STATUS_1 ||
- type == MSG_GPS_LBS_STATUS_2 ||
- type == MSG_GPS_PHONE ||
- type == MSG_GPS_LBS_EXTEND)) {
+ } else if (deviceId != null && (
+ type == MSG_GPS ||
+ type == MSG_GPS_LBS_1 ||
+ type == MSG_GPS_LBS_2 ||
+ type == MSG_GPS_LBS_STATUS_1 ||
+ type == MSG_GPS_LBS_STATUS_2 ||
+ type == MSG_GPS_LBS_STATUS_3 ||
+ type == MSG_GPS_PHONE ||
+ type == MSG_GPS_LBS_EXTEND)) {
// Create new position
Position position = new Position();
@@ -191,10 +189,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(gpsLength - 12); // skip reserved
if (type == MSG_GPS_LBS_1 || type == MSG_GPS_LBS_2 ||
- type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2) {
+ type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_LBS_STATUS_3) {
int lbsLength = 0;
- if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2) {
+ if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_LBS_STATUS_3) {
lbsLength = buf.readUnsignedByte();
}
@@ -206,10 +204,25 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(lbsLength - 9);
// Status
- if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2) {
- extendedInfo.set("alarm", true);
-
+ if (type == MSG_GPS_LBS_STATUS_1 || type == MSG_GPS_LBS_STATUS_2 || type == MSG_GPS_LBS_STATUS_3) {
+
int flags = buf.readUnsignedByte();
+ String binaryAlarm = Integer.toBinaryString(flags);
+ Log.debug("Binary of Flags" + binaryAlarm);
+
+ String alarm = binaryAlarm.substring(1, 4);
+
+
+ if(alarm.equals("100")) {
+ Log.debug("SOS ALARM");
+ extendedInfo.set("sos", true);
+ } else if(alarm.equals("011")){
+ Log.debug("LOW BATTERY ALARM");
+ extendedInfo.set("sos", true);
+ }
+
+ extendedInfo.set("alarm", true);
+
extendedInfo.set("acc", (flags & 0x2) != 0);
// TODO parse other flags