aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/BasePipelineFactory.java3
-rw-r--r--src/org/traccar/FilterHandler.java2
-rw-r--r--src/org/traccar/api/resource/DeviceAttributeResource.java2
-rw-r--r--src/org/traccar/api/resource/GroupAttributeResource.java2
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocol.java4
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java27
6 files changed, 29 insertions, 11 deletions
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index edbebc9e2..b368c800d 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -127,7 +127,8 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
}
}
- distanceHandler = new DistanceHandler(Context.getConfig().getBoolean("coordinates.filter"),
+ distanceHandler = new DistanceHandler(
+ Context.getConfig().getBoolean("coordinates.filter"),
Context.getConfig().getInteger("coordinates.minError"),
Context.getConfig().getInteger("coordinates.maxError"));
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index 9e532347d..71c0a1cf5 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -127,7 +127,7 @@ public class FilterHandler extends BaseDataHandler {
if (filterMaxSpeed != 0 && last != null) {
double distance = position.getDouble(Position.KEY_DISTANCE);
long time = position.getFixTime().getTime() - last.getFixTime().getTime();
- return UnitsConverter.knotsFromMps(distance / time) > filterMaxSpeed;
+ return UnitsConverter.knotsFromMps(distance / (time / 1000)) > filterMaxSpeed;
}
return false;
}
diff --git a/src/org/traccar/api/resource/DeviceAttributeResource.java b/src/org/traccar/api/resource/DeviceAttributeResource.java
index 8d80c9235..82d17bcc6 100644
--- a/src/org/traccar/api/resource/DeviceAttributeResource.java
+++ b/src/org/traccar/api/resource/DeviceAttributeResource.java
@@ -49,7 +49,7 @@ public class DeviceAttributeResource extends BaseResource {
public Response remove(DeviceAttribute entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId());
- Context.getPermissionsManager().checkGeofence(getUserId(), entity.getAttributeId());
+ Context.getPermissionsManager().checkAttribute(getUserId(), entity.getAttributeId());
Context.getDataManager().unlinkDeviceAttribute(entity.getDeviceId(), entity.getAttributeId());
Context.getAttributesManager().refresh();
return Response.noContent().build();
diff --git a/src/org/traccar/api/resource/GroupAttributeResource.java b/src/org/traccar/api/resource/GroupAttributeResource.java
index 84b876d34..d8b8b58c9 100644
--- a/src/org/traccar/api/resource/GroupAttributeResource.java
+++ b/src/org/traccar/api/resource/GroupAttributeResource.java
@@ -49,7 +49,7 @@ public class GroupAttributeResource extends BaseResource {
public Response remove(GroupAttribute entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getPermissionsManager().checkGroup(getUserId(), entity.getGroupId());
- Context.getPermissionsManager().checkGeofence(getUserId(), entity.getAttributeId());
+ Context.getPermissionsManager().checkAttribute(getUserId(), entity.getAttributeId());
Context.getDataManager().unlinkGroupAttribute(entity.getGroupId(), entity.getAttributeId());
Context.getAttributesManager().refresh();
return Response.noContent().build();
diff --git a/src/org/traccar/protocol/TeltonikaProtocol.java b/src/org/traccar/protocol/TeltonikaProtocol.java
index 524e6d5b5..d0177da97 100644
--- a/src/org/traccar/protocol/TeltonikaProtocol.java
+++ b/src/org/traccar/protocol/TeltonikaProtocol.java
@@ -39,14 +39,14 @@ public class TeltonikaProtocol extends BaseProtocol {
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new TeltonikaFrameDecoder());
pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
- pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this));
+ pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this, false));
}
});
serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
- pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this));
+ pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this, true));
}
});
}
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 72e06c083..15c5b8e80 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -18,8 +18,8 @@ package org.traccar.protocol;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.socket.DatagramChannel;
import org.traccar.BaseProtocolDecoder;
+import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
@@ -35,8 +35,17 @@ import java.util.List;
public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
- public TeltonikaProtocolDecoder(TeltonikaProtocol protocol) {
+ private boolean connectionless;
+ private boolean extended;
+
+ public void setExtended(boolean extended) {
+ this.extended = extended;
+ }
+
+ public TeltonikaProtocolDecoder(TeltonikaProtocol protocol, boolean connectionless) {
super(protocol);
+ this.connectionless = connectionless;
+ this.extended = Context.getConfig().getBoolean(getProtocolName() + ".extended");
}
private DeviceSession parseIdentification(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
@@ -243,13 +252,21 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
+ // Read 16 byte data
+ if (extended) {
+ int cnt = buf.readUnsignedByte();
+ for (int j = 0; j < cnt; j++) {
+ position.set(Position.PREFIX_IO + buf.readUnsignedByte(), ChannelBuffers.hexDump(buf.readBytes(16)));
+ }
+ }
+
}
private List<Position> parseData(
Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int locationPacketId, String... imei) {
List<Position> positions = new LinkedList<>();
- if (!(channel instanceof DatagramChannel)) {
+ if (!connectionless) {
buf.readUnsignedInt(); // data length
}
@@ -278,7 +295,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
if (channel != null) {
- if (channel instanceof DatagramChannel) {
+ if (connectionless) {
ChannelBuffer response = ChannelBuffers.dynamicBuffer();
response.writeShort(5);
response.writeShort(0);
@@ -301,7 +318,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
ChannelBuffer buf = (ChannelBuffer) msg;
- if (channel instanceof DatagramChannel) {
+ if (connectionless) {
return decodeUdp(channel, remoteAddress, buf);
} else {
return decodeTcp(channel, remoteAddress, buf);