aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-11-09 20:48:39 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2013-11-09 20:48:39 +1300
commitfa260aad4a99772e1b116474dd702849f6ee5727 (patch)
tree2d2f2b79002697177e6f45c006a4737b23e01385
parentf65d8164e673c5a1e2aa4d02aee8e269b19c4900 (diff)
downloadtrackermap-server-fa260aad4a99772e1b116474dd702849f6ee5727.tar.gz
trackermap-server-fa260aad4a99772e1b116474dd702849f6ee5727.tar.bz2
trackermap-server-fa260aad4a99772e1b116474dd702849f6ee5727.zip
Update gl100 and gl200
-rw-r--r--src/org/traccar/ServerManager.java2
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java4
-rw-r--r--test/org/traccar/protocol/Gl100ProtocolDecoderTest.java9
-rw-r--r--test/org/traccar/protocol/Gl200ProtocolDecoderTest.java8
5 files changed, 16 insertions, 23 deletions
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index daa2981b6..56a5a1c08 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -260,7 +260,7 @@ public class ServerManager {
serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- byte delimiter[] = { (byte) 0x0 };
+ byte delimiter[] = { (byte) '\0' };
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
index 88f9047bb..984303572 100644
--- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,21 +27,12 @@ import org.traccar.helper.Log;
import org.traccar.model.ExtendedInfoFormatter;
import org.traccar.model.Position;
-/**
- * GL200 tracker protocol decoder
- */
public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
- /**
- * Initialize
- */
public Gl100ProtocolDecoder(ServerManager serverManager) {
super(serverManager);
}
- /**
- * Regular expressions pattern
- */
private static final Pattern pattern = Pattern.compile(
"\\+RESP:GT...," +
"(\\d{15})," + // IMEI
@@ -60,9 +51,6 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
"(\\d{2})(\\d{2})(\\d{2})," + // Time (HHMMSS)
".*");
- /**
- * Decode message
- */
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
@@ -71,7 +59,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
// Send response
- if (sentence.contains("AT+GTHBD=")) {
+ if (sentence.contains("AT+GTHBD=") && channel != null) {
String response = "+RESP:GTHBD,GPRS ACTIVE,";
response += sentence.substring(9, sentence.lastIndexOf(','));
response += '\0';
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 8f3579d38..f1101bde4 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -33,7 +33,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
super(serverManager);
}
- static private Pattern pattern = Pattern.compile(
+ private static final Pattern pattern = Pattern.compile(
"\\+RESP:GT...," +
"[0-9a-fA-F]{6}," + // Protocol version
"(\\d{15}),.*," + // IMEI
@@ -76,7 +76,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
}
// Validity
- position.setValid(Integer.valueOf(parser.group(index++)) == 0 ? false : true);
+ position.setValid(Integer.valueOf(parser.group(index++)) == 0);
// Position info
position.setSpeed(Double.valueOf(parser.group(index++)));
diff --git a/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java
index 6cfa34501..b7aaef5b8 100644
--- a/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java
@@ -1,5 +1,6 @@
package org.traccar.protocol;
+import static org.junit.Assert.assertNull;
import org.traccar.helper.TestDataManager;
import static org.traccar.helper.DecoderVerifier.verify;
import org.junit.Test;
@@ -12,6 +13,9 @@ public class Gl100ProtocolDecoderTest {
Gl100ProtocolDecoder decoder = new Gl100ProtocolDecoder(null);
decoder.setDataManager(new TestDataManager());
+ assertNull(decoder.decode(null, null,
+ "AT+GTHBD=HeartBeat,359231030000010,20090101000000,11F0,0102120204"));
+
verify(decoder.decode(null, null,
"+RESP:GTSOS,359231030000010,0,0,0,1,4.3,92,70.0,1,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,11F0,0102120204"));
@@ -33,8 +37,9 @@ public class Gl100ProtocolDecoderTest {
verify(decoder.decode(null, null,
"+RESP:GTTRI,359231030000010,2,0,0,1,4.3,92,70.0,1,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,0,0,1,-3.6,145,30.0,2,121.354442,31.221940,20090101000100,0460,0000,18d8,6141,00,11F0,0102120204"));
- //verify(decoder.decode(null, null,
- // "AT+GTHBD=HeartBeat,359231030000010,20090101000000,11F0,0102120204"));
+ verify(decoder.decode(null, null,
+ "+RESP:GTTRI,359464030073766,1,0,0,0,1.7,254,-27.8,3,30.474475,50.488383,20131107155511,0255,0003,6995,4761,00,0071,0103090402"));
+
}
}
diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
index 2ec7f189c..70cf1b013 100644
--- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
@@ -13,6 +13,9 @@ public class Gl200ProtocolDecoderTest {
Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(null);
decoder.setDataManager(new TestDataManager());
+ assertNull(decoder.decode(null, null,
+ "+RESP:GTINF,359464030073766,8938003990320469804f,18,99,100,1,0,+2.00,0,20131018084015,00EE,0103090402"));
+
verify(decoder.decode(null, null,
"+RESP:GTFRI,04040C,359231038939904,,,10,1,2,0.0,117,346.0,8.924243,50.798077,20130618122040,0262,0002,0299,109C,00,0.0,,,,,,,,,20130618122045,00F6"));
@@ -39,9 +42,6 @@ public class Gl200ProtocolDecoderTest {
verify(decoder.decode(null, null,
"+RESP:GTFRI,07000D,868487001005941,,0,0,1,1,0.0,0,46.3,-77.039627,38.907573,20120731175232,0310,0260,B44B,EBC9,0015e96913a7,-58,,100,20120731175244,0114"));
-
- assertNull(decoder.decode(null, null,
- "+RESP:GTINF,359464030073766,8938003990320469804f,18,99,100,1,0,+2.00,0,20131018084015,00EE,0103090402"));
verify(decoder.decode(null, null,
"+RESP:GTTOW,0F0100,135790246811220,,,10,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,20090214093254,11F0$"));
@@ -75,7 +75,7 @@ public class Gl200ProtocolDecoderTest {
verify(decoder.decode(null, null,
"+RESP:GTHBM,0F0100,135790246811220,,,11,1,1,24.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,20090214093254,11F0$"));
-
+
}
}