diff options
Diffstat (limited to 'src/org/traccar/protocol/Gps103Protocol.java')
-rw-r--r-- | src/org/traccar/protocol/Gps103Protocol.java | 25 |
1 files changed, 9 insertions, 16 deletions
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<CommandType, CommandTemplate> 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<Duration>() { - @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<TrackerServer> 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()); } }); } |