aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-06-29 10:49:13 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-06-29 10:49:13 +1200
commit55448d82b2971bc16c67bfa2b2e996d81c4c702e (patch)
tree565ee245ea0e98b88674b775147fbc6d3e1933cb /src/org/traccar
parent88b3f00f3855aa408c7859051efdcb5b37fe559f (diff)
parentd1c4cd526845aad56c5b0a3e20454638bbc7fecc (diff)
downloadtrackermap-server-55448d82b2971bc16c67bfa2b2e996d81c4c702e.tar.gz
trackermap-server-55448d82b2971bc16c67bfa2b2e996d81c4c702e.tar.bz2
trackermap-server-55448d82b2971bc16c67bfa2b2e996d81c4c702e.zip
Merge branch implement commands (fix #1271)
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/BaseProtocol.java40
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java21
-rw-r--r--src/org/traccar/Protocol.java15
-rw-r--r--src/org/traccar/ServerManager.java1376
-rw-r--r--src/org/traccar/TrackerServer.java2
-rw-r--r--src/org/traccar/database/ActiveDevice.java37
-rw-r--r--src/org/traccar/database/DataManager.java13
-rw-r--r--src/org/traccar/http/CommandsServlet.java58
-rw-r--r--src/org/traccar/http/EnumFactory.java20
-rw-r--r--src/org/traccar/http/JsonConverter.java44
-rw-r--r--src/org/traccar/http/WebServer.java1
-rw-r--r--src/org/traccar/http/commands/CommandType.java28
-rw-r--r--src/org/traccar/http/commands/Duration.java38
-rw-r--r--src/org/traccar/http/commands/FixPositioningCommand.java25
-rw-r--r--src/org/traccar/http/commands/GpsCommand.java27
-rw-r--r--src/org/traccar/http/commands/NoParameterCommand.java11
-rw-r--r--src/org/traccar/protocol/ApelProtocol.java38
-rw-r--r--src/org/traccar/protocol/ApelProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/AplicomProtocol.java34
-rw-r--r--src/org/traccar/protocol/AplicomProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Ardi01Protocol.java37
-rw-r--r--src/org/traccar/protocol/Ardi01ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/AtrackProtocol.java41
-rw-r--r--src/org/traccar/protocol/AtrackProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/AutoFon45Protocol.java34
-rw-r--r--src/org/traccar/protocol/AutoFon45ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/AutoFonProtocol.java34
-rw-r--r--src/org/traccar/protocol/AutoFonProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Avl301Protocol.java35
-rw-r--r--src/org/traccar/protocol/Avl301ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/BceProtocol.java37
-rw-r--r--src/org/traccar/protocol/BceProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/BoxProtocol.java37
-rw-r--r--src/org/traccar/protocol/BoxProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CalAmpProtocol.java33
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CarTrackProtocol.java37
-rw-r--r--src/org/traccar/protocol/CarTrackProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CarscopProtocol.java39
-rw-r--r--src/org/traccar/protocol/CarscopProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CastelProtocol.java48
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CellocatorProtocol.java37
-rw-r--r--src/org/traccar/protocol/CellocatorProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/EasyTrackProtocol.java37
-rw-r--r--src/org/traccar/protocol/EasyTrackProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/EelinkProtocol.java35
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/EnforaProtocol.java35
-rw-r--r--src/org/traccar/protocol/EnforaProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Ev603Protocol.java37
-rw-r--r--src/org/traccar/protocol/Ev603ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/FreedomProtocol.java37
-rw-r--r--src/org/traccar/protocol/FreedomProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/GalileoProtocol.java37
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/GatorProtocol.java33
-rw-r--r--src/org/traccar/protocol/GatorProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Gl100Protocol.java39
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Gl200Protocol.java50
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocol.java39
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/GoSafeProtocol.java37
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/GotopProtocol.java37
-rw-r--r--src/org/traccar/protocol/GotopProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Gps103Protocol.java62
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/GpsGateProtocol.java39
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Gt02Protocol.java35
-rw-r--r--src/org/traccar/protocol/Gt02ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Gt06Protocol.java79
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/H02Protocol.java34
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/HaicomProtocol.java37
-rw-r--r--src/org/traccar/protocol/HaicomProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/IntellitracProtocol.java38
-rw-r--r--src/org/traccar/protocol/IntellitracProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Jt600Protocol.java34
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/KhdProtocol.java35
-rw-r--r--src/org/traccar/protocol/KhdProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/LaipacProtocol.java39
-rw-r--r--src/org/traccar/protocol/LaipacProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/M2mProtocol.java35
-rw-r--r--src/org/traccar/protocol/M2mProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/ManPowerProtocol.java39
-rw-r--r--src/org/traccar/protocol/ManPowerProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/MaxonProtocol.java39
-rw-r--r--src/org/traccar/protocol/MaxonProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/MegastekProtocol.java39
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocol.java34
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/MeitrackProtocol.java39
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocol.java37
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Mta6Protocol.java37
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/Mta6canProtocol.java37
-rw-r--r--src/org/traccar/protocol/MtxProtocol.java39
-rw-r--r--src/org/traccar/protocol/MtxProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/MxtProtocol.java37
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/NavigilProtocol.java37
-rw-r--r--src/org/traccar/protocol/NavigilProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/NavisProtocol.java38
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/NoranProtocol.java36
-rw-r--r--src/org/traccar/protocol/NoranProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/OrionProtocol.java37
-rw-r--r--src/org/traccar/protocol/OrionProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/OsmAndProtocol.java37
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/PiligrimProtocol.java39
-rw-r--r--src/org/traccar/protocol/PiligrimProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/ProgressProtocol.java38
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Pt3000Protocol.java39
-rw-r--r--src/org/traccar/protocol/Pt3000ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Pt502Protocol.java39
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/RitiProtocol.java38
-rw-r--r--src/org/traccar/protocol/RitiProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/RuptelaProtocol.java35
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/SanavProtocol.java37
-rw-r--r--src/org/traccar/protocol/SanavProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/SkypatrolProtocol.java33
-rw-r--r--src/org/traccar/protocol/SkypatrolProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Stl060Protocol.java36
-rw-r--r--src/org/traccar/protocol/Stl060ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/SuntechProtocol.java37
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/SyrusProtocol.java39
-rw-r--r--src/org/traccar/protocol/SyrusProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/T55Protocol.java39
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java22
-rw-r--r--src/org/traccar/protocol/TaipProtocol.java35
-rw-r--r--src/org/traccar/protocol/TelikProtocol.java37
-rw-r--r--src/org/traccar/protocol/TelikProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocol.java34
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Tk102Protocol.java39
-rw-r--r--src/org/traccar/protocol/Tk102ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Tk103Protocol.java48
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocol.java39
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/TopflytechProtocol.java37
-rw-r--r--src/org/traccar/protocol/TopflytechProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/TotemProtocol.java36
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Tr20Protocol.java39
-rw-r--r--src/org/traccar/protocol/Tr20ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Tr900Protocol.java49
-rw-r--r--src/org/traccar/protocol/Tr900ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/TrackboxProtocol.java39
-rw-r--r--src/org/traccar/protocol/TrackboxProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/TramigoProtocol.java37
-rw-r--r--src/org/traccar/protocol/TramigoProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/TytanProtocol.java33
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/UlbotechProtocol.java34
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/V680Protocol.java37
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/VisiontekProtocol.java37
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/WialonProtocol.java39
-rw-r--r--src/org/traccar/protocol/WialonProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/WondexProtocol.java36
-rw-r--r--src/org/traccar/protocol/WondexProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Xexun2ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/XexunProtocol.java44
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/XirgoProtocol.java39
-rw-r--r--src/org/traccar/protocol/XirgoProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Xt013Protocol.java37
-rw-r--r--src/org/traccar/protocol/Xt013ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Xt7Protocol.java35
-rw-r--r--src/org/traccar/protocol/Xt7ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/YwtProtocol.java39
-rw-r--r--src/org/traccar/protocol/YwtProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/commands/CommandTemplate.java8
-rw-r--r--src/org/traccar/protocol/commands/CommandValueConversion.java5
-rw-r--r--src/org/traccar/protocol/commands/StringCommandTemplate.java56
192 files changed, 4141 insertions, 1621 deletions
diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java
new file mode 100644
index 000000000..f8bf7ef30
--- /dev/null
+++ b/src/org/traccar/BaseProtocol.java
@@ -0,0 +1,40 @@
+package org.traccar;
+
+import org.traccar.database.ActiveDevice;
+import org.traccar.http.commands.CommandType;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.GpsCommand;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class BaseProtocol implements Protocol {
+
+ private final String name;
+ private Map<CommandType, CommandTemplate> commandTemplates = new HashMap<CommandType, CommandTemplate>();
+
+ public BaseProtocol(String name) {
+ this.name = name;
+ this.loadCommandsTemplates(commandTemplates);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void sendCommand(ActiveDevice activeDevice, GpsCommand command) {
+ CommandTemplate commandMessage = commandTemplates.get(command.getType());
+
+ if (commandMessage == null) {
+ throw new RuntimeException("The command " + command + " is not yet supported in protocol " + this.getName());
+ }
+
+ Object response = commandMessage.applyTo(activeDevice, command);
+
+ activeDevice.write(response);
+ }
+
+ protected abstract void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates);
+
+}
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index b10f4d355..6e9efd830 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -16,7 +16,6 @@
package org.traccar;
import java.net.SocketAddress;
-import java.util.Properties;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelEvent;
@@ -25,7 +24,6 @@ import static org.jboss.netty.channel.Channels.fireMessageReceived;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
-import org.traccar.database.DataManager;
import org.traccar.helper.Log;
import org.traccar.model.Device;
@@ -34,10 +32,10 @@ import org.traccar.model.Device;
*/
public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
- private final String protocol;
+ private final Protocol protocol;
- public String getProtocol() {
- return protocol;
+ public String getProtocolName() {
+ return protocol.getName();
}
private long deviceId;
@@ -50,11 +48,12 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
return deviceId;
}
- public boolean identify(String uniqueId, boolean logWarning) {
+ public boolean identify(String uniqueId, Channel channel, SocketAddress remoteAddress, boolean logWarning) {
try {
Device device = Context.getDataManager().getDeviceByUniqueId(uniqueId);
if (device != null) {
deviceId = device.getId();
+ Context.getDataManager().setActiveDevice(device.getUniqueId(), protocol, channel, remoteAddress);
return true;
} else {
deviceId = 0;
@@ -70,11 +69,15 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
}
}
- public boolean identify(String uniqueId) {
- return identify(uniqueId, true);
+ public boolean identify(String uniqueId, Channel channel, SocketAddress remoteAddress) {
+ return identify(uniqueId, channel, remoteAddress, true);
}
- public BaseProtocolDecoder(String protocol) {
+ public boolean identify(String uniqueId, Channel channel) {
+ return identify(uniqueId, channel, null, true);
+ }
+
+ public BaseProtocolDecoder(Protocol protocol) {
this.protocol = protocol;
}
diff --git a/src/org/traccar/Protocol.java b/src/org/traccar/Protocol.java
new file mode 100644
index 000000000..bcb591aaf
--- /dev/null
+++ b/src/org/traccar/Protocol.java
@@ -0,0 +1,15 @@
+package org.traccar;
+
+import org.traccar.database.ActiveDevice;
+import org.traccar.http.commands.GpsCommand;
+
+import java.util.List;
+
+public interface Protocol {
+
+ public String getName();
+
+ void sendCommand(ActiveDevice activeDevice, GpsCommand command);
+
+ void addTrackerServersTo(List<TrackerServer> serverList);
+}
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index 3ad7cb474..bf6e87e17 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -32,100 +32,99 @@ import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.protocol.*;
-
public class ServerManager {
private final List<TrackerServer> serverList = new LinkedList<TrackerServer>();
public void init() throws Exception {
- initGps103Server("gps103");
- initTk103Server("tk103");
- initGl100Server("gl100");
- initGl200Server("gl200");
- initT55Server("t55");
- initXexunServer("xexun");
- initTotemServer("totem");
- initEnforaServer("enfora");
- initMeiligaoServer("meiligao");
- initMaxonServer("maxon");
- initSuntechServer("suntech");
- initProgressServer("progress");
- initH02Server("h02");
- initJt600Server("jt600");
- initEv603Server("ev603");
- initV680Server("v680");
- initPt502Server("pt502");
- initTr20Server("tr20");
- initNavisServer("navis");
- initMeitrackServer("meitrack");
- initSkypatrolServer("skypatrol");
- initGt02Server("gt02");
- initGt06Server("gt06");
- initMegastekServer("megastek");
- initNavigilServer("navigil");
- initGpsGateServer("gpsgate");
- initTeltonikaServer("teltonika");
- initMta6Server("mta6");
- initMta6CanServer("mta6can");
- initTlt2hServer("tlt2h");
- initSyrusServer("syrus");
- initWondexServer("wondex");
- initCellocatorServer("cellocator");
- initGalileoServer("galileo");
- initYwtServer("ywt");
- initTk102Server("tk102");
- initIntellitracServer("intellitrac");
- initXt7Server("xt7");
- initWialonServer("wialon");
- initCarscopServer("carscop");
- initApelServer("apel");
- initManPowerServer("manpower");
- initGlobalSatServer("globalsat");
- initAtrackServer("atrack");
- initPt3000Server("pt3000");
- initRuptelaServer("ruptela");
- initTopflytechServer("topflytech");
- initLaipacServer("laipac");
- initAplicomServer("aplicom");
- initGotopServer("gotop");
- initSanavServer("sanav");
- initGatorServer("gator");
- initNoranServer("noran");
- initM2mServer("m2m");
- initOsmAndServer("osmand");
- initEasyTrackServer("easytrack");
- initTaipServer("taip");
- initKhdServer("khd");
- initPiligrimServer("piligrim");
- initStl060Server("stl060");
- initCarTrackServer("cartrack");
- initMiniFinderServer("minifinder");
- initHaicomServer("haicom");
- initEelinkServer("eelink");
- initBoxServer("box");
- initFreedomServer("freedom");
- initTelikServer("telik");
- initTrackboxServer("trackbox");
- initVisiontekServer("visiontek");
- initOrionServer("orion");
- initRitiServer("riti");
- initUlbotechServer("ulbotech");
- initTramigoServer("tramigo");
- initTr900Server("tr900");
- initArdi01Server("ardi01");
- initXt013Server("xt013");
- initAutoFonServer("autofon");
- initGoSafeServer("gosafe");
- initAutoFon45Server("autofon45");
- initBceServer("bce");
- initXirgoServer("xirgo");
- initCalAmpServer("calamp");
- initMtxServer("mtx");
- initTytanServer("tytan");
- initAvl301Server("avl301");
- initCastelServer("castel");
- initMxtServer("mxt");
+ initProtocolServer(new Gps103Protocol());
+ initProtocolServer(new Tk103Protocol());
+ initProtocolServer(new Gl100Protocol());
+ initProtocolServer(new Gl200Protocol());
+ initProtocolServer(new T55Protocol());
+ initProtocolServer(new XexunProtocol());
+ initProtocolServer(new TotemProtocol());
+ initProtocolServer(new EnforaProtocol());
+ initProtocolServer(new MeiligaoProtocol());
+ initProtocolServer(new MaxonProtocol());
+ initProtocolServer(new SuntechProtocol());
+ initProtocolServer(new ProgressProtocol());
+ initProtocolServer(new H02Protocol());
+ initProtocolServer(new Jt600Protocol());
+ initProtocolServer(new Ev603Protocol());
+ initProtocolServer(new V680Protocol());
+ initProtocolServer(new Pt502Protocol());
+ initProtocolServer(new Tr20Protocol());
+ initProtocolServer(new NavisProtocol());
+ initProtocolServer(new MeitrackProtocol());
+ initProtocolServer(new SkypatrolProtocol());
+ initProtocolServer(new Gt02Protocol());
+ initProtocolServer(new Gt06Protocol());
+ initProtocolServer(new MegastekProtocol());
+ initProtocolServer(new NavigilProtocol());
+ initProtocolServer(new GpsGateProtocol());
+ initProtocolServer(new TeltonikaProtocol());
+ initProtocolServer(new Mta6Protocol());
+ initProtocolServer(new Mta6canProtocol());
+ initProtocolServer(new Tlt2hProtocol());
+ initProtocolServer(new SyrusProtocol());
+ initProtocolServer(new WondexProtocol());
+ initProtocolServer(new CellocatorProtocol());
+ initProtocolServer(new GalileoProtocol());
+ initProtocolServer(new YwtProtocol());
+ initProtocolServer(new Tk102Protocol());
+ initProtocolServer(new IntellitracProtocol());
+ initProtocolServer(new Xt7Protocol());
+ initProtocolServer(new WialonProtocol());
+ initProtocolServer(new CarscopProtocol());
+ initProtocolServer(new ApelProtocol());
+ initProtocolServer(new ManPowerProtocol());
+ initProtocolServer(new GlobalSatProtocol());
+ initProtocolServer(new AtrackProtocol());
+ initProtocolServer(new Pt3000Protocol());
+ initProtocolServer(new RuptelaProtocol());
+ initProtocolServer(new TopflytechProtocol());
+ initProtocolServer(new LaipacProtocol());
+ initProtocolServer(new AplicomProtocol());
+ initProtocolServer(new GotopProtocol());
+ initProtocolServer(new SanavProtocol());
+ initProtocolServer(new GatorProtocol());
+ initProtocolServer(new NoranProtocol());
+ initProtocolServer(new M2mProtocol());
+ initProtocolServer(new OsmAndProtocol());
+ initProtocolServer(new EasyTrackProtocol());
+ initProtocolServer(new TaipProtocol());
+ initProtocolServer(new KhdProtocol());
+ initProtocolServer(new PiligrimProtocol());
+ initProtocolServer(new Stl060Protocol());
+ initProtocolServer(new CarTrackProtocol());
+ initProtocolServer(new MiniFinderProtocol());
+ initProtocolServer(new HaicomProtocol());
+ initProtocolServer(new EelinkProtocol());
+ initProtocolServer(new BoxProtocol());
+ initProtocolServer(new FreedomProtocol());
+ initProtocolServer(new TelikProtocol());
+ initProtocolServer(new TrackboxProtocol());
+ initProtocolServer(new VisiontekProtocol());
+ initProtocolServer(new OrionProtocol());
+ initProtocolServer(new RitiProtocol());
+ initProtocolServer(new UlbotechProtocol());
+ initProtocolServer(new TramigoProtocol());
+ initProtocolServer(new Tr900Protocol());
+ initProtocolServer(new Ardi01Protocol());
+ initProtocolServer(new Xt013Protocol());
+ initProtocolServer(new AutoFonProtocol());
+ initProtocolServer(new GoSafeProtocol());
+ initProtocolServer(new AutoFon45Protocol());
+ initProtocolServer(new BceProtocol());
+ initProtocolServer(new XirgoProtocol());
+ initProtocolServer(new CalAmpProtocol());
+ initProtocolServer(new MtxProtocol());
+ initProtocolServer(new TytanProtocol());
+ initProtocolServer(new Avl301Protocol());
+ initProtocolServer(new CastelProtocol());
+ initProtocolServer(new MxtProtocol());
initProtocolDetector();
}
@@ -168,1204 +167,9 @@ public class ServerManager {
}
}
- private void initGps103Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r\n", "\n", ";"));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(protocol));
- }
- });
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTk103Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(protocol));
- }
- });
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGl100Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\0'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGl200Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "$", "\0"));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(protocol));
- }
- });
-
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
-
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initT55Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new T55ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initXexunServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- if (Boolean.valueOf(Context.getProps().getProperty(protocol + ".extended"))) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); // tracker bug \n\r
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Xexun2ProtocolDecoder(protocol));
- } else {
- pipeline.addLast("frameDecoder", new XexunFrameDecoder());
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new XexunProtocolDecoder(protocol));
- }
- }
- });
- }
- }
-
- private void initTotemServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new TotemFrameDecoder());
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new TotemProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initEnforaServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2));
- pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initMeiligaoServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new MeiligaoFrameDecoder());
- pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initMaxonServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initSuntechServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new SuntechProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initProgressServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0));
- pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initH02Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new H02FrameDecoder());
- pipeline.addLast("objectDecoder", new H02ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initJt600Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new Jt600FrameDecoder());
- pipeline.addLast("objectDecoder", new Jt600ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initEv603Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Ev603ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initV680Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new V680ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initPt502Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new Pt502FrameDecoder());
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Pt502ProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initTr20Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tr20ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initNavisServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(4 * 1024, 12, 2, 2, 0));
- pipeline.addLast("objectDecoder", new NavisProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initMeitrackServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new MeitrackFrameDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initSkypatrolServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGt02Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0));
- pipeline.addLast("objectDecoder", new Gt02ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGt06Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new Gt06FrameDecoder());
- pipeline.addLast("objectDecoder", new Gt06ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initMegastekServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new MegastekProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initNavigilServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new NavigilFrameDecoder());
- pipeline.addLast("objectDecoder", new NavigilProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initGpsGateServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new GpsGateProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTeltonikaServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new TeltonikaFrameDecoder());
- pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initMta6Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpEncoder", new HttpResponseEncoder());
- pipeline.addLast("objectDecoder", new Mta6ProtocolDecoder(protocol, false));
- }
- });
- }
- }
-
- private void initMta6CanServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpEncoder", new HttpResponseEncoder());
- pipeline.addLast("objectDecoder", new Mta6ProtocolDecoder(protocol, true));
- }
- });
- }
- }
-
- private void initTlt2hServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(32 * 1024, "##"));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tlt2hProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initSyrusServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '<'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new SyrusProtocolDecoder(protocol, true));
- }
- });
- }
- }
-
- private void initWondexServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new WondexFrameDecoder());
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new WondexProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initCellocatorServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CellocatorFrameDecoder());
- pipeline.addLast("objectDecoder", new CellocatorProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initGalileoServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new GalileoFrameDecoder());
- pipeline.addLast("objectDecoder", new GalileoProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initYwtServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new YwtProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTk102Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ']'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tk102ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initIntellitracServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new IntellitracFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new IntellitracProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initXt7Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 20, 1, 5, 0));
- pipeline.addLast("objectDecoder", new Xt7ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initWialonServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(4 * 1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new WialonProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initCarscopServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '^'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new CarscopProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initApelServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0));
- pipeline.addLast("objectDecoder", new ApelProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initManPowerServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new ManPowerProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGlobalSatServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '!'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new GlobalSatProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initAtrackServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new AtrackFrameDecoder());
- pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(protocol));
- }
- });
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(protocol));
- }
- });
-
- }
- }
-
- private void initPt3000Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, 'd')); // probably wrong
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Pt3000ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initRuptelaServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, 2, 0));
- pipeline.addLast("objectDecoder", new RuptelaProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTopflytechServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new TopflytechProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initLaipacServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new LaipacProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initAplicomServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new AplicomFrameDecoder());
- pipeline.addLast("objectDecoder", new AplicomProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGotopServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new GotopProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initSanavServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new SanavProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGatorServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new GatorProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initNoranServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new NoranProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initM2mServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new FixedLengthFrameDecoder(23));
- pipeline.addLast("objectDecoder", new M2mProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initOsmAndServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpEncoder", new HttpResponseEncoder());
- pipeline.addLast("objectDecoder", new OsmAndProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initEasyTrackServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new EasyTrackProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTaipServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new SyrusProtocolDecoder(protocol, false));
- }
- });
- }
- }
-
- private void initKhdServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 3, 2));
- pipeline.addLast("objectDecoder", new KhdProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initPiligrimServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpAggregator", new HttpChunkAggregator(16384));
- pipeline.addLast("httpEncoder", new HttpResponseEncoder());
- pipeline.addLast("objectDecoder", new PiligrimProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initStl060Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new Stl060FrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Stl060ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initCarTrackServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new CarTrackProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initMiniFinderServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new MiniFinderProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initHaicomServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new HaicomProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initEelinkServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2));
- pipeline.addLast("objectDecoder", new EelinkProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initBoxServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new BoxProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initFreedomServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new FreedomProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTelikServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\0'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new TelikProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTrackboxServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new TrackboxProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initVisiontekServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new VisiontekProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initOrionServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new OrionFrameDecoder());
- pipeline.addLast("objectDecoder", new OrionProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initRitiServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 105, 2, 3, 0));
- pipeline.addLast("objectDecoder", new RitiProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initUlbotechServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new UlbotechFrameDecoder());
- pipeline.addLast("objectDecoder", new UlbotechProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTramigoServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new TramigoFrameDecoder());
- pipeline.addLast("objectDecoder", new TramigoProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initTr900Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(protocol));
- }
- });
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initArdi01Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Ardi01ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initXt013Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new Xt013ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initAutoFonServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new AutoFonFrameDecoder());
- pipeline.addLast("objectDecoder", new AutoFonProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initGoSafeServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("objectDecoder", new GoSafeProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initAutoFon45Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new AutoFon45FrameDecoder());
- pipeline.addLast("objectDecoder", new AutoFon45ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initBceServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new BceFrameDecoder());
- pipeline.addLast("objectDecoder", new BceProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initXirgoServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new XirgoProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initCalAmpServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new CalAmpProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initMtxServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
- pipeline.addLast("stringDecoder", new StringDecoder());
- pipeline.addLast("stringEncoder", new StringEncoder());
- pipeline.addLast("objectDecoder", new MtxProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initTytanServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new TytanProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initAvl301Server(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- serverList.add(new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, -3, 0));
- pipeline.addLast("objectDecoder", new Avl301ProtocolDecoder(protocol));
- }
- });
- }
- }
-
- private void initCastelServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
- pipeline.addLast("objectDecoder", new CastelProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
-
- server = new TrackerServer(new ConnectionlessBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("objectDecoder", new CastelProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- }
- }
-
- private void initMxtServer(final String protocol) throws SQLException {
- if (isProtocolEnabled(protocol)) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), protocol) {
- @Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new MxtFrameDecoder());
- pipeline.addLast("objectDecoder", new MxtProtocolDecoder(protocol));
- }
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ private void initProtocolServer(final Protocol protocol) throws SQLException {
+ if (isProtocolEnabled(protocol.getName())) {
+ protocol.addTrackerServersTo(serverList);
}
}
diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java
index c65583584..6796f2064 100644
--- a/src/org/traccar/TrackerServer.java
+++ b/src/org/traccar/TrackerServer.java
@@ -94,7 +94,7 @@ public abstract class TrackerServer {
/**
* Set endianness
*/
- void setEndianness(ByteOrder byteOrder) {
+ public void setEndianness(ByteOrder byteOrder) {
bootstrap.setOption("bufferFactory", new HeapChannelBufferFactory(byteOrder));
bootstrap.setOption("child.bufferFactory", new HeapChannelBufferFactory(byteOrder));
}
diff --git a/src/org/traccar/database/ActiveDevice.java b/src/org/traccar/database/ActiveDevice.java
new file mode 100644
index 000000000..29f2b47d2
--- /dev/null
+++ b/src/org/traccar/database/ActiveDevice.java
@@ -0,0 +1,37 @@
+package org.traccar.database;
+
+import org.jboss.netty.channel.Channel;
+import org.traccar.Protocol;
+import org.traccar.http.commands.GpsCommand;
+
+import java.net.SocketAddress;
+
+public class ActiveDevice {
+ private String uniqueId;
+ private Protocol protocol;
+ private Channel channel;
+ private SocketAddress remoteAddress;
+
+ public ActiveDevice(String uniqueId, Protocol protocol, Channel channel, SocketAddress remoteAddress) {
+ this.uniqueId = uniqueId;
+ this.protocol = protocol;
+ this.channel = channel;
+ this.remoteAddress = remoteAddress;
+ }
+
+ public Channel getChannel() {
+ return channel;
+ }
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void sendCommand(GpsCommand command) {
+ protocol.sendCommand(this, command);
+ }
+
+ public void write(Object message) {
+ getChannel().write(message, remoteAddress);
+ }
+}
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 496a5a1b6..62275af3c 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -17,6 +17,7 @@ package org.traccar.database;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.io.File;
+import java.net.SocketAddress;
import java.net.URL;
import java.net.URLClassLoader;
import java.sql.Connection;
@@ -32,7 +33,10 @@ import java.util.Map;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.sql.DataSource;
+
+import org.jboss.netty.channel.Channel;
import org.traccar.Context;
+import org.traccar.Protocol;
import org.traccar.helper.DriverDelegate;
import org.traccar.helper.Log;
import org.traccar.http.AsyncServlet;
@@ -52,6 +56,7 @@ public class DataManager {
private DataSource dataSource;
private final Map<String, Device> devices = new HashMap<String, Device>();
+ private Map<String, ActiveDevice> activeDevices = new HashMap<String, ActiveDevice>();
private long devicesLastUpdate;
private long devicesRefreshDelay;
@@ -74,6 +79,14 @@ public class DataManager {
return dataSource;
}
+ public void setActiveDevice(String uniqueId, Protocol protocol, Channel channel, SocketAddress remoteAddress) {
+ this.activeDevices.put(uniqueId, new ActiveDevice(uniqueId, protocol, channel, remoteAddress));
+ }
+
+ public ActiveDevice getActiveDevice(String uniqueId) {
+ return this.activeDevices.get(uniqueId);
+ }
+
private void initDatabase(Properties properties) throws Exception {
String jndiName = properties.getProperty("database.jndi");
diff --git a/src/org/traccar/http/CommandsServlet.java b/src/org/traccar/http/CommandsServlet.java
new file mode 100644
index 000000000..3e3ab9086
--- /dev/null
+++ b/src/org/traccar/http/CommandsServlet.java
@@ -0,0 +1,58 @@
+package org.traccar.http;
+
+import org.traccar.Context;
+import org.traccar.database.ActiveDevice;
+import org.traccar.http.commands.CommandType;
+import org.traccar.http.commands.GpsCommand;
+
+import javax.json.Json;
+import javax.json.JsonObject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class CommandsServlet extends BaseServlet {
+
+ @Override
+ protected boolean handle(String command, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ if (command.equals("/send")) {
+ send(req, resp);
+ }
+ else if (command.equals("/raw")) {
+ sendRawCommand(req, resp);
+ }
+ else {
+ return false;
+ }
+ return true;
+ }
+
+ private void send(HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ GpsCommand command = JsonConverter.<GpsCommand>enumObjectFromJson(req.getReader(), new EnumFactory(CommandType.class, "type"));
+
+ String uniqueId = command.getUniqueId();
+
+ ActiveDevice activeDevice = Context.getDataManager().getActiveDevice(uniqueId);
+ if(activeDevice == null) {
+ throw new RuntimeException("The device has not yet registered to the server");
+ }
+
+ activeDevice.sendCommand(command);
+
+ sendResponse(resp.getWriter(), JsonConverter.objectToJson(new Object()));
+ }
+
+ private void sendRawCommand(HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ JsonObject json = Json.createReader(req.getReader()).readObject();
+ String uniqueId = json.getString("uniqueId");
+
+ ActiveDevice activeDevice = Context.getDataManager().getActiveDevice(uniqueId);
+ if(activeDevice == null) {
+ throw new RuntimeException("The device has not yet registered to the server");
+ }
+
+ String command = json.getString("command");
+ activeDevice.write(command);
+
+ sendResponse(resp.getWriter(), JsonConverter.objectToJson(new Object()));
+ }
+}
diff --git a/src/org/traccar/http/EnumFactory.java b/src/org/traccar/http/EnumFactory.java
new file mode 100644
index 000000000..6e9971f71
--- /dev/null
+++ b/src/org/traccar/http/EnumFactory.java
@@ -0,0 +1,20 @@
+package org.traccar.http;
+
+import org.traccar.model.Factory;
+
+import javax.json.JsonObject;
+
+public class EnumFactory<T extends Enum<T> & Factory> {
+ private Class<T> commandTypeClass;
+ private String jsonKey;
+
+ public EnumFactory(Class<T> commandTypeClass, String type) {
+ this.commandTypeClass = commandTypeClass;
+ jsonKey = type;
+ }
+
+ public <K> K create(JsonObject json) {
+ Factory factory = Enum.valueOf(commandTypeClass, json.getString(jsonKey));
+ return (K) factory.create();
+ }
+}
diff --git a/src/org/traccar/http/JsonConverter.java b/src/org/traccar/http/JsonConverter.java
index f18470d9d..eb672da8d 100644
--- a/src/org/traccar/http/JsonConverter.java
+++ b/src/org/traccar/http/JsonConverter.java
@@ -35,7 +35,7 @@ import org.traccar.helper.IgnoreOnSerialization;
import org.traccar.model.Factory;
public class JsonConverter {
-
+
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
public static Date parseDate(String value) throws ParseException {
@@ -45,19 +45,29 @@ public class JsonConverter {
public static <T extends Factory> T objectFromJson(Reader reader, T prototype) throws ParseException {
return objectFromJson(Json.createReader(reader).readObject(), prototype);
}
-
- public static <T extends Factory> T objectFromJson(JsonObject json, T prototype) throws ParseException {
+ public static <T> T enumObjectFromJson(Reader reader, EnumFactory<? extends Enum<?>> factory) throws ParseException {
+ JsonObject json = Json.createReader(reader).readObject();
+ T object = factory.<T>create(json);
+ populateObject(json, object);
+ return object;
+ }
+
+ public static <T extends Factory> T objectFromJson(JsonObject json, T prototype) throws ParseException {
T object = (T) prototype.create();
-
- Method[] methods = prototype.getClass().getMethods();
-
+ populateObject(json, object);
+ return object;
+ }
+
+ private static void populateObject(JsonObject json, Object object) throws ParseException {
+ Method[] methods = object.getClass().getMethods();
+
for (final Method method : methods) {
if (method.getName().startsWith("set") && method.getParameterTypes().length == 1) {
final String name = Introspector.decapitalize(method.getName().substring(3));
Class<?> parameterType = method.getParameterTypes()[0];
-
+
if (json.containsKey(name)) try {
if (parameterType.equals(boolean.class)) {
method.invoke(object, json.getBoolean(name));
@@ -73,22 +83,28 @@ public class JsonConverter {
method.invoke(object, json.getString(name));
} else if (parameterType.equals(Date.class)) {
method.invoke(object, dateFormat.parse(json.getString(name)));
+ } else if (parameterType.isEnum()) {
+ method.invoke(object, Enum.valueOf((Class<? extends Enum>) parameterType, json.getString(name)));
+ } else {
+ Object nestedObject = parameterType.newInstance();
+ populateObject(json.getJsonObject(name), nestedObject);
+ method.invoke(object, nestedObject);
}
} catch (IllegalAccessException error) {
} catch (InvocationTargetException error) {
+ } catch (InstantiationException e) {
}
}
}
-
- return object;
+
}
-
+
public static <T> JsonObject objectToJson(T object) {
-
+
JsonObjectBuilder json = Json.createObjectBuilder();
-
+
Method[] methods = object.getClass().getMethods();
-
+
for (Method method : methods) {
if(method.isAnnotationPresent(IgnoreOnSerialization.class)) {
continue;
@@ -127,7 +143,7 @@ public class JsonConverter {
public static JsonArray arrayToJson(Collection<?> array) {
JsonArrayBuilder json = Json.createArrayBuilder();
-
+
for (Object object : array) {
json.add(objectToJson(object));
}
diff --git a/src/org/traccar/http/WebServer.java b/src/org/traccar/http/WebServer.java
index 21e43b3d3..9030e992b 100644
--- a/src/org/traccar/http/WebServer.java
+++ b/src/org/traccar/http/WebServer.java
@@ -55,6 +55,7 @@ public class WebServer {
servletHandler.addServlet(new ServletHolder(new UserServlet()), "/user/*");
servletHandler.addServlet(new ServletHolder(new DeviceServlet()), "/device/*");
servletHandler.addServlet(new ServletHolder(new PositionServlet()), "/position/*");
+ servletHandler.addServlet(new ServletHolder(new CommandsServlet()), "/commands/*");
servletHandler.addServlet(new ServletHolder(new MainServlet()), "/*");
/*ResourceHandler mobileResourceHandler = new ResourceHandler();
diff --git a/src/org/traccar/http/commands/CommandType.java b/src/org/traccar/http/commands/CommandType.java
new file mode 100644
index 000000000..12610dbcc
--- /dev/null
+++ b/src/org/traccar/http/commands/CommandType.java
@@ -0,0 +1,28 @@
+package org.traccar.http.commands;
+
+import org.traccar.model.Factory;
+
+public enum CommandType implements Factory {
+ STOP_POSITIONING(NoParameterCommand.class),
+ FIX_POSITIONING(FixPositioningCommand.class),
+ STOP_ENGINE(NoParameterCommand.class),
+ RESUME_ENGINE(NoParameterCommand.class);
+
+
+ private Class<? extends GpsCommand> commandClass;
+
+ CommandType(Class<? extends GpsCommand> commandClass) {
+ this.commandClass = commandClass;
+ }
+
+ @Override
+ public Object create() {
+ try {
+ return commandClass.newInstance();
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/org/traccar/http/commands/Duration.java b/src/org/traccar/http/commands/Duration.java
new file mode 100644
index 000000000..e50f0c23e
--- /dev/null
+++ b/src/org/traccar/http/commands/Duration.java
@@ -0,0 +1,38 @@
+package org.traccar.http.commands;
+
+public class Duration {
+
+ public enum TimeUnit {
+ SECOND("s"), MINUTE("m"), HOUR("h");
+
+ private final String commandFormat;
+
+ TimeUnit(String commandFormat) {
+ this.commandFormat = commandFormat;
+ }
+
+ public String getCommandFormat() {
+ return commandFormat;
+ }
+ }
+
+
+ private TimeUnit unit;
+ private int value;
+
+ public TimeUnit getUnit() {
+ return unit;
+ }
+
+ public void setUnit(TimeUnit unit) {
+ this.unit = unit;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+}
diff --git a/src/org/traccar/http/commands/FixPositioningCommand.java b/src/org/traccar/http/commands/FixPositioningCommand.java
new file mode 100644
index 000000000..f3b25acbc
--- /dev/null
+++ b/src/org/traccar/http/commands/FixPositioningCommand.java
@@ -0,0 +1,25 @@
+package org.traccar.http.commands;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class FixPositioningCommand extends GpsCommand {
+ public static final String FREQUENCY = "frequency";
+
+ private Duration data;
+
+ @Override
+ public Map<String, Object> getReplacements() {
+ Map<String, Object> replacements = new HashMap<String, Object>();
+ replacements.put(FREQUENCY, data);
+ return replacements;
+ }
+
+ public Duration getData() {
+ return data;
+ }
+
+ public void setData(Duration data) {
+ this.data = data;
+ }
+}
diff --git a/src/org/traccar/http/commands/GpsCommand.java b/src/org/traccar/http/commands/GpsCommand.java
new file mode 100644
index 000000000..604bf832f
--- /dev/null
+++ b/src/org/traccar/http/commands/GpsCommand.java
@@ -0,0 +1,27 @@
+package org.traccar.http.commands;
+
+import java.util.Map;
+
+public abstract class GpsCommand {
+ public static final String UNIQUE_ID = "uniqueId";
+ private String uniqueId;
+ private CommandType type;
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public CommandType getType() {
+ return type;
+ }
+
+ public void setType(CommandType type) {
+ this.type = type;
+ }
+
+ public abstract Map<String, Object> getReplacements();
+}
diff --git a/src/org/traccar/http/commands/NoParameterCommand.java b/src/org/traccar/http/commands/NoParameterCommand.java
new file mode 100644
index 000000000..fee3c8097
--- /dev/null
+++ b/src/org/traccar/http/commands/NoParameterCommand.java
@@ -0,0 +1,11 @@
+package org.traccar.http.commands;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class NoParameterCommand extends GpsCommand {
+ @Override
+ public Map<String, Object> getReplacements() {
+ return new HashMap<String, Object>();
+ }
+}
diff --git a/src/org/traccar/protocol/ApelProtocol.java b/src/org/traccar/protocol/ApelProtocol.java
new file mode 100644
index 000000000..fd6174d31
--- /dev/null
+++ b/src/org/traccar/protocol/ApelProtocol.java
@@ -0,0 +1,38 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class ApelProtocol extends BaseProtocol {
+
+ public ApelProtocol() {
+ super("apel");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0));
+ pipeline.addLast("objectDecoder", new ApelProtocolDecoder(ApelProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java
index 4b05f3004..85a4e771a 100644
--- a/src/org/traccar/protocol/ApelProtocolDecoder.java
+++ b/src/org/traccar/protocol/ApelProtocolDecoder.java
@@ -39,7 +39,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
private long lastIndex;
private long newIndex;
- public ApelProtocolDecoder(String protocol) {
+ public ApelProtocolDecoder(ApelProtocol protocol) {
super(protocol);
}
@@ -120,7 +120,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
int length = buf.readUnsignedShort();
buf.skipBytes(length);
length = buf.readUnsignedShort();
- identify(buf.readBytes(length).toString(Charset.defaultCharset()));
+ identify(buf.readBytes(length).toString(Charset.defaultCharset()), channel);
}
else if (type == MSG_TYPE_LAST_LOG_INDEX) {
@@ -142,7 +142,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
for (int j = 0; j < recordCount; j++) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
// Message index
diff --git a/src/org/traccar/protocol/AplicomProtocol.java b/src/org/traccar/protocol/AplicomProtocol.java
new file mode 100644
index 000000000..bd4cfbd9f
--- /dev/null
+++ b/src/org/traccar/protocol/AplicomProtocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class AplicomProtocol extends BaseProtocol {
+
+ public AplicomProtocol() {
+ super("aplicom");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new AplicomFrameDecoder());
+ pipeline.addLast("objectDecoder", new AplicomProtocolDecoder(AplicomProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java
index 81f760654..045eb2adc 100644
--- a/src/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -32,7 +32,7 @@ import org.traccar.model.Position;
public class AplicomProtocolDecoder extends BaseProtocolDecoder {
- public AplicomProtocolDecoder(String protocol) {
+ public AplicomProtocolDecoder(AplicomProtocol protocol) {
super(protocol);
}
@@ -131,8 +131,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
- if (!identify(imei)) {
+ position.setProtocol(getProtocolName());
+ if (!identify(imei, channel)) {
return null;
}
diff --git a/src/org/traccar/protocol/Ardi01Protocol.java b/src/org/traccar/protocol/Ardi01Protocol.java
new file mode 100644
index 000000000..a30560d4f
--- /dev/null
+++ b/src/org/traccar/protocol/Ardi01Protocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Ardi01Protocol extends BaseProtocol {
+
+ public Ardi01Protocol() {
+ super("ardi01");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new Ardi01ProtocolDecoder(Ardi01Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
index 3a254cf41..dcc342b97 100644
--- a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
public class Ardi01ProtocolDecoder extends BaseProtocolDecoder {
- public Ardi01ProtocolDecoder(String protocol) {
+ public Ardi01ProtocolDecoder(Ardi01Protocol protocol) {
super(protocol);
}
@@ -62,11 +62,11 @@ public class Ardi01ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Detect device
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/AtrackProtocol.java b/src/org/traccar/protocol/AtrackProtocol.java
new file mode 100644
index 000000000..7940e4208
--- /dev/null
+++ b/src/org/traccar/protocol/AtrackProtocol.java
@@ -0,0 +1,41 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class AtrackProtocol extends BaseProtocol {
+
+ public AtrackProtocol() {
+ super("atrack");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new AtrackFrameDecoder());
+ pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this));
+ }
+ });
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java
index b0b7ef1fc..6a346f946 100644
--- a/src/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -33,7 +33,7 @@ import org.traccar.model.Position;
public class AtrackProtocolDecoder extends BaseProtocolDecoder {
- public AtrackProtocolDecoder(String protocol) {
+ public AtrackProtocolDecoder(AtrackProtocol protocol) {
super(protocol);
}
@@ -87,7 +87,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
// Get device id
long id = buf.readLong();
- if (!identify(String.valueOf(id))) {
+ if (!identify(String.valueOf(id), channel, remoteAddress)) {
return null;
}
@@ -101,7 +101,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Date and time
position.setTime(new Date(buf.readUnsignedInt() * 1000)); // gps time
diff --git a/src/org/traccar/protocol/AutoFon45Protocol.java b/src/org/traccar/protocol/AutoFon45Protocol.java
new file mode 100644
index 000000000..0af206ea3
--- /dev/null
+++ b/src/org/traccar/protocol/AutoFon45Protocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class AutoFon45Protocol extends BaseProtocol {
+
+ public AutoFon45Protocol() {
+ super("autofon45");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new AutoFon45FrameDecoder());
+ pipeline.addLast("objectDecoder", new AutoFon45ProtocolDecoder(AutoFon45Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
index 55b4ad9dc..4fbf05c94 100644
--- a/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFon45ProtocolDecoder.java
@@ -36,7 +36,7 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder {
return (degrees + seconds) * ((raw & 0x0f) == 0 ? -1 : 1);
}
- public AutoFon45ProtocolDecoder(String protocol) {
+ public AutoFon45ProtocolDecoder(AutoFon45Protocol protocol) {
super(protocol);
}
@@ -51,7 +51,7 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder {
buf.readBytes(bytes);
String imei = ChannelBufferTools.readHexString(ChannelBuffers.wrappedBuffer(bytes, 1, 16), 16).substring(1);
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
@@ -67,7 +67,7 @@ public class AutoFon45ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
short status = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/AutoFonProtocol.java b/src/org/traccar/protocol/AutoFonProtocol.java
new file mode 100644
index 000000000..5dc3b583d
--- /dev/null
+++ b/src/org/traccar/protocol/AutoFonProtocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class AutoFonProtocol extends BaseProtocol {
+
+ public AutoFonProtocol() {
+ super("autofon");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new AutoFonFrameDecoder());
+ pipeline.addLast("objectDecoder", new AutoFonProtocolDecoder(AutoFonProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
index 04cd4da72..b23f7a562 100644
--- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
@@ -28,7 +28,7 @@ import java.util.*;
public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
- public AutoFonProtocolDecoder(String protocol) {
+ public AutoFonProtocolDecoder(AutoFonProtocol protocol) {
super(protocol);
}
@@ -46,7 +46,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
if (!history) {
@@ -121,7 +121,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // software version
String imei = ChannelBufferTools.readHexString(buf, 16).substring(1);
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
diff --git a/src/org/traccar/protocol/Avl301Protocol.java b/src/org/traccar/protocol/Avl301Protocol.java
new file mode 100644
index 000000000..a20919d99
--- /dev/null
+++ b/src/org/traccar/protocol/Avl301Protocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Avl301Protocol extends BaseProtocol {
+
+ public Avl301Protocol() {
+ super("avl301");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, -3, 0));
+ pipeline.addLast("objectDecoder", new Avl301ProtocolDecoder(Avl301Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Avl301ProtocolDecoder.java b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
index 7a53c3d3f..c4ce150c2 100644
--- a/src/org/traccar/protocol/Avl301ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
@@ -28,7 +28,7 @@ import java.util.TimeZone;
public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
- public Avl301ProtocolDecoder(String protocol) {
+ public Avl301ProtocolDecoder(Avl301Protocol protocol) {
super(protocol);
}
@@ -72,7 +72,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_LOGIN) {
- if (identify(readImei(buf))) {
+ if (identify(readImei(buf), channel)) {
sendResponse(channel, type);
}
@@ -85,7 +85,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Date and time(6)
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/src/org/traccar/protocol/BceProtocol.java b/src/org/traccar/protocol/BceProtocol.java
new file mode 100644
index 000000000..6bd1e70e3
--- /dev/null
+++ b/src/org/traccar/protocol/BceProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class BceProtocol extends BaseProtocol {
+
+ public BceProtocol() {
+ super("bce");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new BceFrameDecoder());
+ pipeline.addLast("objectDecoder", new BceProtocolDecoder(BceProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java
index 189cad754..763f35d0c 100644
--- a/src/org/traccar/protocol/BceProtocolDecoder.java
+++ b/src/org/traccar/protocol/BceProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class BceProtocolDecoder extends BaseProtocolDecoder {
- public BceProtocolDecoder(String protocol) {
+ public BceProtocolDecoder(BceProtocol protocol) {
super(protocol);
}
@@ -50,7 +50,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
String imei = String.format("%015d", buf.readLong());
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
@@ -65,7 +65,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
while (buf.readerIndex() < dataEnd) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
int structEnd = buf.readUnsignedByte() + buf.readerIndex();
diff --git a/src/org/traccar/protocol/BoxProtocol.java b/src/org/traccar/protocol/BoxProtocol.java
new file mode 100644
index 000000000..803c8c9c2
--- /dev/null
+++ b/src/org/traccar/protocol/BoxProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class BoxProtocol extends BaseProtocol {
+
+ public BoxProtocol() {
+ super("box");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new BoxProtocolDecoder(BoxProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java
index b7e30733c..77e546cda 100644
--- a/src/org/traccar/protocol/BoxProtocolDecoder.java
+++ b/src/org/traccar/protocol/BoxProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class BoxProtocolDecoder extends BaseProtocolDecoder {
- public BoxProtocolDecoder(String protocol) {
+ public BoxProtocolDecoder(BoxProtocol protocol) {
super(protocol);
}
@@ -58,7 +58,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
int index = sentence.indexOf(',', 2) + 1;
String id = sentence.substring(index, sentence.indexOf(',', index));
- identify(id);
+ identify(id, channel);
}
else if (sentence.startsWith("L,")) {
@@ -72,7 +72,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
diff --git a/src/org/traccar/protocol/CalAmpProtocol.java b/src/org/traccar/protocol/CalAmpProtocol.java
new file mode 100644
index 000000000..a60812324
--- /dev/null
+++ b/src/org/traccar/protocol/CalAmpProtocol.java
@@ -0,0 +1,33 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class CalAmpProtocol extends BaseProtocol {
+
+ public CalAmpProtocol() {
+ super("calamp");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new CalAmpProtocolDecoder(CalAmpProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index f6b06ebe7..99d8651de 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -32,7 +32,7 @@ import org.traccar.model.Position;
public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
- public CalAmpProtocolDecoder(String protocol) {
+ public CalAmpProtocolDecoder(CalAmpProtocol protocol) {
super(protocol);
}
@@ -109,7 +109,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
}
}
- identify(String.valueOf(id));
+ identify(String.valueOf(id), channel, remoteAddress);
}
// Identifier type
@@ -160,7 +160,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Location data
position.setTime(new Date(buf.readUnsignedInt() * 1000));
diff --git a/src/org/traccar/protocol/CarTrackProtocol.java b/src/org/traccar/protocol/CarTrackProtocol.java
new file mode 100644
index 000000000..bab6562b6
--- /dev/null
+++ b/src/org/traccar/protocol/CarTrackProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class CarTrackProtocol extends BaseProtocol {
+
+ public CarTrackProtocol() {
+ super("cartrack");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new CarTrackProtocolDecoder(CarTrackProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
index 223023a31..fea4f6a5e 100644
--- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class CarTrackProtocolDecoder extends BaseProtocolDecoder {
- public CarTrackProtocolDecoder(String protocol) {
+ public CarTrackProtocolDecoder(CarTrackProtocol protocol) {
super(protocol);
}
@@ -70,11 +70,11 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by unique identifier
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/CarscopProtocol.java b/src/org/traccar/protocol/CarscopProtocol.java
new file mode 100644
index 000000000..9f4abb11c
--- /dev/null
+++ b/src/org/traccar/protocol/CarscopProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class CarscopProtocol extends BaseProtocol {
+
+ public CarscopProtocol() {
+ super("carscop");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '^'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new CarscopProtocolDecoder(CarscopProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java
index 5f7ba6374..d9c18d0b5 100644
--- a/src/org/traccar/protocol/CarscopProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarscopProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class CarscopProtocolDecoder extends BaseProtocolDecoder {
- public CarscopProtocolDecoder(String protocol) {
+ public CarscopProtocolDecoder(CarscopProtocol protocol) {
super(protocol);
}
@@ -58,7 +58,7 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder {
int index = sentence.indexOf("UB05");
if (index != -1) {
String imei = sentence.substring(index + 4, index + 4 + 15);
- identify(imei);
+ identify(imei, channel);
}
if (!hasDeviceId()) {
return null;
@@ -73,7 +73,7 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
index = 1;
// Time
diff --git a/src/org/traccar/protocol/CastelProtocol.java b/src/org/traccar/protocol/CastelProtocol.java
new file mode 100644
index 000000000..bfcf0cb1b
--- /dev/null
+++ b/src/org/traccar/protocol/CastelProtocol.java
@@ -0,0 +1,48 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class CastelProtocol extends BaseProtocol {
+
+ public CastelProtocol() {
+ super("castel");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
+ pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+
+ server = new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index e82f837a7..8c2efb114 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -33,7 +33,7 @@ import org.traccar.model.Position;
public class CastelProtocolDecoder extends BaseProtocolDecoder {
- public CastelProtocolDecoder(String protocol) {
+ public CastelProtocolDecoder(CastelProtocol protocol) {
super(protocol);
}
@@ -73,9 +73,9 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_LOGIN || type == MSG_GPS) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
- if (!identify(id.toString(Charset.defaultCharset()).trim())) {
+ if (!identify(id.toString(Charset.defaultCharset()).trim(), channel, remoteAddress)) {
return null;
} else if (type == MSG_LOGIN) {
diff --git a/src/org/traccar/protocol/CellocatorProtocol.java b/src/org/traccar/protocol/CellocatorProtocol.java
new file mode 100644
index 000000000..eedeadebc
--- /dev/null
+++ b/src/org/traccar/protocol/CellocatorProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class CellocatorProtocol extends BaseProtocol {
+
+ public CellocatorProtocol() {
+ super("cellocator");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CellocatorFrameDecoder());
+ pipeline.addLast("objectDecoder", new CellocatorProtocolDecoder(CellocatorProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
index adb01b234..6c3343224 100644
--- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
- public CellocatorProtocolDecoder(String protocol) {
+ public CellocatorProtocolDecoder(CellocatorProtocol protocol) {
super(protocol);
}
@@ -104,10 +104,10 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
// Parse location
if (type == MSG_CLIENT_STATUS) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Device identifier
- if (!identify(String.valueOf(deviceUniqueId))) {
+ if (!identify(String.valueOf(deviceUniqueId), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/EasyTrackProtocol.java b/src/org/traccar/protocol/EasyTrackProtocol.java
new file mode 100644
index 000000000..d6c422943
--- /dev/null
+++ b/src/org/traccar/protocol/EasyTrackProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class EasyTrackProtocol extends BaseProtocol {
+
+ public EasyTrackProtocol() {
+ super("easytrack");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new EasyTrackProtocolDecoder(EasyTrackProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
index a3f75973e..0a08d6394 100644
--- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class EasyTrackProtocolDecoder extends BaseProtocolDecoder {
- public EasyTrackProtocolDecoder(String protocol) {
+ public EasyTrackProtocolDecoder(EasyTrackProtocol protocol) {
super(protocol);
}
@@ -73,12 +73,12 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/EelinkProtocol.java b/src/org/traccar/protocol/EelinkProtocol.java
new file mode 100644
index 000000000..9975133a8
--- /dev/null
+++ b/src/org/traccar/protocol/EelinkProtocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class EelinkProtocol extends BaseProtocol {
+
+ public EelinkProtocol() {
+ super("eelink");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2));
+ pipeline.addLast("objectDecoder", new EelinkProtocolDecoder(EelinkProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index 6628b9c37..3cdf3977e 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class EelinkProtocolDecoder extends BaseProtocolDecoder {
- public EelinkProtocolDecoder(String protocol) {
+ public EelinkProtocolDecoder(EelinkProtocol protocol) {
super(protocol);
}
@@ -84,7 +84,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
}
if (type == MSG_LOGIN) {
- identify(ChannelBufferTools.readHexString(buf, 16).substring(1));
+ identify(ChannelBufferTools.readHexString(buf, 16).substring(1), channel);
}
else if (hasDeviceId() &&
@@ -97,7 +97,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, index);
// Location
diff --git a/src/org/traccar/protocol/EnforaProtocol.java b/src/org/traccar/protocol/EnforaProtocol.java
new file mode 100644
index 000000000..671081ef3
--- /dev/null
+++ b/src/org/traccar/protocol/EnforaProtocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class EnforaProtocol extends BaseProtocol {
+
+ public EnforaProtocol() {
+ super("enfora");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2));
+ pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(EnforaProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java
index 1185c28ad..13148641a 100644
--- a/src/org/traccar/protocol/EnforaProtocolDecoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java
@@ -28,12 +28,11 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.ChannelBufferTools;
import org.traccar.helper.Log;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class EnforaProtocolDecoder extends BaseProtocolDecoder {
- public EnforaProtocolDecoder(String protocol) {
+ public EnforaProtocolDecoder(EnforaProtocol protocol) {
super(protocol);
}
@@ -95,11 +94,11 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Ev603Protocol.java b/src/org/traccar/protocol/Ev603Protocol.java
new file mode 100644
index 000000000..d67e6f15b
--- /dev/null
+++ b/src/org/traccar/protocol/Ev603Protocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Ev603Protocol extends BaseProtocol {
+
+ public Ev603Protocol() {
+ super("ev603");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new Ev603ProtocolDecoder(Ev603Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Ev603ProtocolDecoder.java b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
index 5024ddcd1..36a08f394 100644
--- a/src/org/traccar/protocol/Ev603ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ev603ProtocolDecoder.java
@@ -25,12 +25,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class Ev603ProtocolDecoder extends BaseProtocolDecoder{
- public Ev603ProtocolDecoder(String protocol) {
+ public Ev603ProtocolDecoder(Ev603Protocol protocol) {
super(protocol);
}
@@ -53,7 +52,7 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{
// Detect device ID
if (sentence.startsWith("!1,")) {
- identify(sentence.substring(3));
+ identify(sentence.substring(3), channel);
}
else if (sentence.startsWith("!A,")) {
@@ -66,7 +65,7 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Date
diff --git a/src/org/traccar/protocol/FreedomProtocol.java b/src/org/traccar/protocol/FreedomProtocol.java
new file mode 100644
index 000000000..8e0d20ee9
--- /dev/null
+++ b/src/org/traccar/protocol/FreedomProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class FreedomProtocol extends BaseProtocol {
+
+ public FreedomProtocol() {
+ super("freedom");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new FreedomProtocolDecoder(FreedomProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/FreedomProtocolDecoder.java b/src/org/traccar/protocol/FreedomProtocolDecoder.java
index e4cfe99af..d6e641bb1 100644
--- a/src/org/traccar/protocol/FreedomProtocolDecoder.java
+++ b/src/org/traccar/protocol/FreedomProtocolDecoder.java
@@ -24,12 +24,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class FreedomProtocolDecoder extends BaseProtocolDecoder {
- public FreedomProtocolDecoder(String protocol) {
+ public FreedomProtocolDecoder(FreedomProtocol protocol) {
super(protocol);
}
@@ -56,11 +55,11 @@ public class FreedomProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identification
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/GalileoProtocol.java b/src/org/traccar/protocol/GalileoProtocol.java
new file mode 100644
index 000000000..71594e0e2
--- /dev/null
+++ b/src/org/traccar/protocol/GalileoProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class GalileoProtocol extends BaseProtocol {
+
+ public GalileoProtocol() {
+ super("galileo");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new GalileoFrameDecoder());
+ pipeline.addLast("objectDecoder", new GalileoProtocolDecoder(GalileoProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index c2c8864e9..acf95a552 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class GalileoProtocolDecoder extends BaseProtocolDecoder {
- public GalileoProtocolDecoder(String protocol) {
+ public GalileoProtocolDecoder(GalileoProtocol protocol) {
super(protocol);
}
@@ -91,7 +91,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
Set<Integer> tags = new HashSet<Integer>();
boolean hasLocation = false;
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
while (buf.readerIndex() < length) {
@@ -112,7 +112,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
case TAG_IMEI:
String imei = buf.toString(buf.readerIndex(), 15, Charset.defaultCharset());
buf.skipBytes(imei.length());
- identify(imei);
+ identify(imei, channel);
break;
case TAG_DATE:
diff --git a/src/org/traccar/protocol/GatorProtocol.java b/src/org/traccar/protocol/GatorProtocol.java
new file mode 100644
index 000000000..8518eaa28
--- /dev/null
+++ b/src/org/traccar/protocol/GatorProtocol.java
@@ -0,0 +1,33 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class GatorProtocol extends BaseProtocol {
+
+ public GatorProtocol() {
+ super("gator");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java
index bebba144d..6a3434c8a 100644
--- a/src/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/GatorProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class GatorProtocolDecoder extends BaseProtocolDecoder {
- public GatorProtocolDecoder(String protocol) {
+ public GatorProtocolDecoder(GatorProtocol protocol) {
super(protocol);
}
@@ -70,10 +70,10 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Identification
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Gl100Protocol.java b/src/org/traccar/protocol/Gl100Protocol.java
new file mode 100644
index 000000000..e240c6909
--- /dev/null
+++ b/src/org/traccar/protocol/Gl100Protocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Gl100Protocol extends BaseProtocol {
+
+ public Gl100Protocol() {
+ super("gl100");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\0'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(Gl100Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
index a4545583b..7746395a1 100644
--- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
@@ -24,12 +24,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
- public Gl100ProtocolDecoder(String protocol) {
+ public Gl100ProtocolDecoder(Gl100Protocol protocol) {
super(protocol);
}
@@ -74,12 +73,12 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Gl200Protocol.java b/src/org/traccar/protocol/Gl200Protocol.java
new file mode 100644
index 000000000..363a1b716
--- /dev/null
+++ b/src/org/traccar/protocol/Gl200Protocol.java
@@ -0,0 +1,50 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Gl200Protocol extends BaseProtocol {
+
+ public Gl200Protocol() {
+ super("gl200");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "$", "\0"));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(Gl200Protocol.this));
+ }
+ });
+
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(Gl200Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 59d09ae6a..a3fb8ee4b 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -32,7 +32,7 @@ import org.traccar.model.Position;
public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
- public Gl200ProtocolDecoder(String protocol) {
+ public Gl200ProtocolDecoder(Gl200Protocol protocol) {
super(protocol);
}
@@ -89,12 +89,12 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel, remoteAddress)) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -150,7 +150,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
position.set(Event.KEY_BATTERY, parser.group(index++));
- if (Boolean.valueOf(Context.getProps().getProperty(getProtocol() + ".ack")) && channel != null) {
+ if (Boolean.valueOf(Context.getProps().getProperty(getProtocolName() + ".ack")) && channel != null) {
channel.write("+SACK:" + parser.group(index++) + "$", remoteAddress);
}
diff --git a/src/org/traccar/protocol/GlobalSatProtocol.java b/src/org/traccar/protocol/GlobalSatProtocol.java
new file mode 100644
index 000000000..3f9e7af04
--- /dev/null
+++ b/src/org/traccar/protocol/GlobalSatProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class GlobalSatProtocol extends BaseProtocol {
+
+ public GlobalSatProtocol() {
+ super("globalsat");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '!'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new GlobalSatProtocolDecoder(GlobalSatProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index 17cfacbb5..e427def3a 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -36,7 +36,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
private String format0 = "TSPRXAB27GHKLMnaicz*U!";
private String format1 = "SARY*U!";
- public GlobalSatProtocolDecoder(String protocol) {
+ public GlobalSatProtocolDecoder(GlobalSatProtocol protocol) {
super(protocol);
Properties properties = Context.getProps();
@@ -91,14 +91,14 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
// Parse data
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
for (int formatIndex = 0, valueIndex = 1; formatIndex < format.length() && valueIndex < values.length; formatIndex++) {
String value = values[valueIndex];
switch(format.charAt(formatIndex)) {
case 'S':
- if (!identify(value)) {
+ if (!identify(value, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -208,11 +208,11 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identification
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/GoSafeProtocol.java b/src/org/traccar/protocol/GoSafeProtocol.java
new file mode 100644
index 000000000..5d0e67c26
--- /dev/null
+++ b/src/org/traccar/protocol/GoSafeProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class GoSafeProtocol extends BaseProtocol {
+
+ public GoSafeProtocol() {
+ super("gosafe");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new GoSafeProtocolDecoder(GoSafeProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index a768ac589..0a24e7029 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
- public GoSafeProtocolDecoder(String protocol) {
+ public GoSafeProtocolDecoder(GoSafeProtocol protocol) {
super(protocol);
}
@@ -65,12 +65,12 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel, remoteAddress)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/GotopProtocol.java b/src/org/traccar/protocol/GotopProtocol.java
new file mode 100644
index 000000000..ce7a18bae
--- /dev/null
+++ b/src/org/traccar/protocol/GotopProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class GotopProtocol extends BaseProtocol {
+
+ public GotopProtocol() {
+ super("gotop");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new GotopProtocolDecoder(GotopProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/GotopProtocolDecoder.java b/src/org/traccar/protocol/GotopProtocolDecoder.java
index eed0b4703..81b17b29f 100644
--- a/src/org/traccar/protocol/GotopProtocolDecoder.java
+++ b/src/org/traccar/protocol/GotopProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class GotopProtocolDecoder extends BaseProtocolDecoder {
- public GotopProtocolDecoder(String protocol) {
+ public GotopProtocolDecoder(GotopProtocol protocol) {
super(protocol);
}
@@ -61,11 +61,11 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Gps103Protocol.java b/src/org/traccar/protocol/Gps103Protocol.java
new file mode 100644
index 000000000..8b0322f4e
--- /dev/null
+++ b/src/org/traccar/protocol/Gps103Protocol.java
@@ -0,0 +1,62 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.http.commands.CommandType;
+import org.traccar.http.commands.Duration;
+import org.traccar.http.commands.FixPositioningCommand;
+import org.traccar.http.commands.GpsCommand;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.protocol.commands.CommandValueConversion;
+import org.traccar.protocol.commands.StringCommandTemplate;
+
+import java.util.List;
+import java.util.Map;
+
+public class Gps103Protocol extends BaseProtocol {
+
+ public Gps103Protocol() {
+ super("gps103");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+ templates.put(CommandType.STOP_POSITIONING, new StringCommandTemplate("**,imei:[%s],A", GpsCommand.UNIQUE_ID));
+ templates.put(CommandType.FIX_POSITIONING, new StringCommandTemplate("**,imei:[%s],C,[%s]", GpsCommand.UNIQUE_ID, FixPositioningCommand.FREQUENCY)
+ .addConverter(Duration.class, new CommandValueConversion<Duration>() {
+ @Override
+ public String convert(Duration value) {
+ return String.format("%02d%s", value.getValue(), value.getUnit().getCommandFormat());
+ }
+ }));
+ templates.put(CommandType.RESUME_ENGINE, new StringCommandTemplate("**,imei:[%s],J", GpsCommand.UNIQUE_ID));
+ templates.put(CommandType.STOP_ENGINE, new StringCommandTemplate("**,imei:[%s],K", GpsCommand.UNIQUE_ID));
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r\n", "\n", ";"));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this));
+ }
+ });
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 60714fbcf..5dadd10e4 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -28,7 +28,7 @@ import org.traccar.model.Position;
public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
- public Gps103ProtocolDecoder(String protocol) {
+ public Gps103ProtocolDecoder(Gps103Protocol protocol) {
super(protocol);
}
@@ -90,13 +90,13 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
String imei = parser.group(index++);
- if (!identify(imei)) {
+ if (!identify(imei, channel, remoteAddress)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/GpsGateProtocol.java b/src/org/traccar/protocol/GpsGateProtocol.java
new file mode 100644
index 000000000..00780de17
--- /dev/null
+++ b/src/org/traccar/protocol/GpsGateProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class GpsGateProtocol extends BaseProtocol {
+
+ public GpsGateProtocol() {
+ super("gpsgate");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new GpsGateProtocolDecoder(GpsGateProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
index dbc1ac5a9..011ec1219 100644
--- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
@@ -25,12 +25,11 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.Crc;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
- public GpsGateProtocolDecoder(String protocol) {
+ public GpsGateProtocolDecoder(GpsGateProtocol protocol) {
super(protocol);
}
@@ -68,7 +67,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
int endIndex = sentence.indexOf(',', beginIndex);
if (endIndex != -1) {
String imei = sentence.substring(beginIndex, endIndex);
- if (identify(imei)) {
+ if (identify(imei, channel)) {
if (channel != null) {
send(channel, "$FRSES," + channel.getId());
}
@@ -99,7 +98,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
diff --git a/src/org/traccar/protocol/Gt02Protocol.java b/src/org/traccar/protocol/Gt02Protocol.java
new file mode 100644
index 000000000..51f78cb68
--- /dev/null
+++ b/src/org/traccar/protocol/Gt02Protocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Gt02Protocol extends BaseProtocol {
+
+ public Gt02Protocol() {
+ super("gt02");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0));
+ pipeline.addLast("objectDecoder", new Gt02ProtocolDecoder(Gt02Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
index 3280be207..8d775a2bb 100644
--- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
- public Gt02ProtocolDecoder(String protocol) {
+ public Gt02ProtocolDecoder(Gt02Protocol protocol) {
super(protocol);
}
@@ -77,11 +77,11 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, index);
// Get device id
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Gt06Protocol.java b/src/org/traccar/protocol/Gt06Protocol.java
new file mode 100644
index 000000000..f3fc6a7b3
--- /dev/null
+++ b/src/org/traccar/protocol/Gt06Protocol.java
@@ -0,0 +1,79 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.database.ActiveDevice;
+import org.traccar.helper.Crc;
+import org.traccar.http.commands.CommandType;
+import org.traccar.http.commands.NoParameterCommand;
+import org.traccar.protocol.commands.CommandTemplate;
+
+import java.util.List;
+import java.util.Map;
+
+public class Gt06Protocol extends BaseProtocol {
+
+ public Gt06Protocol() {
+ super("gt06");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+ templates.put(CommandType.STOP_ENGINE, new Gt06CommandTemplate("DYD#"));
+ templates.put(CommandType.RESUME_ENGINE, new Gt06CommandTemplate("HFYD#"));
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new Gt06FrameDecoder());
+ pipeline.addLast("objectDecoder", new Gt06ProtocolDecoder(Gt06Protocol.this));
+ }
+ });
+ }
+
+ class Gt06CommandTemplate implements CommandTemplate<NoParameterCommand> {
+
+ private String commandContent;
+
+ public Gt06CommandTemplate(String commandContent) {
+ this.commandContent = commandContent;
+ }
+
+ @Override
+ public Object applyTo(ActiveDevice activeDevice, NoParameterCommand command) {
+ int serverFlagBit = 0x0;
+ int commandLength = serverFlagBit + commandContent.length();
+ int packetLength = 0x80 /*Protocol Number */ + commandContent.length() /* Information Content */ + 2 /*Information Serial Number */+ 2 /*Error Check */;
+
+ int informationSerialNumber = 1;
+
+
+ ChannelBuffer response = ChannelBuffers.directBuffer(10);
+ response.writeBytes(new byte[]{0x78, 0x78}); // Start Bit
+ response.writeByte(packetLength); // Packet Length
+ response.writeByte(0x80); // Protocol Number
+
+ // Information Content
+ response.writeByte(commandLength); // Length of command
+ response.writeByte(serverFlagBit); // Server Flag Bit
+ response.writeBytes(commandContent.getBytes()); // Command Content
+ response.writeBytes(new byte[]{0x00, 0x02}); // Language
+
+ response.writeShort(informationSerialNumber); // Information Serial Number
+
+ int crc = Crc.crc16Ccitt(response.toByteBuffer(2, response.writerIndex()));
+ response.writeShort(crc); // Error Check
+
+ response.writeBytes(new byte[] {0x0D, 0x0A}); // Stop Bit
+
+ return response;
+ }
+ }
+}
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 01ffe5490..f5a8dc307 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -35,7 +35,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
private boolean forceTimeZone = false;
private final TimeZone timeZone = TimeZone.getTimeZone("UTC");
- public Gt06ProtocolDecoder(String protocol) {
+ public Gt06ProtocolDecoder(Gt06Protocol protocol) {
super(protocol);
Properties properties = Context.getProps();
@@ -126,7 +126,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
}
- if (identify(imei)) {
+ if (identify(imei, channel)) {
buf.skipBytes(buf.readableBytes() - 6);
sendResponse(channel, type, buf.readUnsignedShort());
}
@@ -144,7 +144,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Date and time
Calendar time = Calendar.getInstance(timeZone);
diff --git a/src/org/traccar/protocol/H02Protocol.java b/src/org/traccar/protocol/H02Protocol.java
new file mode 100644
index 000000000..91ddda772
--- /dev/null
+++ b/src/org/traccar/protocol/H02Protocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class H02Protocol extends BaseProtocol {
+
+ public H02Protocol() {
+ super("h02");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new H02FrameDecoder());
+ pipeline.addLast("objectDecoder", new H02ProtocolDecoder(H02Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 30c0aaa60..95d80edb5 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -32,7 +32,7 @@ import org.traccar.model.Position;
public class H02ProtocolDecoder extends BaseProtocolDecoder {
- public H02ProtocolDecoder(String protocol) {
+ public H02ProtocolDecoder(H02Protocol protocol) {
super(protocol);
}
@@ -55,16 +55,16 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
return result;
}
- private Position decodeBinary(ChannelBuffer buf) {
+ private Position decodeBinary(ChannelBuffer buf, Channel channel) {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
buf.readByte(); // marker
// Identification
- if (!identify(ChannelBufferTools.readHexString(buf, 10))) {
+ if (!identify(ChannelBufferTools.readHexString(buf, 10), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -117,7 +117,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
"(\\p{XDigit}{8})" + // Status
".*");
- private Position decodeText(String sentence) {
+ private Position decodeText(String sentence, Channel channel) {
// Parse message
Matcher parser = pattern.matcher(sentence);
@@ -127,12 +127,12 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -190,9 +190,9 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
// TODO X mode?
if (marker.equals("*")) {
- return decodeText(buf.toString(Charset.defaultCharset()));
+ return decodeText(buf.toString(Charset.defaultCharset()), channel);
} else if (marker.equals("$")) {
- return decodeBinary(buf);
+ return decodeBinary(buf, channel);
}
return null;
diff --git a/src/org/traccar/protocol/HaicomProtocol.java b/src/org/traccar/protocol/HaicomProtocol.java
new file mode 100644
index 000000000..79f7ac1ff
--- /dev/null
+++ b/src/org/traccar/protocol/HaicomProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class HaicomProtocol extends BaseProtocol {
+
+ public HaicomProtocol() {
+ super("haicom");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new HaicomProtocolDecoder(HaicomProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java
index 5955ac905..27fb05d34 100644
--- a/src/org/traccar/protocol/HaicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class HaicomProtocolDecoder extends BaseProtocolDecoder {
- public HaicomProtocolDecoder(String protocol) {
+ public HaicomProtocolDecoder(HaicomProtocol protocol) {
super(protocol);
}
@@ -67,12 +67,12 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/IntellitracProtocol.java b/src/org/traccar/protocol/IntellitracProtocol.java
new file mode 100644
index 000000000..977635a67
--- /dev/null
+++ b/src/org/traccar/protocol/IntellitracProtocol.java
@@ -0,0 +1,38 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class IntellitracProtocol extends BaseProtocol {
+
+ public IntellitracProtocol() {
+ super("intellitrac");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new IntellitracFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new IntellitracProtocolDecoder(IntellitracProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java
index 39d851cf9..9b99fc408 100644
--- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java
+++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
- public IntellitracProtocolDecoder(String protocol) {
+ public IntellitracProtocolDecoder(IntellitracProtocol protocol) {
super(protocol);
}
@@ -76,11 +76,11 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Detect device
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Jt600Protocol.java b/src/org/traccar/protocol/Jt600Protocol.java
new file mode 100644
index 000000000..c650aed7e
--- /dev/null
+++ b/src/org/traccar/protocol/Jt600Protocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Jt600Protocol extends BaseProtocol {
+
+ public Jt600Protocol() {
+ super("jt600");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new Jt600FrameDecoder());
+ pipeline.addLast("objectDecoder", new Jt600ProtocolDecoder(Jt600Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 5c3dcef46..eaf9ff9c6 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -32,20 +32,20 @@ import org.traccar.model.Position;
public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
- public Jt600ProtocolDecoder(String protocol) {
+ public Jt600ProtocolDecoder(Jt600Protocol protocol) {
super(protocol);
}
- private Position decodeNormalMessage(ChannelBuffer buf) throws Exception {
+ private Position decodeNormalMessage(ChannelBuffer buf, Channel channel) throws Exception {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
buf.readByte(); // header
// Get device by identifier
String id = Long.valueOf(ChannelBufferTools.readHexString(buf, 10)).toString();
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -140,7 +140,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
"(\\d+)," + // Alert Type
".*\\)");
- private Position decodeAlertMessage(ChannelBuffer buf) throws Exception {
+ private Position decodeAlertMessage(ChannelBuffer buf, Channel channel) throws Exception {
String message = buf.toString(Charset.defaultCharset());
@@ -152,12 +152,12 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_ALARM, true);
Integer index = 1;
// Get device by identifier
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -209,9 +209,9 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
// Check message type
if (first == '$') {
- return decodeNormalMessage(buf);
+ return decodeNormalMessage(buf, channel);
} else if (first == '(') {
- return decodeAlertMessage(buf);
+ return decodeAlertMessage(buf, channel);
}
return null;
diff --git a/src/org/traccar/protocol/KhdProtocol.java b/src/org/traccar/protocol/KhdProtocol.java
new file mode 100644
index 000000000..313f10a7d
--- /dev/null
+++ b/src/org/traccar/protocol/KhdProtocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class KhdProtocol extends BaseProtocol {
+
+ public KhdProtocol() {
+ super("khd");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 3, 2));
+ pipeline.addLast("objectDecoder", new KhdProtocolDecoder(KhdProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java
index e9d43798c..335e84697 100644
--- a/src/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/org/traccar/protocol/KhdProtocolDecoder.java
@@ -32,7 +32,7 @@ import org.traccar.model.Position;
public class KhdProtocolDecoder extends BaseProtocolDecoder {
- public KhdProtocolDecoder(String protocol) {
+ public KhdProtocolDecoder(KhdProtocol protocol) {
super(protocol);
}
@@ -74,10 +74,10 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Device identification
- if (!identify(readSerialNumber(buf))) {
+ if (!identify(readSerialNumber(buf), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/LaipacProtocol.java b/src/org/traccar/protocol/LaipacProtocol.java
new file mode 100644
index 000000000..96b84a6f4
--- /dev/null
+++ b/src/org/traccar/protocol/LaipacProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class LaipacProtocol extends BaseProtocol {
+
+ public LaipacProtocol() {
+ super("laipac");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new LaipacProtocolDecoder(LaipacProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java
index af43df511..e5838387a 100644
--- a/src/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -25,12 +25,11 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.Crc;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class LaipacProtocolDecoder extends BaseProtocolDecoder {
- public LaipacProtocolDecoder(String protocol) {
+ public LaipacProtocolDecoder(LaipacProtocol protocol) {
super(protocol);
}
@@ -71,11 +70,11 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identification
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/M2mProtocol.java b/src/org/traccar/protocol/M2mProtocol.java
new file mode 100644
index 000000000..53948b93a
--- /dev/null
+++ b/src/org/traccar/protocol/M2mProtocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class M2mProtocol extends BaseProtocol {
+
+ public M2mProtocol() {
+ super("m2m");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new FixedLengthFrameDecoder(23));
+ pipeline.addLast("objectDecoder", new M2mProtocolDecoder(M2mProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/M2mProtocolDecoder.java b/src/org/traccar/protocol/M2mProtocolDecoder.java
index c335a2d41..10df475b3 100644
--- a/src/org/traccar/protocol/M2mProtocolDecoder.java
+++ b/src/org/traccar/protocol/M2mProtocolDecoder.java
@@ -28,7 +28,7 @@ import org.traccar.model.Position;
public class M2mProtocolDecoder extends BaseProtocolDecoder {
- public M2mProtocolDecoder(String protocol) {
+ public M2mProtocolDecoder(M2mProtocol protocol) {
super(protocol);
}
@@ -64,13 +64,13 @@ public class M2mProtocolDecoder extends BaseProtocolDecoder {
}
// Identification
- identify(imei.toString());
+ identify(imei.toString(), channel);
} else if (hasDeviceId()) {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
// Date and time
diff --git a/src/org/traccar/protocol/ManPowerProtocol.java b/src/org/traccar/protocol/ManPowerProtocol.java
new file mode 100644
index 000000000..f2745bd0d
--- /dev/null
+++ b/src/org/traccar/protocol/ManPowerProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class ManPowerProtocol extends BaseProtocol {
+
+ public ManPowerProtocol() {
+ super("manpower");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new ManPowerProtocolDecoder(ManPowerProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/ManPowerProtocolDecoder.java b/src/org/traccar/protocol/ManPowerProtocolDecoder.java
index 773e2d782..7070e8e39 100644
--- a/src/org/traccar/protocol/ManPowerProtocolDecoder.java
+++ b/src/org/traccar/protocol/ManPowerProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class ManPowerProtocolDecoder extends BaseProtocolDecoder {
- public ManPowerProtocolDecoder(String protocol) {
+ public ManPowerProtocolDecoder(ManPowerProtocol protocol) {
super(protocol);
}
@@ -64,12 +64,12 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/MaxonProtocol.java b/src/org/traccar/protocol/MaxonProtocol.java
new file mode 100644
index 000000000..c8b79f876
--- /dev/null
+++ b/src/org/traccar/protocol/MaxonProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class MaxonProtocol extends BaseProtocol {
+
+ public MaxonProtocol() {
+ super("maxon");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new MaxonProtocolDecoder(MaxonProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/MaxonProtocolDecoder.java b/src/org/traccar/protocol/MaxonProtocolDecoder.java
index c25a190f1..c65476590 100644
--- a/src/org/traccar/protocol/MaxonProtocolDecoder.java
+++ b/src/org/traccar/protocol/MaxonProtocolDecoder.java
@@ -16,7 +16,6 @@
package org.traccar.protocol;
import java.util.Calendar;
-import java.util.Properties;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -25,9 +24,6 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.database.DataManager;
-import org.traccar.helper.Log;
-import org.traccar.model.Event;
import org.traccar.model.Position;
/**
@@ -41,7 +37,7 @@ public class MaxonProtocolDecoder extends BaseProtocolDecoder {
private Position position = null;
- public MaxonProtocolDecoder(String protocol) {
+ public MaxonProtocolDecoder(MaxonProtocol protocol) {
super(protocol);
}
@@ -126,7 +122,7 @@ public class MaxonProtocolDecoder extends BaseProtocolDecoder {
Matcher parser = gpfidPattern.matcher(sentence);
if (parser.matches()) {
- if (!identify(parser.group(1))) {
+ if (!identify(parser.group(1), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/MegastekProtocol.java b/src/org/traccar/protocol/MegastekProtocol.java
new file mode 100644
index 000000000..ec747a6d1
--- /dev/null
+++ b/src/org/traccar/protocol/MegastekProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class MegastekProtocol extends BaseProtocol {
+
+ public MegastekProtocol() {
+ super("megastek");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new MegastekProtocolDecoder(MegastekProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 3f29d8470..5b9f0408c 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class MegastekProtocolDecoder extends BaseProtocolDecoder {
- public MegastekProtocolDecoder(String protocol) {
+ public MegastekProtocolDecoder(MegastekProtocol protocol) {
super(protocol);
}
@@ -171,7 +171,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Parse location data
if (!parseGPRMC(gprmc, position)) {
@@ -192,8 +192,8 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_ALARM, parser.group(index++));
// IMEI
- if (!identify(parser.group(index++), false)) {
- if (!identify(id)) {
+ if (!identify(parser.group(index++), channel, null, false)) {
+ if (!identify(id, channel)) {
return null;
}
}
@@ -231,7 +231,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder {
int index = 1;
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/MeiligaoProtocol.java b/src/org/traccar/protocol/MeiligaoProtocol.java
new file mode 100644
index 000000000..37aa35df2
--- /dev/null
+++ b/src/org/traccar/protocol/MeiligaoProtocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class MeiligaoProtocol extends BaseProtocol {
+
+ public MeiligaoProtocol() {
+ super("meiligao");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new MeiligaoFrameDecoder());
+ pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(MeiligaoProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 2b1ea9434..f17d2e168 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -34,7 +34,7 @@ import org.traccar.model.Position;
public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
- public MeiligaoProtocolDecoder(String protocol) {
+ public MeiligaoProtocolDecoder(MeiligaoProtocol protocol) {
super(protocol);
}
@@ -118,8 +118,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
private String getMeiligaoServer(Channel channel) {
Properties p = Context.getProps();
- if (p != null && p.containsKey(getProtocol() + ".server")) {
- return p.getProperty(getProtocol() + ".server");
+ if (p != null && p.containsKey(getProtocolName() + ".server")) {
+ return p.getProperty(getProtocolName() + ".server");
} else {
InetSocketAddress address = (InetSocketAddress) channel.getLocalAddress();
return address.getAddress().getHostAddress() + ":" + address.getPort();
@@ -168,7 +168,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Custom data
if (command == MSG_ALARM) {
@@ -178,7 +178,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
// Get device by id
- if (!identify(getImei(id))) {
+ if (!identify(getImei(id), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/MeitrackProtocol.java b/src/org/traccar/protocol/MeitrackProtocol.java
new file mode 100644
index 000000000..c0261153b
--- /dev/null
+++ b/src/org/traccar/protocol/MeitrackProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class MeitrackProtocol extends BaseProtocol {
+
+ public MeitrackProtocol() {
+ super("meitrack");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new MeitrackFrameDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 3d6eb2a78..4e6927e56 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -36,7 +36,7 @@ import org.traccar.model.Position;
public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
- public MeitrackProtocolDecoder(String protocol) {
+ public MeitrackProtocolDecoder(MeitrackProtocol protocol) {
super(protocol);
}
@@ -84,12 +84,12 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identification
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
@@ -184,7 +184,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
// Identification
String imei = buf.toString(index + 1, 15, Charset.defaultCharset());
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
@@ -193,7 +193,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
while (buf.readableBytes() >= 0x34) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
// Event
diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java
new file mode 100644
index 000000000..88dfdd147
--- /dev/null
+++ b/src/org/traccar/protocol/MiniFinderProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class MiniFinderProtocol extends BaseProtocol {
+
+ public MiniFinderProtocol() {
+ super("minifinder");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new MiniFinderProtocolDecoder(MiniFinderProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
index 27442875a..cd1cc4eec 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
- public MiniFinderProtocolDecoder(String protocol) {
+ public MiniFinderProtocolDecoder(MiniFinderProtocol protocol) {
super(protocol);
}
@@ -57,7 +57,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
// Identification
if (sentence.startsWith("!1")) {
- identify(sentence.substring(3, sentence.length()));
+ identify(sentence.substring(3, sentence.length()), channel);
}
// Location
@@ -71,7 +71,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
diff --git a/src/org/traccar/protocol/Mta6Protocol.java b/src/org/traccar/protocol/Mta6Protocol.java
new file mode 100644
index 000000000..af6c35e1a
--- /dev/null
+++ b/src/org/traccar/protocol/Mta6Protocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Mta6Protocol extends BaseProtocol {
+
+ public Mta6Protocol() {
+ super("mta6");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpEncoder", new HttpResponseEncoder());
+ pipeline.addLast("objectDecoder", new Mta6ProtocolDecoder(Mta6Protocol.this, false));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index 459b8bcb8..8872ba76a 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -32,6 +32,7 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.BitUtil;
+import org.traccar.Protocol;
import org.traccar.helper.ChannelBufferTools;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -40,7 +41,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
private boolean simple;
- public Mta6ProtocolDecoder(String protocol, boolean simple) {
+ public Mta6ProtocolDecoder(Protocol protocol, boolean simple) {
super(protocol);
this.simple = simple;
}
@@ -123,7 +124,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
while (buf.readable()) {
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
short flags = buf.readUnsignedByte();
@@ -202,7 +203,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
private Position parseFormatA1(ChannelBuffer buf) {
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
short flags = buf.readUnsignedByte();
@@ -289,7 +290,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes("id=".length());
int index = ChannelBufferTools.find(buf, buf.readerIndex(), length, "&");
String uniqueId = buf.toString(buf.readerIndex(), index - buf.readerIndex(), Charset.defaultCharset());
- if (!identify(uniqueId)) {
+ if (!identify(uniqueId, channel)) {
return null;
}
buf.skipBytes(uniqueId.length());
diff --git a/src/org/traccar/protocol/Mta6canProtocol.java b/src/org/traccar/protocol/Mta6canProtocol.java
new file mode 100644
index 000000000..ed4003575
--- /dev/null
+++ b/src/org/traccar/protocol/Mta6canProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Mta6canProtocol extends BaseProtocol {
+
+ public Mta6canProtocol() {
+ super("mta6can");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpEncoder", new HttpResponseEncoder());
+ pipeline.addLast("objectDecoder", new Mta6ProtocolDecoder(Mta6canProtocol.this, true));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/MtxProtocol.java b/src/org/traccar/protocol/MtxProtocol.java
new file mode 100644
index 000000000..8dc5c43fb
--- /dev/null
+++ b/src/org/traccar/protocol/MtxProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class MtxProtocol extends BaseProtocol {
+
+ public MtxProtocol() {
+ super("mtx");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new MtxProtocolDecoder(MtxProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/MtxProtocolDecoder.java b/src/org/traccar/protocol/MtxProtocolDecoder.java
index 0151e9a8c..860f3a5a0 100644
--- a/src/org/traccar/protocol/MtxProtocolDecoder.java
+++ b/src/org/traccar/protocol/MtxProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class MtxProtocolDecoder extends BaseProtocolDecoder {
- public MtxProtocolDecoder(String protocol) {
+ public MtxProtocolDecoder(MtxProtocol protocol) {
super(protocol);
}
@@ -71,12 +71,12 @@ public class MtxProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/MxtProtocol.java b/src/org/traccar/protocol/MxtProtocol.java
new file mode 100644
index 000000000..5e6d4374e
--- /dev/null
+++ b/src/org/traccar/protocol/MxtProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.http.commands.CommandType;
+import org.traccar.protocol.commands.CommandTemplate;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class MxtProtocol extends BaseProtocol {
+
+ public MxtProtocol() {
+ super("mxt");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new MxtFrameDecoder());
+ pipeline.addLast("objectDecoder", new MxtProtocolDecoder(MxtProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index 32aa5a4ba..b6d9a2f9e 100644
--- a/src/org/traccar/protocol/MxtProtocolDecoder.java
+++ b/src/org/traccar/protocol/MxtProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class MxtProtocolDecoder extends BaseProtocolDecoder {
- public MxtProtocolDecoder(String protocol) {
+ public MxtProtocolDecoder(MxtProtocol protocol) {
super(protocol);
}
@@ -49,14 +49,14 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
int type = buf.readUnsignedByte();
String id = String.valueOf(buf.readUnsignedInt());
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
if (type == MSG_POSITION) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
buf.readUnsignedByte(); // protocol
diff --git a/src/org/traccar/protocol/NavigilProtocol.java b/src/org/traccar/protocol/NavigilProtocol.java
new file mode 100644
index 000000000..f41575e02
--- /dev/null
+++ b/src/org/traccar/protocol/NavigilProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class NavigilProtocol extends BaseProtocol {
+
+ public NavigilProtocol() {
+ super("navigil");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new NavigilFrameDecoder());
+ pipeline.addLast("objectDecoder", new NavigilProtocolDecoder(NavigilProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java
index 0a2e8ce44..711a51047 100644
--- a/src/org/traccar/protocol/NavigilProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class NavigilProtocolDecoder extends BaseProtocolDecoder {
- public NavigilProtocolDecoder(String protocol) {
+ public NavigilProtocolDecoder(NavigilProtocol protocol) {
super(protocol);
}
@@ -81,7 +81,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private Position parseUnitReport(ChannelBuffer buf, int sequenceNumber) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setValid(true);
position.set(Event.KEY_INDEX, sequenceNumber);
@@ -116,7 +116,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private Position parseTg2Report(ChannelBuffer buf, int sequenceNumber) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setValid(true);
position.set(Event.KEY_INDEX, sequenceNumber);
@@ -153,7 +153,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private Position parsePositionReport(ChannelBuffer buf, int sequenceNumber, long timestamp) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, sequenceNumber);
position.setDeviceId(getDeviceId());
@@ -174,7 +174,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private Position parsePositionReport2(ChannelBuffer buf, int sequenceNumber, long timestamp) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, sequenceNumber);
position.setDeviceId(getDeviceId());
@@ -197,7 +197,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private Position parseSnapshot4(ChannelBuffer buf, int sequenceNumber) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, sequenceNumber);
position.setDeviceId(getDeviceId());
@@ -236,7 +236,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private Position parseTrackingData(ChannelBuffer buf, int sequenceNumber, long timestamp) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, sequenceNumber);
position.setDeviceId(getDeviceId());
@@ -278,7 +278,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedShort(); // checksum
// Get device identifier
- if (!identify(String.valueOf(buf.readUnsignedInt()))) {
+ if (!identify(String.valueOf(buf.readUnsignedInt()), channel)) {
return null;
}
diff --git a/src/org/traccar/protocol/NavisProtocol.java b/src/org/traccar/protocol/NavisProtocol.java
new file mode 100644
index 000000000..726a28c03
--- /dev/null
+++ b/src/org/traccar/protocol/NavisProtocol.java
@@ -0,0 +1,38 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class NavisProtocol extends BaseProtocol {
+
+ public NavisProtocol() {
+ super("navis");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(4 * 1024, 12, 2, 2, 0));
+ pipeline.addLast("objectDecoder", new NavisProtocolDecoder(NavisProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 125559aab..94dcec1a4 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -38,7 +38,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
private static final Charset charset = Charset.defaultCharset();
- public NavisProtocolDecoder(String protocol) {
+ public NavisProtocolDecoder(NavisProtocol protocol) {
super(protocol);
}
@@ -80,7 +80,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
private ParseResult parsePosition(ChannelBuffer buf) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
@@ -252,7 +252,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
private Object processHandshake(Channel channel, ChannelBuffer buf) {
buf.readByte(); // semicolon symbol
- if (identify(buf.toString(Charset.defaultCharset()))) {
+ if (identify(buf.toString(Charset.defaultCharset()), channel)) {
sendReply(channel, ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*<S", charset));
}
return null;
diff --git a/src/org/traccar/protocol/NoranProtocol.java b/src/org/traccar/protocol/NoranProtocol.java
new file mode 100644
index 000000000..bf06b6ea0
--- /dev/null
+++ b/src/org/traccar/protocol/NoranProtocol.java
@@ -0,0 +1,36 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class NoranProtocol extends BaseProtocol {
+
+ public NoranProtocol() {
+ super("noran");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new NoranProtocolDecoder(NoranProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java
index 69ed623d8..f7eb26e97 100644
--- a/src/org/traccar/protocol/NoranProtocolDecoder.java
+++ b/src/org/traccar/protocol/NoranProtocolDecoder.java
@@ -21,7 +21,6 @@ import java.nio.charset.Charset;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Date;
import java.util.TimeZone;
import org.jboss.netty.buffer.ChannelBuffer;
@@ -35,7 +34,7 @@ import org.traccar.model.Position;
public class NoranProtocolDecoder extends BaseProtocolDecoder {
- public NoranProtocolDecoder(String protocol) {
+ public NoranProtocolDecoder(NoranProtocol protocol) {
super(protocol);
}
@@ -88,7 +87,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
if (type == MSG_CONTROL_RESPONSE) {
buf.readUnsignedInt(); // GIS ip
@@ -129,7 +128,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
// Identification
String id = buf.readBytes(newFormat ? 12 : 11).toString(Charset.defaultCharset()).replaceAll("[^\\p{Print}]", "");
- if (!identify(id)) {
+ if (!identify(id, channel, remoteAddress)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/OrionProtocol.java b/src/org/traccar/protocol/OrionProtocol.java
new file mode 100644
index 000000000..e074d3ea5
--- /dev/null
+++ b/src/org/traccar/protocol/OrionProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class OrionProtocol extends BaseProtocol {
+
+ public OrionProtocol() {
+ super("orion");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new OrionFrameDecoder());
+ pipeline.addLast("objectDecoder", new OrionProtocolDecoder(OrionProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/OrionProtocolDecoder.java b/src/org/traccar/protocol/OrionProtocolDecoder.java
index 7265a9762..e43ced8a5 100644
--- a/src/org/traccar/protocol/OrionProtocolDecoder.java
+++ b/src/org/traccar/protocol/OrionProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class OrionProtocolDecoder extends BaseProtocolDecoder {
- public OrionProtocolDecoder(String protocol) {
+ public OrionProtocolDecoder(OrionProtocol protocol) {
super(protocol);
}
@@ -72,7 +72,7 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, buf);
}
- if (!identify(String.valueOf(buf.readUnsignedInt()))) {
+ if (!identify(String.valueOf(buf.readUnsignedInt()), channel)) {
return null;
}
@@ -83,7 +83,7 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_EVENT, buf.readUnsignedByte());
buf.readUnsignedByte(); // length
diff --git a/src/org/traccar/protocol/OsmAndProtocol.java b/src/org/traccar/protocol/OsmAndProtocol.java
new file mode 100644
index 000000000..58702cf45
--- /dev/null
+++ b/src/org/traccar/protocol/OsmAndProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class OsmAndProtocol extends BaseProtocol {
+
+ public OsmAndProtocol() {
+ super("osmand");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpEncoder", new HttpResponseEncoder());
+ pipeline.addLast("objectDecoder", new OsmAndProtocolDecoder(OsmAndProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index 6fb858d70..91f15e098 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -38,7 +38,7 @@ import org.traccar.model.Position;
public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
- public OsmAndProtocolDecoder(String protocol) {
+ public OsmAndProtocolDecoder(OsmAndProtocol protocol) {
super(protocol);
}
@@ -58,11 +58,11 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Identification
String id = params.get(params.containsKey("id") ? "id" : "deviceid").get(0);
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/PiligrimProtocol.java b/src/org/traccar/protocol/PiligrimProtocol.java
new file mode 100644
index 000000000..438908b30
--- /dev/null
+++ b/src/org/traccar/protocol/PiligrimProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class PiligrimProtocol extends BaseProtocol {
+
+ public PiligrimProtocol() {
+ super("piligrim");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpAggregator", new HttpChunkAggregator(16384));
+ pipeline.addLast("httpEncoder", new HttpResponseEncoder());
+ pipeline.addLast("objectDecoder", new PiligrimProtocolDecoder(PiligrimProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
index 30b81f5fb..f3c9056af 100644
--- a/src/org/traccar/protocol/PiligrimProtocolDecoder.java
+++ b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
@@ -39,7 +39,7 @@ import org.traccar.model.Position;
public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
- public PiligrimProtocolDecoder(String protocol) {
+ public PiligrimProtocolDecoder(PiligrimProtocol protocol) {
super(protocol);
}
@@ -83,7 +83,7 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
// Identification
QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
- if (!identify(decoder.getParameters().get("imei").get(0))) {
+ if (!identify(decoder.getParameters().get("imei").get(0), channel)) {
return null;
}
@@ -99,7 +99,7 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_GPS || type == MSG_GPS_SENSORS) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
// Time
diff --git a/src/org/traccar/protocol/ProgressProtocol.java b/src/org/traccar/protocol/ProgressProtocol.java
new file mode 100644
index 000000000..8a84c8990
--- /dev/null
+++ b/src/org/traccar/protocol/ProgressProtocol.java
@@ -0,0 +1,38 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class ProgressProtocol extends BaseProtocol {
+
+ public ProgressProtocol() {
+ super("progress");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0));
+ pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(ProgressProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index 9ec0e08eb..4c3e58ddc 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -36,7 +36,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
private long lastIndex;
private long newIndex;
- public ProgressProtocolDecoder(String protocol) {
+ public ProgressProtocolDecoder(ProgressProtocol protocol) {
super(protocol);
}
@@ -81,7 +81,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(length);
length = buf.readUnsignedShort();
String imei = buf.readBytes(length).toString(Charset.defaultCharset());
- identify(imei);
+ identify(imei, channel);
}
// Position
@@ -95,7 +95,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
for (int j = 0; j < recordCount; j++) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
// Message index
diff --git a/src/org/traccar/protocol/Pt3000Protocol.java b/src/org/traccar/protocol/Pt3000Protocol.java
new file mode 100644
index 000000000..4d22418c0
--- /dev/null
+++ b/src/org/traccar/protocol/Pt3000Protocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Pt3000Protocol extends BaseProtocol {
+
+ public Pt3000Protocol() {
+ super("pt3000");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, 'd')); // probably wrong
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Pt3000ProtocolDecoder(Pt3000Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
index 01b7b284c..ebfded3d5 100644
--- a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
@@ -24,12 +24,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class Pt3000ProtocolDecoder extends BaseProtocolDecoder {
- public Pt3000ProtocolDecoder(String protocol) {
+ public Pt3000ProtocolDecoder(Pt3000Protocol protocol) {
super(protocol);
}
@@ -62,12 +61,12 @@ public class Pt3000ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identifier
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Pt502Protocol.java b/src/org/traccar/protocol/Pt502Protocol.java
new file mode 100644
index 000000000..53e2a8665
--- /dev/null
+++ b/src/org/traccar/protocol/Pt502Protocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class Pt502Protocol extends BaseProtocol {
+
+ public Pt502Protocol() {
+ super("pt502");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new Pt502FrameDecoder());
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new Pt502ProtocolDecoder(Pt502Protocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index fe22b0fdc..145d3d42d 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
- public Pt502ProtocolDecoder(String protocol) {
+ public Pt502ProtocolDecoder(Pt502Protocol protocol) {
super(protocol);
}
@@ -71,12 +71,12 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/RitiProtocol.java b/src/org/traccar/protocol/RitiProtocol.java
new file mode 100644
index 000000000..360f1ab7e
--- /dev/null
+++ b/src/org/traccar/protocol/RitiProtocol.java
@@ -0,0 +1,38 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class RitiProtocol extends BaseProtocol {
+
+ public RitiProtocol() {
+ super("riti");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 105, 2, 3, 0));
+ pipeline.addLast("objectDecoder", new RitiProtocolDecoder(RitiProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java
index 7c53ec37f..b684ad2e7 100644
--- a/src/org/traccar/protocol/RitiProtocolDecoder.java
+++ b/src/org/traccar/protocol/RitiProtocolDecoder.java
@@ -32,7 +32,7 @@ import org.traccar.model.Position;
public class RitiProtocolDecoder extends BaseProtocolDecoder {
- public RitiProtocolDecoder(String protocol) {
+ public RitiProtocolDecoder(RitiProtocol protocol) {
super(protocol);
}
@@ -58,12 +58,12 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
buf.skipBytes(2); // header
// Get device id
- if (!identify(String.valueOf(buf.readUnsignedShort()))) {
+ if (!identify(String.valueOf(buf.readUnsignedShort()), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/RuptelaProtocol.java b/src/org/traccar/protocol/RuptelaProtocol.java
new file mode 100644
index 000000000..79df3587d
--- /dev/null
+++ b/src/org/traccar/protocol/RuptelaProtocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class RuptelaProtocol extends BaseProtocol {
+
+ public RuptelaProtocol() {
+ super("ruptela");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, 2, 0));
+ pipeline.addLast("objectDecoder", new RuptelaProtocolDecoder(RuptelaProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
index 833285ca3..7938026e8 100644
--- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
- public RuptelaProtocolDecoder(String protocol) {
+ public RuptelaProtocolDecoder(RuptelaProtocol protocol) {
super(protocol);
}
@@ -47,7 +47,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
// Identify device
String imei = String.format("%015d", buf.readLong());
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
@@ -61,7 +61,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
for (int i = 0; i < count; i++) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
// Time
diff --git a/src/org/traccar/protocol/SanavProtocol.java b/src/org/traccar/protocol/SanavProtocol.java
new file mode 100644
index 000000000..6af6e90c5
--- /dev/null
+++ b/src/org/traccar/protocol/SanavProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class SanavProtocol extends BaseProtocol {
+
+ public SanavProtocol() {
+ super("sanav");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new SanavProtocolDecoder(SanavProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/SanavProtocolDecoder.java b/src/org/traccar/protocol/SanavProtocolDecoder.java
index 91bba54c7..d8c3bd65b 100644
--- a/src/org/traccar/protocol/SanavProtocolDecoder.java
+++ b/src/org/traccar/protocol/SanavProtocolDecoder.java
@@ -24,12 +24,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class SanavProtocolDecoder extends BaseProtocolDecoder {
- public SanavProtocolDecoder(String protocol) {
+ public SanavProtocolDecoder(SanavProtocol protocol) {
super(protocol);
}
@@ -62,11 +61,11 @@ public class SanavProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identification
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/SkypatrolProtocol.java b/src/org/traccar/protocol/SkypatrolProtocol.java
new file mode 100644
index 000000000..60bc86fdd
--- /dev/null
+++ b/src/org/traccar/protocol/SkypatrolProtocol.java
@@ -0,0 +1,33 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class SkypatrolProtocol extends BaseProtocol {
+
+ public SkypatrolProtocol() {
+ super("skypatrol");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(SkypatrolProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
index 5521502f6..a23ebc1e6 100644
--- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
+++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
- public SkypatrolProtocolDecoder(String protocol) {
+ public SkypatrolProtocolDecoder(SkypatrolProtocol protocol) {
super(protocol);
}
@@ -71,7 +71,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Status code
if (BitUtil.check(mask, 1)) {
@@ -90,7 +90,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
Log.warning("No device id field");
return null;
}
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Stl060Protocol.java b/src/org/traccar/protocol/Stl060Protocol.java
new file mode 100644
index 000000000..b8cd70664
--- /dev/null
+++ b/src/org/traccar/protocol/Stl060Protocol.java
@@ -0,0 +1,36 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Stl060Protocol extends BaseProtocol {
+
+ public Stl060Protocol() {
+ super("stl060");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new Stl060FrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new Stl060ProtocolDecoder(Stl060Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
index 30dc4ab5c..d9c21b441 100644
--- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
@@ -27,7 +27,7 @@ import org.traccar.model.Position;
public class Stl060ProtocolDecoder extends BaseProtocolDecoder {
- public Stl060ProtocolDecoder(String protocol) {
+ public Stl060ProtocolDecoder(Stl060Protocol protocol) {
super(protocol);
}
@@ -82,12 +82,12 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Device identification
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/SuntechProtocol.java b/src/org/traccar/protocol/SuntechProtocol.java
new file mode 100644
index 000000000..a7a72ef42
--- /dev/null
+++ b/src/org/traccar/protocol/SuntechProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class SuntechProtocol extends BaseProtocol {
+
+ public SuntechProtocol() {
+ super("suntech");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new SuntechProtocolDecoder(SuntechProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index f21f6e0a0..f7b109cb0 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class SuntechProtocolDecoder extends BaseProtocolDecoder {
- public SuntechProtocolDecoder(String protocol) {
+ public SuntechProtocolDecoder(SuntechProtocol protocol) {
super(protocol);
}
@@ -64,11 +64,11 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
int index = 1;
// Identifier
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/SyrusProtocol.java b/src/org/traccar/protocol/SyrusProtocol.java
new file mode 100644
index 000000000..0fb321c8e
--- /dev/null
+++ b/src/org/traccar/protocol/SyrusProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class SyrusProtocol extends BaseProtocol {
+
+ public SyrusProtocol() {
+ super("syrus");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '<'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new SyrusProtocolDecoder(SyrusProtocol.this, true));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/SyrusProtocolDecoder.java b/src/org/traccar/protocol/SyrusProtocolDecoder.java
index b182b8b37..236ded2dc 100644
--- a/src/org/traccar/protocol/SyrusProtocolDecoder.java
+++ b/src/org/traccar/protocol/SyrusProtocolDecoder.java
@@ -25,15 +25,15 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.Protocol;
import org.traccar.helper.UnitsConverter;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class SyrusProtocolDecoder extends BaseProtocolDecoder {
boolean sendResponse;
- public SyrusProtocolDecoder(String protocol, boolean sendResponse) {
+ public SyrusProtocolDecoder(Protocol protocol, boolean sendResponse) {
super(protocol);
this.sendResponse = sendResponse;
}
@@ -111,7 +111,7 @@ public class SyrusProtocolDecoder extends BaseProtocolDecoder {
// Find device in database
String id = sentence.substring(beginIndex, endIndex);
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
@@ -131,7 +131,7 @@ public class SyrusProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
diff --git a/src/org/traccar/protocol/T55Protocol.java b/src/org/traccar/protocol/T55Protocol.java
new file mode 100644
index 000000000..b547fd70d
--- /dev/null
+++ b/src/org/traccar/protocol/T55Protocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class T55Protocol extends BaseProtocol {
+
+ public T55Protocol() {
+ super("t55");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new T55ProtocolDecoder(T55Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index f20eb1bf7..ce9f98f2d 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class T55ProtocolDecoder extends BaseProtocolDecoder {
- public T55ProtocolDecoder(String protocol) {
+ public T55ProtocolDecoder(T55Protocol protocol) {
super(protocol);
}
@@ -92,33 +92,33 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
if (id.endsWith(",")) {
id = id.substring(0, id.length() - 1);
}
- identify(id);
+ identify(id, channel);
sentence = sentence.substring(index);
}
// Identification
if (sentence.startsWith("$PGID")) {
- identify(sentence.substring(6, sentence.length() - 3));
+ identify(sentence.substring(6, sentence.length() - 3), channel);
}
// Identification
else if (sentence.startsWith("$PCPTI")) {
- identify(sentence.substring(7, sentence.indexOf(",", 7)));
+ identify(sentence.substring(7, sentence.indexOf(",", 7)), channel);
}
// Identification
else if (sentence.startsWith("IMEI")) {
- identify(sentence.substring(5, sentence.length()));
+ identify(sentence.substring(5, sentence.length()), channel);
}
// Identification
else if (sentence.startsWith("$GPFID")) {
- identify(sentence.substring(6, sentence.length()));
+ identify(sentence.substring(6, sentence.length()), channel);
}
// Identification
else if (Character.isDigit(sentence.charAt(0)) & sentence.length() == 15) {
- identify(sentence);
+ identify(sentence, channel);
}
// Location
@@ -137,7 +137,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
@@ -195,7 +195,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
@@ -236,7 +236,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
@@ -284,7 +284,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
diff --git a/src/org/traccar/protocol/TaipProtocol.java b/src/org/traccar/protocol/TaipProtocol.java
new file mode 100644
index 000000000..fc66d23e8
--- /dev/null
+++ b/src/org/traccar/protocol/TaipProtocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class TaipProtocol extends BaseProtocol {
+
+ public TaipProtocol() {
+ super("taip");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new SyrusProtocolDecoder(TaipProtocol.this, false));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/TelikProtocol.java b/src/org/traccar/protocol/TelikProtocol.java
new file mode 100644
index 000000000..02d3b0875
--- /dev/null
+++ b/src/org/traccar/protocol/TelikProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class TelikProtocol extends BaseProtocol {
+
+ public TelikProtocol() {
+ super("telik");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\0'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new TelikProtocolDecoder(TelikProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/TelikProtocolDecoder.java b/src/org/traccar/protocol/TelikProtocolDecoder.java
index c1e5c9370..ece134c83 100644
--- a/src/org/traccar/protocol/TelikProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelikProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class TelikProtocolDecoder extends BaseProtocolDecoder {
- public TelikProtocolDecoder(String protocol) {
+ public TelikProtocolDecoder(TelikProtocol protocol) {
super(protocol);
}
@@ -62,12 +62,12 @@ public class TelikProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/TeltonikaProtocol.java b/src/org/traccar/protocol/TeltonikaProtocol.java
new file mode 100644
index 000000000..8c4495dfb
--- /dev/null
+++ b/src/org/traccar/protocol/TeltonikaProtocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class TeltonikaProtocol extends BaseProtocol {
+
+ public TeltonikaProtocol() {
+ super("teltonika");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new TeltonikaFrameDecoder());
+ pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 792a64b79..37168ce22 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
- public TeltonikaProtocolDecoder(String protocol) {
+ public TeltonikaProtocolDecoder(TeltonikaProtocol protocol) {
super(protocol);
}
@@ -39,7 +39,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
int length = buf.readUnsignedShort();
String imei = buf.toString(buf.readerIndex(), length, Charset.defaultCharset());
- boolean result = identify(imei);
+ boolean result = identify(imei, channel);
if (channel != null) {
ChannelBuffer response = ChannelBuffers.directBuffer(1);
@@ -68,7 +68,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
for (int i = 0; i < count; i++) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Tk102Protocol.java b/src/org/traccar/protocol/Tk102Protocol.java
new file mode 100644
index 000000000..dc27eb283
--- /dev/null
+++ b/src/org/traccar/protocol/Tk102Protocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Tk102Protocol extends BaseProtocol {
+
+ public Tk102Protocol() {
+ super("tk102");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ']'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Tk102ProtocolDecoder(Tk102Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
index 020fb8013..2a752f16f 100644
--- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
@@ -24,12 +24,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
- public Tk102ProtocolDecoder(String protocol) {
+ public Tk102ProtocolDecoder(Tk102Protocol protocol) {
super(protocol);
}
@@ -54,7 +53,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
// Login
if (sentence.startsWith("[!")) {
- if (!identify(sentence.substring(14, 14 + 15))) {
+ if (!identify(sentence.substring(14, 14 + 15), channel)) {
return null;
}
@@ -79,7 +78,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
diff --git a/src/org/traccar/protocol/Tk103Protocol.java b/src/org/traccar/protocol/Tk103Protocol.java
new file mode 100644
index 000000000..f7208861a
--- /dev/null
+++ b/src/org/traccar/protocol/Tk103Protocol.java
@@ -0,0 +1,48 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Tk103Protocol extends BaseProtocol {
+
+ public Tk103Protocol() {
+ super("tk103");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(Tk103Protocol.this));
+ }
+ });
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(Tk103Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index e51f8dea5..ded23da26 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
- public Tk103ProtocolDecoder(String protocol) {
+ public Tk103ProtocolDecoder(Tk103Protocol protocol) {
super(protocol);
}
@@ -83,11 +83,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Tlt2hProtocol.java b/src/org/traccar/protocol/Tlt2hProtocol.java
new file mode 100644
index 000000000..2313f8c59
--- /dev/null
+++ b/src/org/traccar/protocol/Tlt2hProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Tlt2hProtocol extends BaseProtocol {
+
+ public Tlt2hProtocol() {
+ super("tlt2h");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(32 * 1024, "##"));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Tlt2hProtocolDecoder(Tlt2hProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
index ecc61d740..fed224937 100644
--- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
- public Tlt2hProtocolDecoder(String protocol) {
+ public Tlt2hProtocolDecoder(Tlt2hProtocol protocol) {
super(protocol);
}
@@ -72,7 +72,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
}
// Get device identifier
- if (!identify(parser.group(1))) {
+ if (!identify(parser.group(1), channel)) {
return null;
}
@@ -86,7 +86,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder {
parser = patternPosition.matcher(message);
if (parser.matches()) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
diff --git a/src/org/traccar/protocol/TopflytechProtocol.java b/src/org/traccar/protocol/TopflytechProtocol.java
new file mode 100644
index 000000000..805a63d5b
--- /dev/null
+++ b/src/org/traccar/protocol/TopflytechProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class TopflytechProtocol extends BaseProtocol {
+
+ public TopflytechProtocol() {
+ super("topflytech");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new TopflytechProtocolDecoder(TopflytechProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/TopflytechProtocolDecoder.java b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
index e62f77c20..c2aafdea3 100644
--- a/src/org/traccar/protocol/TopflytechProtocolDecoder.java
+++ b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
@@ -24,12 +24,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class TopflytechProtocolDecoder extends BaseProtocolDecoder {
- public TopflytechProtocolDecoder(String protocol) {
+ public TopflytechProtocolDecoder(TopflytechProtocol protocol) {
super(protocol);
}
@@ -62,11 +61,11 @@ public class TopflytechProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identifier
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/TotemProtocol.java b/src/org/traccar/protocol/TotemProtocol.java
new file mode 100644
index 000000000..004a29173
--- /dev/null
+++ b/src/org/traccar/protocol/TotemProtocol.java
@@ -0,0 +1,36 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class TotemProtocol extends BaseProtocol {
+
+ public TotemProtocol() {
+ super("totem");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new TotemFrameDecoder());
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new TotemProtocolDecoder(TotemProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index cf4eaf9af..b348089ff 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class TotemProtocolDecoder extends BaseProtocolDecoder {
- public TotemProtocolDecoder(String protocol) {
+ public TotemProtocolDecoder(TotemProtocol protocol) {
super(protocol);
}
@@ -159,12 +159,12 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Tr20Protocol.java b/src/org/traccar/protocol/Tr20Protocol.java
new file mode 100644
index 000000000..0f8b6656e
--- /dev/null
+++ b/src/org/traccar/protocol/Tr20Protocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Tr20Protocol extends BaseProtocol {
+
+ public Tr20Protocol() {
+ super("tr20");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Tr20ProtocolDecoder(Tr20Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
index 048f510b4..c278fef73 100644
--- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
@@ -25,12 +25,11 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.UnitsConverter;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class Tr20ProtocolDecoder extends BaseProtocolDecoder {
- public Tr20ProtocolDecoder(String protocol) {
+ public Tr20ProtocolDecoder(Tr20Protocol protocol) {
super(protocol);
}
@@ -78,12 +77,12 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by id
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Tr900Protocol.java b/src/org/traccar/protocol/Tr900Protocol.java
new file mode 100644
index 000000000..b26652312
--- /dev/null
+++ b/src/org/traccar/protocol/Tr900Protocol.java
@@ -0,0 +1,49 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Tr900Protocol extends BaseProtocol {
+
+ public Tr900Protocol() {
+ super("tr900");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(Tr900Protocol.this));
+ }
+ });
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(Tr900Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Tr900ProtocolDecoder.java b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
index fadca5fc6..ff99a8e8a 100644
--- a/src/org/traccar/protocol/Tr900ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
@@ -28,7 +28,7 @@ import org.traccar.model.Position;
public class Tr900ProtocolDecoder extends BaseProtocolDecoder {
- public Tr900ProtocolDecoder(String protocol) {
+ public Tr900ProtocolDecoder(Tr900Protocol protocol) {
super(protocol);
}
@@ -69,11 +69,11 @@ public class Tr900ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identification
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel, remoteAddress)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/TrackboxProtocol.java b/src/org/traccar/protocol/TrackboxProtocol.java
new file mode 100644
index 000000000..447376f78
--- /dev/null
+++ b/src/org/traccar/protocol/TrackboxProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class TrackboxProtocol extends BaseProtocol {
+
+ public TrackboxProtocol() {
+ super("trackbox");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new TrackboxProtocolDecoder(TrackboxProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java
index 3404486aa..800fa16bd 100644
--- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class TrackboxProtocolDecoder extends BaseProtocolDecoder {
- public TrackboxProtocolDecoder(String protocol) {
+ public TrackboxProtocolDecoder(TrackboxProtocol protocol) {
super(protocol);
}
@@ -61,7 +61,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder {
if (sentence.startsWith("a=connect")) {
String id = sentence.substring(sentence.indexOf("i=") + 2);
- if (identify(id)) {
+ if (identify(id, channel)) {
sendResponse(channel);
}
}
@@ -77,7 +77,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
position.setDeviceId(getDeviceId());
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
diff --git a/src/org/traccar/protocol/TramigoProtocol.java b/src/org/traccar/protocol/TramigoProtocol.java
new file mode 100644
index 000000000..305107fc1
--- /dev/null
+++ b/src/org/traccar/protocol/TramigoProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.nio.ByteOrder;
+import java.util.List;
+import java.util.Map;
+
+public class TramigoProtocol extends BaseProtocol {
+
+ public TramigoProtocol() {
+ super("tramigo");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new TramigoFrameDecoder());
+ pipeline.addLast("objectDecoder", new TramigoProtocolDecoder(TramigoProtocol.this));
+ }
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
+ }
+}
diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java
index 38b343ad9..7694d1dcb 100644
--- a/src/org/traccar/protocol/TramigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java
@@ -35,7 +35,7 @@ import java.util.regex.Pattern;
public class TramigoProtocolDecoder extends BaseProtocolDecoder {
- public TramigoProtocolDecoder(String protocol) {
+ public TramigoProtocolDecoder(TramigoProtocol protocol) {
super(protocol);
}
@@ -61,12 +61,12 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.set(Event.KEY_INDEX, index);
position.setValid(true);
// Get device id
- if (!identify(String.valueOf(id))) {
+ if (!identify(String.valueOf(id), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/TytanProtocol.java b/src/org/traccar/protocol/TytanProtocol.java
new file mode 100644
index 000000000..11acae175
--- /dev/null
+++ b/src/org/traccar/protocol/TytanProtocol.java
@@ -0,0 +1,33 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class TytanProtocol extends BaseProtocol {
+
+ public TytanProtocol() {
+ super("tytan");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectDecoder", new TytanProtocolDecoder(TytanProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index 3ef0e11b7..5296d23a0 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class TytanProtocolDecoder extends BaseProtocolDecoder {
- public TytanProtocolDecoder(String protocol) {
+ public TytanProtocolDecoder(TytanProtocol protocol) {
super(protocol);
}
@@ -52,7 +52,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
}
String id = String.valueOf(buf.readUnsignedInt());
- if (!identify(id)) {
+ if (!identify(id, channel, remoteAddress)) {
return null;
}
@@ -61,7 +61,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
while (buf.readable()) {
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
int end = buf.readerIndex() + buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/UlbotechProtocol.java b/src/org/traccar/protocol/UlbotechProtocol.java
new file mode 100644
index 000000000..f60df7f30
--- /dev/null
+++ b/src/org/traccar/protocol/UlbotechProtocol.java
@@ -0,0 +1,34 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class UlbotechProtocol extends BaseProtocol {
+
+ public UlbotechProtocol() {
+ super("ulbotech");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new UlbotechFrameDecoder());
+ pipeline.addLast("objectDecoder", new UlbotechProtocolDecoder(UlbotechProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index 3ec50b3fc..e6ccfe2c5 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -28,7 +28,7 @@ import java.util.Date;
public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
- public UlbotechProtocolDecoder(String protocol) {
+ public UlbotechProtocolDecoder(UlbotechProtocol protocol) {
super(protocol);
}
@@ -57,11 +57,11 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Get device id
String imei = ChannelBufferTools.readHexString(buf, 16).substring(1);
- if (!identify(imei)) {
+ if (!identify(imei, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/V680Protocol.java b/src/org/traccar/protocol/V680Protocol.java
new file mode 100644
index 000000000..bb5b537d6
--- /dev/null
+++ b/src/org/traccar/protocol/V680Protocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class V680Protocol extends BaseProtocol {
+
+ public V680Protocol() {
+ super("v680");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new V680ProtocolDecoder(V680Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index 1558c7d8e..7fbbe400b 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class V680ProtocolDecoder extends BaseProtocolDecoder {
- public V680ProtocolDecoder(String protocol) {
+ public V680ProtocolDecoder(V680Protocol protocol) {
super(protocol);
}
@@ -63,7 +63,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
// Detect device ID
if (sentence.length() == 16) {
String imei = sentence.substring(1, sentence.length());
- identify(imei);
+ identify(imei, channel);
} else {
// Parse message
@@ -74,13 +74,13 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
String imei = parser.group(index++);
if (imei != null) {
- identify(imei);
+ identify(imei, channel);
}
if (!hasDeviceId()) {
return null;
diff --git a/src/org/traccar/protocol/VisiontekProtocol.java b/src/org/traccar/protocol/VisiontekProtocol.java
new file mode 100644
index 000000000..acce3fc35
--- /dev/null
+++ b/src/org/traccar/protocol/VisiontekProtocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class VisiontekProtocol extends BaseProtocol {
+
+ public VisiontekProtocol() {
+ super("visiontek");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new VisiontekProtocolDecoder(VisiontekProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
index 236f417e3..abb94ea3a 100644
--- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java
+++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
@@ -28,7 +28,7 @@ import org.traccar.model.Position;
public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
- public VisiontekProtocolDecoder(String protocol) {
+ public VisiontekProtocolDecoder(VisiontekProtocol protocol) {
super(protocol);
}
@@ -70,14 +70,14 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Device identification
String id = parser.group(index++);
String imei = parser.group(index++);
- if (!identify(id, false) && !identify(imei)) {
+ if (!identify(id, channel, null, false) && !identify(imei, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/WialonProtocol.java b/src/org/traccar/protocol/WialonProtocol.java
new file mode 100644
index 000000000..80854d1e6
--- /dev/null
+++ b/src/org/traccar/protocol/WialonProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class WialonProtocol extends BaseProtocol {
+
+ public WialonProtocol() {
+ super("wialon");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(4 * 1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new WialonProtocolDecoder(WialonProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java
index 423f614bc..d85a64d31 100644
--- a/src/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/org/traccar/protocol/WialonProtocolDecoder.java
@@ -32,7 +32,7 @@ import org.traccar.model.Position;
public class WialonProtocolDecoder extends BaseProtocolDecoder {
- public WialonProtocolDecoder(String protocol) {
+ public WialonProtocolDecoder(WialonProtocol protocol) {
super(protocol);
}
@@ -77,7 +77,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
Integer index = 1;
@@ -174,7 +174,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
// Detect device ID
if (sentence.startsWith("#L#")) {
String imei = sentence.substring(3, sentence.indexOf(';'));
- if (identify(imei)) {
+ if (identify(imei, channel)) {
sendResponse(channel, "#AL#", 1);
}
}
diff --git a/src/org/traccar/protocol/WondexProtocol.java b/src/org/traccar/protocol/WondexProtocol.java
new file mode 100644
index 000000000..a16c6b57d
--- /dev/null
+++ b/src/org/traccar/protocol/WondexProtocol.java
@@ -0,0 +1,36 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class WondexProtocol extends BaseProtocol {
+
+ public WondexProtocol() {
+ super("wondex");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new WondexFrameDecoder());
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new WondexProtocolDecoder(WondexProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java
index 0c627b07c..25d58d17b 100644
--- a/src/org/traccar/protocol/WondexProtocolDecoder.java
+++ b/src/org/traccar/protocol/WondexProtocolDecoder.java
@@ -30,7 +30,7 @@ import org.traccar.model.Position;
public class WondexProtocolDecoder extends BaseProtocolDecoder {
- public WondexProtocolDecoder(String protocol) {
+ public WondexProtocolDecoder(WondexProtocol protocol) {
super(protocol);
}
@@ -66,11 +66,11 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
int index = 1;
// Device identifier
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
index 8b654bef3..aba913ed3 100644
--- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
- public Xexun2ProtocolDecoder(String protocol) {
+ public Xexun2ProtocolDecoder(XexunProtocol protocol) {
super(protocol);
}
@@ -72,7 +72,7 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
@@ -127,7 +127,7 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder {
position.set(Event.KEY_ALARM, parser.group(index++));
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/XexunProtocol.java b/src/org/traccar/protocol/XexunProtocol.java
new file mode 100644
index 000000000..24e0d3279
--- /dev/null
+++ b/src/org/traccar/protocol/XexunProtocol.java
@@ -0,0 +1,44 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.Context;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class XexunProtocol extends BaseProtocol {
+
+ public XexunProtocol() {
+ super("xexun");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ if (Boolean.valueOf(Context.getProps().getProperty(XexunProtocol.this.getName() + ".extended"))) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); // tracker bug \n\r
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new Xexun2ProtocolDecoder(XexunProtocol.this));
+ } else {
+ pipeline.addLast("frameDecoder", new XexunFrameDecoder());
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new XexunProtocolDecoder(XexunProtocol.this));
+ }
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index 231d7a969..4f01faa0c 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -25,12 +25,11 @@ import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.model.Event;
import org.traccar.model.Position;
public class XexunProtocolDecoder extends BaseProtocolDecoder {
- public XexunProtocolDecoder(String protocol) {
+ public XexunProtocolDecoder(XexunProtocol protocol) {
super(protocol);
}
@@ -62,7 +61,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
@@ -108,7 +107,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder {
position.setTime(time.getTime());
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/XirgoProtocol.java b/src/org/traccar/protocol/XirgoProtocol.java
new file mode 100644
index 000000000..81026a676
--- /dev/null
+++ b/src/org/traccar/protocol/XirgoProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class XirgoProtocol extends BaseProtocol {
+
+ public XirgoProtocol() {
+ super("xirgo");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new XirgoProtocolDecoder(XirgoProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java
index 397924791..a08986f71 100644
--- a/src/org/traccar/protocol/XirgoProtocolDecoder.java
+++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class XirgoProtocolDecoder extends BaseProtocolDecoder {
- public XirgoProtocolDecoder(String protocol) {
+ public XirgoProtocolDecoder(XirgoProtocol protocol) {
super(protocol);
}
@@ -69,12 +69,12 @@ public class XirgoProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Get device by IMEI
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel, remoteAddress)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Xt013Protocol.java b/src/org/traccar/protocol/Xt013Protocol.java
new file mode 100644
index 000000000..b9b118081
--- /dev/null
+++ b/src/org/traccar/protocol/Xt013Protocol.java
@@ -0,0 +1,37 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Xt013Protocol extends BaseProtocol {
+
+ public Xt013Protocol() {
+ super("xt013");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("objectDecoder", new Xt013ProtocolDecoder(Xt013Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Xt013ProtocolDecoder.java b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
index 9e2f1fe40..c64869aa1 100644
--- a/src/org/traccar/protocol/Xt013ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
public class Xt013ProtocolDecoder extends BaseProtocolDecoder {
- public Xt013ProtocolDecoder(String protocol) {
+ public Xt013ProtocolDecoder(Xt013Protocol protocol) {
super(protocol);
}
@@ -71,12 +71,12 @@ public class Xt013ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
// Identify device
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/Xt7Protocol.java b/src/org/traccar/protocol/Xt7Protocol.java
new file mode 100644
index 000000000..59e387ee4
--- /dev/null
+++ b/src/org/traccar/protocol/Xt7Protocol.java
@@ -0,0 +1,35 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class Xt7Protocol extends BaseProtocol {
+
+ public Xt7Protocol() {
+ super("xt7");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 20, 1, 5, 0));
+ pipeline.addLast("objectDecoder", new Xt7ProtocolDecoder(Xt7Protocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/Xt7ProtocolDecoder.java b/src/org/traccar/protocol/Xt7ProtocolDecoder.java
index 69e72aa70..d6f82e453 100644
--- a/src/org/traccar/protocol/Xt7ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt7ProtocolDecoder.java
@@ -31,7 +31,7 @@ import org.traccar.model.Position;
public class Xt7ProtocolDecoder extends BaseProtocolDecoder {
- public Xt7ProtocolDecoder(String protocol) {
+ public Xt7ProtocolDecoder(Xt7Protocol protocol) {
super(protocol);
}
@@ -67,11 +67,11 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
// Get device by id
String id = buf.readBytes(16).toString(Charset.defaultCharset()).trim();
- if (!identify(id)) {
+ if (!identify(id, channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/YwtProtocol.java b/src/org/traccar/protocol/YwtProtocol.java
new file mode 100644
index 000000000..52cc98b92
--- /dev/null
+++ b/src/org/traccar/protocol/YwtProtocol.java
@@ -0,0 +1,39 @@
+package org.traccar.protocol;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.traccar.BaseProtocol;
+import org.traccar.TrackerServer;
+import org.traccar.protocol.commands.CommandTemplate;
+import org.traccar.http.commands.CommandType;
+
+import java.util.List;
+import java.util.Map;
+
+public class YwtProtocol extends BaseProtocol {
+
+ public YwtProtocol() {
+ super("ywt");
+ }
+
+ @Override
+ protected void loadCommandsTemplates(Map<CommandType, CommandTemplate> templates) {
+
+ }
+
+ @Override
+ public void addTrackerServersTo(List<TrackerServer> serverList) {
+ serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ @Override
+ protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("stringDecoder", new StringDecoder());
+ pipeline.addLast("stringEncoder", new StringEncoder());
+ pipeline.addLast("objectDecoder", new YwtProtocolDecoder(YwtProtocol.this));
+ }
+ });
+ }
+}
diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java
index e216d61fc..c0b814349 100644
--- a/src/org/traccar/protocol/YwtProtocolDecoder.java
+++ b/src/org/traccar/protocol/YwtProtocolDecoder.java
@@ -29,7 +29,7 @@ import org.traccar.model.Position;
public class YwtProtocolDecoder extends BaseProtocolDecoder {
- public YwtProtocolDecoder(String protocol) {
+ public YwtProtocolDecoder(YwtProtocol protocol) {
super(protocol);
}
@@ -81,12 +81,12 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder {
// Create new position
Position position = new Position();
- position.setProtocol(getProtocol());
+ position.setProtocol(getProtocolName());
Integer index = 1;
String type = parser.group(index++);
// Device
- if (!identify(parser.group(index++))) {
+ if (!identify(parser.group(index++), channel)) {
return null;
}
position.setDeviceId(getDeviceId());
diff --git a/src/org/traccar/protocol/commands/CommandTemplate.java b/src/org/traccar/protocol/commands/CommandTemplate.java
new file mode 100644
index 000000000..5d461b276
--- /dev/null
+++ b/src/org/traccar/protocol/commands/CommandTemplate.java
@@ -0,0 +1,8 @@
+package org.traccar.protocol.commands;
+
+import org.traccar.database.ActiveDevice;
+import org.traccar.http.commands.GpsCommand;
+
+public interface CommandTemplate<T extends GpsCommand> {
+ Object applyTo(ActiveDevice activeDevice, T command);
+}
diff --git a/src/org/traccar/protocol/commands/CommandValueConversion.java b/src/org/traccar/protocol/commands/CommandValueConversion.java
new file mode 100644
index 000000000..cfbf3ce5a
--- /dev/null
+++ b/src/org/traccar/protocol/commands/CommandValueConversion.java
@@ -0,0 +1,5 @@
+package org.traccar.protocol.commands;
+
+public interface CommandValueConversion<T> {
+ public String convert(T value);
+}
diff --git a/src/org/traccar/protocol/commands/StringCommandTemplate.java b/src/org/traccar/protocol/commands/StringCommandTemplate.java
new file mode 100644
index 000000000..2ac0ce9a8
--- /dev/null
+++ b/src/org/traccar/protocol/commands/StringCommandTemplate.java
@@ -0,0 +1,56 @@
+package org.traccar.protocol.commands;
+
+import org.traccar.database.ActiveDevice;
+import org.traccar.http.commands.GpsCommand;
+import org.traccar.protocol.commands.CommandValueConversion;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class StringCommandTemplate<T extends GpsCommand> implements CommandTemplate<T> {
+
+ private String messageTemplate;
+ private Map<Class<?>, CommandValueConversion> converters = new HashMap<Class<?>, CommandValueConversion>();
+
+ public StringCommandTemplate(String template, Object... replacements) {
+ this.messageTemplate = String.format(template, replacements);
+ }
+
+ @Override
+ public Object applyTo(ActiveDevice activeDevice, T command) {
+ String currentMessage = messageTemplate;
+ currentMessage = this.replace(currentMessage, GpsCommand.UNIQUE_ID, activeDevice.getUniqueId());
+
+ Map<String, Object> replacements = command.getReplacements();
+
+ for (Map.Entry<String, Object> entry : replacements.entrySet()) {
+ currentMessage = this.replace(currentMessage, entry.getKey(), entry.getValue());
+ }
+
+ return currentMessage;
+ }
+
+ public CommandTemplate addConverter(Class<?> type, CommandValueConversion converter) {
+ converters.put(type, converter);
+ return this;
+ }
+
+ protected CommandValueConversion getConverter(Class<?> type) {
+ return converters.containsKey(type) ? converters.get(type) : idConverter();
+ }
+
+ private CommandValueConversion idConverter() {
+ return new CommandValueConversion() {
+ @Override
+ public String convert(Object value) {
+ return value.toString();
+ }
+ };
+ }
+
+ private String replace(String currentMessage, String key, Object value) {
+ String replacementValue = getConverter(value.getClass()).convert(value);
+ return currentMessage.replace("[" + key + "]", replacementValue);
+ }
+
+}