From b2cca44879abd12492054bde4d84b8b8ae1c3cea Mon Sep 17 00:00:00 2001 From: Oliver S Date: Mon, 24 May 2021 02:47:35 +0200 Subject: Fix poweroff alarm and extend megastek protocol --- .../traccar/protocol/MegastekProtocolDecoder.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/main/java') 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: -- cgit v1.2.3