diff options
Diffstat (limited to 'src/main/java/org/traccar')
84 files changed, 353 insertions, 132 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolEncoder.java b/src/main/java/org/traccar/BaseProtocolEncoder.java index 6d96280f7..69d1fe6f5 100644 --- a/src/main/java/org/traccar/BaseProtocolEncoder.java +++ b/src/main/java/org/traccar/BaseProtocolEncoder.java @@ -27,6 +27,18 @@ public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter private static final Logger LOGGER = LoggerFactory.getLogger(BaseProtocolEncoder.class); + private static final String PROTOCOL_UNKNOWN = "unknown"; + + private final Protocol protocol; + + public BaseProtocolEncoder(Protocol protocol) { + this.protocol = protocol; + } + + public String getProtocolName() { + return protocol != null ? protocol.getName() : PROTOCOL_UNKNOWN; + } + protected String getUniqueId(long deviceId) { return Context.getIdentityManager().getById(deviceId).getUniqueId(); } diff --git a/src/main/java/org/traccar/StringProtocolEncoder.java b/src/main/java/org/traccar/StringProtocolEncoder.java index 1945ae174..d9acce7f0 100644 --- a/src/main/java/org/traccar/StringProtocolEncoder.java +++ b/src/main/java/org/traccar/StringProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -21,6 +21,10 @@ import java.util.Map; public abstract class StringProtocolEncoder extends BaseProtocolEncoder { + public StringProtocolEncoder(Protocol protocol) { + super(protocol); + } + public interface ValueFormatter { String formatValue(String key, Object value); } diff --git a/src/main/java/org/traccar/protocol/AdmProtocol.java b/src/main/java/org/traccar/protocol/AdmProtocol.java index 08f932ceb..93b1e355a 100644 --- a/src/main/java/org/traccar/protocol/AdmProtocol.java +++ b/src/main/java/org/traccar/protocol/AdmProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -35,7 +35,7 @@ public class AdmProtocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 2, 1, -3, 0, true)); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new AdmProtocolEncoder()); + pipeline.addLast(new AdmProtocolEncoder(AdmProtocol.this)); pipeline.addLast(new AdmProtocolDecoder(AdmProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/AdmProtocolEncoder.java b/src/main/java/org/traccar/protocol/AdmProtocolEncoder.java index e76bc2ddc..1c3dfc156 100644 --- a/src/main/java/org/traccar/protocol/AdmProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/AdmProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2017 Anatoliy Golubev (darth.naihil@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class AdmProtocolEncoder extends StringProtocolEncoder { + public AdmProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/AtrackProtocol.java b/src/main/java/org/traccar/protocol/AtrackProtocol.java index 8e5cfe9ff..429708b26 100644 --- a/src/main/java/org/traccar/protocol/AtrackProtocol.java +++ b/src/main/java/org/traccar/protocol/AtrackProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -29,14 +29,14 @@ public class AtrackProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new AtrackFrameDecoder()); - pipeline.addLast(new AtrackProtocolEncoder()); + pipeline.addLast(new AtrackProtocolEncoder(AtrackProtocol.this)); pipeline.addLast(new AtrackProtocolDecoder(AtrackProtocol.this)); } }); addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new AtrackProtocolEncoder()); + pipeline.addLast(new AtrackProtocolEncoder(AtrackProtocol.this)); pipeline.addLast(new AtrackProtocolDecoder(AtrackProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/AtrackProtocolEncoder.java b/src/main/java/org/traccar/protocol/AtrackProtocolEncoder.java index 1e085cb26..d803ae391 100644 --- a/src/main/java/org/traccar/protocol/AtrackProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/AtrackProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 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. @@ -18,11 +18,16 @@ package org.traccar.protocol; import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; public class AtrackProtocolEncoder extends BaseProtocolEncoder { + public AtrackProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/BceProtocol.java b/src/main/java/org/traccar/protocol/BceProtocol.java index 6453a05a9..c5e1dd04c 100644 --- a/src/main/java/org/traccar/protocol/BceProtocol.java +++ b/src/main/java/org/traccar/protocol/BceProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -29,7 +29,7 @@ public class BceProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new BceFrameDecoder()); - pipeline.addLast(new BceProtocolEncoder()); + pipeline.addLast(new BceProtocolEncoder(BceProtocol.this)); pipeline.addLast(new BceProtocolDecoder(BceProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/BceProtocolEncoder.java b/src/main/java/org/traccar/protocol/BceProtocolEncoder.java index 1bbf3db12..53ac51581 100644 --- a/src/main/java/org/traccar/protocol/BceProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/BceProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -20,9 +20,14 @@ import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; public class BceProtocolEncoder extends BaseProtocolEncoder { + public BceProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/CarcellProtocol.java b/src/main/java/org/traccar/protocol/CarcellProtocol.java index 0c305efcb..f08ab3bd9 100644 --- a/src/main/java/org/traccar/protocol/CarcellProtocol.java +++ b/src/main/java/org/traccar/protocol/CarcellProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -35,7 +35,7 @@ public class CarcellProtocol extends BaseProtocol { pipeline.addLast(new CharacterDelimiterFrameDecoder(1024, '\r')); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new CarcellProtocolEncoder()); + pipeline.addLast(new CarcellProtocolEncoder(CarcellProtocol.this)); pipeline.addLast(new CarcellProtocolDecoder(CarcellProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/CarcellProtocolEncoder.java b/src/main/java/org/traccar/protocol/CarcellProtocolEncoder.java index e8f0081a0..083fe9a9e 100644 --- a/src/main/java/org/traccar/protocol/CarcellProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/CarcellProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class CarcellProtocolEncoder extends StringProtocolEncoder { + public CarcellProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/CastelProtocol.java b/src/main/java/org/traccar/protocol/CastelProtocol.java index 9b854afc3..44c52d68f 100644 --- a/src/main/java/org/traccar/protocol/CastelProtocol.java +++ b/src/main/java/org/traccar/protocol/CastelProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -32,14 +32,14 @@ public class CastelProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 2, 2, -4, 0, true)); - pipeline.addLast(new CastelProtocolEncoder()); + pipeline.addLast(new CastelProtocolEncoder(CastelProtocol.this)); pipeline.addLast(new CastelProtocolDecoder(CastelProtocol.this)); } }); addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new CastelProtocolEncoder()); + pipeline.addLast(new CastelProtocolEncoder(CastelProtocol.this)); pipeline.addLast(new CastelProtocolDecoder(CastelProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java b/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java index e1f78e7c1..dc694da28 100644 --- a/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/CastelProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 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. @@ -21,11 +21,16 @@ import org.traccar.BaseProtocolEncoder; import org.traccar.Context; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; public class CastelProtocolEncoder extends BaseProtocolEncoder { + public CastelProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(long deviceId, short type, ByteBuf content) { ByteBuf buf = Unpooled.buffer(0); diff --git a/src/main/java/org/traccar/protocol/CellocatorProtocol.java b/src/main/java/org/traccar/protocol/CellocatorProtocol.java index a52170dc9..d910877cf 100644 --- a/src/main/java/org/traccar/protocol/CellocatorProtocol.java +++ b/src/main/java/org/traccar/protocol/CellocatorProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -29,14 +29,14 @@ public class CellocatorProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new CellocatorFrameDecoder()); - pipeline.addLast(new CellocatorProtocolEncoder()); + pipeline.addLast(new CellocatorProtocolEncoder(CellocatorProtocol.this)); pipeline.addLast(new CellocatorProtocolDecoder(CellocatorProtocol.this)); } }); addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new CellocatorProtocolEncoder()); + pipeline.addLast(new CellocatorProtocolEncoder(CellocatorProtocol.this)); pipeline.addLast(new CellocatorProtocolDecoder(CellocatorProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/CellocatorProtocolEncoder.java b/src/main/java/org/traccar/protocol/CellocatorProtocolEncoder.java index 0382dbbc7..52de4593c 100644 --- a/src/main/java/org/traccar/protocol/CellocatorProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/CellocatorProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 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. @@ -19,9 +19,14 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class CellocatorProtocolEncoder extends BaseProtocolEncoder { + public CellocatorProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(long deviceId, int command, int data1, int data2) { ByteBuf buf = Unpooled.buffer(0); diff --git a/src/main/java/org/traccar/protocol/CityeasyProtocol.java b/src/main/java/org/traccar/protocol/CityeasyProtocol.java index f4b49c9ff..8ab4ce93a 100644 --- a/src/main/java/org/traccar/protocol/CityeasyProtocol.java +++ b/src/main/java/org/traccar/protocol/CityeasyProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -33,7 +33,7 @@ public class CityeasyProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0)); - pipeline.addLast(new CityeasyProtocolEncoder()); + pipeline.addLast(new CityeasyProtocolEncoder(CityeasyProtocol.this)); pipeline.addLast(new CityeasyProtocolDecoder(CityeasyProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/CityeasyProtocolEncoder.java b/src/main/java/org/traccar/protocol/CityeasyProtocolEncoder.java index 350fdf0ab..934105862 100644 --- a/src/main/java/org/traccar/protocol/CityeasyProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/CityeasyProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -22,9 +22,14 @@ import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; public class CityeasyProtocolEncoder extends BaseProtocolEncoder { + public CityeasyProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(int type, ByteBuf content) { ByteBuf buf = Unpooled.buffer(); diff --git a/src/main/java/org/traccar/protocol/EelinkProtocol.java b/src/main/java/org/traccar/protocol/EelinkProtocol.java index de4ea971b..8a055d643 100644 --- a/src/main/java/org/traccar/protocol/EelinkProtocol.java +++ b/src/main/java/org/traccar/protocol/EelinkProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -34,14 +34,14 @@ public class EelinkProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 3, 2)); - pipeline.addLast(new EelinkProtocolEncoder(false)); + pipeline.addLast(new EelinkProtocolEncoder(EelinkProtocol.this, false)); pipeline.addLast(new EelinkProtocolDecoder(EelinkProtocol.this)); } }); addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new EelinkProtocolEncoder(true)); + pipeline.addLast(new EelinkProtocolEncoder(EelinkProtocol.this, true)); pipeline.addLast(new EelinkProtocolDecoder(EelinkProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/EelinkProtocolEncoder.java b/src/main/java/org/traccar/protocol/EelinkProtocolEncoder.java index 8f33441fb..3673c35b3 100644 --- a/src/main/java/org/traccar/protocol/EelinkProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/EelinkProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -20,6 +20,7 @@ import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.DataConverter; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -28,7 +29,8 @@ public class EelinkProtocolEncoder extends BaseProtocolEncoder { private boolean connectionless; - public EelinkProtocolEncoder(boolean connectionless) { + public EelinkProtocolEncoder(Protocol protocol, boolean connectionless) { + super(protocol); this.connectionless = connectionless; } diff --git a/src/main/java/org/traccar/protocol/EnforaProtocol.java b/src/main/java/org/traccar/protocol/EnforaProtocol.java index f78e4b377..e462ab322 100644 --- a/src/main/java/org/traccar/protocol/EnforaProtocol.java +++ b/src/main/java/org/traccar/protocol/EnforaProtocol.java @@ -32,14 +32,14 @@ public class EnforaProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2)); - pipeline.addLast(new EnforaProtocolEncoder()); + pipeline.addLast(new EnforaProtocolEncoder(EnforaProtocol.this)); pipeline.addLast(new EnforaProtocolDecoder(EnforaProtocol.this)); } }); addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new EnforaProtocolEncoder()); + pipeline.addLast(new EnforaProtocolEncoder(EnforaProtocol.this)); pipeline.addLast(new EnforaProtocolDecoder(EnforaProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/EnforaProtocolEncoder.java b/src/main/java/org/traccar/protocol/EnforaProtocolEncoder.java index a46e6367d..8cc24dc0f 100644 --- a/src/main/java/org/traccar/protocol/EnforaProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/EnforaProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2017 Jose Castellanos * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,11 +20,16 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; public class EnforaProtocolEncoder extends StringProtocolEncoder { + public EnforaProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(String content) { ByteBuf buf = Unpooled.buffer(); diff --git a/src/main/java/org/traccar/protocol/EsealProtocol.java b/src/main/java/org/traccar/protocol/EsealProtocol.java index 7a27c617d..fc1d342e1 100644 --- a/src/main/java/org/traccar/protocol/EsealProtocol.java +++ b/src/main/java/org/traccar/protocol/EsealProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 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 EsealProtocol extends BaseProtocol { pipeline.addLast(new LineBasedFrameDecoder(1024)); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new EsealProtocolEncoder()); + pipeline.addLast(new EsealProtocolEncoder(EsealProtocol.this)); pipeline.addLast(new EsealProtocolDecoder(EsealProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/EsealProtocolEncoder.java b/src/main/java/org/traccar/protocol/EsealProtocolEncoder.java index b9bcc5b0a..6ee305ed8 100644 --- a/src/main/java/org/traccar/protocol/EsealProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/EsealProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class EsealProtocolEncoder extends StringProtocolEncoder { + public EsealProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/FifotrackProtocol.java b/src/main/java/org/traccar/protocol/FifotrackProtocol.java index d1c3cf695..4a0a12ed3 100644 --- a/src/main/java/org/traccar/protocol/FifotrackProtocol.java +++ b/src/main/java/org/traccar/protocol/FifotrackProtocol.java @@ -32,7 +32,7 @@ public class FifotrackProtocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new FifotrackFrameDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new FifotrackProtocolEncoder()); + pipeline.addLast(new FifotrackProtocolEncoder(FifotrackProtocol.this)); pipeline.addLast(new FifotrackProtocolDecoder(FifotrackProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/FifotrackProtocolEncoder.java b/src/main/java/org/traccar/protocol/FifotrackProtocolEncoder.java index ff0a2e56e..a4e69b47b 100644 --- a/src/main/java/org/traccar/protocol/FifotrackProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/FifotrackProtocolEncoder.java @@ -18,9 +18,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; public class FifotrackProtocolEncoder extends StringProtocolEncoder { + public FifotrackProtocolEncoder(Protocol protocol) { + super(protocol); + } + private Object formatCommand(Command command, String content) { String uniqueId = getUniqueId(command.getDeviceId()); int length = 1 + uniqueId.length() + 3 + content.length(); diff --git a/src/main/java/org/traccar/protocol/GalileoProtocol.java b/src/main/java/org/traccar/protocol/GalileoProtocol.java index 9b7fe1a4b..a1570c9b0 100644 --- a/src/main/java/org/traccar/protocol/GalileoProtocol.java +++ b/src/main/java/org/traccar/protocol/GalileoProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -30,7 +30,7 @@ public class GalileoProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new GalileoFrameDecoder()); - pipeline.addLast(new GalileoProtocolEncoder()); + pipeline.addLast(new GalileoProtocolEncoder(GalileoProtocol.this)); pipeline.addLast(new GalileoProtocolDecoder(GalileoProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/GalileoProtocolEncoder.java b/src/main/java/org/traccar/protocol/GalileoProtocolEncoder.java index 3b2145e74..cd068b251 100644 --- a/src/main/java/org/traccar/protocol/GalileoProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/GalileoProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 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. @@ -20,11 +20,16 @@ import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; public class GalileoProtocolEncoder extends BaseProtocolEncoder { + public GalileoProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeText(String uniqueId, String text) { ByteBuf buf = Unpooled.buffer(256); diff --git a/src/main/java/org/traccar/protocol/Gl200Protocol.java b/src/main/java/org/traccar/protocol/Gl200Protocol.java index c5343dae0..e2d0c6d2a 100644 --- a/src/main/java/org/traccar/protocol/Gl200Protocol.java +++ b/src/main/java/org/traccar/protocol/Gl200Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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 Gl200Protocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new Gl200FrameDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new Gl200ProtocolEncoder()); + pipeline.addLast(new Gl200ProtocolEncoder(Gl200Protocol.this)); pipeline.addLast(new Gl200ProtocolDecoder(Gl200Protocol.this)); } }); @@ -44,7 +44,7 @@ public class Gl200Protocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new StringEncoder()); - pipeline.addLast(new Gl200ProtocolEncoder()); + pipeline.addLast(new Gl200ProtocolEncoder(Gl200Protocol.this)); pipeline.addLast(new Gl200ProtocolDecoder(Gl200Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/Gl200ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Gl200ProtocolEncoder.java index 285106c67..32307446b 100644 --- a/src/main/java/org/traccar/protocol/Gl200ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Gl200ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class Gl200ProtocolEncoder extends StringProtocolEncoder { + public Gl200ProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/Gps103Protocol.java b/src/main/java/org/traccar/protocol/Gps103Protocol.java index 6272a3fd1..5356387ce 100644 --- a/src/main/java/org/traccar/protocol/Gps103Protocol.java +++ b/src/main/java/org/traccar/protocol/Gps103Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -42,7 +42,7 @@ public class Gps103Protocol extends BaseProtocol { pipeline.addLast(new CharacterDelimiterFrameDecoder(2048, false, "\r\n", "\n", ";", "*")); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new Gps103ProtocolEncoder()); + pipeline.addLast(new Gps103ProtocolEncoder(Gps103Protocol.this)); pipeline.addLast(new Gps103ProtocolDecoder(Gps103Protocol.this)); } }); @@ -51,7 +51,7 @@ public class Gps103Protocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new Gps103ProtocolEncoder()); + pipeline.addLast(new Gps103ProtocolEncoder(Gps103Protocol.this)); pipeline.addLast(new Gps103ProtocolDecoder(Gps103Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/Gps103ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Gps103ProtocolEncoder.java index 47ef2f333..7128823ed 100644 --- a/src/main/java/org/traccar/protocol/Gps103ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Gps103ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class Gps103ProtocolEncoder extends StringProtocolEncoder implements StringProtocolEncoder.ValueFormatter { + public Gps103ProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override public String formatValue(String key, Object value) { diff --git a/src/main/java/org/traccar/protocol/GranitProtocol.java b/src/main/java/org/traccar/protocol/GranitProtocol.java index 6785f2a2e..cc5b125f1 100644 --- a/src/main/java/org/traccar/protocol/GranitProtocol.java +++ b/src/main/java/org/traccar/protocol/GranitProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +28,7 @@ public class GranitProtocol extends BaseProtocol { Command.TYPE_IDENTIFICATION, Command.TYPE_REBOOT_DEVICE, Command.TYPE_POSITION_SINGLE); - setTextCommandEncoder(new GranitProtocolSmsEncoder()); + setTextCommandEncoder(new GranitProtocolSmsEncoder(GranitProtocol.this)); setSupportedTextCommands( Command.TYPE_REBOOT_DEVICE, Command.TYPE_POSITION_PERIODIC); @@ -36,7 +36,7 @@ public class GranitProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new GranitFrameDecoder()); - pipeline.addLast(new GranitProtocolEncoder()); + pipeline.addLast(new GranitProtocolEncoder(GranitProtocol.this)); pipeline.addLast(new GranitProtocolDecoder(GranitProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/GranitProtocolEncoder.java b/src/main/java/org/traccar/protocol/GranitProtocolEncoder.java index 6345ff971..66c2a4973 100644 --- a/src/main/java/org/traccar/protocol/GranitProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/GranitProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -21,9 +21,14 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class GranitProtocolEncoder extends BaseProtocolEncoder { + public GranitProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeCommand(String commandString) { ByteBuf buffer = Unpooled.buffer(); buffer.writeBytes(commandString.getBytes(StandardCharsets.US_ASCII)); diff --git a/src/main/java/org/traccar/protocol/GranitProtocolSmsEncoder.java b/src/main/java/org/traccar/protocol/GranitProtocolSmsEncoder.java index 7d5518c17..7dd4b2d77 100644 --- a/src/main/java/org/traccar/protocol/GranitProtocolSmsEncoder.java +++ b/src/main/java/org/traccar/protocol/GranitProtocolSmsEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class GranitProtocolSmsEncoder extends StringProtocolEncoder { + public GranitProtocolSmsEncoder(Protocol protocol) { + super(protocol); + } + @Override protected String encodeCommand(Command command) { switch (command.getType()) { diff --git a/src/main/java/org/traccar/protocol/Gt06Protocol.java b/src/main/java/org/traccar/protocol/Gt06Protocol.java index 6e5435cd4..9ec8de098 100644 --- a/src/main/java/org/traccar/protocol/Gt06Protocol.java +++ b/src/main/java/org/traccar/protocol/Gt06Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -31,7 +31,7 @@ public class Gt06Protocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new Gt06FrameDecoder()); - pipeline.addLast(new Gt06ProtocolEncoder()); + pipeline.addLast(new Gt06ProtocolEncoder(Gt06Protocol.this)); pipeline.addLast(new Gt06ProtocolDecoder(Gt06Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java index 05560229f..2fb18d2a2 100644 --- a/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Gt06ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -21,11 +21,16 @@ import org.traccar.BaseProtocolEncoder; import org.traccar.Context; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; public class Gt06ProtocolEncoder extends BaseProtocolEncoder { + public Gt06ProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(long deviceId, String content) { boolean language = Context.getIdentityManager().lookupAttributeBoolean(deviceId, "gt06.language", false, true); diff --git a/src/main/java/org/traccar/protocol/H02Protocol.java b/src/main/java/org/traccar/protocol/H02Protocol.java index 251beac5e..b897d83ad 100644 --- a/src/main/java/org/traccar/protocol/H02Protocol.java +++ b/src/main/java/org/traccar/protocol/H02Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -38,7 +38,7 @@ public class H02Protocol extends BaseProtocol { int messageLength = Context.getConfig().getInteger(getName() + ".messageLength"); pipeline.addLast(new H02FrameDecoder(messageLength)); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new H02ProtocolEncoder()); + pipeline.addLast(new H02ProtocolEncoder(H02Protocol.this)); pipeline.addLast(new H02ProtocolDecoder(H02Protocol.this)); } }); @@ -46,7 +46,7 @@ public class H02Protocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new StringEncoder()); - pipeline.addLast(new H02ProtocolEncoder()); + pipeline.addLast(new H02ProtocolEncoder(H02Protocol.this)); pipeline.addLast(new H02ProtocolDecoder(H02Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/H02ProtocolEncoder.java b/src/main/java/org/traccar/protocol/H02ProtocolEncoder.java index 614a07dd1..3dbdf879e 100644 --- a/src/main/java/org/traccar/protocol/H02ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/H02ProtocolEncoder.java @@ -1,6 +1,6 @@ /* * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -19,6 +19,7 @@ package org.traccar.protocol; import org.traccar.Context; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; import java.util.Date; @@ -26,6 +27,10 @@ public class H02ProtocolEncoder extends StringProtocolEncoder { private static final String MARKER = "HQ"; + public H02ProtocolEncoder(Protocol protocol) { + super(protocol); + } + private Object formatCommand(Date time, String uniqueId, String type, String... params) { StringBuilder result = new StringBuilder( diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocol.java b/src/main/java/org/traccar/protocol/HuabaoProtocol.java index 44c9f7ac7..791672b85 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocol.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -30,7 +30,7 @@ public class HuabaoProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new HuabaoFrameDecoder()); - pipeline.addLast(new HuabaoProtocolEncoder()); + pipeline.addLast(new HuabaoProtocolEncoder(HuabaoProtocol.this)); pipeline.addLast(new HuabaoProtocolDecoder(HuabaoProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolEncoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolEncoder.java index 7759790c4..2038c8d48 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolEncoder.java @@ -21,12 +21,17 @@ import org.traccar.BaseProtocolEncoder; import org.traccar.Context; import org.traccar.helper.DataConverter; import org.traccar.model.Command; +import org.traccar.Protocol; import java.text.SimpleDateFormat; import java.util.Date; public class HuabaoProtocolEncoder extends BaseProtocolEncoder { + public HuabaoProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/ItsProtocolEncoder.java b/src/main/java/org/traccar/protocol/ItsProtocolEncoder.java index ebbbd87cd..f82b8e3ac 100644 --- a/src/main/java/org/traccar/protocol/ItsProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/ItsProtocolEncoder.java @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class ItsProtocolEncoder extends StringProtocolEncoder { + public ItsProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/Jt600Protocol.java b/src/main/java/org/traccar/protocol/Jt600Protocol.java index 97c5fa6ce..37c82f741 100644 --- a/src/main/java/org/traccar/protocol/Jt600Protocol.java +++ b/src/main/java/org/traccar/protocol/Jt600Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -34,7 +34,7 @@ public class Jt600Protocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new Jt600FrameDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new Jt600ProtocolEncoder()); + pipeline.addLast(new Jt600ProtocolEncoder(Jt600Protocol.this)); pipeline.addLast(new Jt600ProtocolDecoder(Jt600Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/Jt600ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Jt600ProtocolEncoder.java index fe5c63c32..199467a38 100644 --- a/src/main/java/org/traccar/protocol/Jt600ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Jt600ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -19,9 +19,14 @@ import java.util.TimeZone; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class Jt600ProtocolEncoder extends StringProtocolEncoder { + public Jt600ProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/KhdProtocol.java b/src/main/java/org/traccar/protocol/KhdProtocol.java index cec7158ed..f77f4c311 100644 --- a/src/main/java/org/traccar/protocol/KhdProtocol.java +++ b/src/main/java/org/traccar/protocol/KhdProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -31,7 +31,7 @@ public class KhdProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(512, 3, 2)); - pipeline.addLast(new KhdProtocolEncoder()); + pipeline.addLast(new KhdProtocolEncoder(KhdProtocol.this)); pipeline.addLast(new KhdProtocolDecoder(KhdProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java b/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java index c66129283..4a8df26c8 100644 --- a/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/KhdProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -20,12 +20,17 @@ import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; public class KhdProtocolEncoder extends BaseProtocolEncoder { public static final int MSG_CUT_OIL = 0x39; public static final int MSG_RESUME_OIL = 0x38; + public KhdProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeCommand(int command, String uniqueId) { ByteBuf buf = Unpooled.buffer(); diff --git a/src/main/java/org/traccar/protocol/LaipacProtocol.java b/src/main/java/org/traccar/protocol/LaipacProtocol.java index b325755c8..1d561dbd2 100644 --- a/src/main/java/org/traccar/protocol/LaipacProtocol.java +++ b/src/main/java/org/traccar/protocol/LaipacProtocol.java @@ -38,7 +38,7 @@ public class LaipacProtocol extends BaseProtocol { pipeline.addLast(new LineBasedFrameDecoder(1024)); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new LaipacProtocolEncoder()); + pipeline.addLast(new LaipacProtocolEncoder(LaipacProtocol.this)); pipeline.addLast(new LaipacProtocolDecoder(LaipacProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java index dec76b83c..343ac9431 100644 --- a/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/LaipacProtocolEncoder.java @@ -18,9 +18,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; import org.traccar.helper.Checksum; +import org.traccar.Protocol; public class LaipacProtocolEncoder extends StringProtocolEncoder { + public LaipacProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected String formatCommand(Command command, String format, String... keys) { String sentence = super.formatCommand(command, "$" + format, keys); diff --git a/src/main/java/org/traccar/protocol/MeiligaoProtocol.java b/src/main/java/org/traccar/protocol/MeiligaoProtocol.java index c307c7318..e8a66e49f 100644 --- a/src/main/java/org/traccar/protocol/MeiligaoProtocol.java +++ b/src/main/java/org/traccar/protocol/MeiligaoProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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,14 +36,14 @@ public class MeiligaoProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new MeiligaoFrameDecoder()); - pipeline.addLast(new MeiligaoProtocolEncoder()); + pipeline.addLast(new MeiligaoProtocolEncoder(MeiligaoProtocol.this)); pipeline.addLast(new MeiligaoProtocolDecoder(MeiligaoProtocol.this)); } }); addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new MeiligaoProtocolEncoder()); + pipeline.addLast(new MeiligaoProtocolEncoder(MeiligaoProtocol.this)); pipeline.addLast(new MeiligaoProtocolDecoder(MeiligaoProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java b/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java index 57cbbe0fc..36e94195c 100644 --- a/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/MeiligaoProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -21,12 +21,17 @@ import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.helper.DataConverter; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; import java.util.TimeZone; public class MeiligaoProtocolEncoder extends BaseProtocolEncoder { + public MeiligaoProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(long deviceId, int type, ByteBuf content) { ByteBuf buf = Unpooled.buffer(); diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocol.java b/src/main/java/org/traccar/protocol/MeitrackProtocol.java index c887cd3a0..7439ea611 100644 --- a/src/main/java/org/traccar/protocol/MeitrackProtocol.java +++ b/src/main/java/org/traccar/protocol/MeitrackProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -37,7 +37,7 @@ public class MeitrackProtocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new MeitrackFrameDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new MeitrackProtocolEncoder()); + pipeline.addLast(new MeitrackProtocolEncoder(MeitrackProtocol.this)); pipeline.addLast(new MeitrackProtocolDecoder(MeitrackProtocol.this)); } }); @@ -45,7 +45,7 @@ public class MeitrackProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new StringEncoder()); - pipeline.addLast(new MeitrackProtocolEncoder()); + pipeline.addLast(new MeitrackProtocolEncoder(MeitrackProtocol.this)); pipeline.addLast(new MeitrackProtocolDecoder(MeitrackProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/MeitrackProtocolEncoder.java b/src/main/java/org/traccar/protocol/MeitrackProtocolEncoder.java index abb6ec9d4..a0dc95c5d 100644 --- a/src/main/java/org/traccar/protocol/MeitrackProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/MeitrackProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -19,11 +19,16 @@ import org.traccar.Context; import org.traccar.StringProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; import java.util.Map; public class MeitrackProtocolEncoder extends StringProtocolEncoder { + public MeitrackProtocolEncoder(Protocol protocol) { + super(protocol); + } + private Object formatCommand(Command command, char dataId, String content) { String uniqueId = getUniqueId(command.getDeviceId()); int length = 1 + uniqueId.length() + 1 + content.length() + 5; diff --git a/src/main/java/org/traccar/protocol/MiniFinderProtocol.java b/src/main/java/org/traccar/protocol/MiniFinderProtocol.java index d4a154053..82534ecd8 100644 --- a/src/main/java/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/main/java/org/traccar/protocol/MiniFinderProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -44,7 +44,7 @@ public class MiniFinderProtocol extends BaseProtocol { pipeline.addLast(new CharacterDelimiterFrameDecoder(1024, ';')); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new MiniFinderProtocolEncoder()); + pipeline.addLast(new MiniFinderProtocolEncoder(MiniFinderProtocol.this)); pipeline.addLast(new MiniFinderProtocolDecoder(MiniFinderProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/MiniFinderProtocolEncoder.java b/src/main/java/org/traccar/protocol/MiniFinderProtocolEncoder.java index 7a3d5b226..36fb9fc2f 100644 --- a/src/main/java/org/traccar/protocol/MiniFinderProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/MiniFinderProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -19,9 +19,14 @@ import java.util.TimeZone; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class MiniFinderProtocolEncoder extends StringProtocolEncoder implements StringProtocolEncoder.ValueFormatter { + public MiniFinderProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override public String formatValue(String key, Object value) { switch (key) { diff --git a/src/main/java/org/traccar/protocol/NoranProtocol.java b/src/main/java/org/traccar/protocol/NoranProtocol.java index 9f3078d6d..3df364c30 100644 --- a/src/main/java/org/traccar/protocol/NoranProtocol.java +++ b/src/main/java/org/traccar/protocol/NoranProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -32,7 +32,7 @@ public class NoranProtocol extends BaseProtocol { addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new NoranProtocolEncoder()); + pipeline.addLast(new NoranProtocolEncoder(NoranProtocol.this)); pipeline.addLast(new NoranProtocolDecoder(NoranProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java b/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java index 92826c8b2..e02a1313c 100644 --- a/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/NoranProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -19,11 +19,16 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; public class NoranProtocolEncoder extends BaseProtocolEncoder { + public NoranProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(String content) { ByteBuf buf = Unpooled.buffer(12 + 56); diff --git a/src/main/java/org/traccar/protocol/PretraceProtocol.java b/src/main/java/org/traccar/protocol/PretraceProtocol.java index f753cbdb4..9d35c1c2f 100644 --- a/src/main/java/org/traccar/protocol/PretraceProtocol.java +++ b/src/main/java/org/traccar/protocol/PretraceProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 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. @@ -35,7 +35,7 @@ public class PretraceProtocol extends BaseProtocol { pipeline.addLast(new CharacterDelimiterFrameDecoder(1024, ')')); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new PretraceProtocolEncoder()); + pipeline.addLast(new PretraceProtocolEncoder(PretraceProtocol.this)); pipeline.addLast(new PretraceProtocolDecoder(PretraceProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java b/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java index 9cf951e3b..1083a252e 100644 --- a/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/PretraceProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -19,9 +19,14 @@ import org.traccar.BaseProtocolEncoder; import org.traccar.Context; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; public class PretraceProtocolEncoder extends BaseProtocolEncoder { + public PretraceProtocolEncoder(Protocol protocol) { + super(protocol); + } + private String formatCommand(String uniqueId, String data) { String content = uniqueId + data; return String.format("(%s^%02X)", content, Checksum.xor(content)); diff --git a/src/main/java/org/traccar/protocol/Pt502Protocol.java b/src/main/java/org/traccar/protocol/Pt502Protocol.java index 5afb9451d..56444fb42 100644 --- a/src/main/java/org/traccar/protocol/Pt502Protocol.java +++ b/src/main/java/org/traccar/protocol/Pt502Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -35,7 +35,7 @@ public class Pt502Protocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new Pt502FrameDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new Pt502ProtocolEncoder()); + pipeline.addLast(new Pt502ProtocolEncoder(Pt502Protocol.this)); pipeline.addLast(new Pt502ProtocolDecoder(Pt502Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java index ed18208cc..ba08b16ae 100644 --- a/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Pt502ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -19,9 +19,14 @@ import java.util.TimeZone; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class Pt502ProtocolEncoder extends StringProtocolEncoder implements StringProtocolEncoder.ValueFormatter { + public Pt502ProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override public String formatValue(String key, Object value) { if (key.equals(Command.KEY_TIMEZONE)) { diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocol.java b/src/main/java/org/traccar/protocol/RuptelaProtocol.java index a574293cd..b8f72336b 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocol.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -37,7 +37,7 @@ public class RuptelaProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 0, 2, 2, 0)); - pipeline.addLast(new RuptelaProtocolEncoder()); + pipeline.addLast(new RuptelaProtocolEncoder(RuptelaProtocol.this)); pipeline.addLast(new RuptelaProtocolDecoder(RuptelaProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java index 96d0da5a7..51967403d 100644 --- a/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/RuptelaProtocolEncoder.java @@ -20,11 +20,16 @@ import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; public class RuptelaProtocolEncoder extends BaseProtocolEncoder { + public RuptelaProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(int type, ByteBuf content) { ByteBuf buf = Unpooled.buffer(); diff --git a/src/main/java/org/traccar/protocol/SuntechProtocol.java b/src/main/java/org/traccar/protocol/SuntechProtocol.java index 48d6e81c1..7e2c20e6f 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocol.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocol.java @@ -39,7 +39,7 @@ public class SuntechProtocol extends BaseProtocol { pipeline.addLast(new SuntechFrameDecoder()); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new SuntechProtocolEncoder()); + pipeline.addLast(new SuntechProtocolEncoder(SuntechProtocol.this)); pipeline.addLast(new SuntechProtocolDecoder(SuntechProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java b/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java index 90fa4aa39..6dae42ad5 100644 --- a/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/SuntechProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class SuntechProtocolEncoder extends StringProtocolEncoder { + public SuntechProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/SviasProtocol.java b/src/main/java/org/traccar/protocol/SviasProtocol.java index f01f28389..accfa173f 100644 --- a/src/main/java/org/traccar/protocol/SviasProtocol.java +++ b/src/main/java/org/traccar/protocol/SviasProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 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. @@ -42,7 +42,7 @@ public class SviasProtocol extends BaseProtocol { pipeline.addLast(new CharacterDelimiterFrameDecoder(1024, "]")); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new SviasProtocolEncoder()); + pipeline.addLast(new SviasProtocolEncoder(SviasProtocol.this)); pipeline.addLast(new SviasProtocolDecoder(SviasProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/SviasProtocolEncoder.java b/src/main/java/org/traccar/protocol/SviasProtocolEncoder.java index 8bfbef119..2607d7bd1 100644 --- a/src/main/java/org/traccar/protocol/SviasProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/SviasProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class SviasProtocolEncoder extends StringProtocolEncoder { + public SviasProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { switch (command.getType()) { diff --git a/src/main/java/org/traccar/protocol/T800xProtocol.java b/src/main/java/org/traccar/protocol/T800xProtocol.java index 85749d0cf..8b91265cb 100644 --- a/src/main/java/org/traccar/protocol/T800xProtocol.java +++ b/src/main/java/org/traccar/protocol/T800xProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -30,7 +30,7 @@ public class T800xProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new LengthFieldBasedFrameDecoder(1024, 3, 2, -5, 0)); - pipeline.addLast(new T800xProtocolEncoder()); + pipeline.addLast(new T800xProtocolEncoder(T800xProtocol.this)); pipeline.addLast(new T800xProtocolDecoder(T800xProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/T800xProtocolEncoder.java b/src/main/java/org/traccar/protocol/T800xProtocolEncoder.java index 34f30b147..439bedb57 100644 --- a/src/main/java/org/traccar/protocol/T800xProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/T800xProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -20,6 +20,7 @@ import io.netty.buffer.Unpooled; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.DataConverter; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; @@ -29,6 +30,10 @@ public class T800xProtocolEncoder extends BaseProtocolEncoder { public static final int MODE_BROADCAST = 0x02; public static final int MODE_FORWARD = 0x03; + public T800xProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(Command command, String content) { ByteBuf buf = Unpooled.buffer(); diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocol.java b/src/main/java/org/traccar/protocol/TeltonikaProtocol.java index eef9662d7..5817b86be 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocol.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -29,14 +29,14 @@ public class TeltonikaProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new TeltonikaFrameDecoder()); - pipeline.addLast(new TeltonikaProtocolEncoder()); + pipeline.addLast(new TeltonikaProtocolEncoder(TeltonikaProtocol.this)); pipeline.addLast(new TeltonikaProtocolDecoder(TeltonikaProtocol.this, false)); } }); addServer(new TrackerServer(true, getName()) { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { - pipeline.addLast(new TeltonikaProtocolEncoder()); + pipeline.addLast(new TeltonikaProtocolEncoder(TeltonikaProtocol.this)); pipeline.addLast(new TeltonikaProtocolDecoder(TeltonikaProtocol.this, true)); } }); diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java index 5380cf3a0..8a614618a 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolEncoder.java @@ -19,6 +19,7 @@ import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; import org.traccar.helper.DataConverter; import org.traccar.model.Command; +import org.traccar.Protocol; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -27,6 +28,10 @@ import java.nio.charset.StandardCharsets; public class TeltonikaProtocolEncoder extends BaseProtocolEncoder { + public TeltonikaProtocolEncoder(Protocol protocol) { + super(protocol); + } + private ByteBuf encodeContent(byte[] content) { ByteBuf buf = Unpooled.buffer(); diff --git a/src/main/java/org/traccar/protocol/Tk103Protocol.java b/src/main/java/org/traccar/protocol/Tk103Protocol.java index fa83133e2..ff0bedfb7 100644 --- a/src/main/java/org/traccar/protocol/Tk103Protocol.java +++ b/src/main/java/org/traccar/protocol/Tk103Protocol.java @@ -1,6 +1,6 @@ /* * Copyright 2017 Christoph Krey (c@ckrey.de) - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -51,7 +51,7 @@ public class Tk103Protocol extends BaseProtocol { pipeline.addLast(new Tk103FrameDecoder()); pipeline.addLast(new StringDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new Tk103ProtocolEncoder()); + pipeline.addLast(new Tk103ProtocolEncoder(Tk103Protocol.this)); pipeline.addLast(new Tk103ProtocolDecoder(Tk103Protocol.this)); } }); @@ -60,7 +60,7 @@ public class Tk103Protocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new StringDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new Tk103ProtocolEncoder()); + pipeline.addLast(new Tk103ProtocolEncoder(Tk103Protocol.this)); pipeline.addLast(new Tk103ProtocolDecoder(Tk103Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolEncoder.java index 98edc8cb5..cc79968b7 100644 --- a/src/main/java/org/traccar/protocol/Tk103ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Tk103ProtocolEncoder.java @@ -1,6 +1,6 @@ /* * Copyright 2017 Christoph Krey (c@ckrey.de) - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 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. @@ -19,16 +19,19 @@ package org.traccar.protocol; import org.traccar.Context; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class Tk103ProtocolEncoder extends StringProtocolEncoder { private final boolean forceAlternative; - public Tk103ProtocolEncoder() { + public Tk103ProtocolEncoder(Protocol protocol) { + super(protocol); this.forceAlternative = false; } - public Tk103ProtocolEncoder(boolean forceAlternative) { + public Tk103ProtocolEncoder(Protocol protocol, boolean forceAlternative) { + super(protocol); this.forceAlternative = forceAlternative; } diff --git a/src/main/java/org/traccar/protocol/TotemProtocol.java b/src/main/java/org/traccar/protocol/TotemProtocol.java index 66e1ec4f1..f8cda8358 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocol.java +++ b/src/main/java/org/traccar/protocol/TotemProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -35,7 +35,7 @@ public class TotemProtocol extends BaseProtocol { pipeline.addLast(new TotemFrameDecoder()); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new TotemProtocolEncoder()); + pipeline.addLast(new TotemProtocolEncoder(TotemProtocol.this)); pipeline.addLast(new TotemProtocolDecoder(TotemProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java b/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java index b5049859d..3bbb92031 100644 --- a/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/TotemProtocolEncoder.java @@ -1,6 +1,6 @@ /* * Copyright 2015 Irving Gonzalez - * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -18,9 +18,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class TotemProtocolEncoder extends StringProtocolEncoder { + public TotemProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/WatchProtocol.java b/src/main/java/org/traccar/protocol/WatchProtocol.java index fe285e70d..6dc3bf9fb 100644 --- a/src/main/java/org/traccar/protocol/WatchProtocol.java +++ b/src/main/java/org/traccar/protocol/WatchProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -44,7 +44,7 @@ public class WatchProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new WatchFrameDecoder()); - pipeline.addLast(new WatchProtocolEncoder()); + pipeline.addLast(new WatchProtocolEncoder(WatchProtocol.this)); pipeline.addLast(new WatchProtocolDecoder(WatchProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/WatchProtocolEncoder.java b/src/main/java/org/traccar/protocol/WatchProtocolEncoder.java index 264aec81f..b433dfd2a 100644 --- a/src/main/java/org/traccar/protocol/WatchProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/WatchProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -21,6 +21,7 @@ import io.netty.channel.Channel; import org.traccar.StringProtocolEncoder; import org.traccar.helper.DataConverter; import org.traccar.model.Command; +import org.traccar.Protocol; import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; @@ -32,6 +33,10 @@ import java.util.TimeZone; public class WatchProtocolEncoder extends StringProtocolEncoder implements StringProtocolEncoder.ValueFormatter { + public WatchProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override public String formatValue(String key, Object value) { if (key.equals(Command.KEY_TIMEZONE)) { diff --git a/src/main/java/org/traccar/protocol/WialonProtocol.java b/src/main/java/org/traccar/protocol/WialonProtocol.java index 06b54dceb..3838791a7 100644 --- a/src/main/java/org/traccar/protocol/WialonProtocol.java +++ b/src/main/java/org/traccar/protocol/WialonProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -45,7 +45,7 @@ public class WialonProtocol extends BaseProtocol { } else { pipeline.addLast(new StringDecoder()); } - pipeline.addLast(new WialonProtocolEncoder()); + pipeline.addLast(new WialonProtocolEncoder(WialonProtocol.this)); pipeline.addLast(new WialonProtocolDecoder(WialonProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/WialonProtocolEncoder.java b/src/main/java/org/traccar/protocol/WialonProtocolEncoder.java index 9ff1631eb..c45edf00d 100644 --- a/src/main/java/org/traccar/protocol/WialonProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/WialonProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,9 +18,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class WialonProtocolEncoder extends StringProtocolEncoder { + public WialonProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { switch (command.getType()) { diff --git a/src/main/java/org/traccar/protocol/WondexProtocol.java b/src/main/java/org/traccar/protocol/WondexProtocol.java index 8c6283d66..82a18840e 100644 --- a/src/main/java/org/traccar/protocol/WondexProtocol.java +++ b/src/main/java/org/traccar/protocol/WondexProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -25,7 +25,7 @@ import io.netty.handler.codec.string.StringEncoder; public class WondexProtocol extends BaseProtocol { public WondexProtocol() { - setTextCommandEncoder(new WondexProtocolEncoder()); + setTextCommandEncoder(new WondexProtocolEncoder(WondexProtocol.this)); setSupportedCommands( Command.TYPE_GET_DEVICE_STATUS, Command.TYPE_GET_MODEM_STATUS, @@ -38,7 +38,7 @@ public class WondexProtocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new WondexFrameDecoder()); pipeline.addLast(new StringEncoder()); - pipeline.addLast(new WondexProtocolEncoder()); + pipeline.addLast(new WondexProtocolEncoder(WondexProtocol.this)); pipeline.addLast(new WondexProtocolDecoder(WondexProtocol.this)); } }); @@ -46,7 +46,7 @@ public class WondexProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new StringEncoder()); - pipeline.addLast(new WondexProtocolEncoder()); + pipeline.addLast(new WondexProtocolEncoder(WondexProtocol.this)); pipeline.addLast(new WondexProtocolDecoder(WondexProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/WondexProtocolEncoder.java b/src/main/java/org/traccar/protocol/WondexProtocolEncoder.java index f9e8eeb9b..e9bb23d15 100644 --- a/src/main/java/org/traccar/protocol/WondexProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/WondexProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class WondexProtocolEncoder extends StringProtocolEncoder { + public WondexProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/XexunProtocol.java b/src/main/java/org/traccar/protocol/XexunProtocol.java index 0005270fb..401844e7b 100644 --- a/src/main/java/org/traccar/protocol/XexunProtocol.java +++ b/src/main/java/org/traccar/protocol/XexunProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -42,7 +42,7 @@ public class XexunProtocol extends BaseProtocol { } pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new XexunProtocolEncoder()); + pipeline.addLast(new XexunProtocolEncoder(XexunProtocol.this)); pipeline.addLast(new XexunProtocolDecoder(XexunProtocol.this, full)); } }); diff --git a/src/main/java/org/traccar/protocol/XexunProtocolEncoder.java b/src/main/java/org/traccar/protocol/XexunProtocolEncoder.java index 515cfbbd0..fc849fe15 100644 --- a/src/main/java/org/traccar/protocol/XexunProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/XexunProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class XexunProtocolEncoder extends StringProtocolEncoder { + public XexunProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/XirgoProtocol.java b/src/main/java/org/traccar/protocol/XirgoProtocol.java index 4979fda5d..1be5b6c4b 100644 --- a/src/main/java/org/traccar/protocol/XirgoProtocol.java +++ b/src/main/java/org/traccar/protocol/XirgoProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 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. @@ -35,7 +35,7 @@ public class XirgoProtocol extends BaseProtocol { pipeline.addLast(new CharacterDelimiterFrameDecoder(1024, "##")); pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new XirgoProtocolEncoder()); + pipeline.addLast(new XirgoProtocolEncoder(XirgoProtocol.this)); pipeline.addLast(new XirgoProtocolDecoder(XirgoProtocol.this)); } }); @@ -44,7 +44,7 @@ public class XirgoProtocol extends BaseProtocol { protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new StringEncoder()); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new XirgoProtocolEncoder()); + pipeline.addLast(new XirgoProtocolEncoder(XirgoProtocol.this)); pipeline.addLast(new XirgoProtocolDecoder(XirgoProtocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/XirgoProtocolEncoder.java b/src/main/java/org/traccar/protocol/XirgoProtocolEncoder.java index dd5e30cca..aa85e9e0e 100644 --- a/src/main/java/org/traccar/protocol/XirgoProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/XirgoProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2019 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. @@ -17,9 +17,14 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class XirgoProtocolEncoder extends StringProtocolEncoder { + public XirgoProtocolEncoder(Protocol protocol) { + super(protocol); + } + @Override protected Object encodeCommand(Command command) { diff --git a/src/main/java/org/traccar/protocol/Xrb28Protocol.java b/src/main/java/org/traccar/protocol/Xrb28Protocol.java index b1f1c34fb..5d8af418b 100644 --- a/src/main/java/org/traccar/protocol/Xrb28Protocol.java +++ b/src/main/java/org/traccar/protocol/Xrb28Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 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. @@ -40,7 +40,7 @@ public class Xrb28Protocol extends BaseProtocol { pipeline.addLast(new LineBasedFrameDecoder(1024)); pipeline.addLast(new StringEncoder(StandardCharsets.ISO_8859_1)); pipeline.addLast(new StringDecoder()); - pipeline.addLast(new Xrb28ProtocolEncoder()); + pipeline.addLast(new Xrb28ProtocolEncoder(Xrb28Protocol.this)); pipeline.addLast(new Xrb28ProtocolDecoder(Xrb28Protocol.this)); } }); diff --git a/src/main/java/org/traccar/protocol/Xrb28ProtocolEncoder.java b/src/main/java/org/traccar/protocol/Xrb28ProtocolEncoder.java index 617639312..3e69af329 100644 --- a/src/main/java/org/traccar/protocol/Xrb28ProtocolEncoder.java +++ b/src/main/java/org/traccar/protocol/Xrb28ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 - 2019 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. @@ -18,9 +18,14 @@ package org.traccar.protocol; import io.netty.channel.Channel; import org.traccar.BaseProtocolEncoder; import org.traccar.model.Command; +import org.traccar.Protocol; public class Xrb28ProtocolEncoder extends BaseProtocolEncoder { + public Xrb28ProtocolEncoder(Protocol protocol) { + super(protocol); + } + private String formatCommand(Command command, String content) { return String.format("\u00ff\u00ff*SCOS,OM,%s,%s#\n", getUniqueId(command.getDeviceId()), content); } |