aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-12-08 15:58:27 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-12-08 15:58:27 -0800
commitf8e1a7eb00a6bd11543dc8e3ee1ef43e2ccd7bc2 (patch)
tree410ae9c4c2a9e628b4003a9cdff52f6b330c9f38 /src/main/java/org/traccar/protocol
parent90416b230c97c470b0b942c643fce2bb5afbcb5d (diff)
downloadtrackermap-server-f8e1a7eb00a6bd11543dc8e3ee1ef43e2ccd7bc2.tar.gz
trackermap-server-f8e1a7eb00a6bd11543dc8e3ee1ef43e2ccd7bc2.tar.bz2
trackermap-server-f8e1a7eb00a6bd11543dc8e3ee1ef43e2ccd7bc2.zip
Support photo files
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java39
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java2
2 files changed, 40 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java
index 2d476427d..4d9ec4e01 100644
--- a/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java
@@ -19,6 +19,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
@@ -34,6 +35,8 @@ import java.util.List;
public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
+ private ByteBuf photo;
+
public RuptelaProtocolDecoder(Protocol protocol) {
super(protocol);
}
@@ -247,6 +250,42 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
return positions;
+ } else if (type == MSG_FILES) {
+
+ int subtype = buf.readUnsignedByte();
+ int source = buf.readUnsignedByte();
+
+ if (subtype == 2) {
+ ByteBuf filename = buf.readSlice(8);
+ int total = buf.readUnsignedShort();
+ int current = buf.readUnsignedShort();
+ if (photo == null) {
+ photo = Unpooled.buffer();
+ }
+ photo.writeBytes(buf.readSlice(buf.readableBytes() - 2));
+ if (current < total - 1) {
+ ByteBuf content = Unpooled.buffer();
+ content.writeByte(subtype);
+ content.writeByte(source);
+ content.writeBytes(filename);
+ content.writeShort(current + 1);
+ ByteBuf response = RuptelaProtocolEncoder.encodeContent(type, content);
+ content.release();
+ if (channel != null) {
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
+ }
+ } else {
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
+ getLastLocation(position, null);
+ position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(imei, photo, "jpg"));
+ photo.release();
+ photo = null;
+ }
+ }
+
+ return null;
+
} else {
return decodeCommandResponse(deviceSession, type, buf);
diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
index 5c053dbcb..fb0dcf690 100644
--- a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
+++ b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java
@@ -31,7 +31,7 @@ public class RuptelaProtocolEncoder extends BaseProtocolEncoder {
super(protocol);
}
- private ByteBuf encodeContent(int type, ByteBuf content) {
+ public static ByteBuf encodeContent(int type, ByteBuf content) {
ByteBuf buf = Unpooled.buffer();