From eb2165714a1ef71b4ec48a80613598b222284f0f Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 7 Nov 2016 02:10:44 +1300 Subject: Handle new line in ET messages (fix #2509) --- src/org/traccar/protocol/EasyTrackProtocol.java | 4 ++-- test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/protocol/EasyTrackProtocol.java b/src/org/traccar/protocol/EasyTrackProtocol.java index 78f7f0b12..eeed07129 100644 --- a/src/org/traccar/protocol/EasyTrackProtocol.java +++ b/src/org/traccar/protocol/EasyTrackProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public class EasyTrackProtocol extends BaseProtocol { serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { - pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#')); + pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "#", "\r\n")); pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("objectDecoder", new EasyTrackProtocolDecoder(EasyTrackProtocol.this)); diff --git a/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java b/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java index 41c747ad6..51c515544 100644 --- a/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java @@ -10,6 +10,18 @@ public class EasyTrackProtocolDecoderTest extends ProtocolTest { EasyTrackProtocolDecoder decoder = new EasyTrackProtocolDecoder(new EasyTrackProtocol()); + verifyPosition(decoder, text( + "*ET,358155100054249,HB,A,100b06,053318,803a0b51,03d507c9,0017,0000,00400000,07,100,0000,1435,63")); + + verifyNothing(decoder, text( + "*ET,358155100054249,MQ")); + + verifyNothing(decoder, text( + "*ET,358155100054249,TX,A,100b06,053230")); + + verifyPosition(decoder, text( + "*ET,358155100054249,HB,A,100b06,053212,803a0b20,03d507a2,0054,0000,40400000,06,100,0000,1435,44")); + verifyNothing(decoder, text( "*ET,135790246811221,GZ,0001,0005")); -- cgit v1.2.3