From 7dd85faa3018aa6d3c8a192eed99360cb406eb71 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 17 Aug 2016 09:52:27 +0500 Subject: - Added Kenji, T800x, Xexun alarm decoders - Fixed GT06 mistake --- src/org/traccar/protocol/Gt06ProtocolDecoder.java | 2 +- src/org/traccar/protocol/KenjiProtocolDecoder.java | 20 +++++++++++++++++++- src/org/traccar/protocol/T800xProtocolDecoder.java | 21 ++++++++++++++++++++- src/org/traccar/protocol/XexunProtocolDecoder.java | 19 ++++++++++++++++++- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index c0b475b1e..3df8a4686 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -180,7 +180,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { case 0x0F: return Position.ALARM_LOW_BATTERY; case 0x11: - return Position.ALARM_LOW_BATTERY; + return Position.ALARM_POWER_OFF; default: break; } diff --git a/src/org/traccar/protocol/KenjiProtocolDecoder.java b/src/org/traccar/protocol/KenjiProtocolDecoder.java index 2a95717ee..e13c91e3a 100755 --- a/src/org/traccar/protocol/KenjiProtocolDecoder.java +++ b/src/org/traccar/protocol/KenjiProtocolDecoder.java @@ -18,6 +18,7 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.helper.BitUtil; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; @@ -49,6 +50,23 @@ public class KenjiProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private String decodeAlarm(int value) { + if (BitUtil.check(value, 2)) { + return Position.ALARM_SOS; + } + if (BitUtil.check(value, 4)) { + return Position.ALARM_LOW_BATTERY; + } + if (BitUtil.check(value, 6)) { + return Position.ALARM_MOVEMENT; + } + if (BitUtil.check(value, 1) || BitUtil.check(value, 10) || BitUtil.check(value, 11)) { + return Position.ALARM_VIBRATION; + } + + return null; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -67,7 +85,7 @@ public class KenjiProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(deviceSession.getDeviceId()); - position.set(Position.KEY_ALARM, parser.nextInt(16)); + position.set(Position.KEY_ALARM, decodeAlarm(parser.nextInt(16))); position.set(Position.KEY_OUTPUT, parser.nextInt(16)); position.set(Position.KEY_INPUT, parser.nextInt(16)); diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java index de966f901..8301450d5 100644 --- a/src/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/org/traccar/protocol/T800xProtocolDecoder.java @@ -60,6 +60,25 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { } } + private String decodeAlarm(short value) { + switch (value) { + case 3: + return Position.ALARM_SOS; + case 4: + return Position.ALARM_OVERSPEED; + case 5: + return Position.ALARM_GEOFENCE_ENTER; + case 6: + return Position.ALARM_GEOFENCE_EXIT; + case 8: + case 10: + return Position.ALARM_VIBRATION; + default: + break; + } + return null; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -111,7 +130,7 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort()); position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort()); - position.set(Position.KEY_ALARM, buf.readUnsignedByte()); + position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); buf.readUnsignedByte(); // reserved diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 7b6a84f1f..69100f54b 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -64,6 +64,23 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { .any() .compile(); + private String decodeAlarm(String value) { + if (value != null) { + switch (value) { + case "help me!": + return Position.ALARM_SOS; + case "low battery": + return Position.ALARM_LOW_BATTERY; + case "move!": + case "moved!": + return Position.ALARM_MOVEMENT; + default: + break; + } + } + return null; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -99,7 +116,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { position.setTime(dateBuilder.getDate()); position.set("signal", parser.next()); - position.set(Position.KEY_ALARM, parser.next()); + position.set(Position.KEY_ALARM, decodeAlarm(parser.next())); DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { -- cgit v1.2.3 From 54a64d8c0186e71ce557b5e9764d478084e9443c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 17 Aug 2016 14:35:11 +0500 Subject: Used ALARM_GENERAL for Tytan --- src/org/traccar/protocol/TytanProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index 092ba431a..2733a568b 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -66,7 +66,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { int alarm = buf.readUnsignedByte(); buf.readUnsignedByte(); if (BitUtil.check(alarm, 5)) { - position.set(Position.KEY_ALARM, BitUtil.to(alarm, 4)); + position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); } break; case 8: -- cgit v1.2.3