aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-04-08 11:43:38 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-04-08 11:43:38 +1200
commit5d9be1c5eebcd6da5a39a774a770a1020b7414dd (patch)
tree6988224b1b8a2a418bcff90649ccbfdf04c999f4 /src/org/traccar
parent718b65194f146b05a4100f35ce8008d3cff6540c (diff)
downloadtraccar-server-5d9be1c5eebcd6da5a39a774a770a1020b7414dd.tar.gz
traccar-server-5d9be1c5eebcd6da5a39a774a770a1020b7414dd.tar.bz2
traccar-server-5d9be1c5eebcd6da5a39a774a770a1020b7414dd.zip
Implement Ulbotech acknowledgement
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java20
1 files changed, 20 insertions, 0 deletions
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));
}
}