aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-02 10:47:36 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-02 10:47:36 +1300
commitf5d687b7adb86e259f7b1f3b04a48d625cf1ca5e (patch)
treeeef1f44b391c1237eae0f5beb175b7c5188b7b98 /src
parentea5d08507fc82073bf198b2c3fffd90870d291d3 (diff)
downloadtrackermap-server-f5d687b7adb86e259f7b1f3b04a48d625cf1ca5e.tar.gz
trackermap-server-f5d687b7adb86e259f7b1f3b04a48d625cf1ca5e.tar.bz2
trackermap-server-f5d687b7adb86e259f7b1f3b04a48d625cf1ca5e.zip
Implement Meitrack photo request
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/protocol/MeitrackProtocol.java7
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolEncoder.java12
3 files changed, 24 insertions, 11 deletions
diff --git a/src/org/traccar/protocol/MeitrackProtocol.java b/src/org/traccar/protocol/MeitrackProtocol.java
index c957d4ea1..266d9bcd5 100644
--- a/src/org/traccar/protocol/MeitrackProtocol.java
+++ b/src/org/traccar/protocol/MeitrackProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,8 @@ public class MeitrackProtocol extends BaseProtocol {
Command.TYPE_ENGINE_STOP,
Command.TYPE_ENGINE_RESUME,
Command.TYPE_ALARM_ARM,
- Command.TYPE_ALARM_DISARM);
+ Command.TYPE_ALARM_DISARM,
+ Command.TYPE_REQUEST_PHOTO);
}
@Override
@@ -45,6 +46,7 @@ public class MeitrackProtocol extends BaseProtocol {
pipeline.addLast("frameDecoder", new MeitrackFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
+ pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
@@ -54,6 +56,7 @@ public class MeitrackProtocol extends BaseProtocol {
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
+ pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index e0ca01412..a920c6e76 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -24,6 +24,7 @@ import java.util.regex.Pattern;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.Context;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -237,10 +238,17 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
index = buf.indexOf(index + 1, buf.writerIndex(), (byte) ',');
String type = buf.toString(index + 1, 3, Charset.defaultCharset());
- if (type.equals("CCC")) {
- return decodeBinaryMessage(channel, remoteAddress, buf);
- } else {
- return decodeRegularMessage(channel, remoteAddress, buf);
+ switch (type) {
+ case "D03":
+ if (channel != null) {
+ String imei = Context.getIdentityManager().getDeviceById(getDeviceId()).getUniqueId();
+ channel.write("@@O46," + imei + ",D00,camera_picture.jpg,0*00\r\n");
+ }
+ return null;
+ case "CCC":
+ return decodeBinaryMessage(channel, remoteAddress, buf);
+ default:
+ return decodeRegularMessage(channel, remoteAddress, buf);
}
}
diff --git a/src/org/traccar/protocol/MeitrackProtocolEncoder.java b/src/org/traccar/protocol/MeitrackProtocolEncoder.java
index bfda2b7d2..90fa5b624 100644
--- a/src/org/traccar/protocol/MeitrackProtocolEncoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,13 +26,15 @@ public class MeitrackProtocolEncoder extends StringProtocolEncoder {
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
- return formatCommand(command, "@@M33,{%s},C01,0,12222*18\r\n", Command.KEY_UNIQUE_ID);
+ return formatCommand(command, "@@M33,{%s},C01,0,12222*00\r\n", Command.KEY_UNIQUE_ID);
case Command.TYPE_ENGINE_RESUME:
- return formatCommand(command, "@@M33,{%s},C01,0,02222*18\r\n", Command.KEY_UNIQUE_ID);
+ return formatCommand(command, "@@M33,{%s},C01,0,02222*00\r\n", Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_ARM:
- return formatCommand(command, "@@M33,{%s},C01,0,22122*18\r\n", Command.KEY_UNIQUE_ID);
+ return formatCommand(command, "@@M33,{%s},C01,0,22122*00\r\n", Command.KEY_UNIQUE_ID);
case Command.TYPE_ALARM_DISARM:
- return formatCommand(command, "@@M33,{%s},C01,0,22022*18\r\n", Command.KEY_UNIQUE_ID);
+ return formatCommand(command, "@@M33,{%s},C01,0,22022*00\r\n", Command.KEY_UNIQUE_ID);
+ case Command.TYPE_REQUEST_PHOTO:
+ return formatCommand(command, "@@D46,{%s},D03,1,camera_picture.jpg*00\r\n", Command.KEY_UNIQUE_ID);
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;