aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent90416b230c97c470b0b942c643fce2bb5afbcb5d (diff)
downloadtrackermap-server-f8e1a7eb00a6bd11543dc8e3ee1ef43e2ccd7bc2.tar.gz
trackermap-server-f8e1a7eb00a6bd11543dc8e3ee1ef43e2ccd7bc2.tar.bz2
trackermap-server-f8e1a7eb00a6bd11543dc8e3ee1ef43e2ccd7bc2.zip
Support photo files
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolDecoder.java39
-rw-r--r--src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java2
-rw-r--r--src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java3
3 files changed, 43 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();
diff --git a/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java
index 12f63ef7d..4c7b09bcc 100644
--- a/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class RuptelaProtocolDecoderTest extends ProtocolTest {
RuptelaProtocolDecoder decoder = new RuptelaProtocolDecoder(null);
verifyNull(decoder, binary(
+ "03fc0003142b0c152acd2502003544444131464144000a0000ffd8ffe000104a46494600010100000100010000ffdb00c50006040506050406060506070706080a100a0a09090a140e0f0c1017141818171416161a1d251f1a1b231c1616202c20232627292a29191f2d302d283025282928010707070a080a130a0a13281a161a2828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828020707070a080a130a0a13281a161a2828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828282828ffc000110800f0014003012200021101031102ffc401a20000010501010101010100000000000000000102030405060708090a0b100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa0100030101010101010101010000000000000102030405060708090a0b1100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffdd00040000ffda000c03010002110311003f00e27534fde484fa66950079add40e153754d73892794f552e00a6da0c4b282794f947d2aa92b2b1d7887795fb9b5a4200eee7e957e6bdfb2b0f2cb6eff669cba4dee99656d25f5acb02dd209622e38753d08fc315177cf151562e337196e8e46f5352cb5d6603cd52ebeb8c1adcb4be82e07eedc67d0f06b8f071daa64618c8383508573ae991251891430f7a836cd07fa97de9fdc7fe86b0adf51b8830377989e8d5a96daa413603131bfa350061fc49d41adbc39e5edc34ee14f7c639af1b91f2719aef7e2c5d4bf6cb780b7ee7607500f19e735e7a06e3c9e2b4a4b4b88b51b2aaf14bbc1351226796a79e3815b81283c500d460d381a405988d7a6785ad8c3a241bc9f9f2e47d7ffad5e73a5db35dddc30a757603e83bd7aba011c6a8bc2a8000a89e8807b1551815a5636fba38ce3af359248cd7516298862ff7456713fc58"));
+
+ verifyNull(decoder, binary(
"002e000315bc70d3e2ff0f4f42443130302e30312e30382e30300000c2b30ea77e430000601b000001f40000003c00144aa0"));
verifyAttributes(decoder, binary(