diff options
-rw-r--r-- | src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java | 26 | ||||
-rw-r--r-- | src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 6 |
2 files changed, 22 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java index 6c0380278..71c37b27c 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -410,7 +410,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { } } - private String decodeAlarm(short value) { + private String decodeAlarm(short value, String model) { + boolean modelLW = model != null && model.startsWith("LW"); switch (value) { case 0x01: return Position.ALARM_SOS; @@ -427,7 +428,6 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { return Position.ALARM_OVERSPEED; case 0x0E: case 0x0F: - case 0x19: return Position.ALARM_LOW_BATTERY; case 0x11: return Position.ALARM_POWER_OFF; @@ -438,17 +438,21 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { case 0x14: return Position.ALARM_DOOR; case 0x18: - return Position.ALARM_REMOVING; - case 0x23: - return Position.ALARM_FALL_DOWN; + return modelLW ? Position.ALARM_ACCIDENT : Position.ALARM_REMOVING; + case 0x19: + return modelLW ? Position.ALARM_ACCELERATION : Position.ALARM_LOW_BATTERY; + case 0x1A: case 0x28: return Position.ALARM_BRAKING; - case 0x29: - return Position.ALARM_ACCELERATION; + case 0x1B: case 0x2A: case 0x2B: case 0x2E: return Position.ALARM_CORNERING; + case 0x23: + return Position.ALARM_FALL_DOWN; + case 0x29: + return Position.ALARM_ACCELERATION; case 0x2C: return Position.ALARM_ACCIDENT; case 0x30: @@ -831,7 +835,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { int satellites = BitUtil.between(signal, 10, 15) + BitUtil.between(signal, 5, 10); position.set(Position.KEY_SATELLITES, satellites); position.set(Position.KEY_RSSI, BitUtil.to(signal, 5)); - position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); + position.set(Position.KEY_ALARM, decodeAlarm( + buf.readUnsignedByte(), getDeviceModel(deviceSession))); buf.readUnsignedByte(); // language position.set(Position.KEY_BATTERY_LEVEL, buf.readUnsignedByte()); buf.readUnsignedByte(); // working mode @@ -842,7 +847,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RSSI, buf.readUnsignedByte()); short alarmExtension = buf.readUnsignedByte(); if (variant != Variant.VXT01) { - position.set(Position.KEY_ALARM, decodeAlarm(alarmExtension)); + position.set(Position.KEY_ALARM, decodeAlarm(alarmExtension, getDeviceModel(deviceSession))); } } } @@ -881,7 +886,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { decodeStatus(position, buf); position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); position.set(Position.KEY_RSSI, buf.readUnsignedByte()); - position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); + position.set(Position.KEY_ALARM, decodeAlarm( + buf.readUnsignedByte(), getDeviceModel(deviceSession))); position.set("oil", buf.readUnsignedShort()); int temperature = buf.readUnsignedByte(); if (BitUtil.check(temperature, 7)) { diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 04d7fafb3..05a33cc72 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -494,6 +494,12 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { "78785195140a020c2914055D4A800209D9C014009300004556454e545f3335333337363131303032333139365f30303030303030305f323032305f31305f30325f31345f34315f32305f30352e6d70340004e3a60d0a"), Position.KEY_ALARM, Position.ALARM_ACCIDENT); + decoder.setModelOverride("LW4G-4B"); + + verifyAttribute(decoder, binary( + "78782516180516150812c804b50ee80880e40805dcf909012e000000986633460604190106c393490d0a"), + Position.KEY_ALARM, Position.ALARM_ACCELERATION); + } } |