aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-16 13:48:07 +0300
committerGitHub <noreply@github.com>2016-08-16 13:48:07 +0300
commit376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3 (patch)
tree3e1336a0597ca649f54e2b271a96df4b37273c9b /src/org
parent70bea1304ded17bb8a94ce8495d1e395e7cdf748 (diff)
parent96f0143b2cbbb93f1c325e1df7c66a2fc3d55b7e (diff)
downloadtrackermap-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.tar.gz
trackermap-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.tar.bz2
trackermap-server-376bd7a7342ed46f20b7c0c94d7c9b0074ae99f3.zip
Merge pull request #2219 from Abyss777/alarms_2
Alarm decoding for next protocols
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java32
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java27
-rw-r--r--src/org/traccar/protocol/HuabaoProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/IdplProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java37
-rw-r--r--src/org/traccar/protocol/TzoneProtocolDecoder.java19
6 files changed, 138 insertions, 9 deletions
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index 85f231a17..24cd6b570 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -64,6 +64,36 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
}
}
+ private String decodeAlarm(Short value) {
+ switch (value) {
+ case 0x01:
+ return Position.ALARM_POWER_OFF;
+ case 0x02:
+ return Position.ALARM_SOS;
+ case 0x03:
+ return Position.ALARM_LOW_BATTERY;
+ case 0x04:
+ return Position.ALARM_VIBRATION;
+ case 0x08:
+ case 0x09:
+ return Position.ALARM_GPS_ANTENNA_CUT;
+ case 0x81:
+ return Position.ALARM_LOW_SPEED;
+ case 0x82:
+ return Position.ALARM_OVERSPEED;
+ case 0x83:
+ return Position.ALARM_GEOFENCE_ENTER;
+ case 0x84:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 0x85:
+ return Position.ALARM_ACCIDENT;
+ case 0x86:
+ return Position.ALARM_FALL_DOWN;
+ default:
+ return null;
+ }
+ }
+
private Position decodeOld(DeviceSession deviceSession, ChannelBuffer buf, int type, int index) {
Position position = new Position();
@@ -90,7 +120,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
}
if (type == MSG_STATE) {
- position.set(Position.KEY_STATUS, buf.readUnsignedByte());
+ position.set(Position.KEY_STATUS, decodeAlarm(buf.readUnsignedByte()));
}
return position;
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index d69f425ab..c0b475b1e 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -154,14 +154,37 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private void decodeStatus(Position position, ChannelBuffer buf) {
- position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
-
int flags = buf.readUnsignedByte();
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_GSM, buf.readUnsignedByte());
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
+ }
+
+ private String decodeAlarm(short value) {
+ switch (value) {
+ case 0x01:
+ return Position.ALARM_SOS;
+ case 0x03:
+ case 0x09:
+ return Position.ALARM_VIBRATION;
+ case 0x04:
+ return Position.ALARM_GEOFENCE_ENTER;
+ case 0x05:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 0x06:
+ return Position.ALARM_OVERSPEED;
+ case 0x0E:
+ case 0x0F:
+ return Position.ALARM_LOW_BATTERY;
+ case 0x11:
+ return Position.ALARM_LOW_BATTERY;
+ default:
+ break;
+ }
+ return null;
}
@Override
diff --git a/src/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
index e4c9a9860..9223ea9a5 100644
--- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -70,6 +70,32 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, remoteAddress, MSG_GENERAL_RESPONSE, id, response);
}
+ private String decodeAlarm(long value) {
+ if (BitUtil.check(value, 0)) {
+ return Position.ALARM_SOS;
+ }
+ if (BitUtil.check(value, 1)) {
+ return Position.ALARM_OVERSPEED;
+ }
+ if (BitUtil.check(value, 5)) {
+ return Position.ALARM_GPS_ANTENNA_CUT;
+ }
+ if (BitUtil.check(value, 4) || BitUtil.check(value, 9)
+ || BitUtil.check(value, 10) || BitUtil.check(value, 11)) {
+ return Position.ALARM_FAULT;
+ }
+ if (BitUtil.check(value, 8)) {
+ return Position.ALARM_POWER_OFF;
+ }
+ if (BitUtil.check(value, 20)) {
+ return Position.ALARM_GEOFENCE;
+ }
+ if (BitUtil.check(value, 29)) {
+ return Position.ALARM_ACCIDENT;
+ }
+ return null;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -105,7 +131,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
position.setProtocol(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_ALARM, buf.readUnsignedInt());
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedInt()));
int flags = buf.readInt();
diff --git a/src/org/traccar/protocol/IdplProtocolDecoder.java b/src/org/traccar/protocol/IdplProtocolDecoder.java
index 5b8ec7897..4fdf9d677 100644
--- a/src/org/traccar/protocol/IdplProtocolDecoder.java
+++ b/src/org/traccar/protocol/IdplProtocolDecoder.java
@@ -97,7 +97,9 @@ public class IdplProtocolDecoder extends BaseProtocolDecoder {
parser.next(); // vehicle status
position.set(Position.KEY_POWER, parser.nextInt());
position.set(Position.KEY_BATTERY, parser.nextDouble());
- position.set(Position.KEY_ALARM, parser.nextInt());
+ if (parser.nextInt() == 1) {
+ position.set(Position.KEY_ALARM, Position.ALARM_SOS);
+ }
parser.nextInt(); // body tamper
parser.nextInt(); // ac status
position.set(Position.KEY_IGNITION, parser.nextInt() == 1);
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 1ff7add1a..d20532faa 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -156,7 +156,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
Parser parser = new Parser(PATTERN_SIMPLE, status);
if (parser.matches()) {
- position.set(Position.KEY_ALARM, parser.next());
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.next()));
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next(), id);
if (deviceSession == null) {
@@ -217,7 +217,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + 1, parser.next());
position.set(Position.PREFIX_ADC + 2, parser.next());
position.set(Position.PREFIX_ADC + 3, parser.next());
- position.set(Position.KEY_ALARM, parser.next());
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.next()));
}
}
@@ -337,11 +337,42 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_BATTERY, Integer.parseInt(battery));
}
- position.set(Position.KEY_ALARM, parser.next());
+ position.set(Position.KEY_ALARM, decodeAlarm(parser.next()));
return position;
}
+ private String decodeAlarm(String value) {
+ switch (value) {
+ case "SOS":
+ case "Help":
+ return Position.ALARM_SOS;
+ case "Over Speed":
+ case "OverSpeed":
+ return Position.ALARM_OVERSPEED;
+ case "LowSpeed":
+ return Position.ALARM_LOW_SPEED;
+ case "Low Battery":
+ case "LowBattery":
+ return Position.ALARM_LOW_BATTERY;
+ case "VIB":
+ return Position.ALARM_VIBRATION;
+ case "Move in":
+ case "Geo in":
+ case "Geo1 in":
+ case "Geo2 in":
+ return Position.ALARM_GEOFENCE_ENTER;
+ case "Move out":
+ case "Geo out":
+ case "Geo1 out":
+ case "Geo2 out":
+ return Position.ALARM_GEOFENCE_EXIT;
+ default:
+ break;
+ }
+ return null;
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java
index 9caf77b0c..4b530efa4 100644
--- a/src/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -32,6 +32,23 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
+ private String decodeAlarm(Short value) {
+ switch (value) {
+ case 0x01:
+ return Position.ALARM_SOS;
+ case 0x10:
+ return Position.ALARM_LOW_BATTERY;
+ case 0x11:
+ return Position.ALARM_OVERSPEED;
+ case 0x42:
+ return Position.ALARM_GEOFENCE_EXIT;
+ case 0x43:
+ return Position.ALARM_GEOFENCE_ENTER;
+ default:
+ return null;
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -116,7 +133,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
if (blockLength > 0) {
- position.set(Position.KEY_ALARM, buf.readUnsignedByte());
+ position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
buf.readUnsignedByte(); // terminal info
position.set(Position.PREFIX_IO + 1, buf.readUnsignedShort());
position.set(Position.KEY_GSM, buf.readUnsignedByte());