aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/MegastekProtocolDecoder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/protocol/MegastekProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java37
1 files changed, 34 insertions, 3 deletions
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 {