diff options
author | jon-stumpf <jon.stumpf@gmail.com> | 2014-10-10 19:23:21 -0400 |
---|---|---|
committer | jon-stumpf <jon.stumpf@gmail.com> | 2014-10-21 16:01:41 -0400 |
commit | 1948e0f63202dddca607dcb51fa9a92a83e49154 (patch) | |
tree | 3771c3d64b219704cbbb2cb8f69ac941dbb34da0 /src/org/traccar/protocol | |
parent | 8876e964cf26a090d11fd855642c95bc02a17c7f (diff) | |
download | traccar-server-1948e0f63202dddca607dcb51fa9a92a83e49154.tar.gz traccar-server-1948e0f63202dddca607dcb51fa9a92a83e49154.tar.bz2 traccar-server-1948e0f63202dddca607dcb51fa9a92a83e49154.zip |
Eliminated the need for hardcoded protocol strings in the src/org/traccar/protocol/*ProtocolDecoder.java files.
Diffstat (limited to 'src/org/traccar/protocol')
70 files changed, 386 insertions, 88 deletions
diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java index 54b112b59..954006807 100644 --- a/src/org/traccar/protocol/ApelProtocolDecoder.java +++ b/src/org/traccar/protocol/ApelProtocolDecoder.java @@ -42,6 +42,10 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public ApelProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + /* * Message types */ @@ -165,7 +169,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < recordCount; j++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("apel"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); // Message index diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index 21a3127d1..468e4a5fc 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -31,6 +31,10 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public AplicomProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final long IMEI_BASE_TC65_V20 = 0x1437207000000L; private static final long IMEI_BASE_TC65_V28 = 358244010000000L; private static final long IMEI_BASE_TC65I_V11 = 0x14143B4000000L; @@ -124,7 +128,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("aplicom"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); try { position.setDeviceId(getDataManager().getDeviceByImei(imei).getId()); } catch(Exception error) { diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java index 3dbd214d9..7edafa057 100644 --- a/src/org/traccar/protocol/AtrackProtocolDecoder.java +++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java @@ -35,6 +35,10 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public AtrackProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final int MSG_HEARTBEAT = 0x1A; private static final int MSG_DATA = 0x10; @@ -96,7 +100,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("atrack"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Date and time position.setTime(new Date(buf.readUnsignedInt() * 1000)); // gps time diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java index 239b0aac5..4184ee0e2 100644 --- a/src/org/traccar/protocol/BoxProtocolDecoder.java +++ b/src/org/traccar/protocol/BoxProtocolDecoder.java @@ -35,6 +35,10 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public BoxProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "L," + "(\\d{2})(\\d{2})(\\d{2})" + // Date @@ -79,7 +83,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("box"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java index 559a5ccc1..aa02ba044 100644 --- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java @@ -34,6 +34,10 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public CarTrackProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\$\\$" + // Header "(\\d+)\\?*" + // Device ID @@ -70,7 +74,7 @@ public class CarTrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("cartrack"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Get device by unique identifier diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java index 9748b2e09..6683a463f 100644 --- a/src/org/traccar/protocol/CarscopProtocolDecoder.java +++ b/src/org/traccar/protocol/CarscopProtocolDecoder.java @@ -35,6 +35,10 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public CarscopProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + // Very similar to TK103 protocol static private Pattern pattern = Pattern.compile( "\\*.*" + @@ -80,7 +84,7 @@ public class CarscopProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("carscop"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); index = 1; // Time diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java index 7e55a6865..8cce47bd5 100644 --- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java +++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java @@ -34,6 +34,10 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public CellocatorProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private String readImei(ChannelBuffer buf) { int b = buf.readUnsignedByte(); StringBuilder imei = new StringBuilder(); @@ -103,7 +107,7 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder { // Parse location if (type == MSG_CLIENT_STATUS) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("cellocator"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Device identifier try { diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java index 4b0080267..87a0135eb 100644 --- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java +++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java @@ -33,6 +33,10 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public EasyTrackProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + //ET,358155100003016,HB,A,0d081e,07381e,8038ee09,03d2e9be,004f,0000,40c00000,0f,100,0000,00037c,29 static private Pattern pattern = Pattern.compile( "\\*..," + // Manufacturer @@ -74,7 +78,7 @@ public class EasyTrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("easytrack"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index 00c74f7f3..97c2821b5 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -36,6 +36,10 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public EelinkProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private String readImei(ChannelBuffer buf) { int b = buf.readUnsignedByte(); StringBuilder imei = new StringBuilder(); @@ -105,7 +109,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("eelink"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("index", index); // Location diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java index eec724e30..0509b0c6d 100644 --- a/src/org/traccar/protocol/EnforaProtocolDecoder.java +++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java @@ -36,6 +36,10 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public EnforaProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "GPRMC," + "(\\d{2})(\\d{2})(\\d{2}).(\\d+)," + // Time (HHMMSS.SS) @@ -94,7 +98,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("enfora"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Get device by IMEI diff --git a/src/org/traccar/protocol/Ev603ProtocolDecoder.java b/src/org/traccar/protocol/Ev603ProtocolDecoder.java index a57a0e79b..c73067b0c 100644 --- a/src/org/traccar/protocol/Ev603ProtocolDecoder.java +++ b/src/org/traccar/protocol/Ev603ProtocolDecoder.java @@ -36,6 +36,10 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{ super(serverManager);
}
+ public Ev603ProtocolDecoder(ServerManager serverManager, String protocol) {
+ super(serverManager, protocol);
+ }
+
private static final Pattern pattern = Pattern.compile(
"!A," + // Type
"(\\d{2})\\/(\\d{2})\\/(\\d{2})," + // Date dd/mm/YY
@@ -74,7 +78,7 @@ public class Ev603ProtocolDecoder extends BaseProtocolDecoder{ // Create new position
Position position = new Position();
position.setDeviceId(deviceId);
- ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("ev603");
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
Integer index = 1;
// Date
diff --git a/src/org/traccar/protocol/FreedomProtocolDecoder.java b/src/org/traccar/protocol/FreedomProtocolDecoder.java index 7e86d285f..0acff7f22 100644 --- a/src/org/traccar/protocol/FreedomProtocolDecoder.java +++ b/src/org/traccar/protocol/FreedomProtocolDecoder.java @@ -33,6 +33,10 @@ public class FreedomProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public FreedomProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "IMEI," + "(\\d+)," + // IMEI @@ -56,7 +60,7 @@ public class FreedomProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("freedom"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Identification diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java index 079b76ea4..cb29a0920 100644 --- a/src/org/traccar/protocol/GalileoProtocolDecoder.java +++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java @@ -40,6 +40,10 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public GalileoProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final int TAG_IMEI = 0x03; private static final int TAG_DATE = 0x20; private static final int TAG_COORDINATES = 0x30; @@ -97,7 +101,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { List<Position> positions = new LinkedList<Position>(); Set<Integer> tags = new HashSet<Integer>(); Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("galileo"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); while (buf.readerIndex() < length) { @@ -108,7 +112,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder { positions.add(position); tags.clear(); position = new Position(); - extendedInfo = new ExtendedInfoFormatter("galileo"); + extendedInfo = new ExtendedInfoFormatter(getProtocol()); } tags.add(tag); diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java index 15a46d375..7f93082fd 100644 --- a/src/org/traccar/protocol/GatorProtocolDecoder.java +++ b/src/org/traccar/protocol/GatorProtocolDecoder.java @@ -33,6 +33,10 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public GatorProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final int PACKET_HEARTBEAT = 0x21; private static final int PACKET_POSITION_DATA = 0x80; private static final int PACKET_ROLLCALL_RESPONSE = 0x81; @@ -66,7 +70,7 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gator"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Identification try { diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java index 572615053..0dac5d2b3 100644 --- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Gl100ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\+RESP:GT...," + "(\\d{15})," + // IMEI @@ -74,7 +78,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gl100"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java index 942d6ef10..83fd42b74 100644 --- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Gl200ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\+(?:RESP|BUFF):GT...," + "[0-9a-fA-F]{6}," + // Protocol version @@ -67,7 +71,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gl200"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java index 5b4dc5e9b..bd56fde1f 100644 --- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java +++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java @@ -36,6 +36,10 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { public GlobalSatProtocolDecoder(ServerManager serverManager) { super(serverManager); + // This is now only called by test classes. + // This will be deleted in the next commit. + assert (serverManager == null); + // Initialize format strings format0 = "TSPRXAB27GHKLMnaicz*U!"; format1 = "SARY*U!"; @@ -49,6 +53,23 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { } } } + + public GlobalSatProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + + // Initialize format strings + format0 = "TSPRXAB27GHKLMnaicz*U!"; + format1 = "SARY*U!"; + if (getServerManager() != null) { + Properties p = getServerManager().getProperties(); + if (p.containsKey(protocol + ".format0")) { + format0 = p.getProperty(protocol + ".format0"); + } + if (p.containsKey(protocol + ".format1")) { + format1 = p.getProperty(protocol + ".format1"); + } + } + } private Position decodeOriginal(Channel channel, String sentence) { @@ -83,7 +104,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { // Parse data Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("globalsat"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); for (int formatIndex = 0, valueIndex = 1; formatIndex < format.length() && valueIndex < values.length; formatIndex++) { String value = values[valueIndex]; @@ -204,7 +225,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("globalsat"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Identification diff --git a/src/org/traccar/protocol/GotopProtocolDecoder.java b/src/org/traccar/protocol/GotopProtocolDecoder.java index 826faf531..70d0063a1 100644 --- a/src/org/traccar/protocol/GotopProtocolDecoder.java +++ b/src/org/traccar/protocol/GotopProtocolDecoder.java @@ -33,6 +33,10 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public GotopProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "(\\d+)," + // IMEI "[^,]+," + // Type @@ -60,7 +64,7 @@ public class GotopProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gotop"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Get device by IMEI diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 124df4377..ca578841a 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -34,6 +34,10 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Gps103ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "imei:" + "(\\d+)," + // IMEI @@ -88,7 +92,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gps103"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java index 268f9ea8a..bc8c759c3 100644 --- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java +++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java @@ -36,6 +36,10 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public GpsGateProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + /** * Regular expressions pattern */ @@ -104,7 +108,7 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gpsgate"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java index 561377f7f..8e351f456 100644 --- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Gt02ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private String readImei(ChannelBuffer buf) { int b = buf.readUnsignedByte(); StringBuilder imei = new StringBuilder(); @@ -77,7 +81,7 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gt02"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("index", index); // Get device id diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 44702924c..f1e8585e5 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -36,12 +36,16 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { public Gt06ProtocolDecoder(ServerManager serverManager) { super(serverManager); + } + + public Gt06ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); if (serverManager != null) { Properties p = getServerManager().getProperties(); - if (p.containsKey("gt06.timezone")) { + if (p.containsKey(protocol + ".timezone")) { timeZone.setRawOffset( - Integer.valueOf(p.getProperty("gt06.timezone")) * 1000); + Integer.valueOf(p.getProperty(protocol + ".timezone")) * 1000); } } } @@ -144,7 +148,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("gt06"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Date and time Calendar time = Calendar.getInstance(timeZone); diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index 51b1aff5e..f7843e2c8 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -35,6 +35,10 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { public H02ProtocolDecoder(ServerManager serverManager) { super(serverManager); } + + public H02ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } private static double readCoordinate(ChannelBuffer buf, boolean lon) { @@ -59,7 +63,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("h02"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); buf.readByte(); // marker @@ -133,7 +137,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("h02"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java index 1845dc31b..199093492 100644 --- a/src/org/traccar/protocol/HaicomProtocolDecoder.java +++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java @@ -33,6 +33,10 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public HaicomProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\$GPRS" + "(\\d+)," + // IMEI @@ -67,7 +71,7 @@ public class HaicomProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("haicom"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java index 53e67af3d..fe093a033 100644 --- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java +++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java @@ -33,6 +33,10 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public IntellitracProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "(?:.+,)?(\\d+)," + // Device Identifier "(\\d{4})(\\d{2})(\\d{2})" + // Date (YYYYMMDD) @@ -76,7 +80,7 @@ public class IntellitracProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("intellitrac"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Detect device diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index b8273b5a4..7f67daafe 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -36,10 +36,14 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Jt600ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private Position decodeNormalMessage(ChannelBuffer buf) throws Exception { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("jt600"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); buf.readByte(); // header @@ -158,7 +162,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("jt600"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("alert", "true"); Integer index = 1; diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java index bd21592e1..e8716ffd0 100644 --- a/src/org/traccar/protocol/KhdProtocolDecoder.java +++ b/src/org/traccar/protocol/KhdProtocolDecoder.java @@ -35,6 +35,10 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public KhdProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private String readSerialNumber(ChannelBuffer buf) { int b1 = buf.readUnsignedByte(); int b2 = buf.readUnsignedByte(); if (b2 > 0x80) b2 -= 0x80; @@ -73,7 +77,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("khd"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Device identification String id = readSerialNumber(buf); diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java index a62a50e51..cba86f7b4 100644 --- a/src/org/traccar/protocol/LaipacProtocolDecoder.java +++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java @@ -34,6 +34,10 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public LaipacProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\$AVRMC," + "([^,]+)," + // Identifier @@ -71,7 +75,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("laipac"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Identification diff --git a/src/org/traccar/protocol/M2mProtocolDecoder.java b/src/org/traccar/protocol/M2mProtocolDecoder.java index f54934536..2a0c8ebaf 100644 --- a/src/org/traccar/protocol/M2mProtocolDecoder.java +++ b/src/org/traccar/protocol/M2mProtocolDecoder.java @@ -31,6 +31,10 @@ public class M2mProtocolDecoder extends BaseProtocolDecoder { public M2mProtocolDecoder(ServerManager serverManager) { super(serverManager); } + + public M2mProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } private boolean firstPacket = true; private Long deviceId; @@ -75,7 +79,7 @@ public class M2mProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("m2m"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); // Date and time diff --git a/src/org/traccar/protocol/ManPowerProtocolDecoder.java b/src/org/traccar/protocol/ManPowerProtocolDecoder.java index d8bcdb937..57b47ce5e 100644 --- a/src/org/traccar/protocol/ManPowerProtocolDecoder.java +++ b/src/org/traccar/protocol/ManPowerProtocolDecoder.java @@ -33,6 +33,10 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public ManPowerProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + static private Pattern pattern = Pattern.compile( "simei:" + "(\\d+)," + // IMEI @@ -64,7 +68,7 @@ public class ManPowerProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("manpower"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/MaxonProtocolDecoder.java b/src/org/traccar/protocol/MaxonProtocolDecoder.java index b6ba2fb4b..c1e9e4ec5 100644 --- a/src/org/traccar/protocol/MaxonProtocolDecoder.java +++ b/src/org/traccar/protocol/MaxonProtocolDecoder.java @@ -47,6 +47,10 @@ public class MaxonProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public MaxonProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + /** * Regular expressions pattern */ diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index 96b2d564d..a4e25510d 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -33,6 +33,10 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public MegastekProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern patternGPRMC = Pattern.compile( "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2})\\.\\d+," + // Time (HHMMSS.SSS) @@ -176,7 +180,7 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("megastek"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Parse location data if (!parseGPRMC(gprmc, position)) { diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 6221ce4e7..73b238443 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -38,6 +38,10 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public MeiligaoProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "(\\d{2})(\\d{2})(\\d{2})\\.?(\\d+)?," + // Time (HHMMSS.SSS) "([AV])," + // Validity @@ -116,8 +120,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { private String getMeiligaoServer(Channel channel) { if (getServerManager() != null && - getServerManager().getProperties().containsKey("meiligao.server")) { - return getServerManager().getProperties().getProperty("meiligao.server"); + getServerManager().getProperties().containsKey(getProtocol() + ".server")) { + return getServerManager().getProperties().getProperty(getProtocol() + ".server"); } else { InetSocketAddress address = (InetSocketAddress) channel.getLocalAddress(); return address.getAddress().getHostAddress() + ":" + address.getPort(); @@ -160,7 +164,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("meiligao"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Custom data if (command == MSG_ALARM) { diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 166c77e60..972f69061 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -39,6 +39,10 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public MeitrackProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + //$$J163,123123123123123,AFF,0004,35,58.588926,16.180473,140928192856,A,10,27,0,161,1.2,19 //,1648894,435695,240|24|88B9|E435,0000,|||0A22|0000,00000001,,50,,,,,,,,,,,,,*70\r\n private static final Pattern pattern = Pattern.compile( @@ -81,7 +85,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("meitrack"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; @@ -182,7 +186,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { while (buf.readableBytes() >= 0x34) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("meitrack"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); // Event diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index 2d524a23a..96057f347 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -35,6 +35,10 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public MiniFinderProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\!D," + "(\\d+)/(\\d+)/(\\d+)," + // Date @@ -78,7 +82,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("minifinder"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java index 62fa87e68..0908a5793 100644 --- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java +++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java @@ -41,8 +41,12 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { private boolean simple; - public Mta6ProtocolDecoder(ServerManager serverManager, boolean simple) { + public Mta6ProtocolDecoder(ServerManager serverManager) { super(serverManager); + } + + public Mta6ProtocolDecoder(ServerManager serverManager, String protocol, boolean simple) { + super(serverManager, protocol); this.simple = simple; } @@ -129,7 +133,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { while (buf.readable()) { Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("mta6"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); short flags = buf.readUnsignedByte(); @@ -211,7 +215,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder { private Position parseFormatA1(ChannelBuffer buf, long deviceId) { Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("mta6"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); short flags = buf.readUnsignedByte(); diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java index 29be1e5ad..938426297 100644 --- a/src/org/traccar/protocol/NavigilProtocolDecoder.java +++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java @@ -33,6 +33,10 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { public NavigilProtocolDecoder(ServerManager serverManager) { super(serverManager); } + + public NavigilProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } private static final int LEAP_SECONDS_DELTA = 25; @@ -80,7 +84,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private Position parseUnitReport(ChannelBuffer buf, long deviceId, int sequenceNumber) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("navigil"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setValid(true); extendedInfo.set("index", sequenceNumber); @@ -117,7 +121,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private Position parseTg2Report(ChannelBuffer buf, long deviceId, int sequenceNumber) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("navigil"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setValid(true); extendedInfo.set("index", sequenceNumber); @@ -156,7 +160,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private Position parsePositionReport(ChannelBuffer buf, long deviceId, int sequenceNumber, long timestamp) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("navigil"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("index", sequenceNumber); position.setDeviceId(deviceId); @@ -180,7 +184,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private Position parsePositionReport2(ChannelBuffer buf, long deviceId, int sequenceNumber, long timestamp) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("navigil"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("index", sequenceNumber); position.setDeviceId(deviceId); @@ -207,7 +211,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private Position parseSnapshot4(ChannelBuffer buf, long deviceId, int sequenceNumber) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("navigil"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("index", sequenceNumber); position.setDeviceId(deviceId); @@ -248,7 +252,7 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder { private Position parseTrackingData(ChannelBuffer buf, long deviceId, int sequenceNumber, long timestamp) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("navigil"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("index", sequenceNumber); position.setDeviceId(deviceId); diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java index 1ee28e0aa..fe4b04543 100644 --- a/src/org/traccar/protocol/NavisProtocolDecoder.java +++ b/src/org/traccar/protocol/NavisProtocolDecoder.java @@ -45,6 +45,10 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public NavisProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + // Format types public static final int F10 = 0x01; public static final int F20 = 0x02; @@ -83,7 +87,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder { private ParseResult parsePosition(ChannelBuffer buf) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("navis"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(databaseDeviceId); position.setAltitude(0.0); diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java index 4cb35fee5..207975aec 100644 --- a/src/org/traccar/protocol/NoranProtocolDecoder.java +++ b/src/org/traccar/protocol/NoranProtocolDecoder.java @@ -36,6 +36,10 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public NoranProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final int MSG_UPLOAD_POSITION = 0x0008; private static final int MSG_CONTROL_RESPONSE = 0x8009; private static final int MSG_ALARM = 0x0003; @@ -73,7 +77,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("noran"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); if (type == MSG_CONTROL_RESPONSE) { buf.readUnsignedInt(); // GIS ip diff --git a/src/org/traccar/protocol/OrionProtocolDecoder.java b/src/org/traccar/protocol/OrionProtocolDecoder.java index 1846bba23..ed0e7c169 100644 --- a/src/org/traccar/protocol/OrionProtocolDecoder.java +++ b/src/org/traccar/protocol/OrionProtocolDecoder.java @@ -34,6 +34,10 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder { public OrionProtocolDecoder(ServerManager serverManager) { super(serverManager); } + + public OrionProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } private static final int TYPE_USERLOG = 0; private static final int TYPE_SYSLOG = 3; @@ -88,7 +92,7 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("orion"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); extendedInfo.set("event", buf.readUnsignedByte()); buf.readUnsignedByte(); // length diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index e150275bd..7c76ea851 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -41,6 +41,10 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { public OsmAndProtocolDecoder(ServerManager serverManager) { super(serverManager); } + + public OsmAndProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } @Override protected Object decode( @@ -58,7 +62,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("osmand"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Identification String id = params.get(params.containsKey("id") ? "id" : "deviceid").get(0); diff --git a/src/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/org/traccar/protocol/PiligrimProtocolDecoder.java index e0947b02a..db051c39f 100644 --- a/src/org/traccar/protocol/PiligrimProtocolDecoder.java +++ b/src/org/traccar/protocol/PiligrimProtocolDecoder.java @@ -43,6 +43,10 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public PiligrimProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private void sendResponse(Channel channel, String message) { if (channel != null) { HttpResponse response = new DefaultHttpResponse( @@ -104,7 +108,7 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_GPS || type == MSG_GPS_SENSORS) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("piligrim"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); // Time diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java index 85680c039..492c5afd3 100644 --- a/src/org/traccar/protocol/ProgressProtocolDecoder.java +++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java @@ -44,6 +44,10 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public ProgressProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + /* * Message types */ @@ -128,7 +132,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder { for (int j = 0; j < recordCount; j++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("progress"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); // Message index diff --git a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java index 50b5aca02..8767b0f7c 100644 --- a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Pt3000ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Pt3000ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + static private Pattern pattern = Pattern.compile( "\\%(\\d+)," + // IMEI "\\$GPRMC," + @@ -62,7 +66,7 @@ public class Pt3000ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("pt3000"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index b324e3c55..c555a3690 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -34,6 +34,10 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { super(serverManager);
}
+ public Pt502ProtocolDecoder(ServerManager serverManager, String protocol) {
+ super(serverManager, protocol);
+ }
+
private static final Pattern pattern = Pattern.compile(
".*\\$POS," + // Data Frame start
"(\\d+)," + // Id
@@ -63,7 +67,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { // Create new position
Position position = new Position();
- ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("pt502");
+ ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
Integer index = 1;
diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java index aad68a37d..1c7a0500b 100644 --- a/src/org/traccar/protocol/RitiProtocolDecoder.java +++ b/src/org/traccar/protocol/RitiProtocolDecoder.java @@ -36,6 +36,10 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public RitiProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2})\\.?\\d*," + // Time (HHMMSS.SSS) @@ -58,7 +62,7 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("riti"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); buf.skipBytes(2); // header diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java index c9f8bd392..c5d678a06 100644 --- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -34,6 +34,10 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public RuptelaProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final int COMMAND_RECORDS = 0x01; @Override @@ -64,7 +68,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { for (int i = 0; i < count; i++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("ruptela"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); // Time diff --git a/src/org/traccar/protocol/SanavProtocolDecoder.java b/src/org/traccar/protocol/SanavProtocolDecoder.java index e60209855..d09065355 100644 --- a/src/org/traccar/protocol/SanavProtocolDecoder.java +++ b/src/org/traccar/protocol/SanavProtocolDecoder.java @@ -33,6 +33,10 @@ public class SanavProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public SanavProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( ".*imei[:=]" + "(\\d+)" + // IMEI @@ -62,7 +66,7 @@ public class SanavProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("sanav"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Identification diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java index 4c7829bf6..5ef8a09a4 100644 --- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java +++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java @@ -33,6 +33,10 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public SkypatrolProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static boolean checkBit(long mask, int bit) { long checkMask = 1 << bit; return (mask & checkMask) == checkMask; @@ -76,7 +80,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("skypatrol"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Status code if (checkBit(mask, 1)) { diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java index 211483aed..77d7ed3bf 100644 --- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java +++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Stl060ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( ".*\\$1," + "(\\d+)," + // IMEI @@ -67,7 +71,7 @@ public class Stl060ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("stl060"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java index 124b4feaf..5b5f4f136 100644 --- a/src/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java @@ -33,6 +33,10 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public SuntechProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + static private Pattern pattern = Pattern.compile( "S.\\d{3}(?:\\w{3})?;" + // Header "(?:[^;]+;)?" + @@ -62,7 +66,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("suntech"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); int index = 1; // Identifier diff --git a/src/org/traccar/protocol/SyrusProtocolDecoder.java b/src/org/traccar/protocol/SyrusProtocolDecoder.java index 0d61daf82..fc307d09a 100644 --- a/src/org/traccar/protocol/SyrusProtocolDecoder.java +++ b/src/org/traccar/protocol/SyrusProtocolDecoder.java @@ -37,6 +37,11 @@ public class SyrusProtocolDecoder extends BaseProtocolDecoder { this.sendResponse = sendResponse; } + public SyrusProtocolDecoder(ServerManager serverManager, String protocol, boolean sendResponse) { + super(serverManager, protocol); + this.sendResponse = sendResponse; + } + private static final Pattern pattern = Pattern.compile( "R[EP]V" + // Type "(?:\\d{2}" + // Event index @@ -132,7 +137,7 @@ public class SyrusProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("syrus"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java index da473d994..c3128bf97 100644 --- a/src/org/traccar/protocol/T55ProtocolDecoder.java +++ b/src/org/traccar/protocol/T55ProtocolDecoder.java @@ -35,6 +35,10 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public T55ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern patternGPRMC = Pattern.compile( "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2})\\.?\\d*," + // Time (HHMMSS.SSS) @@ -143,7 +147,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("t55"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; @@ -210,7 +214,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("t55"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; @@ -262,7 +266,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("t55"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; @@ -319,7 +323,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("t55"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; diff --git a/src/org/traccar/protocol/TelikProtocolDecoder.java b/src/org/traccar/protocol/TelikProtocolDecoder.java index d632cc478..0f5e3794b 100644 --- a/src/org/traccar/protocol/TelikProtocolDecoder.java +++ b/src/org/traccar/protocol/TelikProtocolDecoder.java @@ -33,6 +33,10 @@ public class TelikProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public TelikProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\d{4}" + "(\\d{6})" + // Device ID @@ -62,7 +66,7 @@ public class TelikProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("telik"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 876a1e4ff..5f7ce1638 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -37,6 +37,10 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public TeltonikaProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private void parseIdentification(Channel channel, ChannelBuffer buf) { boolean result = false; @@ -81,7 +85,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { for (int i = 0; i < count; i++) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("teltonika"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java index e142d95b5..9b1157d50 100644 --- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java @@ -35,6 +35,10 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Tk102ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + static private Pattern pattern = Pattern.compile( "\\[.\\d{10}.\\(\\p{Upper}+" + "(\\d{2})(\\d{2})(\\d{2})" + // Time (HHMMSS) @@ -85,7 +89,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("tk102"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index d3220368a..2309012ab 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Tk103ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "(\\d+)(,)?" + // Device ID ".{4},?" + // Command @@ -82,7 +86,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("tk103"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Get device by IMEI diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java index e4e6cb300..0f5bc5275 100644 --- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java +++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java @@ -35,6 +35,10 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Tlt2hProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern patternHeader = Pattern.compile( "#(\\d+)#" + // IMEI "[^#]+#" + @@ -91,7 +95,7 @@ public class Tlt2hProtocolDecoder extends BaseProtocolDecoder { parser = patternPosition.matcher(message); if (parser.matches()) { Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("tlt2h"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; diff --git a/src/org/traccar/protocol/TopflytechProtocolDecoder.java b/src/org/traccar/protocol/TopflytechProtocolDecoder.java index 58448f881..112b1e183 100644 --- a/src/org/traccar/protocol/TopflytechProtocolDecoder.java +++ b/src/org/traccar/protocol/TopflytechProtocolDecoder.java @@ -35,6 +35,10 @@ public class TopflytechProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public TopflytechProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + static private Pattern pattern = Pattern.compile( "\\(" + "(\\d+)" + // IMEI @@ -64,7 +68,7 @@ public class TopflytechProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("topflytech"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Identifier diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 466929777..180289b20 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -33,6 +33,10 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public TotemProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern patternFirst = Pattern.compile( "\\$\\$" + // Header "\\p{XDigit}{2}" + // Length @@ -159,7 +163,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("totem"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java index de21f4420..4d17b45fe 100644 --- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Tr20ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + static private Pattern patternPing = Pattern.compile( "\\%\\%[^,]+,(\\d+)"); @@ -77,7 +81,7 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("tr20"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java index 865d81e30..8f495cca8 100644 --- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java +++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.java @@ -35,6 +35,10 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public TrackboxProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "(\\d{2})(\\d{2})(\\d{2})\\.(\\d{3})," + // Time "(\\d{2})(\\d{2}\\.\\d{4})([NS])," + // Latitude (DDMM.MMMM) @@ -82,7 +86,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); position.setDeviceId(deviceId); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("trackbox"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java index 25c943e57..6c8673775 100644 --- a/src/org/traccar/protocol/V680ProtocolDecoder.java +++ b/src/org/traccar/protocol/V680ProtocolDecoder.java @@ -35,6 +35,10 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public V680ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "(?:#(\\d+)#" + // IMEI "([^#]*)#)?" + // User @@ -80,7 +84,7 @@ public class V680ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("v680"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; // Get device by IMEI diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java index 4ca97be67..70f1ae194 100644 --- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java +++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java @@ -33,6 +33,10 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public VisiontekProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\$1," + "([^,]+)," + // Identifier @@ -71,7 +75,7 @@ public class VisiontekProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("visiontek"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java index 93e32ced0..1f14886c4 100644 --- a/src/org/traccar/protocol/WialonProtocolDecoder.java +++ b/src/org/traccar/protocol/WialonProtocolDecoder.java @@ -37,6 +37,10 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public WialonProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "(\\d{2})(\\d{2})(\\d{2});" + // Date (DDMMYY) "(\\d{2})(\\d{2})(\\d{2});" + // Time (HHMMSS) @@ -71,7 +75,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("wialon"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); position.setDeviceId(deviceId); Integer index = 1; diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java index a9c4ea4c1..6d404a57d 100644 --- a/src/org/traccar/protocol/WondexProtocolDecoder.java +++ b/src/org/traccar/protocol/WondexProtocolDecoder.java @@ -33,6 +33,10 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public WondexProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "[^\\d]*" + // Header "(\\d+)," + // Device Identifier @@ -65,7 +69,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("wondex"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); int index = 1; // Device identifier diff --git a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java index d974ce227..bccd8a8cf 100644 --- a/src/org/traccar/protocol/Xexun2ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xexun2ProtocolDecoder.java @@ -33,6 +33,10 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Xexun2ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + static private Pattern pattern = Pattern.compile( "[\r\n]*" + "(\\d+)," + // Serial @@ -72,7 +76,7 @@ public class Xexun2ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("xexun2"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 7a0d71e64..16573dd7c 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -34,6 +34,10 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public XexunProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "GPRMC," + "(\\d{2})(\\d{2})(\\d{2}).(\\d+)," + // Time (HHMMSS.SSS) @@ -62,7 +66,7 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("xexun"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; diff --git a/src/org/traccar/protocol/Xt7ProtocolDecoder.java b/src/org/traccar/protocol/Xt7ProtocolDecoder.java index a30977263..2ee0e6b0f 100644 --- a/src/org/traccar/protocol/Xt7ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xt7ProtocolDecoder.java @@ -35,6 +35,10 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public Xt7ProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "\\$GPRMC," + "(\\d{2})(\\d{2})(\\d{2})\\.(\\d+)," + // Time (HHMMSS.SSS) @@ -67,7 +71,7 @@ public class Xt7ProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("xt7"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); // Get device by id String id = buf.readBytes(16).toString(Charset.defaultCharset()).trim(); diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java index 2b189ea7c..01cfbc8dc 100644 --- a/src/org/traccar/protocol/YwtProtocolDecoder.java +++ b/src/org/traccar/protocol/YwtProtocolDecoder.java @@ -33,6 +33,10 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder { super(serverManager); } + public YwtProtocolDecoder(ServerManager serverManager, String protocol) { + super(serverManager, protocol); + } + private static final Pattern pattern = Pattern.compile( "%(..)," + // Type "(\\d+):" + // Unit identifier @@ -81,7 +85,7 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder { // Create new position Position position = new Position(); - ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter("ywt"); + ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol()); Integer index = 1; String type = parser.group(index++); |