aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-04-17 00:34:04 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-04-17 09:34:25 +1200
commitfb4f041b75d5a8e7630dccf3dbd67840d8417629 (patch)
tree523def5b40ffc9e8026d83e03db05bbcd4dbf5a5 /src/org/traccar/protocol
parent171896fdbaa498fea269a5c163617c29a66c722b (diff)
downloadtraccar-server-fb4f041b75d5a8e7630dccf3dbd67840d8417629.tar.gz
traccar-server-fb4f041b75d5a8e7630dccf3dbd67840d8417629.tar.bz2
traccar-server-fb4f041b75d5a8e7630dccf3dbd67840d8417629.zip
Update Continental protocol
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/ContinentalProtocol.java2
-rw-r--r--src/org/traccar/protocol/ContinentalProtocolDecoder.java34
2 files changed, 15 insertions, 21 deletions
diff --git a/src/org/traccar/protocol/ContinentalProtocol.java b/src/org/traccar/protocol/ContinentalProtocol.java
index e2b1226cf..5f43a51f7 100644
--- a/src/org/traccar/protocol/ContinentalProtocol.java
+++ b/src/org/traccar/protocol/ContinentalProtocol.java
@@ -34,7 +34,7 @@ public class ContinentalProtocol extends BaseProtocol {
serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2));
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
pipeline.addLast("objectDecoder", new ContinentalProtocolDecoder(ContinentalProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/ContinentalProtocolDecoder.java b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
index 726d9e16b..37913b657 100644
--- a/src/org/traccar/protocol/ContinentalProtocolDecoder.java
+++ b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
@@ -16,10 +16,10 @@
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;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -37,22 +37,6 @@ 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 {
@@ -69,8 +53,6 @@ public class ContinentalProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- sendResponse(channel, serialNumber);
-
buf.readUnsignedByte(); // product
int type = buf.readUnsignedByte();
@@ -96,13 +78,25 @@ public class ContinentalProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceTime(new Date(buf.readUnsignedInt() * 1000L));
position.set(Position.KEY_EVENT, buf.readUnsignedShort());
- position.set(Position.KEY_INPUT, buf.readUnsignedShort());
+
+ int input = buf.readUnsignedShort();
+ position.set(Position.KEY_IGNITION, BitUtil.check(input, 0));
+ position.set(Position.KEY_INPUT, input);
+
position.set(Position.KEY_OUTPUT, buf.readUnsignedShort());
position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
position.set(Position.KEY_DEVICE_TEMP, buf.readByte());
buf.readUnsignedShort(); // reserved
+ if (buf.readableBytes() > 4) {
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ }
+
+ if (buf.readableBytes() > 4) {
+ position.set(Position.KEY_HOURS, buf.readUnsignedInt());
+ }
+
return position;
}