From 51d4e557703a0322b983a8b294f2a8c6920718c5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 17 Jul 2015 20:10:48 +1200 Subject: Start GPS103 encoder implementation --- src/org/traccar/protocol/Gps103Protocol.java | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/org/traccar/protocol/Gps103Protocol.java') diff --git a/src/org/traccar/protocol/Gps103Protocol.java b/src/org/traccar/protocol/Gps103Protocol.java index 3f04ede4e..59d8e62a7 100644 --- a/src/org/traccar/protocol/Gps103Protocol.java +++ b/src/org/traccar/protocol/Gps103Protocol.java @@ -15,6 +15,7 @@ */ package org.traccar.protocol; +import java.util.List; import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; @@ -23,29 +24,19 @@ import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; - -import java.util.List; +import org.traccar.model.Command; public class Gps103Protocol extends BaseProtocol { public Gps103Protocol() { super("gps103"); + setSupportedCommands( + Command.TYPE_POSITION_STOP, + Command.TYPE_POSITION_FIX, + Command.TYPE_ENGINE_STOP, + Command.TYPE_ENGINE_RESUME); } - /*@Override - protected void initCommandsTemplates(Map templates) { - templates.put(CommandType.STOP_POSITIONING, new StringCommandTemplate("**,imei:[%s],A", Command.UNIQUE_ID)); - templates.put(CommandType.FIX_POSITIONING, new StringCommandTemplate("**,imei:[%s],C,[%s]", Command.UNIQUE_ID, FixPositioningCommand.FREQUENCY) - .addConverter(Duration.class, new CommandValueConversion() { - @Override - public String convert(Duration value) { - return String.format("%02d%s", value.getValue(), value.getUnit().getCommandFormat()); - } - })); - templates.put(CommandType.RESUME_ENGINE, new StringCommandTemplate("**,imei:[%s],J", Command.UNIQUE_ID)); - templates.put(CommandType.STOP_ENGINE, new StringCommandTemplate("**,imei:[%s],K", Command.UNIQUE_ID)); - }*/ - @Override public void initTrackerServers(List serverList) { serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { @@ -55,6 +46,7 @@ public class Gps103Protocol extends BaseProtocol { pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this)); + pipeline.addLast("objectEncoder", new Gps103ProtocolEncoder()); } }); serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { @@ -63,6 +55,7 @@ public class Gps103Protocol extends BaseProtocol { pipeline.addLast("stringDecoder", new StringDecoder()); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this)); + pipeline.addLast("objectEncoder", new Gps103ProtocolEncoder()); } }); } -- cgit v1.2.3