diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-08 11:25:44 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-08 11:25:44 +1200 |
commit | 09e0d8de59fd662efd210be521e772ba59170c37 (patch) | |
tree | bcd1f44f25d4513c5016dfe077ec1ca48ea93603 /src/org/traccar/protocol | |
parent | a413abaf255fdb70ed8c77c801d277fbfc558bbb (diff) | |
download | trackermap-server-09e0d8de59fd662efd210be521e772ba59170c37.tar.gz trackermap-server-09e0d8de59fd662efd210be521e772ba59170c37.tar.bz2 trackermap-server-09e0d8de59fd662efd210be521e772ba59170c37.zip |
Implement PT502 photo request
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r-- | src/org/traccar/protocol/Pt502Protocol.java | 3 | ||||
-rw-r--r-- | src/org/traccar/protocol/Pt502ProtocolDecoder.java | 11 | ||||
-rw-r--r-- | src/org/traccar/protocol/Pt502ProtocolEncoder.java | 2 |
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; |