From ae2612e060e390773cc49955ddc422a889abd2f5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 6 Dec 2016 05:58:14 +1300 Subject: Request smaller photo chunk --- src/org/traccar/protocol/Pt502ProtocolDecoder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index 2d3cb9101..f3d9e8380 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -29,6 +29,10 @@ import java.util.regex.Pattern; public class Pt502ProtocolDecoder extends BaseProtocolDecoder { + private static final int MAX_CHUNK_SIZE = 960; + + private byte[] photo; + public Pt502ProtocolDecoder(Pt502Protocol protocol) { super(protocol); } @@ -92,7 +96,8 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { String type = parser.next(); if (type.startsWith("PHO") && channel != null) { - channel.write("#PHD0," + type.substring(3) + "\r\n"); + photo = new byte[Integer.parseInt(type.substring(3))]; + channel.write("#PHD0," + Math.min(photo.length, MAX_CHUNK_SIZE) + "\r\n"); } position.set(Position.KEY_ALARM, decodeAlarm(type)); -- cgit v1.2.3