From 0ebf3a50268bc6e7d1937b376a5a97f71f7608e7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 20 Dec 2014 11:44:27 +1300 Subject: Clean up GT06 decoder --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 31 +++++++---------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index e7fe9453b..12187e1ed 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -133,13 +133,13 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } 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)) { + 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(); @@ -206,23 +206,10 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { // Status 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); + int flags = buf.readUnsignedByte(); + extendedInfo.set("acc", (flags & 0x2) != 0); // TODO parse other flags -- cgit v1.2.3