From 1cf3134cd4212462aec79419a7eac9fe053ac966 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 8 Mar 2017 20:36:34 +1300 Subject: Fix Laipac protocol acknowledgement --- .../traccar/protocol/LaipacProtocolDecoder.java | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java index a0e394d2c..62bc8fa37 100644 --- a/src/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,21 +91,23 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { String type = parser.next(); String checksum = parser.next(); - String response = null; - - if (type.equals("0") && Character.isLowerCase(status.charAt(0))) { - response = "$EAVACK,0," + checksum; - response += Checksum.nmea(response); - } else if (type.equals("S") || type.equals("T")) { - response = "$AVCFG,00000000,t*21"; - } else if (type.equals("3")) { - response = "$AVCFG,00000000,d*31"; - } else if (type.equals("X") || type.equals("4")) { - response = "$AVCFG,00000000,x*2D"; - } - if (response != null && channel != null) { - channel.write(response + "\r\n"); + if (channel != null) { + + if (Character.isLowerCase(status.charAt(0))) { + String response = "$EAVACK," + type + "," + checksum; + response += Checksum.nmea(response); + channel.write(response); + } + + if (type.equals("S") || type.equals("T")) { + channel.write("$AVCFG,00000000,t*21"); + } else if (type.equals("3")) { + channel.write("$AVCFG,00000000,d*31"); + } else if (type.equals("X") || type.equals("4")) { + channel.write("$AVCFG,00000000,x*2D"); + } + } return position; -- cgit v1.2.3