From 40bf728938311fa9619ad2bb0eb89b21c16e9585 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 14 Mar 2016 14:24:41 +1300 Subject: Implement Fox Lite protocol --- src/org/traccar/protocol/FoxProtocol.java | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/org/traccar/protocol/FoxProtocol.java (limited to 'src/org/traccar/protocol/FoxProtocol.java') diff --git a/src/org/traccar/protocol/FoxProtocol.java b/src/org/traccar/protocol/FoxProtocol.java new file mode 100644 index 000000000..25190e967 --- /dev/null +++ b/src/org/traccar/protocol/FoxProtocol.java @@ -0,0 +1,47 @@ +/* + * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.protocol; + +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder; +import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; +import org.traccar.BaseProtocol; +import org.traccar.CharacterDelimiterFrameDecoder; +import org.traccar.TrackerServer; + +import java.util.List; + +public class FoxProtocol extends BaseProtocol { + + public FoxProtocol() { + super("fox"); + } + + @Override + public void initTrackerServers(List serverList) { + serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "")); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("objectDecoder", new FoxProtocolDecoder(FoxProtocol.this)); + } + }); + } + +} -- cgit v1.2.3 From 0a1019b59481b6bf8ee8989feb23cef084b6caf5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 14 Mar 2016 14:48:39 +1300 Subject: Fix PMD and CheckStyle issues --- src/org/traccar/api/resource/GroupResource.java | 1 - src/org/traccar/database/GroupTree.java | 16 ++++++---------- src/org/traccar/protocol/FoxProtocol.java | 2 -- src/org/traccar/protocol/MiniFinderProtocolEncoder.java | 2 -- 4 files changed, 6 insertions(+), 15 deletions(-) (limited to 'src/org/traccar/protocol/FoxProtocol.java') diff --git a/src/org/traccar/api/resource/GroupResource.java b/src/org/traccar/api/resource/GroupResource.java index 49f839499..e22796645 100644 --- a/src/org/traccar/api/resource/GroupResource.java +++ b/src/org/traccar/api/resource/GroupResource.java @@ -17,7 +17,6 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; -import org.traccar.model.Device; import org.traccar.model.Group; import javax.ws.rs.Consumes; diff --git a/src/org/traccar/database/GroupTree.java b/src/org/traccar/database/GroupTree.java index b383b1501..4a2321f58 100644 --- a/src/org/traccar/database/GroupTree.java +++ b/src/org/traccar/database/GroupTree.java @@ -33,11 +33,11 @@ public class GroupTree { private Device device; private Collection children = new HashSet<>(); - public TreeNode(Group group) { + TreeNode(Group group) { this.group = group; } - public TreeNode(Device device) { + TreeNode(Device device) { this.device = device; } @@ -59,14 +59,10 @@ public class GroupTree { if (other == this) { return true; } - if (group != null) { - if (other.group != null) { - return group.getId() == other.group.getId(); - } - } else if (device != null) { - if (other.device != null) { - return device.getId() == other.device.getId(); - } + if (group != null && other.group != null) { + return group.getId() == other.group.getId(); + } else if (device != null && other.device != null) { + return device.getId() == other.device.getId(); } return false; } diff --git a/src/org/traccar/protocol/FoxProtocol.java b/src/org/traccar/protocol/FoxProtocol.java index 25190e967..cc069692b 100644 --- a/src/org/traccar/protocol/FoxProtocol.java +++ b/src/org/traccar/protocol/FoxProtocol.java @@ -17,9 +17,7 @@ package org.traccar.protocol; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder; import org.jboss.netty.handler.codec.string.StringDecoder; -import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.CharacterDelimiterFrameDecoder; import org.traccar.TrackerServer; diff --git a/src/org/traccar/protocol/MiniFinderProtocolEncoder.java b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java index 729c57573..e5762f5dd 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolEncoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolEncoder.java @@ -21,8 +21,6 @@ import org.traccar.model.Command; public class MiniFinderProtocolEncoder extends StringProtocolEncoder { - private static final String prefix = "123456"; - @Override protected Object encodeCommand(Command command) { -- cgit v1.2.3