aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-03-28 02:24:49 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2018-03-28 02:24:50 +1300
commit96f2d637d35fafa6226855eea6e39919848e1e80 (patch)
tree63b43403355bba2de21edcf1a03a98f310ac143d /src/org/traccar/protocol
parent25d8e41ec8402c915e582874dd246b7c6bb0e5e8 (diff)
downloadtrackermap-server-96f2d637d35fafa6226855eea6e39919848e1e80.tar.gz
trackermap-server-96f2d637d35fafa6226855eea6e39919848e1e80.tar.bz2
trackermap-server-96f2d637d35fafa6226855eea6e39919848e1e80.zip
Implement Continental ACK response
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/ContinentalProtocolDecoder.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/ContinentalProtocolDecoder.java b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
index 2138eb39e..726d9e16b 100644
--- a/src/org/traccar/protocol/ContinentalProtocolDecoder.java
+++ b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
@@ -16,6 +16,7 @@
package org.traccar.protocol;
import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
@@ -36,6 +37,22 @@ public class ContinentalProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ACK = 0x06;
public static final int MSG_NACK = 0x15;
+ private void sendResponse(Channel channel, long serialNumber) {
+ if (channel != null) {
+ ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+
+ response.writeByte('S');
+ response.writeByte('V');
+ response.writeShort(2 + 2 + 1 + 4 + 2); // length
+ response.writeByte(1); // version
+ response.writeInt((int) serialNumber);
+ response.writeByte(0); // product
+ response.writeByte(MSG_ACK);
+
+ channel.write(response);
+ }
+ }
+
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
@@ -46,11 +63,14 @@ public class ContinentalProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // length
buf.readUnsignedByte(); // software version
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(buf.readUnsignedInt()));
+ long serialNumber = buf.readUnsignedInt();
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(serialNumber));
if (deviceSession == null) {
return null;
}
+ sendResponse(channel, serialNumber);
+
buf.readUnsignedByte(); // product
int type = buf.readUnsignedByte();