aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-15 17:21:07 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-15 17:21:07 +1200
commitd4ef43999690896d317f6d798b94596ccda53f1a (patch)
tree33bc8b0c619920879b772cc36530c62c7e0b2014 /src/org/traccar
parentdb86eb01e0e82fe79343b3e86d4605509ba8ad1b (diff)
downloadtraccar-server-d4ef43999690896d317f6d798b94596ccda53f1a.tar.gz
traccar-server-d4ef43999690896d317f6d798b94596ccda53f1a.tar.bz2
traccar-server-d4ef43999690896d317f6d798b94596ccda53f1a.zip
Improve GT06 alarm decoding
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/model/Position.java25
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java26
2 files changed, 36 insertions, 15 deletions
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 1a1db717f..f1d8b65d1 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -31,19 +31,19 @@ public class Position extends Message {
public static final String KEY_EVENT = "event";
public static final String KEY_ALARM = "alarm";
public static final String KEY_STATUS = "status";
- public static final String KEY_ODOMETER = "odometer"; // meters
- public static final String KEY_ODOMETER_SERVICE = "serviceOdometer"; // meters
- public static final String KEY_ODOMETER_TRIP = "tripOdometer"; // meters
+ public static final String KEY_ODOMETER = "odometer"; // meters
+ public static final String KEY_ODOMETER_SERVICE = "serviceOdometer"; // meters
+ public static final String KEY_ODOMETER_TRIP = "tripOdometer"; // meters
public static final String KEY_HOURS = "hours";
public static final String KEY_INPUT = "input";
public static final String KEY_OUTPUT = "output";
// The units for the below four KEYs currently vary.
// The preferred units of measure are specified in the comment for each.
- public static final String KEY_POWER = "power"; // volts
- public static final String KEY_BATTERY = "battery"; // volts (or percentage appending '%')
- public static final String KEY_FUEL_LEVEL = "fuel"; // liters
- public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour
+ public static final String KEY_POWER = "power"; // volts
+ public static final String KEY_BATTERY = "battery"; // volts (or percentage appending %)
+ public static final String KEY_FUEL_LEVEL = "fuel"; // liters
+ public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour
public static final String KEY_RFID = "rfid";
public static final String KEY_VERSION_FW = "versionFw";
@@ -54,8 +54,8 @@ public class Position extends Message {
public static final String KEY_CHARGE = "charge";
public static final String KEY_IP = "ip";
public static final String KEY_ARCHIVE = "archive";
- public static final String KEY_DISTANCE = "distance"; // meters
- public static final String KEY_TOTAL_DISTANCE = "totalDistance"; // meters
+ public static final String KEY_DISTANCE = "distance"; // meters
+ public static final String KEY_TOTAL_DISTANCE = "totalDistance"; // meters
public static final String KEY_RPM = "rpm";
public static final String KEY_VIN = "vin";
public static final String KEY_APPROXIMATE = "approximate";
@@ -64,13 +64,14 @@ public class Position extends Message {
public static final String KEY_ARMED = "armed";
public static final String KEY_GEOFENCE = "geofence";
public static final String KEY_ACCELERATION = "acceleration";
- public static final String KEY_DEVICE_TEMP = "deviceTemp"; // celsius
+ public static final String KEY_DEVICE_TEMP = "deviceTemp"; // celsius
public static final String KEY_OPERATOR = "operator";
public static final String KEY_COMMAND = "command";
+ public static final String KEY_BLOCKED = "blocked";
public static final String KEY_DTCS = "dtcs";
- public static final String KEY_OBD_SPEED = "obdSpeed"; // knots
- public static final String KEY_OBD_ODOMETER = "obdOdometer"; // meters
+ public static final String KEY_OBD_SPEED = "obdSpeed"; // knots
+ public static final String KEY_OBD_ODOMETER = "obdOdometer"; // meters
public static final String KEY_RESULT = "result";
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 20b2c8eab..c697191ee 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -157,10 +157,30 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private void decodeStatus(Position position, ChannelBuffer buf) {
- int flags = buf.readUnsignedByte();
+ int status = buf.readUnsignedByte();
+
+ position.set(Position.KEY_STATUS, status);
+ position.set(Position.KEY_IGNITION, BitUtil.check(status, 1));
+ position.set(Position.KEY_CHARGE, BitUtil.check(status, 2));
+ position.set(Position.KEY_BLOCKED, BitUtil.check(status, 7));
+
+ switch (BitUtil.between(status, 3, 6)) {
+ case 1:
+ position.set(Position.KEY_ALARM, Position.ALARM_SHOCK);
+ break;
+ case 2:
+ position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT);
+ break;
+ case 3:
+ position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
+ break;
+ case 4:
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ break;
+ default:
+ break;
+ }
- 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_RSSI, buf.readUnsignedByte());
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));