diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-11-09 20:48:39 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-11-09 20:48:39 +1300 |
commit | fa260aad4a99772e1b116474dd702849f6ee5727 (patch) | |
tree | 2d2f2b79002697177e6f45c006a4737b23e01385 /src/org | |
parent | f65d8164e673c5a1e2aa4d02aee8e269b19c4900 (diff) | |
download | trackermap-server-fa260aad4a99772e1b116474dd702849f6ee5727.tar.gz trackermap-server-fa260aad4a99772e1b116474dd702849f6ee5727.tar.bz2 trackermap-server-fa260aad4a99772e1b116474dd702849f6ee5727.zip |
Update gl100 and gl200
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/ServerManager.java | 2 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gl100ProtocolDecoder.java | 16 | ||||
-rw-r--r-- | src/org/traccar/protocol/Gl200ProtocolDecoder.java | 4 |
3 files changed, 5 insertions, 17 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++))); |