aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-05-27 20:12:39 -0700
committerGitHub <noreply@github.com>2021-05-27 20:12:39 -0700
commit3ebd7383a9fdf797ac06fbe8988c2cba0430410d (patch)
treeeb69ff2879fac473b30f5a5785380a6e68c0b0e9 /src/main/java/org/traccar/protocol
parent0e050e0f85422377096abd0ee8e7deead693c41a (diff)
parentbea7b241c4d29a7c7b49192ac1170ddeeb8bd90d (diff)
downloadtrackermap-server-3ebd7383a9fdf797ac06fbe8988c2cba0430410d.tar.gz
trackermap-server-3ebd7383a9fdf797ac06fbe8988c2cba0430410d.tar.bz2
trackermap-server-3ebd7383a9fdf797ac06fbe8988c2cba0430410d.zip
Merge pull request #4684 from Elsensee/patch-2
Fix poweroff alarm and extend megastek protocol
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java b/src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java
index d81cc0eda..fae73d931 100644
--- a/src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -275,9 +275,10 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
.or().text(" ")
.groupEnd("?").text(",")
.number("(d+)?,") // rfid
+ .number("([01])(d)?").optional() // charge and belt status
.expression("[^,]*,")
.number("(d+)?,") // battery
- .expression("([^,]*)") // alert
+ .expression("([^,]*)[,;]") // alert
.any()
.compile();
@@ -355,6 +356,13 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next());
+ if (parser.hasNext()) {
+ position.set(Position.KEY_CHARGE, parser.nextInt() > 0);
+ }
+ if (parser.hasNext()) {
+ position.set("belt", parser.nextInt());
+ }
+
String battery = parser.next();
if (battery != null) {
position.set(Position.KEY_BATTERY, Integer.parseInt(battery));
@@ -375,10 +383,11 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
}
}
switch (value) {
+ case "pw on":
case "poweron":
return Position.ALARM_POWER_ON;
case "poweroff":
- return Position.ALARM_POWER_ON;
+ return Position.ALARM_POWER_OFF;
case "sos":
case "help":
return Position.ALARM_SOS;
@@ -390,12 +399,32 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
case "low battery":
case "lowbattery":
return Position.ALARM_LOW_BATTERY;
+ case "low extern voltage":
+ return Position.ALARM_LOW_POWER;
+ case "gps cut":
+ return Position.ALARM_GPS_ANTENNA_CUT;
case "vib":
return Position.ALARM_VIBRATION;
case "move in":
return Position.ALARM_GEOFENCE_ENTER;
case "move out":
return Position.ALARM_GEOFENCE_EXIT;
+ case "corner":
+ return Position.ALARM_CORNERING;
+ case "fatigue":
+ return Position.ALARM_FATIGUE_DRIVING;
+ case "psd":
+ return Position.ALARM_POWER_CUT;
+ case "psr":
+ return Position.ALARM_POWER_RESTORED;
+ case "hit":
+ return Position.ALARM_SHOCK;
+ case "belt on":
+ case "belton":
+ return Position.ALARM_LOCK;
+ case "belt off":
+ case "beltoff":
+ return Position.ALARM_UNLOCK;
case "error":
return Position.ALARM_FAULT;
default: