aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/org/traccar/ServerManager.java2
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java26
-rw-r--r--test/org/traccar/protocol/V680ProtocolDecoderTest.java6
3 files changed, 15 insertions, 19 deletions
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index 94e68b7da..18535307c 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -482,7 +482,7 @@ public class ServerManager {
serverList.add(new TrackerServer(this, new ServerBootstrap(), protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- byte delimiter[] = { (byte) '#', (byte) '#' };
+ byte delimiter[] = { (byte) '#', (byte) '#', (byte) '#' };
pipeline.addLast("frameDecoder",
new DelimiterBasedFrameDecoder(1024, ChannelBuffers.wrappedBuffer(delimiter)));
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index c8a16c377..e8c3d3426 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.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.
@@ -26,42 +26,32 @@ import org.traccar.ServerManager;
import org.traccar.helper.Log;
import org.traccar.model.Position;
-/**
- * V680 tracker protocol decoder
- */
public class V680ProtocolDecoder extends BaseProtocolDecoder {
- /**
- * Initialize
- */
public V680ProtocolDecoder(ServerManager serverManager) {
super(serverManager);
}
- /**
- * Regular expressions pattern
- */
static private Pattern pattern = Pattern.compile(
- "#" +
+ "#?" +
"(\\d+)#" + // IMEI
- "([^#]+)#" + // User
+ "([^#]*)#" + // User
"([01])#" + // Fix
"([^#]+)#" + // Password
"[^#]+#" +
"(\\d+)#" + // Packet number
- "([^#]+)#" + // GSM base station
- "(\\d{3})(\\d{2}\\.\\d{4})," + // Longitude (DDDMM.MMMM)
+ "(\\d+)." + // GSM base station
+ "[^#]+#" +
+ "(\\d{3})(\\d{2}\\.\\d+)," + // Longitude (DDDMM.MMMM)
"([EW])," +
- "(\\d{2})(\\d{2}\\.\\d{4})," + // Latitude (DDMM.MMMM)
+ "(\\d{2})(\\d{2}\\.\\d+)," + // Latitude (DDMM.MMMM)
"([NS])," +
"(\\d+\\.\\d+)," + // Speed
"(\\d+)#" + // Course
"(\\d{2})(\\d{2})(\\d{2})#" + // Date (DDMMYY)
"(\\d{2})(\\d{2})(\\d{2})"); // Time (HHMMSS)
- /**
- * Decode message
- */
+ @Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception {
diff --git a/test/org/traccar/protocol/V680ProtocolDecoderTest.java b/test/org/traccar/protocol/V680ProtocolDecoderTest.java
index e185ab9fd..4098535ed 100644
--- a/test/org/traccar/protocol/V680ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/V680ProtocolDecoderTest.java
@@ -10,10 +10,16 @@ public class V680ProtocolDecoderTest {
V680ProtocolDecoder decoder = new V680ProtocolDecoder(null);
decoder.setDataManager(new TestDataManager());
+
+ assertNotNull(decoder.decode(null, null,
+ "#356823031193431##0#0000#SF#1#72403#V#04702.3025,W,2252.18380,S,008.18,0#090413#134938"));
assertNotNull(decoder.decode(null, null,
"#356823033219838#1000#0#1478#AUT#1#66830FFB#03855.6628,E,4716.6821,N,001.41,259#130812#143905"));
+ assertNotNull(decoder.decode(null, null,
+ "356823033219838#1000#0#1478#AUT#1#66830FFB#03855.6628,E,4716.6821,N,001.41,259#130812#143905"));
+
}
}