aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol
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 /src/org/traccar/protocol
parentf65d8164e673c5a1e2aa4d02aee8e269b19c4900 (diff)
downloadtraccar-server-fa260aad4a99772e1b116474dd702849f6ee5727.tar.gz
traccar-server-fa260aad4a99772e1b116474dd702849f6ee5727.tar.bz2
traccar-server-fa260aad4a99772e1b116474dd702849f6ee5727.zip
Update gl100 and gl200
Diffstat (limited to 'src/org/traccar/protocol')
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java4
2 files changed, 4 insertions, 16 deletions
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++)));