diff options
Diffstat (limited to 'src/main/java/org/traccar/protocol/MegastekProtocolDecoder.java')
-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: |