aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml2
-rwxr-xr-xsetup/package.sh2
-rw-r--r--setup/traccar.iss2
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java6
-rw-r--r--src/org/traccar/api/resource/EventResource.java1
-rw-r--r--src/org/traccar/api/resource/PositionResource.java3
-rw-r--r--src/org/traccar/api/resource/ReportResource.java4
-rw-r--r--src/org/traccar/protocol/At2000Protocol.java7
-rw-r--r--src/org/traccar/protocol/At2000ProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/GranitProtocolDecoder.java25
-rw-r--r--src/org/traccar/protocol/OigoProtocolDecoder.java3
-rw-r--r--test/org/traccar/ProtocolTest.java4
-rw-r--r--test/org/traccar/protocol/At2000ProtocolDecoderTest.java11
-rw-r--r--test/org/traccar/protocol/GranitProtocolDecoderTest.java18
-rwxr-xr-xtools/test-integration.py9
m---------traccar-web0
16 files changed, 70 insertions, 33 deletions
diff --git a/pom.xml b/pom.xml
index ef44d4786..45df20efc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.traccar</groupId>
<artifactId>traccar</artifactId>
- <version>3.8-SNAPSHOT</version>
+ <version>3.9-SNAPSHOT</version>
<name>traccar</name>
<url>https://www.traccar.org</url>
diff --git a/setup/package.sh b/setup/package.sh
index a6b54717d..404c7b86b 100755
--- a/setup/package.sh
+++ b/setup/package.sh
@@ -22,7 +22,7 @@ check_requirement () {
fi
}
-check_requirement "ls ../../ext-6.0.1" "Missing ../../ext-6.0.1 (https://www.sencha.com/legal/GPL/)"
+check_requirement "ls ../../ext-6.2.0" "Missing ../../ext-6.2.0 (https://www.sencha.com/legal/GPL/)"
check_requirement "ls yajsw-*.zip" "Missing yajsw-*.zip (https://sourceforge.net/projects/yajsw/files/)"
check_requirement "ls innosetup-*.exe" "Missing isetup-*.exe (http://www.jrsoftware.org/isdl.php)"
check_requirement "which sencha" "Missing sencha cmd package (https://www.sencha.com/products/extjs/cmd-download/)"
diff --git a/setup/traccar.iss b/setup/traccar.iss
index 87c2e2fba..50eae41b0 100644
--- a/setup/traccar.iss
+++ b/setup/traccar.iss
@@ -1,6 +1,6 @@
[Setup]
AppName=Traccar
-AppVersion=3.8
+AppVersion=3.9
DefaultDirName={pf}\Traccar
AlwaysRestart=yes
OutputBaseFilename=traccar-setup
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index d8130c79e..ea0905bf2 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -36,6 +36,12 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
Device device = new Device();
device.setName(uniqueId);
device.setUniqueId(uniqueId);
+ device.setCategory(Context.getConfig().getString("database.registerUnknown.defaultCategory"));
+
+ long defaultGroupId = Context.getConfig().getLong("database.registerUnknown.defaultGroupId");
+ if (defaultGroupId != 0) {
+ device.setGroupId(defaultGroupId);
+ }
try {
Context.getDeviceManager().addDevice(device);
diff --git a/src/org/traccar/api/resource/EventResource.java b/src/org/traccar/api/resource/EventResource.java
index c0a8f968d..0ef5456af 100644
--- a/src/org/traccar/api/resource/EventResource.java
+++ b/src/org/traccar/api/resource/EventResource.java
@@ -29,4 +29,5 @@ public class EventResource extends BaseResource {
}
return event;
}
+
}
diff --git a/src/org/traccar/api/resource/PositionResource.java b/src/org/traccar/api/resource/PositionResource.java
index 84f406bee..9d3cd9ae6 100644
--- a/src/org/traccar/api/resource/PositionResource.java
+++ b/src/org/traccar/api/resource/PositionResource.java
@@ -37,6 +37,7 @@ import java.util.Collection;
import java.util.List;
@Path("positions")
+@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class PositionResource extends BaseResource {
@@ -46,7 +47,6 @@ public class PositionResource extends BaseResource {
public static final String CONTENT_DISPOSITION_VALUE_GPX = "attachment; filename=positions.gpx";
@GET
- @Produces(MediaType.APPLICATION_JSON)
public Collection<Position> getJson(
@QueryParam("deviceId") long deviceId, @QueryParam("id") List<Long> positionIds,
@QueryParam("from") String from, @QueryParam("to") String to)
@@ -92,4 +92,5 @@ public class PositionResource extends BaseResource {
deviceId, DateUtil.parseDate(from), DateUtil.parseDate(to)));
return Response.ok(gpx.build()).header(HttpHeaders.CONTENT_DISPOSITION, CONTENT_DISPOSITION_VALUE_GPX).build();
}
+
}
diff --git a/src/org/traccar/api/resource/ReportResource.java b/src/org/traccar/api/resource/ReportResource.java
index e37d6f01d..a1b35d64e 100644
--- a/src/org/traccar/api/resource/ReportResource.java
+++ b/src/org/traccar/api/resource/ReportResource.java
@@ -27,6 +27,7 @@ import org.traccar.reports.model.TripReport;
import org.traccar.reports.Route;
@Path("reports")
+@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class ReportResource extends BaseResource {
@@ -35,7 +36,6 @@ public class ReportResource extends BaseResource {
@Path("route")
@GET
- @Produces(MediaType.APPLICATION_JSON)
public Collection<Position> getRoute(
@QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
@QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
@@ -59,7 +59,6 @@ public class ReportResource extends BaseResource {
@Path("events")
@GET
- @Produces(MediaType.APPLICATION_JSON)
public Collection<Event> getEvents(
@QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
@QueryParam("type") final List<String> types,
@@ -85,7 +84,6 @@ public class ReportResource extends BaseResource {
@Path("summary")
@GET
- @Produces(MediaType.APPLICATION_JSON)
public Collection<SummaryReport> getSummary(
@QueryParam("deviceId") final List<Long> deviceIds, @QueryParam("groupId") final List<Long> groupIds,
@QueryParam("from") String from, @QueryParam("to") String to) throws SQLException {
diff --git a/src/org/traccar/protocol/At2000Protocol.java b/src/org/traccar/protocol/At2000Protocol.java
index 418619cb4..35aa0b469 100644
--- a/src/org/traccar/protocol/At2000Protocol.java
+++ b/src/org/traccar/protocol/At2000Protocol.java
@@ -20,6 +20,7 @@ import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
import org.traccar.TrackerServer;
+import java.nio.ByteOrder;
import java.util.List;
public class At2000Protocol extends BaseProtocol {
@@ -30,13 +31,15 @@ public class At2000Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new At2000FrameDecoder());
pipeline.addLast("objectDecoder", new At2000ProtocolDecoder(At2000Protocol.this));
}
- });
+ };
+ server.setEndianness(ByteOrder.LITTLE_ENDIAN);
+ serverList.add(server);
}
}
diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java
index 17da0eef7..e9c26d406 100644
--- a/src/org/traccar/protocol/At2000ProtocolDecoder.java
+++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java
@@ -50,11 +50,11 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(BLOCK_LENGTH);
+ ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 2 * BLOCK_LENGTH);
response.writeByte(MSG_ACKNOWLEDGEMENT);
- response.writeMedium(1);
+ response.writeMedium(ChannelBuffers.swapMedium(1));
response.writeByte(0x00); // success
- response.writerIndex(BLOCK_LENGTH);
+ response.writerIndex(2 * BLOCK_LENGTH);
channel.write(response);
}
}
diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java
index 5fa786e4d..6e8bc24bf 100644
--- a/src/org/traccar/protocol/GranitProtocolDecoder.java
+++ b/src/org/traccar/protocol/GranitProtocolDecoder.java
@@ -61,7 +61,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponseCurrent(Channel channel, int deviceId, long time) {
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
response.writeBytes("BB+UGRC~".getBytes(StandardCharsets.US_ASCII));
- response.writeShort(6); //binary length
+ response.writeShort(6); // length
response.writeInt((int) time);
response.writeShort(deviceId);
appendChecksum(response, 16);
@@ -71,7 +71,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponseArchive(Channel channel, int deviceId, int packNum) {
ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
response.writeBytes("BB+ARCF~".getBytes(StandardCharsets.US_ASCII));
- response.writeShort(4); //binary length
+ response.writeShort(4); // length
response.writeShort(packNum);
response.writeShort(deviceId);
appendChecksum(response, 14);
@@ -95,14 +95,19 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
int latDegrees = buf.readUnsignedByte();
int lonMinutes = buf.readUnsignedShort();
int latMinutes = buf.readUnsignedShort();
+
double latitude = latDegrees + latMinutes / 60000.0;
double longitude = lonDegrees + lonMinutes / 60000.0;
- if (!BitUtil.check(flags, 4)) {
- latitude = -latitude;
- }
- if (!BitUtil.check(flags, 5)) {
- longitude = -longitude;
+
+ if (position.getValid()) {
+ if (!BitUtil.check(flags, 4)) {
+ latitude = -latitude;
+ }
+ if (!BitUtil.check(flags, 5)) {
+ longitude = -longitude;
+ }
}
+
position.setLongitude(longitude);
position.setLatitude(latitude);
@@ -135,11 +140,11 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
position.setAltitude(buf.readUnsignedByte() * 10);
- short diOut = buf.readUnsignedByte();
+ int output = buf.readUnsignedByte();
for (int i = 0; i < 8; i++) {
- position.set(Position.PREFIX_IO + (i + 1), BitUtil.check(diOut, i));
+ position.set(Position.PREFIX_IO + (i + 1), BitUtil.check(output, i));
}
- buf.skipBytes(1); //StatMess
+ buf.readUnsignedByte(); // status message buffer
}
@Override
diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java
index 90588a628..9e6a9a82e 100644
--- a/src/org/traccar/protocol/OigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/OigoProtocolDecoder.java
@@ -155,7 +155,8 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
boolean negative = value < 0;
value = Math.abs(value);
double minutes = (value % 100000) * 0.001;
- double degrees = value / 100000 + minutes / 60;
+ value /= 100000;
+ double degrees = value + minutes / 60;
return negative ? -degrees : degrees;
}
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index 756393288..93f3150c7 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -135,7 +135,9 @@ public class ProtocolTest extends BaseTest {
if (expected != null) {
if (expected.getFixTime() != null) {
- Assert.assertEquals("time", expected.getFixTime(), position.getFixTime());
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Assert.assertEquals("time", dateFormat.format(expected.getFixTime()), dateFormat.format(position.getFixTime()));
}
Assert.assertEquals("valid", expected.getValid(), position.getValid());
Assert.assertEquals("latitude", expected.getLatitude(), position.getLatitude(), 0.00001);
diff --git a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
index e2b848b45..837d4c3b6 100644
--- a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
@@ -3,6 +3,8 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
+import java.nio.ByteOrder;
+
import static org.junit.Assume.assumeTrue;
public class At2000ProtocolDecoderTest extends ProtocolTest {
@@ -14,13 +16,16 @@ public class At2000ProtocolDecoderTest extends ProtocolTest {
At2000ProtocolDecoder decoder = new At2000ProtocolDecoder(new At2000Protocol());
- verifyNothing(decoder, binary(
+ verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "01012f0000000000000000000000000000333537343534303731363237353938d74dcd195c521a246fb00f16346c7f001919957babc40f84152b60ddeb7ab47a"));
+
+ verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"));
- verifyPosition(decoder, binary(
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e"));
- verifyNothing(decoder, binary(
+ verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"01012f00000000000000000000000000003335373435343037313632363831345612da3748bede02ea4faf04ac02f420c0ff37719eccf2864fa2b8191abf8242"));
}
diff --git a/test/org/traccar/protocol/GranitProtocolDecoderTest.java b/test/org/traccar/protocol/GranitProtocolDecoderTest.java
index 1fea1d98c..6e85b5cfc 100644
--- a/test/org/traccar/protocol/GranitProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GranitProtocolDecoderTest.java
@@ -13,6 +13,20 @@ public class GranitProtocolDecoderTest extends ProtocolTest {
GranitProtocolDecoder decoder = new GranitProtocolDecoder(new GranitProtocol());
verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "2b444441547e8400c500040130050c43495808002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000014002a37420d0a"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "2b525243427e1a00c5008443495808002839aee315020000000064000000000000002a37410d0a"),
+ position("2016-12-08 11:27:00.000", false, 57.00888, 40.97143));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "2b525243427e1a00c500ec904858b842283997e30002000000005e000000000d00002a32390d0a"),
+ position("2016-12-07 22:45:00.000", true, 57.00853, 40.97105));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "2b525243427e1a00c500009148580800283997e30002000000005f000000000000002a33410d0a"));
+
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"2b444441547e84003b6d0401b10e9217445800b051398f35d34a313b000072000000010b000080b051398f35d34a313b000072000000010b0000f0b051390f33314c303b900371000000010b0000f0b05139cd31e54c2f3cd0016f000000010b0000f0b051396831204d303d950071000000010b0000f0b051397530aa4d323c610171000000010b00000a002a30420d0a"));
verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
@@ -24,11 +38,11 @@ public class GranitProtocolDecoderTest extends ProtocolTest {
verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"2b444441547e84003e290401d41680747c57f8a03c38987f50e6005300006c000000001c0000f8b03c38987f50e6005300006c000000001c0000fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe14002a4346"));
- //+IDNT: Navigator.04x Firmware version 0712GLN *21
+ // +IDNT: Navigator.04x Firmware version 0712GLN *21
verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"2b49444e543a204e6176696761746f722e30347820204669726d776172652076657273696f6e202030373132474c4e202a3231"));
- //ERROR WRONG CHECKSUM_1
+ // ERROR WRONG CHECKSUM_1
verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"4552524f522057524f4e4720434845434b53554d5f31"));
diff --git a/tools/test-integration.py b/tools/test-integration.py
index 4b1bca0cc..c3885095f 100755
--- a/tools/test-integration.py
+++ b/tools/test-integration.py
@@ -89,20 +89,20 @@ def login():
def remove_devices(cookie):
request = urllib2.Request(baseUrl + '/api/devices')
- request.add_header('cookie', cookie)
+ request.add_header('Cookie', cookie)
response = urllib2.urlopen(request)
data = json.load(response)
if debug:
print '\ndevices: %s\n' % repr(data)
for device in data:
request = urllib2.Request(baseUrl + '/api/devices/' + str(device['id']))
- request.add_header('cookie', cookie)
+ request.add_header('Cookie', cookie)
request.get_method = lambda: 'DELETE'
response = urllib2.urlopen(request)
def add_device(cookie, unique_id):
request = urllib2.Request(baseUrl + '/api/devices')
- request.add_header('cookie', cookie)
+ request.add_header('Cookie', cookie)
request.add_header('Content-Type', 'application/json')
device = { 'name' : unique_id, 'uniqueId' : unique_id }
response = urllib2.urlopen(request, json.dumps(device))
@@ -118,8 +118,9 @@ def send_message(port, message):
def get_protocols(cookie, device_id):
params = { 'deviceId' : device_id, 'from' : '2000-01-01T00:00:00.000Z', 'to' : '2050-01-01T00:00:00.000Z' }
request = urllib2.Request(baseUrl + '/api/positions?' + urllib.urlencode(params))
- request.add_header('cookie', cookie)
+ request.add_header('Cookie', cookie)
request.add_header('Content-Type', 'application/json')
+ request.add_header('Accept', 'application/json')
response = urllib2.urlopen(request)
protocols = []
for position in json.load(response):
diff --git a/traccar-web b/traccar-web
-Subproject 9dc4e2a38b872f4dd0ba51a821fc2052ab9323f
+Subproject d1fc289c4f57c2f0ea6865c92d6551aa828b2af