aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
authorOliver S <oliver.schramm97@gmail.com>2021-05-24 02:47:35 +0200
committerGitHub <noreply@github.com>2021-05-24 02:47:35 +0200
commitb2cca44879abd12492054bde4d84b8b8ae1c3cea (patch)
tree015e15a74a63745054396c16787a1f9965435524 /src/main/java/org/traccar
parentd5a391ccb44bb526417d33f1e11fd2540b28103b (diff)
downloadtrackermap-server-b2cca44879abd12492054bde4d84b8b8ae1c3cea.tar.gz
trackermap-server-b2cca44879abd12492054bde4d84b8b8ae1c3cea.tar.bz2
trackermap-server-b2cca44879abd12492054bde4d84b8b8ae1c3cea.zip
Fix poweroff alarm and extend megastek protocol
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java22
1 files changed, 20 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..fc27d3502 100644
--- a/src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -275,10 +275,15 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
.or().text(" ")
.groupEnd("?").text(",")
.number("(d+)?,") // rfid
+ .groupBegin() // ext accessories
+ .number("([01])") // charging
+ .number("(d)?") // belt status
+ .groupEnd("?")
.expression("[^,]*,")
.number("(d+)?,") // battery
- .expression("([^,]*)") // alert
+ .expression("([^,]*),?") // alert
.any()
+ .text(";")
.compile();
private Position decodeNew(Channel channel, SocketAddress remoteAddress, String sentence) {
@@ -354,6 +359,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() == 1);
+ }
+ if (parser.hasNext()) {
+ position.set("belt", parser.nextInt());
+ }
String battery = parser.next();
if (battery != null) {
@@ -378,7 +390,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
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;
@@ -396,6 +408,12 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
return Position.ALARM_GEOFENCE_ENTER;
case "move out":
return Position.ALARM_GEOFENCE_EXIT;
+ 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: