diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2023-07-09 15:39:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-09 15:39:20 -0700 |
commit | 8a29f377df8cff9e3c693e3c1201ec0b942d7cd6 (patch) | |
tree | 83c576c1942bbc7ae40c569ce6c156409aec71aa /src/main/java | |
parent | d2ce5af3478265c6c047f5ec4bf206baebb467d1 (diff) | |
parent | 60522a68d292541c44efa3736967f471d4347a50 (diff) | |
download | trackermap-server-8a29f377df8cff9e3c693e3c1201ec0b942d7cd6.tar.gz trackermap-server-8a29f377df8cff9e3c693e3c1201ec0b942d7cd6.tar.bz2 trackermap-server-8a29f377df8cff9e3c693e3c1201ec0b942d7cd6.zip |
Merge pull request #5093 from edvalley/patch-1
Acknowledge mileage alert and decode third input status
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java index e9570ee11..5745909c7 100644 --- a/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/LaipacProtocolDecoder.java @@ -28,6 +28,8 @@ import org.traccar.helper.PatternBuilder; import org.traccar.model.CellTower; import org.traccar.model.Network; import org.traccar.model.Position; +import org.traccar.model.Device; +import org.traccar.helper.BitUtil; import java.net.SocketAddress; import java.util.regex.Pattern; @@ -108,19 +110,31 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { } } - private String decodeEvent(String event, Position position) { + private String decodeEvent(String event, Position position, String model) { if (event.length() == 1) { char inputStatus = event.charAt(0); if (inputStatus >= 'A' && inputStatus <= 'D') { int inputStatusInt = inputStatus - 'A'; - position.set(Position.PREFIX_IN + 1, inputStatusInt & 1); - position.set(Position.PREFIX_IN + 2, inputStatusInt & 2); + position.set(Position.PREFIX_IN + 1, (boolean) BitUtil.check(inputStatusInt, 0)); + position.set(Position.PREFIX_IN + 2, (boolean) BitUtil.check(inputStatusInt, 1)); + if ("SF-Lite".equals(model)) { + position.set(Position.PREFIX_IN + 3, false); + } + return null; + } else if (inputStatus >= 'O' && inputStatus <= 'R') { + int inputStatusInt = inputStatus - 'O'; + position.set(Position.PREFIX_IN + 1, (boolean) BitUtil.check(inputStatusInt, 0)); + position.set(Position.PREFIX_IN + 2, (boolean) BitUtil.check(inputStatusInt, 1)); + if ("SF-Lite".equals(model)) { + position.set(Position.PREFIX_IN + 3, true); + } return null; } } return event; + } private void sendEventResponse( @@ -132,6 +146,9 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { case "3": responseCode = "d"; break; + case "M": + responseCode = "m"; + break; case "S": case "T": responseCode = "t"; @@ -209,6 +226,8 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { return null; } + String model = getCacheManager().getObject(Device.class, deviceSession.getDeviceId()).getModel(); + Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); @@ -230,12 +249,17 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { String event = parser.next(); position.set(Position.KEY_ALARM, decodeAlarm(event)); - position.set(Position.KEY_EVENT, decodeEvent(event, position)); + position.set(Position.KEY_EVENT, decodeEvent(event, position, model)); position.set(Position.KEY_BATTERY, Double.parseDouble(parser.next().replaceAll("\\.", "")) * 0.001); position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); position.set(Position.KEY_GPS, parser.nextInt()); position.set(Position.PREFIX_ADC + 1, parser.nextDouble() * 0.001); - position.set(Position.PREFIX_ADC + 2, parser.nextDouble() * 0.001); + + if ("AVL110".equals(model) || "AVL120".equals(model)) { + position.set(Position.PREFIX_ADC + 2, parser.nextDouble() * 0.001); + } else { + parser.next(); + } Integer lac = parser.nextHexInt(); Integer cid = parser.nextHexInt(); |