aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2014-12-20 11:40:37 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2014-12-20 11:40:37 +1300
commit80cf3d7233ea99f22c4d2e6c7b946c8dbc974251 (patch)
treef01bc415c4d2dd46fc83efb4e9bb624a0d2f5855
parent5c7b1668d524aee47885caa90740b72395b6f6d6 (diff)
parent0bf064dd0e69e009f7213ac70ef034d682a617be (diff)
downloadtrackermap-server-80cf3d7233ea99f22c4d2e6c7b946c8dbc974251.tar.gz
trackermap-server-80cf3d7233ea99f22c4d2e6c7b946c8dbc974251.tar.bz2
trackermap-server-80cf3d7233ea99f22c4d2e6c7b946c8dbc974251.zip
Merge pull request #995 from pnakhat/master
Support for alarm packet
-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