diff options
author | Oliver S <oliver.schramm97@gmail.com> | 2021-05-24 02:47:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-24 02:47:35 +0200 |
commit | b2cca44879abd12492054bde4d84b8b8ae1c3cea (patch) | |
tree | 015e15a74a63745054396c16787a1f9965435524 | |
parent | d5a391ccb44bb526417d33f1e11fd2540b28103b (diff) | |
download | trackermap-server-b2cca44879abd12492054bde4d84b8b8ae1c3cea.tar.gz trackermap-server-b2cca44879abd12492054bde4d84b8b8ae1c3cea.tar.bz2 trackermap-server-b2cca44879abd12492054bde4d84b8b8ae1c3cea.zip |
Fix poweroff alarm and extend megastek protocol
-rw-r--r-- | src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java | 22 |
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: |