aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/Pt502Protocol.java3
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolEncoder.java2
3 files changed, 14 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Pt502Protocol.java b/src/org/traccar/protocol/Pt502Protocol.java
index 75fe0f628..1368dd7b7 100644
--- a/src/org/traccar/protocol/Pt502Protocol.java
+++ b/src/org/traccar/protocol/Pt502Protocol.java
@@ -33,7 +33,8 @@ public class Pt502Protocol extends BaseProtocol {
setSupportedCommands(
Command.TYPE_SET_TIMEZONE,
Command.TYPE_ALARM_SPEED,
- Command.TYPE_OUTPUT_CONTROL);
+ Command.TYPE_OUTPUT_CONTROL,
+ Command.TYPE_REQUEST_PHOTO);
}
@Override
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index 850e9fcff..424d491ae 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -60,7 +60,16 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- Parser parser = new Parser(PATTERN, (String) msg);
+ String sentence = (String) msg;
+
+ if (sentence.startsWith("$PHO")) {
+ if (channel != null) {
+ channel.write("#PHD0," + sentence.substring(4));
+ }
+ return null;
+ }
+
+ Parser parser = new Parser(PATTERN, sentence);
if (!parser.matches()) {
return null;
}
diff --git a/src/org/traccar/protocol/Pt502ProtocolEncoder.java b/src/org/traccar/protocol/Pt502ProtocolEncoder.java
index b8ca8ab15..d8aeb6e5d 100644
--- a/src/org/traccar/protocol/Pt502ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolEncoder.java
@@ -31,6 +31,8 @@ public class Pt502ProtocolEncoder extends StringProtocolEncoder {
return formatCommand(command, "#TMZ{%s}\r\n", Command.KEY_TIMEZONE);
case Command.TYPE_ALARM_SPEED:
return formatCommand(command, "#SPD{%s}\r\n", Command.KEY_DATA);
+ case Command.TYPE_REQUEST_PHOTO:
+ return formatCommand(command, "#PHO\r\n");
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;