diff options
-rw-r--r-- | setup/default.xml | 5 | ||||
-rw-r--r-- | src/org/traccar/Main.java | 2 | ||||
-rw-r--r-- | src/org/traccar/database/DataManager.java | 10 | ||||
-rw-r--r-- | src/org/traccar/protocol/DmtHttpProtocol.java | 45 | ||||
-rw-r--r-- | src/org/traccar/protocol/DmtHttpProtocolDecoder.java | 145 | ||||
-rw-r--r-- | src/org/traccar/protocol/MiniFinderProtocolDecoder.java | 7 | ||||
-rw-r--r-- | src/org/traccar/protocol/Pt502FrameDecoder.java | 28 | ||||
-rw-r--r-- | src/org/traccar/protocol/Pt502ProtocolDecoder.java | 10 | ||||
-rw-r--r-- | src/org/traccar/protocol/XexunProtocolDecoder.java | 13 | ||||
-rw-r--r-- | test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java | 19 | ||||
-rw-r--r-- | test/org/traccar/protocol/H02ProtocolDecoderTest.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java | 3 | ||||
-rw-r--r-- | test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java | 3 | ||||
-rw-r--r-- | test/org/traccar/protocol/Pt502FrameDecoderTest.java | 10 | ||||
-rw-r--r-- | test/org/traccar/protocol/Pt502ProtocolDecoderTest.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/YwtProtocolDecoderTest.java | 3 |
16 files changed, 282 insertions, 33 deletions
diff --git a/setup/default.xml b/setup/default.xml index 0e43b210f..146cba80b 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -290,6 +290,10 @@ DELETE FROM positions WHERE serverTime < :serverTime AND id NOT IN (SELECT positionId FROM devices) </entry> + <entry key='database.deleteEvents'> + DELETE FROM events WHERE serverTime < :serverTime + </entry> + <entry key='database.selectAttributeAliases'> SELECT * FROM attribute_aliases </entry> @@ -565,5 +569,6 @@ <entry key='starlink.port'>5136</entry> <entry key='dmt.port'>5137</entry> <entry key='xt2400.port'>5138</entry> + <entry key='dmthttp.port'>5139</entry> </properties> diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 21625d3c1..1e2db2693 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -44,7 +44,7 @@ public final class Main { @Override public void run() { try { - Context.getDataManager().clearPositionsHistory(); + Context.getDataManager().clearHistory(); } catch (SQLException error) { Log.warning(error); } diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index acbaac17b..840a8931c 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -312,11 +312,15 @@ public class DataManager { .executeQuery(Position.class); } - public void clearPositionsHistory() throws SQLException { - long historyDays = config.getInteger("database.positionsHistoryDays"); + public void clearHistory() throws SQLException { + long historyDays = config.getInteger("database.historyDays"); if (historyDays != 0) { + Date timeLimit = new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000); QueryBuilder.create(dataSource, getQuery("database.deletePositions")) - .setDate("serverTime", new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000)) + .setDate("serverTime", timeLimit) + .executeUpdate(); + QueryBuilder.create(dataSource, getQuery("database.deleteEvents")) + .setDate("serverTime", timeLimit) .executeUpdate(); } } diff --git a/src/org/traccar/protocol/DmtHttpProtocol.java b/src/org/traccar/protocol/DmtHttpProtocol.java new file mode 100644 index 000000000..da8f43bbd --- /dev/null +++ b/src/org/traccar/protocol/DmtHttpProtocol.java @@ -0,0 +1,45 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * + * 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.http.HttpRequestDecoder; +import org.jboss.netty.handler.codec.http.HttpResponseEncoder; +import org.traccar.BaseProtocol; +import org.traccar.TrackerServer; + +import java.util.List; + +public class DmtHttpProtocol extends BaseProtocol { + + public DmtHttpProtocol() { + super("dmthttp"); + } + + @Override + public void initTrackerServers(List<TrackerServer> serverList) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("httpEncoder", new HttpResponseEncoder()); + pipeline.addLast("httpDecoder", new HttpRequestDecoder()); + pipeline.addLast("objectDecoder", new DmtHttpProtocolDecoder(DmtHttpProtocol.this)); + } + }); + } + +} diff --git a/src/org/traccar/protocol/DmtHttpProtocolDecoder.java b/src/org/traccar/protocol/DmtHttpProtocolDecoder.java new file mode 100644 index 000000000..4592bdd55 --- /dev/null +++ b/src/org/traccar/protocol/DmtHttpProtocolDecoder.java @@ -0,0 +1,145 @@ +/* + * Copyright 2017 Anton Tananaev (anton@traccar.org) + * + * 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.channel.Channel; +import org.jboss.netty.handler.codec.http.DefaultHttpResponse; +import org.jboss.netty.handler.codec.http.HttpHeaders; +import org.jboss.netty.handler.codec.http.HttpRequest; +import org.jboss.netty.handler.codec.http.HttpResponse; +import org.jboss.netty.handler.codec.http.HttpResponseStatus; +import org.jboss.netty.handler.codec.http.HttpVersion; +import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; +import org.traccar.helper.BitUtil; +import org.traccar.helper.UnitsConverter; +import org.traccar.model.Position; + +import javax.json.Json; +import javax.json.JsonArray; +import javax.json.JsonObject; +import java.io.StringReader; +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.LinkedList; +import java.util.List; +import java.util.TimeZone; + +public class DmtHttpProtocolDecoder extends BaseProtocolDecoder { + + public DmtHttpProtocolDecoder(DmtHttpProtocol protocol) { + super(protocol); + } + + private void sendResponse(Channel channel, HttpResponseStatus status) { + if (channel != null) { + HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status); + response.headers().add(HttpHeaders.Names.CONTENT_LENGTH, 0); + channel.write(response); + } + } + + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + HttpRequest request = (HttpRequest) msg; + JsonObject root = Json.createReader( + new StringReader(request.getContent().toString(StandardCharsets.US_ASCII))).readObject(); + + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, root.getString("IMEI")); + if (deviceSession == null) { + sendResponse(channel, HttpResponseStatus.BAD_REQUEST); + return null; + } + + List<Position> positions = new LinkedList<>(); + + JsonArray records = root.getJsonArray("Records"); + + for (int i = 0; i < records.size(); i++) { + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + JsonObject record = records.getJsonObject(i); + + position.set(Position.KEY_INDEX, record.getInt("SeqNo")); + position.set(Position.KEY_EVENT, record.getInt("Reason")); + + position.setDeviceTime(dateFormat.parse(record.getString("DateUTC"))); + + JsonArray fields = record.getJsonArray("Fields"); + + for (int j = 0; j < fields.size(); j++) { + JsonObject field = fields.getJsonObject(j); + switch (field.getInt("FType")) { + case 0: + position.setFixTime(dateFormat.parse(field.getString("GpsUTC"))); + position.setLatitude(field.getJsonNumber("Lat").doubleValue()); + position.setLatitude(field.getJsonNumber("Long").doubleValue()); + position.setAltitude(field.getInt("Alt")); + position.setSpeed(UnitsConverter.knotsFromCps(field.getInt("Spd"))); + position.setCourse(field.getInt("Head")); + position.setAccuracy(field.getInt("PosAcc")); + position.setValid(field.getInt("GpsStat") > 0); + break; + case 2: + int input = field.getInt("DIn"); + int output = field.getInt("DOut"); + + position.set(Position.KEY_IGNITION, BitUtil.check(input, 0)); + + position.set(Position.KEY_INPUT, input); + position.set(Position.KEY_OUTPUT, output); + position.set(Position.KEY_STATUS, field.getInt("DevStat")); + break; + case 6: + JsonObject adc = field.getJsonObject("AnalogueData"); + if (adc.containsKey("1")) { + position.set(Position.KEY_BATTERY, adc.getInt("1") * 0.001); + } + if (adc.containsKey("2")) { + position.set(Position.KEY_POWER, adc.getInt("2") * 0.01); + } + if (adc.containsKey("3")) { + position.set(Position.KEY_DEVICE_TEMP, adc.getInt("3") * 0.01); + } + if (adc.containsKey("4")) { + position.set(Position.KEY_RSSI, adc.getInt("4")); + } + if (adc.containsKey("5")) { + position.set("solarPower", adc.getInt("5") * 0.001); + } + break; + default: + break; + } + } + + positions.add(position); + } + + sendResponse(channel, HttpResponseStatus.OK); + return positions; + } + +} diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java index 9b4372c5b..8bfb4fb36 100644 --- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java +++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java @@ -79,7 +79,10 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { private void decodeFlags(Position position, int flags) { - position.setValid(BitUtil.check(flags, 0)); + position.setValid(BitUtil.to(flags, 2) > 0); + if (BitUtil.check(flags, 1)) { + position.set(Position.KEY_APPROXIMATE, true); + } if (BitUtil.check(flags, 2)) { position.set(Position.KEY_ALARM, Position.ALARM_FAULT); @@ -103,7 +106,7 @@ public class MiniFinderProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ALARM, Position.ALARM_MOVEMENT); } - position.set(Position.KEY_RSSI, BitUtil.between(flags, 16, 20)); + position.set(Position.KEY_RSSI, BitUtil.between(flags, 16, 21)); position.set(Position.KEY_CHARGE, BitUtil.check(flags, 22)); } diff --git a/src/org/traccar/protocol/Pt502FrameDecoder.java b/src/org/traccar/protocol/Pt502FrameDecoder.java index 200012965..ce20dff1f 100644 --- a/src/org/traccar/protocol/Pt502FrameDecoder.java +++ b/src/org/traccar/protocol/Pt502FrameDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 Anton Tananaev (anton@traccar.org) + * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,25 +32,15 @@ public class Pt502FrameDecoder extends FrameDecoder { return null; } - if (buf.getUnsignedByte(buf.readerIndex()) == 0xbf && buf.getUnsignedByte(buf.readerIndex() + 1) == 0xfb) { - - int length = buf.getShort(buf.readerIndex() + 3); - if (buf.readableBytes() >= length) { - buf.skipBytes(BINARY_HEADER); - ChannelBuffer result = buf.readBytes(length - BINARY_HEADER - 2); - buf.skipBytes(2); - return result; - } - - } else { - - int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '\n'); - if (index != -1) { - ChannelBuffer result = buf.readBytes(index - 1); - buf.skipBytes(2); - return result; - } + if (buf.getUnsignedByte(buf.readerIndex()) == 0xbf) { + buf.skipBytes(BINARY_HEADER); + } + int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '\r'); + if (index != -1 && index + 1 < buf.writerIndex()) { + ChannelBuffer result = buf.readBytes(index - buf.readerIndex()); + buf.skipBytes(2); + return result; } return null; diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index eb86f01ff..b1851f8ca 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -1,5 +1,5 @@ /*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
* Copyright 2012 Luis Parada (luis.parada@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,9 +43,9 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // id
.number("(dd)(dd)(dd).(ddd),") // time (hhmmss.sss)
.expression("([AV]),") // validity
- .number("(dd)(dd.dddd),") // latitude
+ .number("(d+)(dd.dddd),") // latitude
.expression("([NS]),")
- .number("(ddd)(dd.dddd),") // longitude
+ .number("(d+)(dd.dddd),") // longitude
.expression("([EW]),")
.number("(d+.d+)?,") // speed
.number("(d+.d+)?,") // course
@@ -83,9 +83,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- String sentence = (String) msg;
-
- Parser parser = new Parser(PATTERN, sentence);
+ Parser parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
return null;
}
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 4d44c2326..2b31f414e 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -17,11 +17,13 @@ package org.traccar.protocol; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; +import org.traccar.Context; import org.traccar.DeviceSession; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; import org.traccar.model.Position; +import org.traccar.helper.UnitsConverter; import java.net.SocketAddress; import java.util.regex.Pattern; @@ -109,7 +111,16 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); - position.setSpeed(parser.nextDouble(0)); + + switch (Context.getConfig().getString(getProtocolName() + ".speed", "kn")) { + case "kmh": + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble(0))); + break; + default: + position.setSpeed(parser.nextDouble(0)); + break; + } + position.setCourse(parser.nextDouble(0)); dateBuilder.setDateReverse(parser.nextInt(0), parser.nextInt(0), parser.nextInt(0)); diff --git a/test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java b/test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java new file mode 100644 index 000000000..e7fd086a7 --- /dev/null +++ b/test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java @@ -0,0 +1,19 @@ +package org.traccar.protocol; + +import org.jboss.netty.handler.codec.http.HttpMethod; +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class DmtHttpProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + DmtHttpProtocolDecoder decoder = new DmtHttpProtocolDecoder(new DmtHttpProtocol()); + + verifyPositions(decoder, request(HttpMethod.POST, "/", + buffer("{\"SerNo\":131693,\"IMEI\":\"356692063643328\",\"ICCID\":\"8944538523010771676\",\"ProdId\":33,\"FW\":\"33.4.1.27\",\"Records\":[{\"SeqNo\":125,\"Reason\":11,\"DateUTC\":\"2017-05-11 05:58:44\",\"Fields\":[{\"GpsUTC\":\"2017-05-08 18:04:57\",\"Lat\":43.7370138,\"Long\":-79.3462607,\"Alt\":197,\"Spd\":0,\"SpdAcc\":13,\"Head\":66,\"PDOP\":18,\"PosAcc\":37,\"GpsStat\":7,\"FType\":0},{\"DIn\":2,\"DOut\":0,\"DevStat\":2,\"FType\":2},{\"AnalogueData\":{\"1\":14641,\"3\":2484,\"4\":26,\"5\":10868},\"FType\":6},{\"AnalogueData\":{\"11\":34,\"12\":0,\"13\":309,\"14\":9921,\"15\":3},\"FType\":7}]},{\"SeqNo\":128,\"Reason\":11,\"DateUTC\":\"2017-05-11 17:59:45\",\"Fields\":[{\"GpsUTC\":\"2017-05-08 18:04:57\",\"Lat\":43.7370138,\"Long\":-79.3462607,\"Alt\":197,\"Spd\":0,\"SpdAcc\":13,\"Head\":66,\"PDOP\":18,\"PosAcc\":37,\"GpsStat\":7,\"FType\":0},{\"DIn\":2,\"DOut\":0,\"DevStat\":2,\"FType\":2},{\"AnalogueData\":{\"1\":14607,\"3\":2752,\"4\":26,\"5\":11062},\"FType\":6},{\"AnalogueData\":{\"11\":34,\"12\":1,\"13\":325,\"14\":10881,\"15\":3},\"FType\":7}]},{\"SeqNo\":130,\"Reason\":9,\"DateUTC\":\"2017-05-11 19:30:03\",\"Fields\":[{\"GpsUTC\":\"2017-05-08 18:04:57\",\"Lat\":43.7370138,\"Long\":-79.3462607,\"Alt\":197,\"Spd\":0,\"SpdAcc\":13,\"Head\":66,\"PDOP\":18,\"PosAcc\":37,\"GpsStat\":3,\"FType\":0},{\"DIn\":6,\"DOut\":0,\"DevStat\":2,\"FType\":2},{\"AnalogueData\":{\"1\":14599,\"3\":2731,\"4\":27,\"5\":10965},\"FType\":6},{\"AnalogueData\":{\"11\":34,\"12\":2,\"13\":329,\"14\":11121,\"15\":3},\"FType\":7}]},{\"SeqNo\":131,\"Reason\":11,\"DateUTC\":\"2017-05-11 19:32:03\",\"Fields\":[{\"GpsUTC\":\"2017-05-08 18:04:57\",\"Lat\":43.7370138,\"Long\":-79.3462607,\"Alt\":197,\"Spd\":0,\"SpdAcc\":13,\"Head\":66,\"PDOP\":18,\"PosAcc\":37,\"GpsStat\":7,\"FType\":0},{\"DIn\":6,\"DOut\":0,\"DevStat\":2,\"FType\":2},{\"AnalogueData\":{\"1\":14403,\"3\":2783,\"4\":27,\"5\":10965},\"FType\":6},{\"AnalogueData\":{\"11\":34,\"12\":2,\"13\":330,\"14\":11181,\"15\":3},\"FType\":7}]},{\"SeqNo\":133,\"Reason\":11,\"DateUTC\":\"2017-05-11 19:36:15\",\"Fields\":[{\"GpsUTC\":\"2017-05-08 18:04:57\",\"Lat\":43.7370138,\"Long\":-79.3462607,\"Alt\":197,\"Spd\":0,\"SpdAcc\":13,\"Head\":66,\"PDOP\":18,\"PosAcc\":37,\"GpsStat\":7,\"FType\":0},{\"DIn\":6,\"DOut\":0,\"DevStat\":2,\"FType\":2},{\"AnalogueData\":{\"1\":14319,\"3\":2898,\"4\":23,\"5\":10965},\"FType\":6},{\"AnalogueData\":{\"11\":34,\"12\":3,\"13\":331,\"14\":11241,\"15\":3},\"FType\":7}]}]}"))); + + } + +} diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java index 6e6b37b83..5779853d8 100644 --- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class H02ProtocolDecoderTest extends ProtocolTest { H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol()); + verifyNull(decoder, buffer( + "*HQ,355488020882405,V3,095426,74001,01,010278,045142,128,-92,02DE,0,X,090517,FFFFFBFF#")); + + verifyNull(decoder, buffer( + "*HQ,355488020882405,V3,095426,74001,04,010278,045142,128,-92,010278,026311,125,,010278,026582,125,,010278,028322,119,,02DD,0,X,090517,FFFFFBFF#")); + verifyPosition(decoder, buffer( "*HQ,4109179024,V19,181519,V,3853.2587,S,06205.9175,W,000.00,000,090217,,5492932630888,8954315265044716555?,FFFFFBFF#")); diff --git a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java index 124dcd852..e5bd127ac 100644 --- a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class MeiligaoProtocolDecoderTest extends ProtocolTest { MeiligaoProtocolDecoder decoder = new MeiligaoProtocolDecoder(new MeiligaoProtocol()); + verifyAttributes(decoder, binary( + "242400561001ffffffffff99553030303030302e3030302c562c303030302e303030302c532c30303030302e303030302c572c302e30302c302e30302c3232303839392c2c2c412a37457c7c307c3030303059ae0d0a0000")); + verifyPosition(decoder, binary( "242400706573402852404799553130313932372e3030302c412c313732362e38323739332c4e2c30373832382e31393637312c452c312e382c362e342c3137313131362c2c2a32427c312e36387c3534342e327c313030307c303030302c303030307c3030303032383638373a1a0d0a")); diff --git a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java index c3b5dd674..fd16df779 100644 --- a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java @@ -20,6 +20,9 @@ public class MiniFinderProtocolDecoderTest extends ProtocolTest { "!1,860719027585011")); verifyPosition(decoder, text( + "!D,02/05/17,19:56:17,47.083542,15.482373,0,0,100001,479.3,100,4,9,0")); + + verifyPosition(decoder, text( "!D,15/04/17,13:58:53,51.483067,-0.452548,60,180,140001,28.7,47,4,13,0")); verifyPosition(decoder, text( diff --git a/test/org/traccar/protocol/Pt502FrameDecoderTest.java b/test/org/traccar/protocol/Pt502FrameDecoderTest.java index 34fdf9bb9..44de2459d 100644 --- a/test/org/traccar/protocol/Pt502FrameDecoderTest.java +++ b/test/org/traccar/protocol/Pt502FrameDecoderTest.java @@ -14,8 +14,16 @@ public class Pt502FrameDecoderTest extends ProtocolTest { Pt502FrameDecoder decoder = new Pt502FrameDecoder(); Assert.assertEquals( + binary("244655533836353332383032363234333836342c3531302d56312e31322c4131312d56332e30"), + decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "bffb192d00244655533836353332383032363234333836342c3531302d56312e31322c4131312d56332e300d0d"))); + + Assert.assertEquals( + binary("24504f532c3836353332383032363234333836342c3134343733352e3030302c412c313333322e373038332c4e2c3230342e363833312c452c302e302c3233302e30302c3032303531372c2c2c412f30303030302c31302f312c302f3233342f2f4646392f"), + decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "24504f532c3836353332383032363234333836342c3134343733352e3030302c412c313333322e373038332c4e2c3230342e363833312c452c302e302c3233302e30302c3032303531372c2c2c412f30303030302c31302f312c302f3233342f2f4646392f0d0a"))); + + Assert.assertEquals( binary("24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f"), - decoder.decode(null, null, binary("24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f0d0a"))); + decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f0d0a"))); Assert.assertEquals( binary("24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f"), diff --git a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java index 8b1dd5ad6..62b3bbdaa 100644 --- a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java @@ -11,6 +11,12 @@ public class Pt502ProtocolDecoderTest extends ProtocolTest { Pt502ProtocolDecoder decoder = new Pt502ProtocolDecoder(new Pt502Protocol()); verifyPosition(decoder, text( + "$POS,865328026243864,151105.000,A,1332.7096,N,204.6787,E,0.0,10.00,050517,,,A/00000,10/1,0/234//FD9/")); + + verifyNull(decoder, text( + "$FUS865328026243864,510-V1.12,A11-V3.0")); + + verifyPosition(decoder, text( "$HDA,20007,134657.000,A,0626.1607,N,00330.2245,E,33.38,81.79,041016,,,A/00010,00000/270,0,0,0/19948900//fa4//")); verifyPosition(decoder, text( diff --git a/test/org/traccar/protocol/YwtProtocolDecoderTest.java b/test/org/traccar/protocol/YwtProtocolDecoderTest.java index 96031d510..bc91efa16 100644 --- a/test/org/traccar/protocol/YwtProtocolDecoderTest.java +++ b/test/org/traccar/protocol/YwtProtocolDecoderTest.java @@ -9,6 +9,9 @@ public class YwtProtocolDecoderTest extends ProtocolTest { public void testDecode() throws Exception { YwtProtocolDecoder decoder = new YwtProtocolDecoder(new YwtProtocol()); + + verifyPosition(decoder, text( + "%RP,1222102985:1,170509033842,E102.146563,N14.582175,,0,320,10,0,00-00-00-00-00-00-00-00-00-00-00-00,,1db2-02b3-52004,3>941.523-32,7>1,19>-16,20>30.9V")); verifyNull(decoder, text( "%SN,0417061042:0,0,140117041203,404")); |