From 5d9be1c5eebcd6da5a39a774a770a1020b7414dd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 8 Apr 2017 11:43:38 +1200 Subject: Implement Ulbotech acknowledgement --- .../traccar/protocol/UlbotechProtocolDecoder.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/org/traccar') diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index 97912e128..b5d60431d 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -22,6 +22,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.Context; import org.traccar.DeviceSession; import org.traccar.helper.BitUtil; +import org.traccar.helper.Checksum; import org.traccar.helper.DateBuilder; import org.traccar.helper.ObdDecoder; import org.traccar.helper.Parser; @@ -340,8 +341,27 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer buf = (ChannelBuffer) msg; if (buf.getUnsignedByte(buf.readerIndex()) == 0xF8) { + + if (channel != null) { + ChannelBuffer response = ChannelBuffers.dynamicBuffer(); + response.writeByte(0xF8); + response.writeByte(DATA_GPS); + response.writeByte(0xFE); + response.writeShort(buf.getShort(response.writerIndex() - 1 - 2)); + response.writeShort(Checksum.crc16(Checksum.CRC16_XMODEM, response.toByteBuffer(1, 4))); + response.writeByte(0xF8); + channel.write(response); + } + return decodeBinary(channel, remoteAddress, buf); } else { + + if (channel != null) { + channel.write(ChannelBuffers.copiedBuffer(String.format("*TS01,ACK:%04X#", + Checksum.crc16(Checksum.CRC16_XMODEM, buf.toByteBuffer(1, buf.writerIndex() - 2))), + StandardCharsets.US_ASCII)); + } + return decodeText(channel, remoteAddress, buf.toString(StandardCharsets.US_ASCII)); } } -- cgit v1.2.3