aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-04-16 09:47:23 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-04-16 09:47:23 +1200
commit2f0687aee12999697596c9b028e6d2736d8df6b7 (patch)
treefba5cdd8772d58edc2a73fe58ea11e4a93cc18e6
parent6a827ed071b0ff48264758632afc4965f0c46150 (diff)
downloadtrackermap-server-2f0687aee12999697596c9b028e6d2736d8df6b7.tar.gz
trackermap-server-2f0687aee12999697596c9b028e6d2736d8df6b7.tar.bz2
trackermap-server-2f0687aee12999697596c9b028e6d2736d8df6b7.zip
Support zero delimiter for GpsGate
-rw-r--r--src/org/traccar/protocol/GpsGateProtocol.java6
-rw-r--r--test/org/traccar/protocol/GpsGateProtocolDecoderTest.java3
2 files changed, 6 insertions, 3 deletions
diff --git a/src/org/traccar/protocol/GpsGateProtocol.java b/src/org/traccar/protocol/GpsGateProtocol.java
index c654810b1..bfd3b2883 100644
--- a/src/org/traccar/protocol/GpsGateProtocol.java
+++ b/src/org/traccar/protocol/GpsGateProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 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.
@@ -17,10 +17,10 @@ package org.traccar.protocol;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.CharacterDelimiterFrameDecoder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -36,7 +36,7 @@ public class GpsGateProtocol extends BaseProtocol {
serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
+ pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\0", "\n", "\r\n"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new GpsGateProtocolDecoder(GpsGateProtocol.this));
diff --git a/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java b/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java
index 788830e52..30861099f 100644
--- a/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class GpsGateProtocolDecoderTest extends ProtocolTest {
GpsGateProtocolDecoder decoder = new GpsGateProtocolDecoder(new GpsGateProtocol());
+ verifyPosition(decoder, text(
+ "$FRCMD,353067011068246,_SendMessage,,1918.1942,N,09906.3696,W,2246.5,000.0,295.9,150416,213147.00,1,Odometer=*70"));
+
verifyNothing(decoder, text(
"$FRCMD,862950025974620,_Ping,voltage=4*4F"));