From abe051d297b445f8fb76d4069918b79e9e74d0c9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 7 Sep 2016 20:09:30 +1200 Subject: Implement OBD support for Meiligao --- .../traccar/protocol/MeiligaoProtocolDecoder.java | 241 ++++++++++++--------- 1 file changed, 136 insertions(+), 105 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 41e248791..8b559beec 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -80,6 +80,24 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { .expression("([EW])") .compile(); + private static final Pattern PATTERN_OBD = new PatternBuilder() + .number("(d+.d+),") // battery + .number("(d+),") // rpm + .number("(d+),") // speed + .number("(d+.d+),") // throttle + .number("d+.d+,") // engine load + .number("(-?d+),") // coolant temp + .number("d+.d+,") // instantaneous fuel + .number("(d+.d+),") // average fuel + .number("d+.d+,") // driving range + .number("(d+.?d*),") // odometer + .number("d+.d+,") + .number("d+.d+,") + .number("(d+),") // error code count + .number("d+,") // harsh acceleration count + .number("d+") // harsh break count + .compile(); + public static final int MSG_HEARTBEAT = 0x0001; public static final int MSG_SERVER = 0x0002; public static final int MSG_LOGIN = 0x5000; @@ -91,6 +109,8 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { public static final int MSG_RFID = 0x9966; + public static final int MSG_OBD_RT = 0x9901; + private DeviceSession identify(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { StringBuilder builder = new StringBuilder(); @@ -142,7 +162,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } } - private String getMeiligaoServer(Channel channel) { + private String getServer(Channel channel) { String server = Context.getConfig().getString(getProtocolName() + ".server"); if (server == null) { InetSocketAddress address = (InetSocketAddress) channel.getLocalAddress(); @@ -172,6 +192,102 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } } + private Position decodeRegular(Position position, String sentence) { + Parser parser = new Parser(PATTERN, sentence); + if (!parser.matches()) { + return null; + } + + DateBuilder dateBuilder = new DateBuilder() + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + if (parser.hasNext()) { + dateBuilder.setMillis(parser.nextInt()); + } + + position.setValid(parser.next().equals("A")); + position.setLatitude(parser.nextCoordinate()); + position.setLongitude(parser.nextCoordinate()); + + if (parser.hasNext()) { + position.setSpeed(parser.nextDouble()); + } + + if (parser.hasNext()) { + position.setCourse(parser.nextDouble()); + } + + dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + position.set(Position.KEY_HDOP, parser.next()); + + if (parser.hasNext()) { + position.setAltitude(parser.nextDouble()); + } + + position.set(Position.KEY_STATUS, parser.next()); + + for (int i = 1; i <= 8; i++) { + if (parser.hasNext()) { + position.set(Position.PREFIX_ADC + i, parser.nextInt(16)); + } + } + + if (parser.hasNext()) { + position.set(Position.KEY_GSM, parser.nextInt(16)); + } + + if (parser.hasNext()) { + position.set(Position.KEY_ODOMETER, parser.nextLong(16)); + } + if (parser.hasNext()) { + position.set(Position.KEY_ODOMETER, parser.nextLong(16)); + } + + if (parser.hasNext()) { + position.set(Position.KEY_RFID, parser.nextInt(16)); + } + + return position; + } + + private Position decodeRfid(Position position, String sentence) { + Parser parser = new Parser(PATTERN_RFID, sentence); + if (!parser.matches()) { + return null; + } + + DateBuilder dateBuilder = new DateBuilder() + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + position.setValid(true); + position.setLatitude(parser.nextCoordinate()); + position.setLongitude(parser.nextCoordinate()); + + return position; + } + + private Position decodeObd(Position position, String sentence) { + Parser parser = new Parser(PATTERN_OBD, sentence); + if (!parser.matches()) { + return null; + } + + getLastLocation(position, null); + + position.set(Position.KEY_BATTERY, parser.nextDouble()); + position.set(Position.KEY_RPM, parser.nextInt()); + position.set(Position.KEY_OBD_SPEED, parser.nextInt()); + position.set(Position.KEY_THROTTLE, parser.nextDouble()); + position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); + position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble()); + position.set(Position.KEY_ODOMETER, parser.nextDouble()); + + return position; + } + @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -183,39 +299,22 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { int command = buf.readUnsignedShort(); ChannelBuffer response; - switch (command) { - case MSG_LOGIN: - if (channel != null) { - response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); - sendResponse(channel, remoteAddress, id, MSG_LOGIN_RESPONSE, response); - } - return null; - case MSG_HEARTBEAT: - if (channel != null) { - response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); - sendResponse(channel, remoteAddress, id, MSG_HEARTBEAT, response); - } - return null; - case MSG_SERVER: - if (channel != null) { - response = ChannelBuffers.copiedBuffer( - getMeiligaoServer(channel), StandardCharsets.US_ASCII); - sendResponse(channel, remoteAddress, id, MSG_SERVER, response); - } - return null; - case MSG_POSITION: - case MSG_POSITION_LOGGED: - case MSG_ALARM: - case MSG_RFID: - break; - default: - return null; + if (channel != null) { + if (command == MSG_LOGIN) { + response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); + sendResponse(channel, remoteAddress, id, MSG_LOGIN_RESPONSE, response); + } else if (command == MSG_HEARTBEAT) { + response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); + sendResponse(channel, remoteAddress, id, MSG_HEARTBEAT, response); + } else if (command == MSG_SERVER) { + response = ChannelBuffers.copiedBuffer(getServer(channel), StandardCharsets.US_ASCII); + sendResponse(channel, remoteAddress, id, MSG_SERVER, response); + } } Position position = new Position(); position.setProtocol(getProtocolName()); - // Custom data if (command == MSG_ALARM) { position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte())); } else if (command == MSG_POSITION_LOGGED) { @@ -239,85 +338,17 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { } } - Pattern pattern; - if (command == MSG_RFID) { - pattern = PATTERN_RFID; - } else { - pattern = PATTERN; - } - - Parser parser = new Parser( - pattern, buf.toString(buf.readerIndex(), buf.readableBytes() - 4, StandardCharsets.US_ASCII)); - if (!parser.matches()) { - return null; - } - - if (command == MSG_RFID) { - - DateBuilder dateBuilder = new DateBuilder() - .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()) - .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); - position.setTime(dateBuilder.getDate()); - - position.setValid(true); - position.setLatitude(parser.nextCoordinate()); - position.setLongitude(parser.nextCoordinate()); - - } else { - - DateBuilder dateBuilder = new DateBuilder() - .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); - if (parser.hasNext()) { - dateBuilder.setMillis(parser.nextInt()); - } - - position.setValid(parser.next().equals("A")); - position.setLatitude(parser.nextCoordinate()); - position.setLongitude(parser.nextCoordinate()); - - if (parser.hasNext()) { - position.setSpeed(parser.nextDouble()); - } - - if (parser.hasNext()) { - position.setCourse(parser.nextDouble()); - } - - dateBuilder.setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); - position.setTime(dateBuilder.getDate()); - - position.set(Position.KEY_HDOP, parser.next()); - - if (parser.hasNext()) { - position.setAltitude(parser.nextDouble()); - } - - position.set(Position.KEY_STATUS, parser.next()); - - for (int i = 1; i <= 8; i++) { - if (parser.hasNext()) { - position.set(Position.PREFIX_ADC + i, parser.nextInt(16)); - } - } - - if (parser.hasNext()) { - position.set(Position.KEY_GSM, parser.nextInt(16)); - } - - if (parser.hasNext()) { - position.set(Position.KEY_ODOMETER, parser.nextLong(16)); - } - if (parser.hasNext()) { - position.set(Position.KEY_ODOMETER, parser.nextLong(16)); - } - - if (parser.hasNext()) { - position.set(Position.KEY_RFID, parser.nextInt(16)); - } + String sentence = buf.toString(buf.readerIndex(), buf.readableBytes() - 4, StandardCharsets.US_ASCII); + if (command == MSG_POSITION || command == MSG_POSITION_LOGGED || command == MSG_ALARM) { + return decodeRegular(position, sentence); + } else if (command == MSG_RFID) { + return decodeRfid(position, sentence); + } else if (command == MSG_OBD_RT) { + return decodeObd(position, sentence); } - return position; + return null; } } -- cgit v1.2.3 From 26760bedcb7c66da2d64d75e88e4030136f3e970 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 7 Sep 2016 22:43:54 +1200 Subject: Fix an issue in Meiligao decoder --- src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 8b559beec..3510b56a3 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -303,12 +303,15 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { if (command == MSG_LOGIN) { response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); sendResponse(channel, remoteAddress, id, MSG_LOGIN_RESPONSE, response); + return null; } else if (command == MSG_HEARTBEAT) { response = ChannelBuffers.wrappedBuffer(new byte[] {0x01}); sendResponse(channel, remoteAddress, id, MSG_HEARTBEAT, response); + return null; } else if (command == MSG_SERVER) { response = ChannelBuffers.copiedBuffer(getServer(channel), StandardCharsets.US_ASCII); sendResponse(channel, remoteAddress, id, MSG_SERVER, response); + return null; } } -- cgit v1.2.3 From 9bbb70a0eb76bd81c494c410772a31f19d6fd584 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 9 Sep 2016 21:50:58 +1200 Subject: Add more Meiligao parameters --- src/org/traccar/protocol/MeiligaoProtocolDecoder.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index 3510b56a3..f1a87f4b7 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -85,14 +85,14 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // rpm .number("(d+),") // speed .number("(d+.d+),") // throttle - .number("d+.d+,") // engine load + .number("(d+.d+),") // engine load .number("(-?d+),") // coolant temp .number("d+.d+,") // instantaneous fuel .number("(d+.d+),") // average fuel - .number("d+.d+,") // driving range + .number("(d+.d+),") // driving range .number("(d+.?d*),") // odometer - .number("d+.d+,") - .number("d+.d+,") + .number("(d+.d+),") + .number("(d+.d+),") .number("(d+),") // error code count .number("d+,") // harsh acceleration count .number("d+") // harsh break count @@ -281,9 +281,13 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_RPM, parser.nextInt()); position.set(Position.KEY_OBD_SPEED, parser.nextInt()); position.set(Position.KEY_THROTTLE, parser.nextDouble()); + position.set("engineLoad", parser.nextDouble()); position.set(Position.PREFIX_TEMP + 1, parser.nextInt()); position.set(Position.KEY_FUEL_CONSUMPTION, parser.nextDouble()); - position.set(Position.KEY_ODOMETER, parser.nextDouble()); + position.set("drivingRange", parser.nextDouble() * 1000); + position.set(Position.KEY_ODOMETER, parser.nextDouble() * 1000); + position.set("singleFuelConsumption", parser.nextDouble()); + position.set("totalFuelConsumption", parser.nextDouble()); return position; } -- cgit v1.2.3 From b4185cbf84bdff2927f7d9a8b0cde9f4ea889353 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 9 Sep 2016 15:32:20 +0500 Subject: Store pulse for watch protocol --- src/org/traccar/protocol/WatchProtocolDecoder.java | 11 +++++++++++ test/org/traccar/protocol/WatchProtocolDecoderTest.java | 3 +++ 2 files changed, 14 insertions(+) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index 326552e7f..488d05a3c 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -25,6 +25,7 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; +import java.util.Date; import java.util.regex.Pattern; public class WatchProtocolDecoder extends BaseProtocolDecoder { @@ -146,6 +147,16 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { sendResponse(channel, manufacturer, id, "TKQ"); + } else if (type.equals("PULSE")) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + getLastLocation(position, new Date()); + position.setValid(false); + position.set("pulse", content.split(",")[1]); + return position; + } return null; diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java index a8f7b12bc..6116c2c2b 100644 --- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java @@ -54,6 +54,9 @@ public class WatchProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "[SG*8800000015*0087*AL,220414,134652,A,22.571707,N,113.8613968,E,0.1,0.0,100,7,60,90,1000,50,0001,4,1,460,0,9360,4082,131,9360,4092,148,9360,4091,143,9360,4153,141")); + verifyAttributes(decoder, text( + "[CS*8800000015*0008*PULSE,72")); + } } -- cgit v1.2.3 From 91cc83f8d09f7ee591c9109e61cee6492226a612 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 9 Sep 2016 16:37:24 +0500 Subject: Also store "result" --- src/org/traccar/protocol/WatchProtocolDecoder.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index 488d05a3c..d74fdbe81 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -154,7 +154,9 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); getLastLocation(position, new Date()); position.setValid(false); - position.set("pulse", content.split(",")[1]); + String pulse = content.substring(1); + position.set("pulse", pulse); + position.set(Position.KEY_RESULT, pulse); return position; } -- cgit v1.2.3 From 1fa0849db4a18ee8a81159e87c6a4e616e9150a8 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 10 Sep 2016 11:32:05 +1200 Subject: Mark Astra messages as valid (fix #2300) --- src/org/traccar/protocol/AstraProtocolDecoder.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java index 1889fd3b9..d89a21082 100644 --- a/src/org/traccar/protocol/AstraProtocolDecoder.java +++ b/src/org/traccar/protocol/AstraProtocolDecoder.java @@ -68,6 +68,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder { buf.readUnsignedByte(); // index + position.setValid(true); position.setLatitude(buf.readInt() * 0.000001); position.setLongitude(buf.readInt() * 0.000001); -- cgit v1.2.3 From 223962059fd71881b3f210391cd4414afc3750e9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 10 Sep 2016 16:55:25 +1200 Subject: Fix Java code analytics issues --- src/org/traccar/database/DataManager.java | 2 +- src/org/traccar/protocol/EelinkProtocolDecoder.java | 4 ++-- src/org/traccar/protocol/Pt502ProtocolDecoder.java | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index 78f1b4109..abc48f063 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -305,7 +305,7 @@ public class DataManager { } public void clearPositionsHistory() throws SQLException { - int historyDays = config.getInteger("database.positionsHistoryDays"); + long historyDays = config.getInteger("database.positionsHistoryDays"); if (historyDays != 0) { QueryBuilder.create(dataSource, getQuery("database.deletePositions")) .setDate("serverTime", new Date(System.currentTimeMillis() - historyDays * 24 * 3600 * 1000)) diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index 24cd6b570..7403fd18a 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -126,7 +126,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { return position; } - private Position decodeNew(DeviceSession deviceSession, ChannelBuffer buf, int type, int index) { + private Position decodeNew(DeviceSession deviceSession, ChannelBuffer buf, int index) { Position position = new Position(); position.setDeviceId(deviceSession.getDeviceId()); @@ -206,7 +206,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { if (type == MSG_GPS || type == MSG_ALARM || type == MSG_STATE || type == MSG_SMS) { return decodeOld(deviceSession, buf, type, index); } else if (type >= MSG_NORMAL && type <= MSG_OBD_CODE) { - return decodeNew(deviceSession, buf, type, index); + return decodeNew(deviceSession, buf, index); } } diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java index 7dc4fbe5e..24dc2094f 100644 --- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java +++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java @@ -91,10 +91,8 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder { String type = parser.next(); - if (type.startsWith("PHO")) { - if (channel != null) { - channel.write("#PHD0," + type.substring(3) + "\r\n"); - } + if (type.startsWith("PHO") && channel != null) { + channel.write("#PHD0," + type.substring(3) + "\r\n"); } position.set(Position.KEY_ALARM, decodeAlarm(type)); -- cgit v1.2.3 From d454901a5ff831eaee30db23df12556b6442693a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 13 Sep 2016 23:11:45 +1200 Subject: Improve H02 decoder text pattern --- src/org/traccar/protocol/H02ProtocolDecoder.java | 3 ++- test/org/traccar/protocol/H02ProtocolDecoderTest.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index fc6c9f17c..a0c646900 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -129,7 +129,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { .text("*") .expression("..,") // manufacturer .number("(d+),") // imei - .number("Vd,") // version? + .expression("[^,]+,") .any() .number("(?:(dd)(dd)(dd))?,") // time .expression("([AV])?,") // validity @@ -148,6 +148,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { .number("(d+.?d*),") // speed .number("(d+.?d*)?,") // course .number("(?:(dd)(dd)(dd))?,") // date (ddmmyy) + .any() .number("(x{8})") // status .any() .compile(); diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java index d147cdec2..e4db2f56f 100644 --- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class H02ProtocolDecoderTest extends ProtocolTest { H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol()); + verifyPosition(decoder, buffer( + "*HQ,4209917484,V19,093043,V,5052.9749,N,00426.4322,E,000.00,000,130916,,0032475874141,8944538530000543700F,FFFFFBFF#")); + verifyPosition(decoder, buffer( "*HQ,353505220873067,V1,,V,4605.75732,N,01430.73863,E,0.00,0,,FFFFFFEF,125,194, 64,d3#")); -- cgit v1.2.3 From 0aeeac33163640bbbe23560cbd108ddf290ac873 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 13 Sep 2016 23:17:23 +1200 Subject: Message length parameter for H02 frame decoder --- src/org/traccar/protocol/H02FrameDecoder.java | 19 ++++++++----------- src/org/traccar/protocol/H02Protocol.java | 6 ++++-- test/org/traccar/protocol/H02FrameDecoderTest.java | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java index 79e33c0ca..572ac979e 100644 --- a/src/org/traccar/protocol/H02FrameDecoder.java +++ b/src/org/traccar/protocol/H02FrameDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2013 - 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. @@ -22,7 +22,11 @@ import org.jboss.netty.handler.codec.frame.FrameDecoder; public class H02FrameDecoder extends FrameDecoder { - private static final int MESSAGE_LENGTH = 32; + private int messageLength; + + public H02FrameDecoder(int messageLength) { + this.messageLength = messageLength; + } @Override protected Object decode( @@ -30,13 +34,6 @@ public class H02FrameDecoder extends FrameDecoder { char marker = (char) buf.getByte(buf.readerIndex()); - while (marker != '*' && marker != '$' && buf.readableBytes() > 0) { - buf.skipBytes(1); - if (buf.readableBytes() > 0) { - marker = (char) buf.getByte(buf.readerIndex()); - } - } - if (marker == '*') { // Return text message @@ -45,10 +42,10 @@ public class H02FrameDecoder extends FrameDecoder { return buf.readBytes(index + 1 - buf.readerIndex()); } - } else if (marker == '$' && buf.readableBytes() >= MESSAGE_LENGTH) { + } else if (marker == '$' && buf.readableBytes() >= messageLength) { // Return binary message - return buf.readBytes(MESSAGE_LENGTH); + return buf.readBytes(messageLength); } diff --git a/src/org/traccar/protocol/H02Protocol.java b/src/org/traccar/protocol/H02Protocol.java index 72b4f903d..cdc2d11bb 100644 --- a/src/org/traccar/protocol/H02Protocol.java +++ b/src/org/traccar/protocol/H02Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 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. @@ -19,6 +19,7 @@ import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; +import org.traccar.Context; import org.traccar.TrackerServer; import org.traccar.model.Command; @@ -42,7 +43,8 @@ public class H02Protocol extends BaseProtocol { serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { - pipeline.addLast("frameDecoder", new H02FrameDecoder()); + int messageLength = Context.getConfig().getInteger(getName() + ".messageLength", 32); + pipeline.addLast("frameDecoder", new H02FrameDecoder(messageLength)); pipeline.addLast("stringEncoder", new StringEncoder()); pipeline.addLast("objectEncoder", new H02ProtocolEncoder()); pipeline.addLast("objectDecoder", new H02ProtocolDecoder(H02Protocol.this)); diff --git a/test/org/traccar/protocol/H02FrameDecoderTest.java b/test/org/traccar/protocol/H02FrameDecoderTest.java index e8b045048..a8417341a 100644 --- a/test/org/traccar/protocol/H02FrameDecoderTest.java +++ b/test/org/traccar/protocol/H02FrameDecoderTest.java @@ -9,7 +9,7 @@ public class H02FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - H02FrameDecoder decoder = new H02FrameDecoder(); + H02FrameDecoder decoder = new H02FrameDecoder(32); Assert.assertEquals( binary("2a48512c3335333538383036303031353536382c56312c3139333530352c412c3830392e303031302c532c333435342e383939372c572c302e30302c302e30302c3239313031332c65666666666266662c3030303264342c3030303030622c3030353338352c3030353261612c323523"), -- cgit v1.2.3 From 497627bc9fc7ab9330295ba463b50f4085b6be9b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 13 Sep 2016 23:37:14 +1200 Subject: Put back H02 frame decoder hack --- src/org/traccar/protocol/H02FrameDecoder.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java index 572ac979e..feba8033d 100644 --- a/src/org/traccar/protocol/H02FrameDecoder.java +++ b/src/org/traccar/protocol/H02FrameDecoder.java @@ -34,6 +34,13 @@ public class H02FrameDecoder extends FrameDecoder { char marker = (char) buf.getByte(buf.readerIndex()); + while (marker != '*' && marker != '$' && buf.readableBytes() > 0) { + buf.skipBytes(1); + if (buf.readableBytes() > 0) { + marker = (char) buf.getByte(buf.readerIndex()); + } + } + if (marker == '*') { // Return text message -- cgit v1.2.3 From 3fa2c036a5928ff85e584f1d05a1fa970f9b1a16 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 14 Sep 2016 02:25:52 +1200 Subject: Use IMEI for TK103 identification --- src/org/traccar/protocol/Tk103ProtocolDecoder.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 90c80be71..7b3f44d33 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -111,11 +111,15 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { if (channel != null) { String id = sentence.substring(0, 12); String type = sentence.substring(12, 16); - if (type.equals("BP00")) { - String content = sentence.substring(sentence.length() - 3); - channel.write("(" + id + "AP01" + content + ")"); - } else if (type.equals("BP05")) { - channel.write("(" + id + "AP05)"); + if (type.equals("BP00") || type.equals("BP05")) { + String content = sentence.substring(16); + getDeviceSession(channel, remoteAddress, content.substring(0, 15)); + if (type.equals("BP00")) { + channel.write("(" + id + "AP01" + content.substring(15) + ")"); + return null; + } else if (type.equals("BP05")) { + channel.write("(" + id + "AP05)"); + } } } -- cgit v1.2.3 From 38bbab77b848989b1065a41666518bef64d147e5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 14 Sep 2016 02:47:00 +1200 Subject: Support Xexun messages without time --- src/org/traccar/protocol/XexunProtocolDecoder.java | 4 ++-- test/org/traccar/protocol/XexunProtocolDecoderTest.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 69100f54b..7ec2685fa 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -37,13 +37,13 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { private static final Pattern PATTERN_BASIC = new PatternBuilder() .expression("G[PN]RMC,") - .number("(dd)(dd)(dd).(d+),") // time + .number("(?:(dd)(dd)(dd))?.(d+),") // time .expression("([AV]),") // validity .number("(d*?)(d?d.d+),([NS]),") // latitude .number("(d*?)(d?d.d+),([EW])?,") // longitude .number("(d+.?d*),") // speed .number("(d+.?d*)?,") // course - .number("(dd)(dd)(dd),") // date + .number("(?:(dd)(dd)(dd))?,") // date .expression("[^*]*").text("*") .number("xx") // checksum .expression("\\r\\n").optional() diff --git a/test/org/traccar/protocol/XexunProtocolDecoderTest.java b/test/org/traccar/protocol/XexunProtocolDecoderTest.java index ac90daec5..e94fb62e8 100644 --- a/test/org/traccar/protocol/XexunProtocolDecoderTest.java +++ b/test/org/traccar/protocol/XexunProtocolDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; - import org.junit.Test; import org.traccar.ProtocolTest; @@ -11,6 +10,9 @@ public class XexunProtocolDecoderTest extends ProtocolTest { XexunProtocolDecoder decoder = new XexunProtocolDecoder(new XexunProtocol(), false); + verifyAttributes(decoder, text( + "GPRMC,.000,A,0.000000,S,0.0000,W,0.00,0.00,,00,0000.0,A*55,L,,imei:353579010727036,")); + verifyPosition(decoder, text( "GPRMC,113518.000,A,5303.4150,N,10.2368,E,60.73,207.42,260216,00,0000.0,A*74,F,,imei:351525018007873,")); -- cgit v1.2.3 From 5a3cad30d5b2fa5a4be6cba0eed6df135f496165 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 14 Sep 2016 07:53:15 +1200 Subject: Implement more Castel message types --- src/org/traccar/helper/ObdDecoder.java | 14 +++--- .../traccar/protocol/CastelProtocolDecoder.java | 51 ++++++++++++++++++++++ .../protocol/CastelProtocolDecoderTest.java | 12 ++--- 3 files changed, 66 insertions(+), 11 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/helper/ObdDecoder.java b/src/org/traccar/helper/ObdDecoder.java index 4686aa682..6ffe39662 100644 --- a/src/org/traccar/helper/ObdDecoder.java +++ b/src/org/traccar/helper/ObdDecoder.java @@ -25,9 +25,9 @@ public final class ObdDecoder { private ObdDecoder() { } - public static final int MODE_CURRENT = 0x01; - public static final int MODE_FREEZE_FRAME = 0x02; - public static final int MODE_CODES = 0x03; + private static final int MODE_CURRENT = 0x01; + private static final int MODE_FREEZE_FRAME = 0x02; + private static final int MODE_CODES = 0x03; private static final int PID_ENGINE_LOAD = 0x04; private static final int PID_COOLANT_TEMPERATURE = 0x05; @@ -54,7 +54,7 @@ public final class ObdDecoder { return new AbstractMap.SimpleEntry<>(key, value); } - private static Map.Entry decodeCodes(String value) { + public static Map.Entry decodeCodes(String value) { StringBuilder codes = new StringBuilder(); for (int i = 0; i < value.length() / 4; i++) { int numValue = Integer.parseInt(value.substring(i * 4, (i + 1) * 4), 16); @@ -75,7 +75,11 @@ public final class ObdDecoder { } codes.append(String.format("%04X", numValue & 0x3FFF)); } - return createEntry("dtcs", codes.toString().replaceFirst(",", "")); + if (codes.length() > 0) { + return createEntry("dtcs", codes.toString().replaceFirst(",", "")); + } else { + return null; + } } private static Map.Entry decodeData(int pid, String value) { diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index 38fb11164..b8faed077 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -22,6 +22,7 @@ import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; import org.traccar.helper.Checksum; import org.traccar.helper.DateBuilder; +import org.traccar.helper.ObdDecoder; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; @@ -43,7 +44,13 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { private static final short MSG_SC_HEARTBEAT = 0x1003; private static final short MSG_SC_HEARTBEAT_RESPONSE = (short) 0x9003; private static final short MSG_SC_GPS = 0x4001; + private static final short MSG_SC_PID_DATA = 0x4002; + private static final short MSG_SC_SUPPORTED_PID = 0x4004; + private static final short MSG_SC_OBD_DATA = 0x4005; + private static final short MSG_SC_DTCS_PASSENGER = 0x4006; + private static final short MSG_SC_DTCS_COMMERCIAL = 0x400B; private static final short MSG_SC_ALARM = 0x4007; + private static final short MSG_SC_CELL = 0x4008; private static final short MSG_SC_GPS_SLEEP = 0x4009; private static final short MSG_SC_AGPS_REQUEST = 0x5101; private static final short MSG_SC_CURRENT_LOCATION = (short) 0xB001; @@ -193,6 +200,50 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { return readPosition(deviceSession, buf); + } else if (type == MSG_SC_DTCS_PASSENGER) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + buf.skipBytes(6 * 4 + 2 + 8); + + buf.readUnsignedByte(); // flag + position.add(ObdDecoder.decodeCodes(ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedByte())))); + + return position; + + } else if (type == MSG_SC_OBD_DATA) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + buf.skipBytes(6 * 4 + 2 + 8); + + // decode data + + return position; + + } else if (type == MSG_SC_CELL) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + buf.skipBytes(6 * 4 + 2 + 8); + + position.set(Position.KEY_LAC, buf.readUnsignedShort()); + position.set(Position.KEY_CID, buf.readUnsignedShort()); + + return position; + } return null; diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java index a5b477ea5..ccdd6f726 100644 --- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java @@ -18,10 +18,10 @@ public class CastelProtocolDecoderTest extends ProtocolTest { verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40407800043231334e583230313630303131373700000000004004fa52ce574b53ce57cad1020041020000050c00000d0000000400036401240b0503001b042105210c210d210f211021112113211c211f212121232124212c212d213021312133213e2141214221452149214a214c214f215021384e0d0a")); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040a600043231334e583230313630303131373700000000004005fa52ce575053ce57cad102006b020000050c00000d0000000400036401240b050300001b042105210c210d210f211021112113211c211f212121232124212c212d213021312133213e2141214221452149214a214c214f215021015bd604301f500600000653000000bc0bffff78250000ff2d98642401000f8080e038000f0f0000000000000077b10d0a")); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40404300043231334e583230313630303131373700000000004006fa52ce574e53ce57cad1020053020000050c00000d0000000400036401240b0503000000feec0d0a")); verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, @@ -54,10 +54,10 @@ public class CastelProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40405900043130303131313235323939383700000000000000400101C1F06952E7F069529C9111000000000069830000070000000400036401014C00030001190A0D0412041480D60488C57218000000009F01E803ED9A0D0A")); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040B9000431303031313132353239393837000000000000004005C1F069521BF169529C9111000000000069830000130000000400036401014C0003000022032104210521062107210C210D210E210F2110211121132115211C211F21212124212E212F2130213121322133213C214221432144214521472149214A214C214D214E210100643B6232E803003E64280A3C24FE00010E010F00D5805A483C640000000000010000E02E000000066400000500000000A7710D0A")); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, "404043000431303031313132353239393837000000000000004006C1F0695209F169529C91110000000000698300000D0000000400036401014C00030000009AF40D0A")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, @@ -72,7 +72,7 @@ public class CastelProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40405c000c363131313530303030393536000000000000000040011c0a0f0e362dca53cd0860831303000000000300000000ff000000000000007ba083a650542d3639305f56312e312e320050542d3639302056312e32008a020d0a")); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040450004323132474c31313433303035303033000000000040082ca89b55a6a99b555c57000000000000c40200000b0000001400036401111f000302f5533bd653f10d0a")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, @@ -81,7 +81,7 @@ public class CastelProtocolDecoderTest extends ProtocolTest { verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040420004323132474c31313433303035303033000000000010022ca89b55cca99b555c57000000000000cf0200000b0000000000036401111f0000020013be0d0a")); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040870004323132474c31313433303035303033000000000040052ca89b55e3a89b555c57000000000000c4020000040000001400036401111f0003000012042105210b210c210d210f211021112113211c2121212321242133213421422146214f212b50663603003ce9030dff060000600dffffc25865ffff9e02b43624000000003cbc0d0a")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, -- cgit v1.2.3 From 4e0113f3901617fe0baa1ce2c9e50c5f34089f78 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 15 Sep 2016 05:09:00 +1200 Subject: Add power cut GT06 alarm (fix #2321) --- src/org/traccar/model/Position.java | 1 + src/org/traccar/protocol/Gt06ProtocolDecoder.java | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 95a5011ec..710dd1e83 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -89,6 +89,7 @@ public class Position extends Message { public static final String ALARM_ACCELETATION = "hardAcceleration"; public static final String ALARM_BREAKING = "hardBreaking"; public static final String ALARM_FATIGUE_DRIVING = "fatigueDriving"; + public static final String ALARM_POWER_CUT = "powerCut"; private String protocol; diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 3df8a4686..10e19b131 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -167,6 +167,8 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { switch (value) { case 0x01: return Position.ALARM_SOS; + case 0x02: + return Position.ALARM_POWER_CUT; case 0x03: case 0x09: return Position.ALARM_VIBRATION; -- cgit v1.2.3 From 49754dbd853cd35876d74d7d8781c97a3c1413f7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 15 Sep 2016 06:53:37 +1200 Subject: Implement Arknav X8 series support --- debug.xml | 1 + src/org/traccar/protocol/ArknavX8Protocol.java | 47 +++++++++++ .../traccar/protocol/ArknavX8ProtocolDecoder.java | 95 ++++++++++++++++++++++ .../protocol/ArknavX8ProtocolDecoderTest.java | 33 ++++++++ 4 files changed, 176 insertions(+) create mode 100644 src/org/traccar/protocol/ArknavX8Protocol.java create mode 100644 src/org/traccar/protocol/ArknavX8ProtocolDecoder.java create mode 100644 test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java (limited to 'src/org/traccar/protocol') diff --git a/debug.xml b/debug.xml index 9e2f495aa..2c2d0b334 100644 --- a/debug.xml +++ b/debug.xml @@ -453,5 +453,6 @@ 5116 5117 5118 + 5119 diff --git a/src/org/traccar/protocol/ArknavX8Protocol.java b/src/org/traccar/protocol/ArknavX8Protocol.java new file mode 100644 index 000000000..cf6708c73 --- /dev/null +++ b/src/org/traccar/protocol/ArknavX8Protocol.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.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 ArknavX8Protocol extends BaseProtocol { + + public ArknavX8Protocol() { + super("arknavx8"); + } + + @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("stringEncoder", new StringEncoder()); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("objectDecoder", new ArknavX8ProtocolDecoder(ArknavX8Protocol.this)); + } + }); + } + +} diff --git a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java new file mode 100644 index 000000000..931cb1d14 --- /dev/null +++ b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java @@ -0,0 +1,95 @@ +/* + * 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.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; +import org.traccar.helper.DateBuilder; +import org.traccar.helper.Parser; +import org.traccar.helper.PatternBuilder; +import org.traccar.helper.PatternUtil; +import org.traccar.model.Position; + +import java.net.SocketAddress; +import java.util.regex.Pattern; + +public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder { + + public ArknavX8ProtocolDecoder(ArknavX8Protocol protocol) { + super(protocol); + } + + private static final Pattern PATTERN = new PatternBuilder() + .expression("(..),") // type + .number("(dd)(dd)(dd)") // date (yymmdd) + .number("(dd)(dd)(dd),") // time + .expression("([AV]),") // validity + .number("(d+)(dd.d+)([NS]),") // latitude + .number("(d+)(dd.d+)([EW]),") // longitude + .number("(d+.d+),") // speed + .number("(d+),") // course + .number("(d+.d+),") // hdop + .number("(d+)") // status + .compile(); + + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + String sentence = (String) msg; + + if (sentence.charAt(2) != ',') { + getDeviceSession(channel, remoteAddress, sentence.substring(0, 15)); + return null; + } + + PatternUtil.MatchResult r = PatternUtil.checkPattern(PATTERN.pattern(), sentence); + + Parser parser = new Parser(PATTERN, sentence); + if (!parser.matches()) { + return null; + } + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession == null) { + return null; + } + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + parser.next(); // type + + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + position.setValid(parser.next().equals("A")); + position.setLatitude(parser.nextCoordinate()); + position.setLongitude(parser.nextCoordinate()); + position.setSpeed(parser.nextDouble()); + position.setCourse(parser.nextDouble()); + + position.set(Position.KEY_HDOP, parser.nextDouble()); + position.set(Position.KEY_STATUS, parser.next()); + + return position; + } + +} diff --git a/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java b/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java new file mode 100644 index 000000000..a28e71c64 --- /dev/null +++ b/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java @@ -0,0 +1,33 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class ArknavX8ProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + ArknavX8ProtocolDecoder decoder = new ArknavX8ProtocolDecoder(new ArknavX8Protocol()); + + verifyNothing(decoder, text( + "351856040005407,240101")); + + verifyPosition(decoder, text( + "1R,110509053244,A,2457.9141N,12126.3321E,220.0,315,10.0,00000000")); + + verifyNothing(decoder, text( + "2R,110509053244,837493,,998372,,,")); + + verifyPosition(decoder, text( + "1G,110509053245,A,2457.9141N,12126.3192E,3.1,35,2.0,00000001")); + + verifyPosition(decoder, text( + "1G,110509053246,A,2457.9121N,12126.3415E,2.0,288,1.7,00000000")); + + verifyPosition(decoder, text( + "1M,110509053247,A,2457.9118N,12126.3522E,1.0,55,2.2,00000000")); + + } + +} -- cgit v1.2.3 From a1fdcee9044fcf3114b24423242bdd5b7c0ee18f Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 15 Sep 2016 07:01:33 +1200 Subject: Remove unnecessary this-dot prefix --- src/org/traccar/protocol/AdmProtocol.java | 2 +- src/org/traccar/protocol/ApelProtocol.java | 2 +- src/org/traccar/protocol/AplicomProtocol.java | 2 +- src/org/traccar/protocol/AppelloProtocol.java | 2 +- src/org/traccar/protocol/AquilaProtocol.java | 2 +- src/org/traccar/protocol/Ardi01Protocol.java | 2 +- src/org/traccar/protocol/ArknavProtocol.java | 2 +- src/org/traccar/protocol/ArknavX8Protocol.java | 2 +- src/org/traccar/protocol/ArnaviProtocol.java | 2 +- src/org/traccar/protocol/AstraProtocol.java | 4 ++-- src/org/traccar/protocol/AtrackProtocol.java | 4 ++-- src/org/traccar/protocol/AuroProtocol.java | 2 +- src/org/traccar/protocol/AutoFonProtocol.java | 2 +- src/org/traccar/protocol/Avl301Protocol.java | 2 +- src/org/traccar/protocol/BceProtocol.java | 2 +- src/org/traccar/protocol/BlackKiteProtocol.java | 2 +- src/org/traccar/protocol/BoxProtocol.java | 2 +- src/org/traccar/protocol/CalAmpProtocol.java | 2 +- src/org/traccar/protocol/CarTrackProtocol.java | 2 +- src/org/traccar/protocol/CarcellProtocol.java | 2 +- src/org/traccar/protocol/CarscopProtocol.java | 2 +- src/org/traccar/protocol/CastelProtocol.java | 4 ++-- src/org/traccar/protocol/CellocatorProtocol.java | 2 +- src/org/traccar/protocol/CityeasyProtocol.java | 2 +- src/org/traccar/protocol/CradlepointProtocol.java | 2 +- src/org/traccar/protocol/DishaProtocol.java | 2 +- src/org/traccar/protocol/EasyTrackProtocol.java | 2 +- src/org/traccar/protocol/EelinkProtocol.java | 2 +- src/org/traccar/protocol/EnforaProtocol.java | 2 +- src/org/traccar/protocol/FlextrackProtocol.java | 2 +- src/org/traccar/protocol/FoxProtocol.java | 2 +- src/org/traccar/protocol/FreedomProtocol.java | 2 +- src/org/traccar/protocol/GalileoProtocol.java | 2 +- src/org/traccar/protocol/GatorProtocol.java | 4 ++-- src/org/traccar/protocol/Gl100Protocol.java | 4 ++-- src/org/traccar/protocol/Gl200Protocol.java | 4 ++-- src/org/traccar/protocol/GlobalSatProtocol.java | 2 +- src/org/traccar/protocol/GnxProtocol.java | 2 +- src/org/traccar/protocol/GoSafeProtocol.java | 2 +- src/org/traccar/protocol/GotopProtocol.java | 2 +- src/org/traccar/protocol/Gps103Protocol.java | 4 ++-- src/org/traccar/protocol/GpsGateProtocol.java | 2 +- src/org/traccar/protocol/GpsMarkerProtocol.java | 2 +- src/org/traccar/protocol/GpsmtaProtocol.java | 2 +- src/org/traccar/protocol/GranitProtocol.java | 2 +- src/org/traccar/protocol/Gt02Protocol.java | 2 +- src/org/traccar/protocol/Gt06Protocol.java | 2 +- src/org/traccar/protocol/H02Protocol.java | 2 +- src/org/traccar/protocol/HaicomProtocol.java | 2 +- src/org/traccar/protocol/HomtecsProtocol.java | 2 +- src/org/traccar/protocol/HuaShengProtocol.java | 2 +- src/org/traccar/protocol/HuabaoProtocol.java | 2 +- src/org/traccar/protocol/HunterProProtocol.java | 2 +- src/org/traccar/protocol/IdplProtocol.java | 2 +- src/org/traccar/protocol/IntellitracProtocol.java | 2 +- src/org/traccar/protocol/Jt600Protocol.java | 2 +- src/org/traccar/protocol/KhdProtocol.java | 2 +- src/org/traccar/protocol/L100Protocol.java | 2 +- src/org/traccar/protocol/LaipacProtocol.java | 2 +- src/org/traccar/protocol/M2mProtocol.java | 2 +- src/org/traccar/protocol/ManPowerProtocol.java | 2 +- src/org/traccar/protocol/MegastekProtocol.java | 2 +- src/org/traccar/protocol/MeiligaoProtocol.java | 4 ++-- src/org/traccar/protocol/MeitrackProtocol.java | 4 ++-- src/org/traccar/protocol/MiniFinderProtocol.java | 2 +- src/org/traccar/protocol/Mta6Protocol.java | 2 +- src/org/traccar/protocol/MtxProtocol.java | 2 +- src/org/traccar/protocol/MxtProtocol.java | 2 +- src/org/traccar/protocol/NavigilProtocol.java | 2 +- src/org/traccar/protocol/NavisProtocol.java | 2 +- src/org/traccar/protocol/NoranProtocol.java | 2 +- src/org/traccar/protocol/NvsProtocol.java | 2 +- src/org/traccar/protocol/ObdDongleProtocol.java | 2 +- src/org/traccar/protocol/OrionProtocol.java | 2 +- src/org/traccar/protocol/OsmAndProtocol.java | 2 +- src/org/traccar/protocol/PathAwayProtocol.java | 2 +- src/org/traccar/protocol/PiligrimProtocol.java | 2 +- src/org/traccar/protocol/ProgressProtocol.java | 2 +- src/org/traccar/protocol/Pt3000Protocol.java | 2 +- src/org/traccar/protocol/Pt502Protocol.java | 2 +- src/org/traccar/protocol/RaveonProtocol.java | 2 +- src/org/traccar/protocol/RitiProtocol.java | 2 +- src/org/traccar/protocol/RuptelaProtocol.java | 2 +- src/org/traccar/protocol/SanavProtocol.java | 2 +- src/org/traccar/protocol/SkypatrolProtocol.java | 2 +- src/org/traccar/protocol/Stl060Protocol.java | 2 +- src/org/traccar/protocol/SuntechProtocol.java | 2 +- src/org/traccar/protocol/SupermateProtocol.java | 2 +- src/org/traccar/protocol/T55Protocol.java | 4 ++-- src/org/traccar/protocol/TaipProtocol.java | 4 ++-- src/org/traccar/protocol/TelicProtocol.java | 2 +- src/org/traccar/protocol/TeltonikaProtocol.java | 4 ++-- src/org/traccar/protocol/ThinkRaceProtocol.java | 2 +- src/org/traccar/protocol/Tk102Protocol.java | 2 +- src/org/traccar/protocol/Tk103Protocol.java | 4 ++-- src/org/traccar/protocol/Tlt2hProtocol.java | 2 +- src/org/traccar/protocol/TopflytechProtocol.java | 2 +- src/org/traccar/protocol/TotemProtocol.java | 2 +- src/org/traccar/protocol/Tr20Protocol.java | 2 +- src/org/traccar/protocol/TrackboxProtocol.java | 2 +- src/org/traccar/protocol/TramigoProtocol.java | 2 +- src/org/traccar/protocol/TrvProtocol.java | 2 +- src/org/traccar/protocol/Tt8850Protocol.java | 2 +- src/org/traccar/protocol/TytanProtocol.java | 2 +- src/org/traccar/protocol/TzoneProtocol.java | 2 +- src/org/traccar/protocol/UlbotechProtocol.java | 2 +- src/org/traccar/protocol/UproProtocol.java | 2 +- src/org/traccar/protocol/V680Protocol.java | 4 ++-- src/org/traccar/protocol/VisiontekProtocol.java | 2 +- src/org/traccar/protocol/WatchProtocol.java | 2 +- src/org/traccar/protocol/WialonProtocol.java | 2 +- src/org/traccar/protocol/WondexProtocol.java | 4 ++-- src/org/traccar/protocol/XexunProtocol.java | 2 +- src/org/traccar/protocol/XirgoProtocol.java | 4 ++-- src/org/traccar/protocol/Xt013Protocol.java | 2 +- src/org/traccar/protocol/YwtProtocol.java | 2 +- 116 files changed, 132 insertions(+), 132 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/AdmProtocol.java b/src/org/traccar/protocol/AdmProtocol.java index 40dd340cf..067ccf053 100644 --- a/src/org/traccar/protocol/AdmProtocol.java +++ b/src/org/traccar/protocol/AdmProtocol.java @@ -32,7 +32,7 @@ public class AdmProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 1, -3, 0)); diff --git a/src/org/traccar/protocol/ApelProtocol.java b/src/org/traccar/protocol/ApelProtocol.java index ae1af1243..47bce37a0 100644 --- a/src/org/traccar/protocol/ApelProtocol.java +++ b/src/org/traccar/protocol/ApelProtocol.java @@ -32,7 +32,7 @@ public class ApelProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0)); diff --git a/src/org/traccar/protocol/AplicomProtocol.java b/src/org/traccar/protocol/AplicomProtocol.java index 8aae9554a..5155133c9 100644 --- a/src/org/traccar/protocol/AplicomProtocol.java +++ b/src/org/traccar/protocol/AplicomProtocol.java @@ -30,7 +30,7 @@ public class AplicomProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new AplicomFrameDecoder()); diff --git a/src/org/traccar/protocol/AppelloProtocol.java b/src/org/traccar/protocol/AppelloProtocol.java index f7826caab..b129a7520 100755 --- a/src/org/traccar/protocol/AppelloProtocol.java +++ b/src/org/traccar/protocol/AppelloProtocol.java @@ -33,7 +33,7 @@ public class AppelloProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/AquilaProtocol.java b/src/org/traccar/protocol/AquilaProtocol.java index 1bf5f4ee7..9607edd55 100644 --- a/src/org/traccar/protocol/AquilaProtocol.java +++ b/src/org/traccar/protocol/AquilaProtocol.java @@ -33,7 +33,7 @@ public class AquilaProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/Ardi01Protocol.java b/src/org/traccar/protocol/Ardi01Protocol.java index 595692cc5..5b7770647 100644 --- a/src/org/traccar/protocol/Ardi01Protocol.java +++ b/src/org/traccar/protocol/Ardi01Protocol.java @@ -33,7 +33,7 @@ public class Ardi01Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/ArknavProtocol.java b/src/org/traccar/protocol/ArknavProtocol.java index 3b288b5ab..6b9398f68 100644 --- a/src/org/traccar/protocol/ArknavProtocol.java +++ b/src/org/traccar/protocol/ArknavProtocol.java @@ -33,7 +33,7 @@ public class ArknavProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r')); diff --git a/src/org/traccar/protocol/ArknavX8Protocol.java b/src/org/traccar/protocol/ArknavX8Protocol.java index cf6708c73..3b78a27ff 100644 --- a/src/org/traccar/protocol/ArknavX8Protocol.java +++ b/src/org/traccar/protocol/ArknavX8Protocol.java @@ -33,7 +33,7 @@ public class ArknavX8Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';')); diff --git a/src/org/traccar/protocol/ArnaviProtocol.java b/src/org/traccar/protocol/ArnaviProtocol.java index 5bdb68e86..29661b8d4 100644 --- a/src/org/traccar/protocol/ArnaviProtocol.java +++ b/src/org/traccar/protocol/ArnaviProtocol.java @@ -33,7 +33,7 @@ public class ArnaviProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/AstraProtocol.java b/src/org/traccar/protocol/AstraProtocol.java index 0ff338599..461888c4f 100644 --- a/src/org/traccar/protocol/AstraProtocol.java +++ b/src/org/traccar/protocol/AstraProtocol.java @@ -32,14 +32,14 @@ public class AstraProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 1, 2, -3, 0)); pipeline.addLast("objectDecoder", new AstraProtocolDecoder(AstraProtocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectDecoder", new AstraProtocolDecoder(AstraProtocol.this)); diff --git a/src/org/traccar/protocol/AtrackProtocol.java b/src/org/traccar/protocol/AtrackProtocol.java index 356f7fc28..d61d31522 100644 --- a/src/org/traccar/protocol/AtrackProtocol.java +++ b/src/org/traccar/protocol/AtrackProtocol.java @@ -31,14 +31,14 @@ public class AtrackProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new AtrackFrameDecoder()); pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this)); diff --git a/src/org/traccar/protocol/AuroProtocol.java b/src/org/traccar/protocol/AuroProtocol.java index e8fad85fd..e5635f12a 100644 --- a/src/org/traccar/protocol/AuroProtocol.java +++ b/src/org/traccar/protocol/AuroProtocol.java @@ -33,7 +33,7 @@ public class AuroProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/AutoFonProtocol.java b/src/org/traccar/protocol/AutoFonProtocol.java index dc2830edb..3e61b81a3 100644 --- a/src/org/traccar/protocol/AutoFonProtocol.java +++ b/src/org/traccar/protocol/AutoFonProtocol.java @@ -30,7 +30,7 @@ public class AutoFonProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new AutoFonFrameDecoder()); diff --git a/src/org/traccar/protocol/Avl301Protocol.java b/src/org/traccar/protocol/Avl301Protocol.java index 10ec5ae22..b8453cfb3 100644 --- a/src/org/traccar/protocol/Avl301Protocol.java +++ b/src/org/traccar/protocol/Avl301Protocol.java @@ -31,7 +31,7 @@ public class Avl301Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, -3, 0)); diff --git a/src/org/traccar/protocol/BceProtocol.java b/src/org/traccar/protocol/BceProtocol.java index 06154c1c7..576eb6862 100644 --- a/src/org/traccar/protocol/BceProtocol.java +++ b/src/org/traccar/protocol/BceProtocol.java @@ -31,7 +31,7 @@ public class BceProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new BceFrameDecoder()); diff --git a/src/org/traccar/protocol/BlackKiteProtocol.java b/src/org/traccar/protocol/BlackKiteProtocol.java index 3f1890f88..ea5120b2b 100644 --- a/src/org/traccar/protocol/BlackKiteProtocol.java +++ b/src/org/traccar/protocol/BlackKiteProtocol.java @@ -32,7 +32,7 @@ public class BlackKiteProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new GalileoFrameDecoder()); diff --git a/src/org/traccar/protocol/BoxProtocol.java b/src/org/traccar/protocol/BoxProtocol.java index 33cfca282..6e60a0dd8 100644 --- a/src/org/traccar/protocol/BoxProtocol.java +++ b/src/org/traccar/protocol/BoxProtocol.java @@ -33,7 +33,7 @@ public class BoxProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r')); diff --git a/src/org/traccar/protocol/CalAmpProtocol.java b/src/org/traccar/protocol/CalAmpProtocol.java index ccfd47cc4..a8eb59d0e 100644 --- a/src/org/traccar/protocol/CalAmpProtocol.java +++ b/src/org/traccar/protocol/CalAmpProtocol.java @@ -30,7 +30,7 @@ public class CalAmpProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectDecoder", new CalAmpProtocolDecoder(CalAmpProtocol.this)); diff --git a/src/org/traccar/protocol/CarTrackProtocol.java b/src/org/traccar/protocol/CarTrackProtocol.java index 8a60e3ebb..0244c0ce1 100644 --- a/src/org/traccar/protocol/CarTrackProtocol.java +++ b/src/org/traccar/protocol/CarTrackProtocol.java @@ -33,7 +33,7 @@ public class CarTrackProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##")); diff --git a/src/org/traccar/protocol/CarcellProtocol.java b/src/org/traccar/protocol/CarcellProtocol.java index 5982e9cf8..1303b56b3 100644 --- a/src/org/traccar/protocol/CarcellProtocol.java +++ b/src/org/traccar/protocol/CarcellProtocol.java @@ -37,7 +37,7 @@ public class CarcellProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r')); diff --git a/src/org/traccar/protocol/CarscopProtocol.java b/src/org/traccar/protocol/CarscopProtocol.java index 4432fb87a..23c597a5b 100644 --- a/src/org/traccar/protocol/CarscopProtocol.java +++ b/src/org/traccar/protocol/CarscopProtocol.java @@ -33,7 +33,7 @@ public class CarscopProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '^')); diff --git a/src/org/traccar/protocol/CastelProtocol.java b/src/org/traccar/protocol/CastelProtocol.java index 604ff4ecb..42f7cbb88 100644 --- a/src/org/traccar/protocol/CastelProtocol.java +++ b/src/org/traccar/protocol/CastelProtocol.java @@ -33,7 +33,7 @@ public class CastelProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0)); @@ -43,7 +43,7 @@ public class CastelProtocol extends BaseProtocol { server.setEndianness(ByteOrder.LITTLE_ENDIAN); serverList.add(server); - server = new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + server = new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this)); diff --git a/src/org/traccar/protocol/CellocatorProtocol.java b/src/org/traccar/protocol/CellocatorProtocol.java index 22564d44f..6d8eea8f5 100644 --- a/src/org/traccar/protocol/CellocatorProtocol.java +++ b/src/org/traccar/protocol/CellocatorProtocol.java @@ -31,7 +31,7 @@ public class CellocatorProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CellocatorFrameDecoder()); diff --git a/src/org/traccar/protocol/CityeasyProtocol.java b/src/org/traccar/protocol/CityeasyProtocol.java index 82302d2d7..e22c964ce 100644 --- a/src/org/traccar/protocol/CityeasyProtocol.java +++ b/src/org/traccar/protocol/CityeasyProtocol.java @@ -37,7 +37,7 @@ public class CityeasyProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0)); diff --git a/src/org/traccar/protocol/CradlepointProtocol.java b/src/org/traccar/protocol/CradlepointProtocol.java index ec938aa39..9b8de7fb8 100644 --- a/src/org/traccar/protocol/CradlepointProtocol.java +++ b/src/org/traccar/protocol/CradlepointProtocol.java @@ -33,7 +33,7 @@ public class CradlepointProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/DishaProtocol.java b/src/org/traccar/protocol/DishaProtocol.java index bb0d6cdf1..612316112 100644 --- a/src/org/traccar/protocol/DishaProtocol.java +++ b/src/org/traccar/protocol/DishaProtocol.java @@ -33,7 +33,7 @@ public class DishaProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/EasyTrackProtocol.java b/src/org/traccar/protocol/EasyTrackProtocol.java index d8bebeb5e..86ec530d4 100644 --- a/src/org/traccar/protocol/EasyTrackProtocol.java +++ b/src/org/traccar/protocol/EasyTrackProtocol.java @@ -33,7 +33,7 @@ public class EasyTrackProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#')); diff --git a/src/org/traccar/protocol/EelinkProtocol.java b/src/org/traccar/protocol/EelinkProtocol.java index 9579954f8..4da051159 100644 --- a/src/org/traccar/protocol/EelinkProtocol.java +++ b/src/org/traccar/protocol/EelinkProtocol.java @@ -31,7 +31,7 @@ public class EelinkProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2)); diff --git a/src/org/traccar/protocol/EnforaProtocol.java b/src/org/traccar/protocol/EnforaProtocol.java index 3d8c11fcf..f4ca505ca 100644 --- a/src/org/traccar/protocol/EnforaProtocol.java +++ b/src/org/traccar/protocol/EnforaProtocol.java @@ -31,7 +31,7 @@ public class EnforaProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2)); diff --git a/src/org/traccar/protocol/FlextrackProtocol.java b/src/org/traccar/protocol/FlextrackProtocol.java index c17099fc7..d62c064d0 100644 --- a/src/org/traccar/protocol/FlextrackProtocol.java +++ b/src/org/traccar/protocol/FlextrackProtocol.java @@ -33,7 +33,7 @@ public class FlextrackProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r")); diff --git a/src/org/traccar/protocol/FoxProtocol.java b/src/org/traccar/protocol/FoxProtocol.java index bcda1e433..30b76ef25 100644 --- a/src/org/traccar/protocol/FoxProtocol.java +++ b/src/org/traccar/protocol/FoxProtocol.java @@ -33,7 +33,7 @@ public class FoxProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "")); diff --git a/src/org/traccar/protocol/FreedomProtocol.java b/src/org/traccar/protocol/FreedomProtocol.java index 2eb510cdb..0176d9781 100644 --- a/src/org/traccar/protocol/FreedomProtocol.java +++ b/src/org/traccar/protocol/FreedomProtocol.java @@ -33,7 +33,7 @@ public class FreedomProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/GalileoProtocol.java b/src/org/traccar/protocol/GalileoProtocol.java index 762bf0075..7d5b47bbb 100644 --- a/src/org/traccar/protocol/GalileoProtocol.java +++ b/src/org/traccar/protocol/GalileoProtocol.java @@ -31,7 +31,7 @@ public class GalileoProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new GalileoFrameDecoder()); diff --git a/src/org/traccar/protocol/GatorProtocol.java b/src/org/traccar/protocol/GatorProtocol.java index 3d899fa1f..e6b7161db 100644 --- a/src/org/traccar/protocol/GatorProtocol.java +++ b/src/org/traccar/protocol/GatorProtocol.java @@ -32,14 +32,14 @@ public class GatorProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2)); pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this)); diff --git a/src/org/traccar/protocol/Gl100Protocol.java b/src/org/traccar/protocol/Gl100Protocol.java index f51834ea2..a78aff35f 100644 --- a/src/org/traccar/protocol/Gl100Protocol.java +++ b/src/org/traccar/protocol/Gl100Protocol.java @@ -34,7 +34,7 @@ public class Gl100Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\0')); @@ -43,7 +43,7 @@ public class Gl100Protocol extends BaseProtocol { pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(Gl100Protocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringEncoder", new StringEncoder()); diff --git a/src/org/traccar/protocol/Gl200Protocol.java b/src/org/traccar/protocol/Gl200Protocol.java index 701652e12..d38bdf8a9 100644 --- a/src/org/traccar/protocol/Gl200Protocol.java +++ b/src/org/traccar/protocol/Gl200Protocol.java @@ -40,7 +40,7 @@ public class Gl200Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "$", "\0")); @@ -50,7 +50,7 @@ public class Gl200Protocol extends BaseProtocol { pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(Gl200Protocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringEncoder", new StringEncoder()); diff --git a/src/org/traccar/protocol/GlobalSatProtocol.java b/src/org/traccar/protocol/GlobalSatProtocol.java index 592ba152e..25d7656f1 100644 --- a/src/org/traccar/protocol/GlobalSatProtocol.java +++ b/src/org/traccar/protocol/GlobalSatProtocol.java @@ -33,7 +33,7 @@ public class GlobalSatProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '!')); diff --git a/src/org/traccar/protocol/GnxProtocol.java b/src/org/traccar/protocol/GnxProtocol.java index ff2976286..aeef247c2 100644 --- a/src/org/traccar/protocol/GnxProtocol.java +++ b/src/org/traccar/protocol/GnxProtocol.java @@ -33,7 +33,7 @@ public class GnxProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\n\r")); diff --git a/src/org/traccar/protocol/GoSafeProtocol.java b/src/org/traccar/protocol/GoSafeProtocol.java index b45755fc3..54abacd42 100644 --- a/src/org/traccar/protocol/GoSafeProtocol.java +++ b/src/org/traccar/protocol/GoSafeProtocol.java @@ -33,7 +33,7 @@ public class GoSafeProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#')); diff --git a/src/org/traccar/protocol/GotopProtocol.java b/src/org/traccar/protocol/GotopProtocol.java index 303001756..6b31e1acf 100644 --- a/src/org/traccar/protocol/GotopProtocol.java +++ b/src/org/traccar/protocol/GotopProtocol.java @@ -33,7 +33,7 @@ public class GotopProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#')); diff --git a/src/org/traccar/protocol/Gps103Protocol.java b/src/org/traccar/protocol/Gps103Protocol.java index 6a2f8a7f9..559de3187 100644 --- a/src/org/traccar/protocol/Gps103Protocol.java +++ b/src/org/traccar/protocol/Gps103Protocol.java @@ -44,7 +44,7 @@ public class Gps103Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r\n", "\n", ";")); @@ -54,7 +54,7 @@ public class Gps103Protocol extends BaseProtocol { pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringEncoder", new StringEncoder()); diff --git a/src/org/traccar/protocol/GpsGateProtocol.java b/src/org/traccar/protocol/GpsGateProtocol.java index bfd3b2883..78a7588ad 100644 --- a/src/org/traccar/protocol/GpsGateProtocol.java +++ b/src/org/traccar/protocol/GpsGateProtocol.java @@ -33,7 +33,7 @@ public class GpsGateProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\0", "\n", "\r\n")); diff --git a/src/org/traccar/protocol/GpsMarkerProtocol.java b/src/org/traccar/protocol/GpsMarkerProtocol.java index 69c2637bd..bb4b5b561 100644 --- a/src/org/traccar/protocol/GpsMarkerProtocol.java +++ b/src/org/traccar/protocol/GpsMarkerProtocol.java @@ -33,7 +33,7 @@ public class GpsMarkerProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r")); diff --git a/src/org/traccar/protocol/GpsmtaProtocol.java b/src/org/traccar/protocol/GpsmtaProtocol.java index d1eaa2fd3..51cce2650 100644 --- a/src/org/traccar/protocol/GpsmtaProtocol.java +++ b/src/org/traccar/protocol/GpsmtaProtocol.java @@ -32,7 +32,7 @@ public class GpsmtaProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringEncoder", new StringEncoder()); diff --git a/src/org/traccar/protocol/GranitProtocol.java b/src/org/traccar/protocol/GranitProtocol.java index fb9d10809..1e097c17b 100644 --- a/src/org/traccar/protocol/GranitProtocol.java +++ b/src/org/traccar/protocol/GranitProtocol.java @@ -36,7 +36,7 @@ public class GranitProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new GranitFrameDecoder()); diff --git a/src/org/traccar/protocol/Gt02Protocol.java b/src/org/traccar/protocol/Gt02Protocol.java index e03727b4d..595e6649e 100644 --- a/src/org/traccar/protocol/Gt02Protocol.java +++ b/src/org/traccar/protocol/Gt02Protocol.java @@ -31,7 +31,7 @@ public class Gt02Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0)); diff --git a/src/org/traccar/protocol/Gt06Protocol.java b/src/org/traccar/protocol/Gt06Protocol.java index 7f6d5d914..e4c9ef2e0 100644 --- a/src/org/traccar/protocol/Gt06Protocol.java +++ b/src/org/traccar/protocol/Gt06Protocol.java @@ -34,7 +34,7 @@ public class Gt06Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new Gt06FrameDecoder()); diff --git a/src/org/traccar/protocol/H02Protocol.java b/src/org/traccar/protocol/H02Protocol.java index cdc2d11bb..06ac2a6fa 100644 --- a/src/org/traccar/protocol/H02Protocol.java +++ b/src/org/traccar/protocol/H02Protocol.java @@ -40,7 +40,7 @@ public class H02Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { int messageLength = Context.getConfig().getInteger(getName() + ".messageLength", 32); diff --git a/src/org/traccar/protocol/HaicomProtocol.java b/src/org/traccar/protocol/HaicomProtocol.java index 344f9c1ae..71970d476 100644 --- a/src/org/traccar/protocol/HaicomProtocol.java +++ b/src/org/traccar/protocol/HaicomProtocol.java @@ -33,7 +33,7 @@ public class HaicomProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*')); diff --git a/src/org/traccar/protocol/HomtecsProtocol.java b/src/org/traccar/protocol/HomtecsProtocol.java index 8e65f8572..e8a86fa37 100644 --- a/src/org/traccar/protocol/HomtecsProtocol.java +++ b/src/org/traccar/protocol/HomtecsProtocol.java @@ -32,7 +32,7 @@ public class HomtecsProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringDecoder", new StringDecoder()); diff --git a/src/org/traccar/protocol/HuaShengProtocol.java b/src/org/traccar/protocol/HuaShengProtocol.java index 53a77c603..dcef2bd69 100644 --- a/src/org/traccar/protocol/HuaShengProtocol.java +++ b/src/org/traccar/protocol/HuaShengProtocol.java @@ -30,7 +30,7 @@ public class HuaShengProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new HuaShengFrameDecoder()); diff --git a/src/org/traccar/protocol/HuabaoProtocol.java b/src/org/traccar/protocol/HuabaoProtocol.java index 9f41bb8c6..4a83689e3 100644 --- a/src/org/traccar/protocol/HuabaoProtocol.java +++ b/src/org/traccar/protocol/HuabaoProtocol.java @@ -30,7 +30,7 @@ public class HuabaoProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new HuabaoFrameDecoder()); diff --git a/src/org/traccar/protocol/HunterProProtocol.java b/src/org/traccar/protocol/HunterProProtocol.java index 1eb7d1a42..502a95e11 100644 --- a/src/org/traccar/protocol/HunterProProtocol.java +++ b/src/org/traccar/protocol/HunterProProtocol.java @@ -33,7 +33,7 @@ public class HunterProProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r")); diff --git a/src/org/traccar/protocol/IdplProtocol.java b/src/org/traccar/protocol/IdplProtocol.java index c35ae039d..88e106def 100644 --- a/src/org/traccar/protocol/IdplProtocol.java +++ b/src/org/traccar/protocol/IdplProtocol.java @@ -33,7 +33,7 @@ public class IdplProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/IntellitracProtocol.java b/src/org/traccar/protocol/IntellitracProtocol.java index a6caf770f..6db2b0011 100644 --- a/src/org/traccar/protocol/IntellitracProtocol.java +++ b/src/org/traccar/protocol/IntellitracProtocol.java @@ -32,7 +32,7 @@ public class IntellitracProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new IntellitracFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/Jt600Protocol.java b/src/org/traccar/protocol/Jt600Protocol.java index 3207986bf..2df792b47 100644 --- a/src/org/traccar/protocol/Jt600Protocol.java +++ b/src/org/traccar/protocol/Jt600Protocol.java @@ -30,7 +30,7 @@ public class Jt600Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new Jt600FrameDecoder()); diff --git a/src/org/traccar/protocol/KhdProtocol.java b/src/org/traccar/protocol/KhdProtocol.java index 93edb0415..e5bcc1be3 100644 --- a/src/org/traccar/protocol/KhdProtocol.java +++ b/src/org/traccar/protocol/KhdProtocol.java @@ -35,7 +35,7 @@ public class KhdProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(512, 3, 2)); diff --git a/src/org/traccar/protocol/L100Protocol.java b/src/org/traccar/protocol/L100Protocol.java index 95a4dce68..418b9beb7 100644 --- a/src/org/traccar/protocol/L100Protocol.java +++ b/src/org/traccar/protocol/L100Protocol.java @@ -30,7 +30,7 @@ public class L100Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new L100FrameDecoder()); diff --git a/src/org/traccar/protocol/LaipacProtocol.java b/src/org/traccar/protocol/LaipacProtocol.java index c2e5c585e..f64204749 100644 --- a/src/org/traccar/protocol/LaipacProtocol.java +++ b/src/org/traccar/protocol/LaipacProtocol.java @@ -33,7 +33,7 @@ public class LaipacProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/M2mProtocol.java b/src/org/traccar/protocol/M2mProtocol.java index 1fac9118c..662aa3f0f 100644 --- a/src/org/traccar/protocol/M2mProtocol.java +++ b/src/org/traccar/protocol/M2mProtocol.java @@ -31,7 +31,7 @@ public class M2mProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new FixedLengthFrameDecoder(23)); diff --git a/src/org/traccar/protocol/ManPowerProtocol.java b/src/org/traccar/protocol/ManPowerProtocol.java index 647a1bea7..ce7045899 100644 --- a/src/org/traccar/protocol/ManPowerProtocol.java +++ b/src/org/traccar/protocol/ManPowerProtocol.java @@ -33,7 +33,7 @@ public class ManPowerProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';')); diff --git a/src/org/traccar/protocol/MegastekProtocol.java b/src/org/traccar/protocol/MegastekProtocol.java index f61a4443c..77c2510bd 100644 --- a/src/org/traccar/protocol/MegastekProtocol.java +++ b/src/org/traccar/protocol/MegastekProtocol.java @@ -32,7 +32,7 @@ public class MegastekProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new MegastekFrameDecoder()); diff --git a/src/org/traccar/protocol/MeiligaoProtocol.java b/src/org/traccar/protocol/MeiligaoProtocol.java index bce9b3196..2c61af5cb 100644 --- a/src/org/traccar/protocol/MeiligaoProtocol.java +++ b/src/org/traccar/protocol/MeiligaoProtocol.java @@ -40,7 +40,7 @@ public class MeiligaoProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new MeiligaoFrameDecoder()); @@ -48,7 +48,7 @@ public class MeiligaoProtocol extends BaseProtocol { pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(MeiligaoProtocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectEncoder", new MeiligaoProtocolEncoder()); diff --git a/src/org/traccar/protocol/MeitrackProtocol.java b/src/org/traccar/protocol/MeitrackProtocol.java index 01fdcc08c..0c85c6203 100644 --- a/src/org/traccar/protocol/MeitrackProtocol.java +++ b/src/org/traccar/protocol/MeitrackProtocol.java @@ -42,7 +42,7 @@ public class MeitrackProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new MeitrackFrameDecoder()); @@ -53,7 +53,7 @@ public class MeitrackProtocol extends BaseProtocol { }; server.setEndianness(ByteOrder.LITTLE_ENDIAN); serverList.add(server); - server = new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + server = new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringEncoder", new StringEncoder()); diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java index 8da621ee4..605633267 100644 --- a/src/org/traccar/protocol/MiniFinderProtocol.java +++ b/src/org/traccar/protocol/MiniFinderProtocol.java @@ -44,7 +44,7 @@ public class MiniFinderProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';')); diff --git a/src/org/traccar/protocol/Mta6Protocol.java b/src/org/traccar/protocol/Mta6Protocol.java index ed578b2d7..cafda2bc6 100644 --- a/src/org/traccar/protocol/Mta6Protocol.java +++ b/src/org/traccar/protocol/Mta6Protocol.java @@ -33,7 +33,7 @@ public class Mta6Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("httpEncoder", new HttpResponseEncoder()); diff --git a/src/org/traccar/protocol/MtxProtocol.java b/src/org/traccar/protocol/MtxProtocol.java index e0bef8350..c549653d0 100644 --- a/src/org/traccar/protocol/MtxProtocol.java +++ b/src/org/traccar/protocol/MtxProtocol.java @@ -33,7 +33,7 @@ public class MtxProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/MxtProtocol.java b/src/org/traccar/protocol/MxtProtocol.java index 95223932c..a5d21e445 100644 --- a/src/org/traccar/protocol/MxtProtocol.java +++ b/src/org/traccar/protocol/MxtProtocol.java @@ -31,7 +31,7 @@ public class MxtProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new MxtFrameDecoder()); diff --git a/src/org/traccar/protocol/NavigilProtocol.java b/src/org/traccar/protocol/NavigilProtocol.java index 6d64761fc..7cf6f35ff 100644 --- a/src/org/traccar/protocol/NavigilProtocol.java +++ b/src/org/traccar/protocol/NavigilProtocol.java @@ -31,7 +31,7 @@ public class NavigilProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new NavigilFrameDecoder()); diff --git a/src/org/traccar/protocol/NavisProtocol.java b/src/org/traccar/protocol/NavisProtocol.java index 691a3d08c..d4cf40f1f 100644 --- a/src/org/traccar/protocol/NavisProtocol.java +++ b/src/org/traccar/protocol/NavisProtocol.java @@ -32,7 +32,7 @@ public class NavisProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(4 * 1024, 12, 2, 2, 0)); diff --git a/src/org/traccar/protocol/NoranProtocol.java b/src/org/traccar/protocol/NoranProtocol.java index 6bc15296e..eeddbdead 100644 --- a/src/org/traccar/protocol/NoranProtocol.java +++ b/src/org/traccar/protocol/NoranProtocol.java @@ -38,7 +38,7 @@ public class NoranProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectEncoder", new NoranProtocolEncoder()); diff --git a/src/org/traccar/protocol/NvsProtocol.java b/src/org/traccar/protocol/NvsProtocol.java index 9236668d2..4610e4abc 100644 --- a/src/org/traccar/protocol/NvsProtocol.java +++ b/src/org/traccar/protocol/NvsProtocol.java @@ -30,7 +30,7 @@ public class NvsProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new NvsFrameDecoder()); diff --git a/src/org/traccar/protocol/ObdDongleProtocol.java b/src/org/traccar/protocol/ObdDongleProtocol.java index e87f9a99a..d91eb765a 100644 --- a/src/org/traccar/protocol/ObdDongleProtocol.java +++ b/src/org/traccar/protocol/ObdDongleProtocol.java @@ -31,7 +31,7 @@ public class ObdDongleProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1099, 20, 2, 3, 0)); diff --git a/src/org/traccar/protocol/OrionProtocol.java b/src/org/traccar/protocol/OrionProtocol.java index 4113c4314..c0166b05d 100644 --- a/src/org/traccar/protocol/OrionProtocol.java +++ b/src/org/traccar/protocol/OrionProtocol.java @@ -31,7 +31,7 @@ public class OrionProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new OrionFrameDecoder()); diff --git a/src/org/traccar/protocol/OsmAndProtocol.java b/src/org/traccar/protocol/OsmAndProtocol.java index 3b473c435..7f5318576 100644 --- a/src/org/traccar/protocol/OsmAndProtocol.java +++ b/src/org/traccar/protocol/OsmAndProtocol.java @@ -32,7 +32,7 @@ public class OsmAndProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("httpEncoder", new HttpResponseEncoder()); diff --git a/src/org/traccar/protocol/PathAwayProtocol.java b/src/org/traccar/protocol/PathAwayProtocol.java index d7efdfaf6..2583670a2 100644 --- a/src/org/traccar/protocol/PathAwayProtocol.java +++ b/src/org/traccar/protocol/PathAwayProtocol.java @@ -32,7 +32,7 @@ public class PathAwayProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("httpEncoder", new HttpResponseEncoder()); diff --git a/src/org/traccar/protocol/PiligrimProtocol.java b/src/org/traccar/protocol/PiligrimProtocol.java index 11aafa412..0ab529d5c 100644 --- a/src/org/traccar/protocol/PiligrimProtocol.java +++ b/src/org/traccar/protocol/PiligrimProtocol.java @@ -33,7 +33,7 @@ public class PiligrimProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("httpEncoder", new HttpResponseEncoder()); diff --git a/src/org/traccar/protocol/ProgressProtocol.java b/src/org/traccar/protocol/ProgressProtocol.java index 35bdf9c9b..3fb702b7b 100644 --- a/src/org/traccar/protocol/ProgressProtocol.java +++ b/src/org/traccar/protocol/ProgressProtocol.java @@ -32,7 +32,7 @@ public class ProgressProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0)); diff --git a/src/org/traccar/protocol/Pt3000Protocol.java b/src/org/traccar/protocol/Pt3000Protocol.java index 3a22be214..c4cb4129d 100644 --- a/src/org/traccar/protocol/Pt3000Protocol.java +++ b/src/org/traccar/protocol/Pt3000Protocol.java @@ -33,7 +33,7 @@ public class Pt3000Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, 'd')); // probably wrong diff --git a/src/org/traccar/protocol/Pt502Protocol.java b/src/org/traccar/protocol/Pt502Protocol.java index 1368dd7b7..b609927ac 100644 --- a/src/org/traccar/protocol/Pt502Protocol.java +++ b/src/org/traccar/protocol/Pt502Protocol.java @@ -39,7 +39,7 @@ public class Pt502Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new Pt502FrameDecoder()); diff --git a/src/org/traccar/protocol/RaveonProtocol.java b/src/org/traccar/protocol/RaveonProtocol.java index 551f1683f..a81d52f0e 100644 --- a/src/org/traccar/protocol/RaveonProtocol.java +++ b/src/org/traccar/protocol/RaveonProtocol.java @@ -33,7 +33,7 @@ public class RaveonProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/RitiProtocol.java b/src/org/traccar/protocol/RitiProtocol.java index e968032ca..8a39c29e1 100644 --- a/src/org/traccar/protocol/RitiProtocol.java +++ b/src/org/traccar/protocol/RitiProtocol.java @@ -32,7 +32,7 @@ public class RitiProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 105, 2, 3, 0)); diff --git a/src/org/traccar/protocol/RuptelaProtocol.java b/src/org/traccar/protocol/RuptelaProtocol.java index d806c4c01..1fe7b02ad 100644 --- a/src/org/traccar/protocol/RuptelaProtocol.java +++ b/src/org/traccar/protocol/RuptelaProtocol.java @@ -34,7 +34,7 @@ public class RuptelaProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, 2, 0)); diff --git a/src/org/traccar/protocol/SanavProtocol.java b/src/org/traccar/protocol/SanavProtocol.java index bb329ab70..0e7958b8e 100644 --- a/src/org/traccar/protocol/SanavProtocol.java +++ b/src/org/traccar/protocol/SanavProtocol.java @@ -33,7 +33,7 @@ public class SanavProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*')); diff --git a/src/org/traccar/protocol/SkypatrolProtocol.java b/src/org/traccar/protocol/SkypatrolProtocol.java index 2791ba082..7d8240294 100644 --- a/src/org/traccar/protocol/SkypatrolProtocol.java +++ b/src/org/traccar/protocol/SkypatrolProtocol.java @@ -30,7 +30,7 @@ public class SkypatrolProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(SkypatrolProtocol.this)); diff --git a/src/org/traccar/protocol/Stl060Protocol.java b/src/org/traccar/protocol/Stl060Protocol.java index e37f94b00..ccdd256d7 100644 --- a/src/org/traccar/protocol/Stl060Protocol.java +++ b/src/org/traccar/protocol/Stl060Protocol.java @@ -32,7 +32,7 @@ public class Stl060Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new Stl060FrameDecoder(1024)); diff --git a/src/org/traccar/protocol/SuntechProtocol.java b/src/org/traccar/protocol/SuntechProtocol.java index 4a40e1bfc..df6109722 100644 --- a/src/org/traccar/protocol/SuntechProtocol.java +++ b/src/org/traccar/protocol/SuntechProtocol.java @@ -40,7 +40,7 @@ public class SuntechProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r')); diff --git a/src/org/traccar/protocol/SupermateProtocol.java b/src/org/traccar/protocol/SupermateProtocol.java index bcc2bed16..70c3c00e6 100755 --- a/src/org/traccar/protocol/SupermateProtocol.java +++ b/src/org/traccar/protocol/SupermateProtocol.java @@ -33,7 +33,7 @@ public class SupermateProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "#")); diff --git a/src/org/traccar/protocol/T55Protocol.java b/src/org/traccar/protocol/T55Protocol.java index 86f927e41..657155042 100644 --- a/src/org/traccar/protocol/T55Protocol.java +++ b/src/org/traccar/protocol/T55Protocol.java @@ -34,7 +34,7 @@ public class T55Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); @@ -43,7 +43,7 @@ public class T55Protocol extends BaseProtocol { pipeline.addLast("objectDecoder", new T55ProtocolDecoder(T55Protocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringDecoder", new StringDecoder()); diff --git a/src/org/traccar/protocol/TaipProtocol.java b/src/org/traccar/protocol/TaipProtocol.java index e72639099..8b93eb42d 100644 --- a/src/org/traccar/protocol/TaipProtocol.java +++ b/src/org/traccar/protocol/TaipProtocol.java @@ -34,7 +34,7 @@ public class TaipProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '<')); @@ -43,7 +43,7 @@ public class TaipProtocol extends BaseProtocol { pipeline.addLast("objectDecoder", new TaipProtocolDecoder(TaipProtocol.this, true)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringDecoder", new StringDecoder()); diff --git a/src/org/traccar/protocol/TelicProtocol.java b/src/org/traccar/protocol/TelicProtocol.java index 1e27620ba..b55e16caf 100644 --- a/src/org/traccar/protocol/TelicProtocol.java +++ b/src/org/traccar/protocol/TelicProtocol.java @@ -33,7 +33,7 @@ public class TelicProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new TelicFrameDecoder()); diff --git a/src/org/traccar/protocol/TeltonikaProtocol.java b/src/org/traccar/protocol/TeltonikaProtocol.java index 5a550d4c0..c9c0f0f4d 100644 --- a/src/org/traccar/protocol/TeltonikaProtocol.java +++ b/src/org/traccar/protocol/TeltonikaProtocol.java @@ -34,7 +34,7 @@ public class TeltonikaProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new TeltonikaFrameDecoder()); @@ -42,7 +42,7 @@ public class TeltonikaProtocol extends BaseProtocol { pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder()); diff --git a/src/org/traccar/protocol/ThinkRaceProtocol.java b/src/org/traccar/protocol/ThinkRaceProtocol.java index c9d6c7fc1..add7d33d3 100644 --- a/src/org/traccar/protocol/ThinkRaceProtocol.java +++ b/src/org/traccar/protocol/ThinkRaceProtocol.java @@ -31,7 +31,7 @@ public class ThinkRaceProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2 + 12 + 1 + 1, 2, 2, 0)); diff --git a/src/org/traccar/protocol/Tk102Protocol.java b/src/org/traccar/protocol/Tk102Protocol.java index 1f4eda730..7310d23bd 100644 --- a/src/org/traccar/protocol/Tk102Protocol.java +++ b/src/org/traccar/protocol/Tk102Protocol.java @@ -33,7 +33,7 @@ public class Tk102Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ']')); diff --git a/src/org/traccar/protocol/Tk103Protocol.java b/src/org/traccar/protocol/Tk103Protocol.java index b14264091..3fe82ad8b 100644 --- a/src/org/traccar/protocol/Tk103Protocol.java +++ b/src/org/traccar/protocol/Tk103Protocol.java @@ -34,7 +34,7 @@ public class Tk103Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')')); @@ -43,7 +43,7 @@ public class Tk103Protocol extends BaseProtocol { pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(Tk103Protocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringDecoder", new StringDecoder()); diff --git a/src/org/traccar/protocol/Tlt2hProtocol.java b/src/org/traccar/protocol/Tlt2hProtocol.java index 3a1bf99ff..e33b1b561 100644 --- a/src/org/traccar/protocol/Tlt2hProtocol.java +++ b/src/org/traccar/protocol/Tlt2hProtocol.java @@ -33,7 +33,7 @@ public class Tlt2hProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(32 * 1024, "##\r\n")); diff --git a/src/org/traccar/protocol/TopflytechProtocol.java b/src/org/traccar/protocol/TopflytechProtocol.java index ae250ad02..225cb66d7 100644 --- a/src/org/traccar/protocol/TopflytechProtocol.java +++ b/src/org/traccar/protocol/TopflytechProtocol.java @@ -33,7 +33,7 @@ public class TopflytechProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')')); diff --git a/src/org/traccar/protocol/TotemProtocol.java b/src/org/traccar/protocol/TotemProtocol.java index e573adcc6..638755b7f 100644 --- a/src/org/traccar/protocol/TotemProtocol.java +++ b/src/org/traccar/protocol/TotemProtocol.java @@ -37,7 +37,7 @@ public class TotemProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new TotemFrameDecoder()); diff --git a/src/org/traccar/protocol/Tr20Protocol.java b/src/org/traccar/protocol/Tr20Protocol.java index 4e55d5f98..1c47db86a 100644 --- a/src/org/traccar/protocol/Tr20Protocol.java +++ b/src/org/traccar/protocol/Tr20Protocol.java @@ -33,7 +33,7 @@ public class Tr20Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/TrackboxProtocol.java b/src/org/traccar/protocol/TrackboxProtocol.java index 5477de852..b71eb3810 100644 --- a/src/org/traccar/protocol/TrackboxProtocol.java +++ b/src/org/traccar/protocol/TrackboxProtocol.java @@ -33,7 +33,7 @@ public class TrackboxProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/TramigoProtocol.java b/src/org/traccar/protocol/TramigoProtocol.java index 48892a78e..ea4ea7140 100644 --- a/src/org/traccar/protocol/TramigoProtocol.java +++ b/src/org/traccar/protocol/TramigoProtocol.java @@ -31,7 +31,7 @@ public class TramigoProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - TrackerServer server = new TrackerServer(new ServerBootstrap(), this.getName()) { + TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new TramigoFrameDecoder()); diff --git a/src/org/traccar/protocol/TrvProtocol.java b/src/org/traccar/protocol/TrvProtocol.java index af598ea02..585cb7cf6 100644 --- a/src/org/traccar/protocol/TrvProtocol.java +++ b/src/org/traccar/protocol/TrvProtocol.java @@ -33,7 +33,7 @@ public class TrvProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#')); diff --git a/src/org/traccar/protocol/Tt8850Protocol.java b/src/org/traccar/protocol/Tt8850Protocol.java index db41fae9f..5d188de60 100644 --- a/src/org/traccar/protocol/Tt8850Protocol.java +++ b/src/org/traccar/protocol/Tt8850Protocol.java @@ -33,7 +33,7 @@ public class Tt8850Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "$")); diff --git a/src/org/traccar/protocol/TytanProtocol.java b/src/org/traccar/protocol/TytanProtocol.java index 50918652a..b6608f925 100644 --- a/src/org/traccar/protocol/TytanProtocol.java +++ b/src/org/traccar/protocol/TytanProtocol.java @@ -30,7 +30,7 @@ public class TytanProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("objectDecoder", new TytanProtocolDecoder(TytanProtocol.this)); diff --git a/src/org/traccar/protocol/TzoneProtocol.java b/src/org/traccar/protocol/TzoneProtocol.java index fcf673a57..ca3e490d2 100644 --- a/src/org/traccar/protocol/TzoneProtocol.java +++ b/src/org/traccar/protocol/TzoneProtocol.java @@ -31,7 +31,7 @@ public class TzoneProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2, 2, 0)); diff --git a/src/org/traccar/protocol/UlbotechProtocol.java b/src/org/traccar/protocol/UlbotechProtocol.java index d0413ecbe..ca31dffc9 100644 --- a/src/org/traccar/protocol/UlbotechProtocol.java +++ b/src/org/traccar/protocol/UlbotechProtocol.java @@ -30,7 +30,7 @@ public class UlbotechProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new UlbotechFrameDecoder()); diff --git a/src/org/traccar/protocol/UproProtocol.java b/src/org/traccar/protocol/UproProtocol.java index b62247761..8f940fa15 100644 --- a/src/org/traccar/protocol/UproProtocol.java +++ b/src/org/traccar/protocol/UproProtocol.java @@ -33,7 +33,7 @@ public class UproProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#')); diff --git a/src/org/traccar/protocol/V680Protocol.java b/src/org/traccar/protocol/V680Protocol.java index 4edff3772..83157790d 100644 --- a/src/org/traccar/protocol/V680Protocol.java +++ b/src/org/traccar/protocol/V680Protocol.java @@ -34,7 +34,7 @@ public class V680Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##")); @@ -43,7 +43,7 @@ public class V680Protocol extends BaseProtocol { pipeline.addLast("objectDecoder", new V680ProtocolDecoder(V680Protocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringDecoder", new StringDecoder()); diff --git a/src/org/traccar/protocol/VisiontekProtocol.java b/src/org/traccar/protocol/VisiontekProtocol.java index 2d2a41e89..dde906370 100644 --- a/src/org/traccar/protocol/VisiontekProtocol.java +++ b/src/org/traccar/protocol/VisiontekProtocol.java @@ -33,7 +33,7 @@ public class VisiontekProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#')); diff --git a/src/org/traccar/protocol/WatchProtocol.java b/src/org/traccar/protocol/WatchProtocol.java index 3392e8cbc..8f28916f0 100644 --- a/src/org/traccar/protocol/WatchProtocol.java +++ b/src/org/traccar/protocol/WatchProtocol.java @@ -45,7 +45,7 @@ public class WatchProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ']')); diff --git a/src/org/traccar/protocol/WialonProtocol.java b/src/org/traccar/protocol/WialonProtocol.java index e0255c888..98af6973b 100644 --- a/src/org/traccar/protocol/WialonProtocol.java +++ b/src/org/traccar/protocol/WialonProtocol.java @@ -41,7 +41,7 @@ public class WialonProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(4 * 1024)); diff --git a/src/org/traccar/protocol/WondexProtocol.java b/src/org/traccar/protocol/WondexProtocol.java index 78e090f03..54b39a5c4 100644 --- a/src/org/traccar/protocol/WondexProtocol.java +++ b/src/org/traccar/protocol/WondexProtocol.java @@ -37,7 +37,7 @@ public class WondexProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new WondexFrameDecoder()); @@ -46,7 +46,7 @@ public class WondexProtocol extends BaseProtocol { pipeline.addLast("objectDecoder", new WondexProtocolDecoder(WondexProtocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringEncoder", new StringEncoder()); diff --git a/src/org/traccar/protocol/XexunProtocol.java b/src/org/traccar/protocol/XexunProtocol.java index 14afaf4cb..ecaf18db4 100644 --- a/src/org/traccar/protocol/XexunProtocol.java +++ b/src/org/traccar/protocol/XexunProtocol.java @@ -34,7 +34,7 @@ public class XexunProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { boolean full = Context.getConfig().getBoolean(getName() + ".extended"); diff --git a/src/org/traccar/protocol/XirgoProtocol.java b/src/org/traccar/protocol/XirgoProtocol.java index c5ef27f54..9298f71ad 100644 --- a/src/org/traccar/protocol/XirgoProtocol.java +++ b/src/org/traccar/protocol/XirgoProtocol.java @@ -34,7 +34,7 @@ public class XirgoProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##")); @@ -43,7 +43,7 @@ public class XirgoProtocol extends BaseProtocol { pipeline.addLast("objectDecoder", new XirgoProtocolDecoder(XirgoProtocol.this)); } }); - serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("stringEncoder", new StringEncoder()); diff --git a/src/org/traccar/protocol/Xt013Protocol.java b/src/org/traccar/protocol/Xt013Protocol.java index b11256b7d..db9d21333 100644 --- a/src/org/traccar/protocol/Xt013Protocol.java +++ b/src/org/traccar/protocol/Xt013Protocol.java @@ -33,7 +33,7 @@ public class Xt013Protocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); diff --git a/src/org/traccar/protocol/YwtProtocol.java b/src/org/traccar/protocol/YwtProtocol.java index 3fa154ec0..e24c8b02e 100644 --- a/src/org/traccar/protocol/YwtProtocol.java +++ b/src/org/traccar/protocol/YwtProtocol.java @@ -33,7 +33,7 @@ public class YwtProtocol extends BaseProtocol { @Override public void initTrackerServers(List serverList) { - serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); -- cgit v1.2.3 From 722327b482e51d8b48fd4bab1e6a27fe972fc167 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 15 Sep 2016 08:20:45 +1200 Subject: Implement AutoGrade device protocol --- debug.xml | 1 + src/org/traccar/protocol/AutoGradeProtocol.java | 47 ++++++++++ .../traccar/protocol/AutoGradeProtocolDecoder.java | 102 +++++++++++++++++++++ .../protocol/AutoGradeProtocolDecoderTest.java | 18 ++++ 4 files changed, 168 insertions(+) create mode 100644 src/org/traccar/protocol/AutoGradeProtocol.java create mode 100644 src/org/traccar/protocol/AutoGradeProtocolDecoder.java create mode 100644 test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java (limited to 'src/org/traccar/protocol') diff --git a/debug.xml b/debug.xml index 2c2d0b334..b9b32a639 100644 --- a/debug.xml +++ b/debug.xml @@ -454,5 +454,6 @@ 5117 5118 5119 + 5120 diff --git a/src/org/traccar/protocol/AutoGradeProtocol.java b/src/org/traccar/protocol/AutoGradeProtocol.java new file mode 100644 index 000000000..1fb6b1ce2 --- /dev/null +++ b/src/org/traccar/protocol/AutoGradeProtocol.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.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 AutoGradeProtocol extends BaseProtocol { + + public AutoGradeProtocol() { + super("autograde"); + } + + @Override + public void initTrackerServers(List serverList) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')')); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("stringEncoder", new StringEncoder()); + pipeline.addLast("objectDecoder", new AutoGradeProtocolDecoder(AutoGradeProtocol.this)); + } + }); + } + +} diff --git a/src/org/traccar/protocol/AutoGradeProtocolDecoder.java b/src/org/traccar/protocol/AutoGradeProtocolDecoder.java new file mode 100644 index 000000000..5c9dd7ece --- /dev/null +++ b/src/org/traccar/protocol/AutoGradeProtocolDecoder.java @@ -0,0 +1,102 @@ +/* + * 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.channel.Channel; +import org.traccar.BaseProtocolDecoder; +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 java.net.SocketAddress; +import java.util.regex.Pattern; + +public class AutoGradeProtocolDecoder extends BaseProtocolDecoder { + + public AutoGradeProtocolDecoder(AutoGradeProtocol protocol) { + super(protocol); + } + + private static final Pattern PATTERN = new PatternBuilder() + .text("(") + .number("d{12}") // index + .number("(d{15})") // imei + .number("(dd)(dd)(dd)") // date + .expression("([AV])") // validity + .number("(d+)(dd.d+)([NS])") // latitude + .number("(d+)(dd.d+)([EW])") // longitude + .number("([d.]{5})") // speed + .number("(dd)(dd)(dd)") // time + .number("([d.]{6})") // course + .expression(".") // status + .number("A(xxxx)") + .number("B(xxxx)") + .number("C(xxxx)") + .number("D(xxxx)") + .number("E(xxxx)") + .number("K(xxxx)") + .number("L(xxxx)") + .number("M(xxxx)") + .number("N(xxxx)") + .number("O(xxxx)") + .any() + .compile(); + + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + Parser parser = new Parser(PATTERN, (String) msg); + if (!parser.matches()) { + return null; + } + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession == null) { + return null; + } + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + DateBuilder dateBuilder = new DateBuilder() + .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()); + + position.setValid(parser.next().equals("A")); + position.setLatitude(parser.nextCoordinate()); + position.setLongitude(parser.nextCoordinate()); + position.setSpeed(parser.nextDouble()); + + dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + position.setCourse(parser.nextDouble()); + + for (int i = 1; i <= 5; i++) { + position.set(Position.PREFIX_ADC + i, parser.next()); + } + + for (int i = 1; i <= 5; i++) { + position.set("can" + i, parser.next()); + } + + return position; + } + +} diff --git a/test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java b/test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java new file mode 100644 index 000000000..58e2e4065 --- /dev/null +++ b/test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java @@ -0,0 +1,18 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class AutoGradeProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + AutoGradeProtocolDecoder decoder = new AutoGradeProtocolDecoder(new AutoGradeProtocol()); + + verifyPosition(decoder, text( + "(000000007322865733022629240170415A1001.1971N07618.1375E0.000145312128.59?A0024B0024C0000D0000E0000K0000L0000M0000N0000O0000")); + + } + +} -- cgit v1.2.3 From 3c634fb3c10f8d560b03f87d333ca3cc26281a8a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 16 Sep 2016 01:53:43 +1200 Subject: Decode H02 battery percentage --- src/org/traccar/protocol/H02ProtocolDecoder.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index a0c646900..f876f40bc 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -79,6 +79,23 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_STATUS, status); } + private String decodeBattery(int value) { + switch (value) { + case 6: + return "100%"; + case 5: + return "80%"; + case 4: + return "60%"; + case 3: + return "20%"; + case 2: + return "10%"; + default: + return null; + } + } + private Position decodeBinary(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { Position position = new Position(); @@ -103,7 +120,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setTime(dateBuilder.getDate()); double latitude = readCoordinate(buf, false); - position.set(Position.KEY_POWER, buf.readByte()); + position.set(Position.KEY_BATTERY, decodeBattery(buf.readUnsignedByte())); double longitude = readCoordinate(buf, true); int flags = buf.readUnsignedByte() & 0x0f; -- cgit v1.2.3 From d18e293a891c3ef1f3ab2ff9a3b663320a7f4f0b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 16 Sep 2016 17:36:45 +1200 Subject: Implement SinoCastel OBD decoding --- src/org/traccar/helper/ObdDecoder.java | 23 ++-- .../traccar/protocol/CastelProtocolDecoder.java | 130 ++++++++++++++++++--- .../protocol/CastelProtocolDecoderTest.java | 16 +-- 3 files changed, 131 insertions(+), 38 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/helper/ObdDecoder.java b/src/org/traccar/helper/ObdDecoder.java index 6ffe39662..8383a2b1a 100644 --- a/src/org/traccar/helper/ObdDecoder.java +++ b/src/org/traccar/helper/ObdDecoder.java @@ -42,7 +42,9 @@ public final class ObdDecoder { switch (mode) { case MODE_CURRENT: case MODE_FREEZE_FRAME: - return decodeData(Integer.parseInt(value.substring(0, 2), 16), value.substring(2)); + return decodeData( + Integer.parseInt(value.substring(0, 2), 16), + Integer.parseInt(value.substring(2), 16)); case MODE_CODES: return decodeCodes(value); default: @@ -82,25 +84,24 @@ public final class ObdDecoder { } } - private static Map.Entry decodeData(int pid, String value) { - int intValue = Integer.parseInt(value, 16); + public static Map.Entry decodeData(int pid, int value) { switch (pid) { case PID_ENGINE_LOAD: - return createEntry("engineLoad", intValue * 100 / 255); + return createEntry("engineLoad", value * 100 / 255); case PID_COOLANT_TEMPERATURE: - return createEntry("coolantTemperature", intValue - 40); + return createEntry("coolantTemperature", value - 40); case PID_ENGINE_RPM: - return createEntry(Position.KEY_RPM, intValue / 4); + return createEntry(Position.KEY_RPM, value / 4); case PID_VEHICLE_SPEED: - return createEntry(Position.KEY_OBD_SPEED, intValue); + return createEntry(Position.KEY_OBD_SPEED, value); case PID_THROTTLE_POSITION: - return createEntry("throttle", intValue * 100 / 255); + return createEntry("throttle", value * 100 / 255); case PID_MIL_DISTANCE: - return createEntry("milDistance", intValue); + return createEntry("milDistance", value); case PID_FUEL_LEVEL: - return createEntry(Position.KEY_FUEL, intValue * 100 / 255); + return createEntry(Position.KEY_FUEL, value * 100 / 255); case PID_DISTANCE_CLEARED: - return createEntry("clearedDistance", intValue); + return createEntry("clearedDistance", value); default: return null; } diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index b8faed077..ee5fac5e6 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -29,11 +29,46 @@ import org.traccar.model.Position; import java.net.SocketAddress; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; public class CastelProtocolDecoder extends BaseProtocolDecoder { + private static final Map PID_LENGTH_MAP = new HashMap<>(); + + static { + int[] l1 = { + 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0b, 0x0d, + 0x0e, 0x0f, 0x11, 0x12, 0x13, 0x1c, 0x1d, 0x1e, 0x2c, + 0x2d, 0x2e, 0x2f, 0x30, 0x33, 0x43, 0x45, 0x46, + 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x51, 0x52, + 0x5a + }; + int[] l2 = { + 0x02, 0x03, 0x0a, 0x0c, 0x10, 0x14, 0x15, 0x16, + 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1f, 0x21, 0x22, + 0x23, 0x31, 0x32, 0x3c, 0x3d, 0x3e, 0x3f, 0x42, + 0x44, 0x4d, 0x4e, 0x50, 0x53, 0x54, 0x55, 0x56, + 0x57, 0x58, 0x59 + }; + int[] l4 = { + 0x00, 0x01, 0x20, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x3a, 0x3b, 0x40, 0x41, 0x4f + }; + for (int i : l1) { + PID_LENGTH_MAP.put(i, 1); + } + for (int i : l2) { + PID_LENGTH_MAP.put(i, 2); + } + for (int i : l4) { + PID_LENGTH_MAP.put(i, 4); + } + } + public CastelProtocolDecoder(CastelProtocol protocol) { super(protocol); } @@ -91,6 +126,63 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { return position; } + private Position createPosition(DeviceSession deviceSession) { + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + getLastLocation(position, null); + + return position; + } + + private void decodeObd(Position position, ChannelBuffer buf, boolean groups) { + + int count = buf.readUnsignedByte(); + + int[] pids = new int[count]; + for (int i = 0; i < count; i++) { + pids[i] = buf.readUnsignedShort() & 0xff; + } + + if (groups) { + buf.readUnsignedByte(); // group count + buf.readUnsignedByte(); // group size + } + + for (int i = 0; i < count; i++) { + int value; + switch (PID_LENGTH_MAP.get(pids[i])) { + case 1: + value = buf.readUnsignedByte(); + break; + case 2: + value = buf.readUnsignedShort(); + break; + case 4: + value = buf.readInt(); + break; + default: + value = 0; + break; + } + position.add(ObdDecoder.decodeData(pids[i], value)); + } + } + + private void decodeStat(Position position, ChannelBuffer buf) { + + buf.readUnsignedInt(); // ACC ON time + buf.readUnsignedInt(); // UTC time + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt()); + buf.readUnsignedInt(); // trip odometer + buf.readUnsignedInt(); // total fuel consumption + buf.readUnsignedShort(); // current fuel consumption + position.set(Position.KEY_STATUS, buf.readUnsignedInt()); + buf.skipBytes(8); + } + private void sendResponse( Channel channel, SocketAddress remoteAddress, int version, ChannelBuffer id, short type, ChannelBuffer content) { @@ -200,15 +292,22 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { return readPosition(deviceSession, buf); - } else if (type == MSG_SC_DTCS_PASSENGER) { + } else if (type == MSG_SC_PID_DATA) { - Position position = new Position(); - position.setProtocol(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); + Position position = createPosition(deviceSession); - getLastLocation(position, null); + decodeStat(position, buf); - buf.skipBytes(6 * 4 + 2 + 8); + buf.readUnsignedShort(); // sample rate + decodeObd(position, buf, true); + + return position; + + } else if (type == MSG_SC_DTCS_PASSENGER) { + + Position position = createPosition(deviceSession); + + decodeStat(position, buf); buf.readUnsignedByte(); // flag position.add(ObdDecoder.decodeCodes(ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedByte())))); @@ -217,27 +316,20 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { } else if (type == MSG_SC_OBD_DATA) { - Position position = new Position(); - position.setProtocol(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - - getLastLocation(position, null); + Position position = createPosition(deviceSession); - buf.skipBytes(6 * 4 + 2 + 8); + decodeStat(position, buf); - // decode data + buf.readUnsignedByte(); // flag + decodeObd(position, buf, false); return position; } else if (type == MSG_SC_CELL) { - Position position = new Position(); - position.setProtocol(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - - getLastLocation(position, null); + Position position = createPosition(deviceSession); - buf.skipBytes(6 * 4 + 2 + 8); + decodeStat(position, buf); position.set(Position.KEY_LAC, buf.readUnsignedShort()); position.set(Position.KEY_CID, buf.readUnsignedShort()); diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java index ccdd6f726..e2f2c26bf 100644 --- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java @@ -12,16 +12,16 @@ public class CastelProtocolDecoderTest extends ProtocolTest { CastelProtocolDecoder decoder = new CastelProtocolDecoder(new CastelProtocol()); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40405700043231334e583230313630303131373700000000004002c458ce572159ce57a9e2020082030000500c00000f0000000400036401240e0403023c000505210c210d210f21102101075b14030121330269430d0a")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40407800043231334e583230313630303131373700000000004004fa52ce574b53ce57cad1020041020000050c00000d0000000400036401240b0503001b042105210c210d210f211021112113211c211f212121232124212c212d213021312133213e2141214221452149214a214c214f215021384e0d0a")); - verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040a600043231334e583230313630303131373700000000004005fa52ce575053ce57cad102006b020000050c00000d0000000400036401240b050300001b042105210c210d210f211021112113211c211f212121232124212c212d213021312133213e2141214221452149214a214c214f215021015bd604301f500600000653000000bc0bffff78250000ff2d98642401000f8080e038000f0f0000000000000077b10d0a")); - verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40404300043231334e583230313630303131373700000000004006fa52ce574e53ce57cad1020053020000050c00000d0000000400036401240b0503000000feec0d0a")); verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, @@ -48,16 +48,16 @@ public class CastelProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40406000043130303131313235323939383700000000000000400705000000C1F0695249F469529C9111000000000069830000D80040000400036401014C04030001190A0D04201E1480D60488C5721800000000AF0101060F000F00EA1E0D0A")); - verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "404057000431303031313132353239393837000000000000004002C1F06952F0F169529C9111000000000069830000470000000400036401014C01030078000505210C210D210F21102101073BE8030064280AEB930D0A")); verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40405900043130303131313235323939383700000000000000400101C1F06952E7F069529C9111000000000069830000070000000400036401014C00030001190A0D0412041480D60488C57218000000009F01E803ED9A0D0A")); - verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040B9000431303031313132353239393837000000000000004005C1F069521BF169529C9111000000000069830000130000000400036401014C0003000022032104210521062107210C210D210E210F2110211121132115211C211F21212124212E212F2130213121322133213C214221432144214521472149214A214C214D214E210100643B6232E803003E64280A3C24FE00010E010F00D5805A483C640000000000010000E02E000000066400000500000000A7710D0A")); - verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "404043000431303031313132353239393837000000000000004006C1F0695209F169529C91110000000000698300000D0000000400036401014C00030000009AF40D0A")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, @@ -72,7 +72,7 @@ public class CastelProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, "40405c000c363131313530303030393536000000000000000040011c0a0f0e362dca53cd0860831303000000000300000000ff000000000000007ba083a650542d3639305f56312e312e320050542d3639302056312e32008a020d0a")); - verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040450004323132474c31313433303035303033000000000040082ca89b55a6a99b555c57000000000000c40200000b0000001400036401111f000302f5533bd653f10d0a")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, @@ -81,7 +81,7 @@ public class CastelProtocolDecoderTest extends ProtocolTest { verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040420004323132474c31313433303035303033000000000010022ca89b55cca99b555c57000000000000cf0200000b0000000000036401111f0000020013be0d0a")); - verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN, + verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040870004323132474c31313433303035303033000000000040052ca89b55e3a89b555c57000000000000c4020000040000001400036401111f0003000012042105210b210c210d210f211021112113211c2121212321242133213421422146214f212b50663603003ce9030dff060000600dffffc25865ffff9e02b43624000000003cbc0d0a")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, -- cgit v1.2.3 From 9ea807ed8d651d78b31ef28a81a9fce2c7a91d48 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 16 Sep 2016 17:52:03 +1200 Subject: Use same code formatting for switches --- .../notification/NotificationFormatter.java | 16 +++---- .../traccar/protocol/EelinkProtocolDecoder.java | 50 +++++++++++----------- src/org/traccar/protocol/GnxProtocolDecoder.java | 19 +++----- .../traccar/protocol/Gps103ProtocolDecoder.java | 28 ++++++------ .../traccar/protocol/GranitProtocolEncoder.java | 24 +++++------ src/org/traccar/protocol/Gt06ProtocolDecoder.java | 40 ++++++++--------- .../traccar/protocol/MegastekProtocolDecoder.java | 50 +++++++++++----------- .../traccar/protocol/MeiligaoProtocolDecoder.java | 32 +++++++------- src/org/traccar/protocol/NoranProtocolDecoder.java | 28 ++++++------ src/org/traccar/protocol/T800xProtocolDecoder.java | 26 +++++------ src/org/traccar/protocol/Tk103ProtocolDecoder.java | 28 ++++++------ src/org/traccar/protocol/TotemProtocolDecoder.java | 24 +++++------ src/org/traccar/protocol/TzoneProtocolDecoder.java | 24 +++++------ .../traccar/protocol/WialonProtocolEncoder.java | 22 +++++----- .../traccar/protocol/WondexProtocolEncoder.java | 18 ++++---- src/org/traccar/protocol/XexunProtocolDecoder.java | 18 ++++---- src/org/traccar/reports/ReportUtils.java | 16 +++---- 17 files changed, 228 insertions(+), 235 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java index fb8019900..ae1a58d3a 100644 --- a/src/org/traccar/notification/NotificationFormatter.java +++ b/src/org/traccar/notification/NotificationFormatter.java @@ -201,14 +201,14 @@ public final class NotificationFormatter { DecimalFormat df = new DecimalFormat("#.##"); String result = df.format(speed) + " kn"; switch (Context.getPermissionsManager().getUser(userId).getSpeedUnit()) { - case "kmh": - result = df.format(UnitsConverter.kphFromKnots(speed)) + " km/h"; - break; - case "mph": - result = df.format(UnitsConverter.mphFromKnots(speed)) + " mph"; - break; - default: - break; + case "kmh": + result = df.format(UnitsConverter.kphFromKnots(speed)) + " km/h"; + break; + case "mph": + result = df.format(UnitsConverter.mphFromKnots(speed)) + " mph"; + break; + default: + break; } return result; } diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java index 7403fd18a..87d706aff 100644 --- a/src/org/traccar/protocol/EelinkProtocolDecoder.java +++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java @@ -66,31 +66,31 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(Short value) { switch (value) { - case 0x01: - return Position.ALARM_POWER_OFF; - case 0x02: - return Position.ALARM_SOS; - case 0x03: - return Position.ALARM_LOW_BATTERY; - case 0x04: - return Position.ALARM_VIBRATION; - case 0x08: - case 0x09: - return Position.ALARM_GPS_ANTENNA_CUT; - case 0x81: - return Position.ALARM_LOW_SPEED; - case 0x82: - return Position.ALARM_OVERSPEED; - case 0x83: - return Position.ALARM_GEOFENCE_ENTER; - case 0x84: - return Position.ALARM_GEOFENCE_EXIT; - case 0x85: - return Position.ALARM_ACCIDENT; - case 0x86: - return Position.ALARM_FALL_DOWN; - default: - return null; + case 0x01: + return Position.ALARM_POWER_OFF; + case 0x02: + return Position.ALARM_SOS; + case 0x03: + return Position.ALARM_LOW_BATTERY; + case 0x04: + return Position.ALARM_VIBRATION; + case 0x08: + case 0x09: + return Position.ALARM_GPS_ANTENNA_CUT; + case 0x81: + return Position.ALARM_LOW_SPEED; + case 0x82: + return Position.ALARM_OVERSPEED; + case 0x83: + return Position.ALARM_GEOFENCE_ENTER; + case 0x84: + return Position.ALARM_GEOFENCE_EXIT; + case 0x85: + return Position.ALARM_ACCIDENT; + case 0x86: + return Position.ALARM_FALL_DOWN; + default: + return null; } } diff --git a/src/org/traccar/protocol/GnxProtocolDecoder.java b/src/org/traccar/protocol/GnxProtocolDecoder.java index a2ee5ae48..b88d306a8 100644 --- a/src/org/traccar/protocol/GnxProtocolDecoder.java +++ b/src/org/traccar/protocol/GnxProtocolDecoder.java @@ -71,13 +71,10 @@ public class GnxProtocolDecoder extends BaseProtocolDecoder { String type = sentence.substring(5, 8); Pattern pattern; - switch (type) { - case "MIF": - pattern = PATTERN_MIF; - break; - default: - pattern = PATTERN_OTHER; - break; + if (type.equals("MIF")) { + pattern = PATTERN_MIF; + } else { + pattern = PATTERN_OTHER; } Parser parser = new Parser(pattern, sentence); @@ -115,12 +112,8 @@ public class GnxProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); - switch (type) { - case "MIF": - position.set(Position.KEY_RFID, parser.next()); - break; - default: - break; + if (type.equals("MIF")) { + position.set(Position.KEY_RFID, parser.next()); } return position; diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index af7efa959..1a34a6bd8 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -104,20 +104,20 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(String value) { switch (value) { - case "tracker": - return null; - case "help me": - return Position.ALARM_SOS; - case "low battery": - return Position.ALARM_LOW_BATTERY; - case "stockade": - return Position.ALARM_GEOFENCE; - case "move": - return Position.ALARM_MOVEMENT; - case "speed": - return Position.ALARM_OVERSPEED; - default: - return null; + case "tracker": + return null; + case "help me": + return Position.ALARM_SOS; + case "low battery": + return Position.ALARM_LOW_BATTERY; + case "stockade": + return Position.ALARM_GEOFENCE; + case "move": + return Position.ALARM_MOVEMENT; + case "speed": + return Position.ALARM_OVERSPEED; + default: + return null; } } diff --git a/src/org/traccar/protocol/GranitProtocolEncoder.java b/src/org/traccar/protocol/GranitProtocolEncoder.java index 961f183f5..805bfbe24 100644 --- a/src/org/traccar/protocol/GranitProtocolEncoder.java +++ b/src/org/traccar/protocol/GranitProtocolEncoder.java @@ -30,18 +30,18 @@ public class GranitProtocolEncoder extends BaseProtocolEncoder { String commandString = ""; switch (command.getType()) { - case Command.TYPE_IDENTIFICATION: - commandString = "BB+IDNT"; - break; - case Command.TYPE_REBOOT_DEVICE: - commandString = "BB+RESET"; - break; - case Command.TYPE_POSITION_SINGLE: - commandString = "BB+RRCD"; - break; - default: - Log.warning(new UnsupportedOperationException(command.getType())); - return null; + case Command.TYPE_IDENTIFICATION: + commandString = "BB+IDNT"; + break; + case Command.TYPE_REBOOT_DEVICE: + commandString = "BB+RESET"; + break; + case Command.TYPE_POSITION_SINGLE: + commandString = "BB+RRCD"; + break; + default: + Log.warning(new UnsupportedOperationException(command.getType())); + return null; } if (!commandString.isEmpty()) { ChannelBuffer commandBuf = ChannelBuffers.dynamicBuffer(); diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 10e19b131..4af814e24 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -165,26 +165,26 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(short value) { switch (value) { - case 0x01: - return Position.ALARM_SOS; - case 0x02: - return Position.ALARM_POWER_CUT; - case 0x03: - case 0x09: - return Position.ALARM_VIBRATION; - case 0x04: - return Position.ALARM_GEOFENCE_ENTER; - case 0x05: - return Position.ALARM_GEOFENCE_EXIT; - case 0x06: - return Position.ALARM_OVERSPEED; - case 0x0E: - case 0x0F: - return Position.ALARM_LOW_BATTERY; - case 0x11: - return Position.ALARM_POWER_OFF; - default: - break; + case 0x01: + return Position.ALARM_SOS; + case 0x02: + return Position.ALARM_POWER_CUT; + case 0x03: + case 0x09: + return Position.ALARM_VIBRATION; + case 0x04: + return Position.ALARM_GEOFENCE_ENTER; + case 0x05: + return Position.ALARM_GEOFENCE_EXIT; + case 0x06: + return Position.ALARM_OVERSPEED; + case 0x0E: + case 0x0F: + return Position.ALARM_LOW_BATTERY; + case 0x11: + return Position.ALARM_POWER_OFF; + default: + break; } return null; } diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java index a330947b1..3ea76536c 100644 --- a/src/org/traccar/protocol/MegastekProtocolDecoder.java +++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java @@ -343,31 +343,31 @@ public class MegastekProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(String value) { switch (value) { - case "SOS": - case "Help": - return Position.ALARM_SOS; - case "Over Speed": - case "OverSpeed": - return Position.ALARM_OVERSPEED; - case "LowSpeed": - return Position.ALARM_LOW_SPEED; - case "Low Battery": - case "LowBattery": - return Position.ALARM_LOW_BATTERY; - case "VIB": - return Position.ALARM_VIBRATION; - case "Move in": - case "Geo in": - case "Geo1 in": - case "Geo2 in": - return Position.ALARM_GEOFENCE_ENTER; - case "Move out": - case "Geo out": - case "Geo1 out": - case "Geo2 out": - return Position.ALARM_GEOFENCE_EXIT; - default: - return null; + case "SOS": + case "Help": + return Position.ALARM_SOS; + case "Over Speed": + case "OverSpeed": + return Position.ALARM_OVERSPEED; + case "LowSpeed": + return Position.ALARM_LOW_SPEED; + case "Low Battery": + case "LowBattery": + return Position.ALARM_LOW_BATTERY; + case "VIB": + return Position.ALARM_VIBRATION; + case "Move in": + case "Geo in": + case "Geo1 in": + case "Geo2 in": + return Position.ALARM_GEOFENCE_ENTER; + case "Move out": + case "Geo out": + case "Geo1 out": + case "Geo2 out": + return Position.ALARM_GEOFENCE_EXIT; + default: + return null; } } diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java index f1a87f4b7..f0e5032b4 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java @@ -173,22 +173,22 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(short value) { switch (value) { - case 0x01: - return Position.ALARM_SOS; - case 0x10: - return Position.ALARM_LOW_BATTERY; - case 0x11: - return Position.ALARM_OVERSPEED; - case 0x12: - return Position.ALARM_MOVEMENT; - case 0x13: - return Position.ALARM_GEOFENCE_ENTER; - case 0x50: - return Position.ALARM_POWER_OFF; - case 0x53: - return Position.ALARM_GPS_ANTENNA_CUT; - default: - return null; + case 0x01: + return Position.ALARM_SOS; + case 0x10: + return Position.ALARM_LOW_BATTERY; + case 0x11: + return Position.ALARM_OVERSPEED; + case 0x12: + return Position.ALARM_MOVEMENT; + case 0x13: + return Position.ALARM_GEOFENCE_ENTER; + case 0x50: + return Position.ALARM_POWER_OFF; + case 0x53: + return Position.ALARM_GPS_ANTENNA_CUT; + default: + return null; } } diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java index aaecfc1db..e062a9907 100644 --- a/src/org/traccar/protocol/NoranProtocolDecoder.java +++ b/src/org/traccar/protocol/NoranProtocolDecoder.java @@ -92,20 +92,20 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder { short alarm = buf.readUnsignedByte(); switch (alarm) { - case 1: - position.set(Position.KEY_ALARM, Position.ALARM_SOS); - break; - case 2: - position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); - break; - case 3: - position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT); - break; - case 9: - position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF); - break; - default: - break; + case 1: + position.set(Position.KEY_ALARM, Position.ALARM_SOS); + break; + case 2: + position.set(Position.KEY_ALARM, Position.ALARM_OVERSPEED); + break; + case 3: + position.set(Position.KEY_ALARM, Position.ALARM_GEOFENCE_EXIT); + break; + case 9: + position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF); + break; + default: + break; } if (newFormat) { diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java index 8301450d5..d92145e05 100644 --- a/src/org/traccar/protocol/T800xProtocolDecoder.java +++ b/src/org/traccar/protocol/T800xProtocolDecoder.java @@ -62,19 +62,19 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(short value) { switch (value) { - case 3: - return Position.ALARM_SOS; - case 4: - return Position.ALARM_OVERSPEED; - case 5: - return Position.ALARM_GEOFENCE_ENTER; - case 6: - return Position.ALARM_GEOFENCE_EXIT; - case 8: - case 10: - return Position.ALARM_VIBRATION; - default: - break; + case 3: + return Position.ALARM_SOS; + case 4: + return Position.ALARM_OVERSPEED; + case 5: + return Position.ALARM_GEOFENCE_ENTER; + case 6: + return Position.ALARM_GEOFENCE_EXIT; + case 8: + case 10: + return Position.ALARM_VIBRATION; + default: + break; } return null; } diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 7b3f44d33..c638e7f27 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -78,20 +78,20 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(int value) { switch (value) { - case 1: - return Position.ALARM_ACCIDENT; - case 2: - return Position.ALARM_SOS; - case 3: - return Position.ALARM_VIBRATION; - case 4: - return Position.ALARM_LOW_SPEED; - case 5: - return Position.ALARM_OVERSPEED; - case 6: - return Position.ALARM_GEOFENCE_EXIT; - default: - return null; + case 1: + return Position.ALARM_ACCIDENT; + case 2: + return Position.ALARM_SOS; + case 3: + return Position.ALARM_VIBRATION; + case 4: + return Position.ALARM_LOW_SPEED; + case 5: + return Position.ALARM_OVERSPEED; + case 6: + return Position.ALARM_GEOFENCE_EXIT; + default: + return null; } } diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index e7a689a8b..fbda41921 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -161,18 +161,18 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(Short value) { switch (value) { - case 0x01: - return Position.ALARM_SOS; - case 0x10: - return Position.ALARM_LOW_BATTERY; - case 0x11: - return Position.ALARM_OVERSPEED; - case 0x42: - return Position.ALARM_GEOFENCE_EXIT; - case 0x43: - return Position.ALARM_GEOFENCE_ENTER; - default: - return null; + case 0x01: + return Position.ALARM_SOS; + case 0x10: + return Position.ALARM_LOW_BATTERY; + case 0x11: + return Position.ALARM_OVERSPEED; + case 0x42: + return Position.ALARM_GEOFENCE_EXIT; + case 0x43: + return Position.ALARM_GEOFENCE_ENTER; + default: + return null; } } diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java index 4b530efa4..477dc6399 100644 --- a/src/org/traccar/protocol/TzoneProtocolDecoder.java +++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java @@ -34,18 +34,18 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(Short value) { switch (value) { - case 0x01: - return Position.ALARM_SOS; - case 0x10: - return Position.ALARM_LOW_BATTERY; - case 0x11: - return Position.ALARM_OVERSPEED; - case 0x42: - return Position.ALARM_GEOFENCE_EXIT; - case 0x43: - return Position.ALARM_GEOFENCE_ENTER; - default: - return null; + case 0x01: + return Position.ALARM_SOS; + case 0x10: + return Position.ALARM_LOW_BATTERY; + case 0x11: + return Position.ALARM_OVERSPEED; + case 0x42: + return Position.ALARM_GEOFENCE_EXIT; + case 0x43: + return Position.ALARM_GEOFENCE_ENTER; + default: + return null; } } diff --git a/src/org/traccar/protocol/WialonProtocolEncoder.java b/src/org/traccar/protocol/WialonProtocolEncoder.java index b68dacd79..d3a0fc3b9 100644 --- a/src/org/traccar/protocol/WialonProtocolEncoder.java +++ b/src/org/traccar/protocol/WialonProtocolEncoder.java @@ -25,17 +25,17 @@ public class WialonProtocolEncoder extends StringProtocolEncoder { @Override protected Object encodeCommand(Command command) { switch (command.getType()) { - case Command.TYPE_REBOOT_DEVICE: - return formatCommand(command, "reboot\r\n"); - case Command.TYPE_SEND_USSD: - return formatCommand(command, "USSD:{%s}\r\n", Command.KEY_PHONE); - case Command.TYPE_IDENTIFICATION: - return formatCommand(command, "VER?\r\n"); - case Command.TYPE_OUTPUT_CONTROL: - return formatCommand(command, "L{%s}={%s}\r\n", Command.KEY_INDEX, Command.KEY_DATA); - default: - Log.warning(new UnsupportedOperationException(command.getType())); - break; + case Command.TYPE_REBOOT_DEVICE: + return formatCommand(command, "reboot\r\n"); + case Command.TYPE_SEND_USSD: + return formatCommand(command, "USSD:{%s}\r\n", Command.KEY_PHONE); + case Command.TYPE_IDENTIFICATION: + return formatCommand(command, "VER?\r\n"); + case Command.TYPE_OUTPUT_CONTROL: + return formatCommand(command, "L{%s}={%s}\r\n", Command.KEY_INDEX, Command.KEY_DATA); + default: + Log.warning(new UnsupportedOperationException(command.getType())); + break; } return null; } diff --git a/src/org/traccar/protocol/WondexProtocolEncoder.java b/src/org/traccar/protocol/WondexProtocolEncoder.java index 918c22cda..c350838d0 100644 --- a/src/org/traccar/protocol/WondexProtocolEncoder.java +++ b/src/org/traccar/protocol/WondexProtocolEncoder.java @@ -26,15 +26,15 @@ public class WondexProtocolEncoder extends StringProtocolEncoder { initDevicePassword(command, "0000"); switch (command.getType()) { - case Command.TYPE_REBOOT_DEVICE: - return formatCommand(command, "$WP+REBOOT={%s}", Command.KEY_DEVICE_PASSWORD); - case Command.TYPE_POSITION_SINGLE: - return formatCommand(command, "$WP+GETLOCATION={%s}", Command.KEY_DEVICE_PASSWORD); - case Command.TYPE_IDENTIFICATION: - return formatCommand(command, "$WP+VER={%s}", Command.KEY_DEVICE_PASSWORD); - default: - Log.warning(new UnsupportedOperationException(command.getType())); - break; + case Command.TYPE_REBOOT_DEVICE: + return formatCommand(command, "$WP+REBOOT={%s}", Command.KEY_DEVICE_PASSWORD); + case Command.TYPE_POSITION_SINGLE: + return formatCommand(command, "$WP+GETLOCATION={%s}", Command.KEY_DEVICE_PASSWORD); + case Command.TYPE_IDENTIFICATION: + return formatCommand(command, "$WP+VER={%s}", Command.KEY_DEVICE_PASSWORD); + default: + Log.warning(new UnsupportedOperationException(command.getType())); + break; } return null; diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java index 7ec2685fa..06f255b91 100644 --- a/src/org/traccar/protocol/XexunProtocolDecoder.java +++ b/src/org/traccar/protocol/XexunProtocolDecoder.java @@ -67,15 +67,15 @@ public class XexunProtocolDecoder extends BaseProtocolDecoder { private String decodeAlarm(String value) { if (value != null) { switch (value) { - case "help me!": - return Position.ALARM_SOS; - case "low battery": - return Position.ALARM_LOW_BATTERY; - case "move!": - case "moved!": - return Position.ALARM_MOVEMENT; - default: - break; + case "help me!": + return Position.ALARM_SOS; + case "low battery": + return Position.ALARM_LOW_BATTERY; + case "move!": + case "moved!": + return Position.ALARM_MOVEMENT; + default: + break; } } return null; diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 924dff4c1..818920ad5 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -69,14 +69,14 @@ public final class ReportUtils { && lastPosition.getAttributes().get(Position.KEY_FUEL) != null) { try { switch (firstPosition.getProtocol()) { - case "meitrack": - case "galileo": - case "noran": - return new BigDecimal(firstPosition.getAttributes().get(Position.KEY_FUEL).toString()) - .subtract(new BigDecimal(lastPosition.getAttributes().get(Position.KEY_FUEL).toString())) - .setScale(2, RoundingMode.HALF_EVEN).toString() + " %"; - default: - break; + case "meitrack": + case "galileo": + case "noran": + BigDecimal v = new BigDecimal(firstPosition.getAttributes().get(Position.KEY_FUEL).toString()); + v = v.subtract(new BigDecimal(lastPosition.getAttributes().get(Position.KEY_FUEL).toString())); + return v.setScale(2, RoundingMode.HALF_EVEN).toString() + " %"; + default: + break; } } catch (Exception error) { Log.warning(error); -- cgit v1.2.3 From ef234432c20772b1eaf7fccf6bab7fa536fb47db Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 17 Sep 2016 16:41:58 +1200 Subject: Implement OIGO device protocol --- debug.xml | 1 + src/org/traccar/protocol/OigoProtocol.java | 41 ++++++ src/org/traccar/protocol/OigoProtocolDecoder.java | 155 +++++++++++++++++++++ .../traccar/protocol/OigoProtocolDecoderTest.java | 21 +++ 4 files changed, 218 insertions(+) create mode 100644 src/org/traccar/protocol/OigoProtocol.java create mode 100644 src/org/traccar/protocol/OigoProtocolDecoder.java create mode 100644 test/org/traccar/protocol/OigoProtocolDecoderTest.java (limited to 'src/org/traccar/protocol') diff --git a/debug.xml b/debug.xml index b9b32a639..6ad830402 100644 --- a/debug.xml +++ b/debug.xml @@ -455,5 +455,6 @@ 5118 5119 5120 + 5121 diff --git a/src/org/traccar/protocol/OigoProtocol.java b/src/org/traccar/protocol/OigoProtocol.java new file mode 100644 index 000000000..c60ee1be6 --- /dev/null +++ b/src/org/traccar/protocol/OigoProtocol.java @@ -0,0 +1,41 @@ +/* + * 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.ConnectionlessBootstrap; +import org.jboss.netty.channel.ChannelPipeline; +import org.traccar.BaseProtocol; +import org.traccar.TrackerServer; + +import java.util.List; + +public class OigoProtocol extends BaseProtocol { + + public OigoProtocol() { + super("oigo"); + } + + @Override + public void initTrackerServers(List serverList) { + serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("objectDecoder", new OigoProtocolDecoder(OigoProtocol.this)); + } + }); + } + +} diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java new file mode 100644 index 000000000..799f47ea3 --- /dev/null +++ b/src/org/traccar/protocol/OigoProtocolDecoder.java @@ -0,0 +1,155 @@ +/* + * 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.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; +import org.traccar.helper.BitUtil; +import org.traccar.helper.DateBuilder; +import org.traccar.helper.UnitsConverter; +import org.traccar.model.Position; + +import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; + +public class OigoProtocolDecoder extends BaseProtocolDecoder { + + public OigoProtocolDecoder(OigoProtocol protocol) { + super(protocol); + } + + public static final int MSG_LOCATION = 0x00; + public static final int MSG_REMOTE_START = 0x10; + public static final int MSG_ACKNOWLEDGEMENT = 0xE0; + + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + ChannelBuffer buf = (ChannelBuffer) msg; + + buf.skipBytes(1); // header + buf.readUnsignedShort(); // length + + int type = buf.readUnsignedByte(); + + int tag = buf.readUnsignedByte(); + + DeviceSession deviceSession; + switch (BitUtil.to(tag, 3)) { + case 0: + String imei = ChannelBuffers.hexDump(buf.readBytes(9)).substring(1, 1 + 15); + deviceSession = getDeviceSession(channel, remoteAddress, imei); + break; + case 1: + buf.skipBytes(1); + String meid = buf.readBytes(14).toString(StandardCharsets.US_ASCII); + deviceSession = getDeviceSession(channel, remoteAddress, meid); + break; + default: + deviceSession = getDeviceSession(channel, remoteAddress); + break; + } + + if (deviceSession == null || type != MSG_LOCATION) { + return null; + } + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + int mask = buf.readInt(); + + if (BitUtil.check(mask, 0)) { + position.set(Position.KEY_INDEX, buf.readUnsignedShort()); + } + + if (BitUtil.check(mask, 1)) { + int date = buf.readUnsignedByte(); + DateBuilder dateBuilder = new DateBuilder() + .setDate(BitUtil.between(date, 4, 8) + 2010, BitUtil.to(date, 4), buf.readUnsignedByte()) + .setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte()); + position.setTime(dateBuilder.getDate()); + } + + if (BitUtil.check(mask, 2)) { + buf.skipBytes(5); // device time + } + + if (BitUtil.check(mask, 3)) { + position.setLatitude(buf.readUnsignedInt() * 0.000001 - 90); + position.setLongitude(buf.readUnsignedInt() * 0.000001 - 180.0); + } + + if (BitUtil.check(mask, 4)) { + int status = buf.readUnsignedByte(); + position.setValid(BitUtil.between(status, 4, 8) != 0); + position.set(Position.KEY_SATELLITES, BitUtil.to(status, 4)); + position.set(Position.KEY_HDOP, buf.readUnsignedByte() * 0.1); + } + + if (BitUtil.check(mask, 5)) { + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); + } + + if (BitUtil.check(mask, 6)) { + position.setCourse(buf.readUnsignedShort()); + } + + if (BitUtil.check(mask, 7)) { + position.setAltitude(buf.readShort()); + } + + if (BitUtil.check(mask, 8)) { + position.set(Position.KEY_GSM, buf.readUnsignedByte()); + } + + if (BitUtil.check(mask, 9)) { + position.set(Position.KEY_POWER, buf.readUnsignedShort() + "mV"); + } + + if (BitUtil.check(mask, 10)) { + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() + "mV"); + } + + if (BitUtil.check(mask, 11)) { + buf.skipBytes(2); // gpio + } + + if (BitUtil.check(mask, 12)) { + position.set(Position.KEY_ODOMETER, buf.readUnsignedInt() * 1000); + } + + if (BitUtil.check(mask, 13)) { + buf.skipBytes(6); // software version + } + + if (BitUtil.check(mask, 14)) { + buf.skipBytes(5); // hardware version + } + + if (BitUtil.check(mask, 15)) { + buf.readUnsignedShort(); // device config + } + + return position; + } + +} diff --git a/test/org/traccar/protocol/OigoProtocolDecoderTest.java b/test/org/traccar/protocol/OigoProtocolDecoderTest.java new file mode 100644 index 000000000..b75f3162b --- /dev/null +++ b/test/org/traccar/protocol/OigoProtocolDecoderTest.java @@ -0,0 +1,21 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class OigoProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + OigoProtocolDecoder decoder = new OigoProtocolDecoder(new OigoProtocol()); + + verifyPosition(decoder, binary( + "7e004200000014631000258257000000ffff02d0690e000220690e0002200696dbd204bdfde31a070000b307101135de106e05f500000000010908010402200104ffff8001")); + + verifyPosition(decoder, binary( + "7e004200000014631000258257000000ffff02d1690e00051f690e00051f0696dbd204bdfde31a070000b307100f35c0106305f500000000010908010402200104ffff8001")); + + } + +} -- cgit v1.2.3 From 989956915085944d6d5ac550020a7a854c68b541 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 18 Sep 2016 19:09:28 +1200 Subject: Allow to switch GT06 command format --- src/org/traccar/protocol/Gt06ProtocolEncoder.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java index 3ef9b1313..e478424f9 100644 --- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 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. @@ -18,9 +18,11 @@ package org.traccar.protocol; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.traccar.BaseProtocolEncoder; +import org.traccar.Context; import org.traccar.helper.Checksum; import org.traccar.helper.Log; import org.traccar.model.Command; +import org.traccar.model.Device; import java.nio.charset.StandardCharsets; @@ -54,11 +56,19 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder { @Override protected Object encodeCommand(Command command) { + boolean alternative; + Device device = Context.getIdentityManager().getDeviceById(command.getDeviceId()); + if (device.getAttributes().containsKey("gt06.alternative")) { + alternative = Boolean.parseBoolean((String) device.getAttributes().get("gt06.alternative")); + } else { + alternative = Context.getConfig().getBoolean("gt06.alternative"); + } + switch (command.getType()) { case Command.TYPE_ENGINE_STOP: - return encodeContent("Relay,1#"); + return encodeContent(alternative ? "DYD,123456#\r\n" : "Relay,1#"); case Command.TYPE_ENGINE_RESUME: - return encodeContent("Relay,0#"); + return encodeContent(alternative ? "HFYD,123456#\r\n" : "Relay,0#"); default: Log.warning(new UnsupportedOperationException(command.getType())); break; -- cgit v1.2.3 From d8ba1eccc5ee74bc3bf90724c726de71233a0421 Mon Sep 17 00:00:00 2001 From: nyash Date: Sun, 18 Sep 2016 14:39:10 +0200 Subject: Add jpkorjar protocol --- src/org/traccar/protocol/JpKorjarProtocol.java | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/org/traccar/protocol/JpKorjarProtocol.java (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/JpKorjarProtocol.java b/src/org/traccar/protocol/JpKorjarProtocol.java new file mode 100644 index 000000000..e48e6ea21 --- /dev/null +++ b/src/org/traccar/protocol/JpKorjarProtocol.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 nyashh (nyashh@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.string.StringDecoder; +import org.traccar.BaseProtocol; +import org.traccar.TrackerServer; + +import java.util.List; + +public class JpKorjarProtocol extends BaseProtocol { + + public JpKorjarProtocol() { + super("jpkorjar"); + } + + @Override + public void initTrackerServers(List serverList) { + serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + + pipeline.addLast("frameDecoder", new JpKorjarFrameDecoder()); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("objectDecoder", new JpKorjarProtocolDecoder(JpKorjarProtocol.this)); + } + }); + } + +} -- cgit v1.2.3 From cff3579737ae906c34670f9bf44f62473c7a7466 Mon Sep 17 00:00:00 2001 From: nyash Date: Sun, 18 Sep 2016 14:39:39 +0200 Subject: Add jpkorjar frame decoder --- src/org/traccar/protocol/JpKorjarFrameDecoder.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/org/traccar/protocol/JpKorjarFrameDecoder.java (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/JpKorjarFrameDecoder.java b/src/org/traccar/protocol/JpKorjarFrameDecoder.java new file mode 100644 index 000000000..0b32a7f0b --- /dev/null +++ b/src/org/traccar/protocol/JpKorjarFrameDecoder.java @@ -0,0 +1,46 @@ +/* + * Copyright 2016 nyashh (nyashh@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.buffer.ChannelBuffer; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.handler.codec.frame.FrameDecoder; + +public class JpKorjarFrameDecoder extends FrameDecoder { + + @Override + protected Object decode( + ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception { + + if (buf.readableBytes() < 80) { + return null; + } + + int spaceIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ' '); + if (spaceIndex == -1) { + return null; + } + + int endIndex = buf.indexOf(spaceIndex, buf.writerIndex(), (byte) ','); + if (endIndex == -1) { + return null; + } + + return buf.readBytes(endIndex + 1); + } + +} -- cgit v1.2.3 From 786a6b0b5f3777583a6c6fe6d0365bbcbf4e708b Mon Sep 17 00:00:00 2001 From: nyash Date: Sun, 18 Sep 2016 14:40:48 +0200 Subject: Add jpkorjar protocol decoder --- .../traccar/protocol/JpKorjarProtocolDecoder.java | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/org/traccar/protocol/JpKorjarProtocolDecoder.java (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java new file mode 100644 index 000000000..e5c80ee82 --- /dev/null +++ b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java @@ -0,0 +1,105 @@ +/* + * Copyright 2016 nyashh (nyashh@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.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; +import org.traccar.helper.DateBuilder; +import org.traccar.model.Position; + +import java.net.SocketAddress; + +public class JpKorjarProtocolDecoder extends BaseProtocolDecoder { + + public JpKorjarProtocolDecoder(JpKorjarProtocol protocol) { + super(protocol); + } + + @Override + protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + String line = (String) msg; + + String[] parts = line.split(","); + + if (parts.length == 0) { + return null; + } + + if (!parts[0].equals("KORJAR.PL")) { + return null; + } + + Long imei = Long.parseLong(parts[1]); + + int year = Integer.parseInt(parts[2].substring(0, 2)); + int month = Integer.parseInt(parts[2].substring(2, 4)); + int day = Integer.parseInt(parts[2].substring(4, 6)); + int hour = Integer.parseInt(parts[2].substring(6, 8)); + int minute = Integer.parseInt(parts[2].substring(8, 10)); + int second = Integer.parseInt(parts[2].substring(10, 12)); + + Double latitude = Double.parseDouble(parts[3].substring(0, + Math.max(0, parts[3].length() - 1))); + + Double longitude = Double.parseDouble(parts[4].substring(0, + Math.max(0, parts[4].length() - 1))); + + Double speed = Double.parseDouble(parts[5]); + Double course = Double.parseDouble(parts[6]); + + String[] batteryParts = parts[7].split(":"); + + String batteryLevel = batteryParts[0]; + Double batteryVoltage = Double.parseDouble(batteryParts[1].substring(0, + Math.max(0, batteryParts[1].length() - 1))); + + String[] codeParts = parts[8].split(" "); + + int gpsSignal = Integer.parseInt(codeParts[0]); //0 - low, 1 - high + int mcc = Integer.parseInt(codeParts[1]); + int mnc = Integer.parseInt(codeParts[2]); + int lac = Integer.parseInt(codeParts[3], 16); + int cid = Integer.parseInt(codeParts[4], 16); + + DateBuilder builder = new DateBuilder().setDate(year, month, day) + .setTime(hour, minute, second); + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parts[1]); + if (deviceSession == null) { + return null; + } + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + position.setLatitude(latitude); + position.setLongitude(longitude); + position.setSpeed(speed); + position.setCourse(course); + position.set("signal", gpsSignal); + position.set(Position.KEY_POWER, batteryVoltage); + position.set(Position.KEY_MNC, mnc); + position.set(Position.KEY_MCC, mcc); + position.set(Position.KEY_LAC, lac); + position.set(Position.KEY_CID, cid); + position.setTime(builder.getDate()); + position.setValid(true); + + return position; + } +} -- cgit v1.2.3 From 24c846056fc6bdca120ce96c32d75ff6c36f3ba0 Mon Sep 17 00:00:00 2001 From: nyash Date: Mon, 19 Sep 2016 12:20:49 +0200 Subject: use primitives and remove unused variables --- src/org/traccar/protocol/JpKorjarProtocolDecoder.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java index e5c80ee82..0cdc958c9 100644 --- a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java +++ b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java @@ -44,8 +44,6 @@ public class JpKorjarProtocolDecoder extends BaseProtocolDecoder { return null; } - Long imei = Long.parseLong(parts[1]); - int year = Integer.parseInt(parts[2].substring(0, 2)); int month = Integer.parseInt(parts[2].substring(2, 4)); int day = Integer.parseInt(parts[2].substring(4, 6)); @@ -53,19 +51,18 @@ public class JpKorjarProtocolDecoder extends BaseProtocolDecoder { int minute = Integer.parseInt(parts[2].substring(8, 10)); int second = Integer.parseInt(parts[2].substring(10, 12)); - Double latitude = Double.parseDouble(parts[3].substring(0, + double latitude = Double.parseDouble(parts[3].substring(0, Math.max(0, parts[3].length() - 1))); - Double longitude = Double.parseDouble(parts[4].substring(0, + double longitude = Double.parseDouble(parts[4].substring(0, Math.max(0, parts[4].length() - 1))); - Double speed = Double.parseDouble(parts[5]); - Double course = Double.parseDouble(parts[6]); + double speed = Double.parseDouble(parts[5]); + double course = Double.parseDouble(parts[6]); String[] batteryParts = parts[7].split(":"); - String batteryLevel = batteryParts[0]; - Double batteryVoltage = Double.parseDouble(batteryParts[1].substring(0, + double batteryVoltage = Double.parseDouble(batteryParts[1].substring(0, Math.max(0, batteryParts[1].length() - 1))); String[] codeParts = parts[8].split(" "); -- cgit v1.2.3 From 920f7d9d475bd12d37c51e585ae810c2c0d596c3 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 19 Sep 2016 22:45:32 +1200 Subject: Add GPS103 ignition alarms --- src/org/traccar/protocol/Gps103ProtocolDecoder.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java index 1a34a6bd8..363834f89 100644 --- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java @@ -216,8 +216,14 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder { String alarm = parser.next(); position.set(Position.KEY_ALARM, decodeAlarm(alarm)); - if (channel != null && alarm.equals("help me")) { - channel.write("**,imei:" + imei + ",E;", remoteAddress); + if (alarm.equals("help me")) { + if (channel != null) { + channel.write("**,imei:" + imei + ",E;", remoteAddress); + } + } else if (alarm.equals("acc on")) { + position.set(Position.KEY_IGNITION, true); + } else if (alarm.equals("acc off")) { + position.set(Position.KEY_IGNITION, false); } DateBuilder dateBuilder = new DateBuilder() -- cgit v1.2.3 From 56a4fe28c4d72b8ec1f55fce4c8de18c1ef71f73 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 19 Sep 2016 23:04:34 +1200 Subject: Remove debug code from ArknavX8 --- src/org/traccar/protocol/ArknavX8ProtocolDecoder.java | 3 --- test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java index 931cb1d14..c0a18311e 100644 --- a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java +++ b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java @@ -21,7 +21,6 @@ import org.traccar.DeviceSession; import org.traccar.helper.DateBuilder; import org.traccar.helper.Parser; import org.traccar.helper.PatternBuilder; -import org.traccar.helper.PatternUtil; import org.traccar.model.Position; import java.net.SocketAddress; @@ -57,8 +56,6 @@ public class ArknavX8ProtocolDecoder extends BaseProtocolDecoder { return null; } - PatternUtil.MatchResult r = PatternUtil.checkPattern(PATTERN.pattern(), sentence); - Parser parser = new Parser(PATTERN, sentence); if (!parser.matches()) { return null; diff --git a/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java b/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java index a28e71c64..c5e99f60b 100644 --- a/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java @@ -10,6 +10,12 @@ public class ArknavX8ProtocolDecoderTest extends ProtocolTest { ArknavX8ProtocolDecoder decoder = new ArknavX8ProtocolDecoder(new ArknavX8Protocol()); + verifyNothing(decoder, text( + "351856045213782,241111")); + + verifyNothing(decoder, text( + "2R,090214235955,00,,00.04,03.76,001892024.9")); + verifyNothing(decoder, text( "351856040005407,240101")); -- cgit v1.2.3 From c5ba4d655d3a0e314ab030a32057397a6a579ef0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 20 Sep 2016 11:05:19 +1200 Subject: Update JP-KORJAR decoder with regex --- src/org/traccar/protocol/JpKorjarFrameDecoder.java | 2 +- src/org/traccar/protocol/JpKorjarProtocol.java | 2 +- .../traccar/protocol/JpKorjarProtocolDecoder.java | 103 ++++++++++----------- .../protocol/JpKorjarProtocolDecoderTest.java | 1 - 4 files changed, 49 insertions(+), 59 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/JpKorjarFrameDecoder.java b/src/org/traccar/protocol/JpKorjarFrameDecoder.java index 0b32a7f0b..33a1b3f36 100644 --- a/src/org/traccar/protocol/JpKorjarFrameDecoder.java +++ b/src/org/traccar/protocol/JpKorjarFrameDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 nyashh (nyashh@gmail.com) + * Copyright 2016 Nyash (nyashh@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/protocol/JpKorjarProtocol.java b/src/org/traccar/protocol/JpKorjarProtocol.java index e48e6ea21..c54994708 100644 --- a/src/org/traccar/protocol/JpKorjarProtocol.java +++ b/src/org/traccar/protocol/JpKorjarProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 nyashh (nyashh@gmail.com) + * Copyright 2016 Nyash (nyashh@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java index 0cdc958c9..e0fe0678d 100644 --- a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java +++ b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java @@ -1,5 +1,6 @@ /* - * Copyright 2016 nyashh (nyashh@gmail.com) + * Copyright 2016 Nyash (nyashh@gmail.com) + * 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. @@ -19,9 +20,12 @@ import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; 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 java.net.SocketAddress; +import java.util.regex.Pattern; public class JpKorjarProtocolDecoder extends BaseProtocolDecoder { @@ -29,74 +33,61 @@ public class JpKorjarProtocolDecoder extends BaseProtocolDecoder { super(protocol); } - @Override - protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - - String line = (String) msg; + private static final Pattern PATTERN = new PatternBuilder() + .text("KORJAR.PL,") + .number("(d+),") // imei + .number("(dd)(dd)(dd)") // date + .number("(dd)(dd)(dd),") // time + .number("(d+.d+)([NS]),") // latitude + .number("(d+.d+)([EW]),") // longitude + .number("(d+.d+),") // speed + .number("(d+),") // course + .number("[FL]:(d+.d+)V,") // battery + .number("([01]) ") // valid + .number("(d+) ") // mcc + .number("(d+) ") // mnc + .number("(x+) ") // lac + .number("(x+),") // cid + .compile(); - String[] parts = line.split(","); + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - if (parts.length == 0) { + Parser parser = new Parser(PATTERN, (String) msg); + if (!parser.matches()) { return null; } - if (!parts[0].equals("KORJAR.PL")) { + Position position = new Position(); + position.setProtocol(getProtocolName()); + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession == null) { return null; } + position.setDeviceId(deviceSession.getDeviceId()); - int year = Integer.parseInt(parts[2].substring(0, 2)); - int month = Integer.parseInt(parts[2].substring(2, 4)); - int day = Integer.parseInt(parts[2].substring(4, 6)); - int hour = Integer.parseInt(parts[2].substring(6, 8)); - int minute = Integer.parseInt(parts[2].substring(8, 10)); - int second = Integer.parseInt(parts[2].substring(10, 12)); - - double latitude = Double.parseDouble(parts[3].substring(0, - Math.max(0, parts[3].length() - 1))); - - double longitude = Double.parseDouble(parts[4].substring(0, - Math.max(0, parts[4].length() - 1))); - - double speed = Double.parseDouble(parts[5]); - double course = Double.parseDouble(parts[6]); - - String[] batteryParts = parts[7].split(":"); - - double batteryVoltage = Double.parseDouble(batteryParts[1].substring(0, - Math.max(0, batteryParts[1].length() - 1))); - - String[] codeParts = parts[8].split(" "); + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); - int gpsSignal = Integer.parseInt(codeParts[0]); //0 - low, 1 - high - int mcc = Integer.parseInt(codeParts[1]); - int mnc = Integer.parseInt(codeParts[2]); - int lac = Integer.parseInt(codeParts[3], 16); - int cid = Integer.parseInt(codeParts[4], 16); + position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); + position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); + position.setSpeed(parser.nextDouble()); + position.setCourse(parser.nextDouble()); - DateBuilder builder = new DateBuilder().setDate(year, month, day) - .setTime(hour, minute, second); + position.set(Position.KEY_BATTERY, parser.nextDouble()); - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parts[1]); - if (deviceSession == null) { - return null; - } + position.setValid(parser.nextInt() == 1); - Position position = new Position(); - position.setProtocol(getProtocolName()); - position.setDeviceId(deviceSession.getDeviceId()); - position.setLatitude(latitude); - position.setLongitude(longitude); - position.setSpeed(speed); - position.setCourse(course); - position.set("signal", gpsSignal); - position.set(Position.KEY_POWER, batteryVoltage); - position.set(Position.KEY_MNC, mnc); - position.set(Position.KEY_MCC, mcc); - position.set(Position.KEY_LAC, lac); - position.set(Position.KEY_CID, cid); - position.setTime(builder.getDate()); - position.setValid(true); + position.set(Position.KEY_MCC, parser.nextInt()); + position.set(Position.KEY_MNC, parser.nextInt()); + position.set(Position.KEY_LAC, parser.nextInt(16)); + position.set(Position.KEY_CID, parser.nextInt(16)); return position; } + } diff --git a/test/org/traccar/protocol/JpKorjarProtocolDecoderTest.java b/test/org/traccar/protocol/JpKorjarProtocolDecoderTest.java index 44cdbe2f2..c64be017f 100644 --- a/test/org/traccar/protocol/JpKorjarProtocolDecoderTest.java +++ b/test/org/traccar/protocol/JpKorjarProtocolDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; - import org.junit.Test; import org.traccar.ProtocolTest; -- cgit v1.2.3 From 411edf2fecc6f5d2cceba20f06958f729ebcca54 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 20 Sep 2016 21:21:06 +1200 Subject: Don't convert Castel OBD values --- src/org/traccar/helper/ObdDecoder.java | 14 +++++++------- src/org/traccar/protocol/CastelProtocolDecoder.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/helper/ObdDecoder.java b/src/org/traccar/helper/ObdDecoder.java index 8383a2b1a..3196c25e4 100644 --- a/src/org/traccar/helper/ObdDecoder.java +++ b/src/org/traccar/helper/ObdDecoder.java @@ -44,7 +44,7 @@ public final class ObdDecoder { case MODE_FREEZE_FRAME: return decodeData( Integer.parseInt(value.substring(0, 2), 16), - Integer.parseInt(value.substring(2), 16)); + Integer.parseInt(value.substring(2), 16), true); case MODE_CODES: return decodeCodes(value); default: @@ -84,22 +84,22 @@ public final class ObdDecoder { } } - public static Map.Entry decodeData(int pid, int value) { + public static Map.Entry decodeData(int pid, int value, boolean convert) { switch (pid) { case PID_ENGINE_LOAD: - return createEntry("engineLoad", value * 100 / 255); + return createEntry("engineLoad", convert ? value * 100 / 255 : value); case PID_COOLANT_TEMPERATURE: - return createEntry("coolantTemperature", value - 40); + return createEntry("coolantTemperature", convert ? value - 40 : value); case PID_ENGINE_RPM: - return createEntry(Position.KEY_RPM, value / 4); + return createEntry(Position.KEY_RPM, convert ? value / 4 : value); case PID_VEHICLE_SPEED: return createEntry(Position.KEY_OBD_SPEED, value); case PID_THROTTLE_POSITION: - return createEntry("throttle", value * 100 / 255); + return createEntry("throttle", convert ? value * 100 / 255 : value); case PID_MIL_DISTANCE: return createEntry("milDistance", value); case PID_FUEL_LEVEL: - return createEntry(Position.KEY_FUEL, value * 100 / 255); + return createEntry(Position.KEY_FUEL, convert ? value * 100 / 255 : value); case PID_DISTANCE_CLEARED: return createEntry("clearedDistance", value); default: diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java index ee5fac5e6..47df3735c 100644 --- a/src/org/traccar/protocol/CastelProtocolDecoder.java +++ b/src/org/traccar/protocol/CastelProtocolDecoder.java @@ -167,7 +167,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder { value = 0; break; } - position.add(ObdDecoder.decodeData(pids[i], value)); + position.add(ObdDecoder.decodeData(pids[i], value, false)); } } -- cgit v1.2.3 From 277a28cd11a60246de96bcfb7be75e177f483809 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 21 Sep 2016 05:11:01 +1200 Subject: Read event from OIGO messages --- src/org/traccar/protocol/OigoProtocolDecoder.java | 4 +++- test/org/traccar/protocol/OigoProtocolDecoderTest.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java index 799f47ea3..bbea38183 100644 --- a/src/org/traccar/protocol/OigoProtocolDecoder.java +++ b/src/org/traccar/protocol/OigoProtocolDecoder.java @@ -54,7 +54,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder { DeviceSession deviceSession; switch (BitUtil.to(tag, 3)) { case 0: - String imei = ChannelBuffers.hexDump(buf.readBytes(9)).substring(1, 1 + 15); + String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1); deviceSession = getDeviceSession(channel, remoteAddress, imei); break; case 1: @@ -75,6 +75,8 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder { position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + position.set(Position.KEY_EVENT, buf.readUnsignedByte()); + int mask = buf.readInt(); if (BitUtil.check(mask, 0)) { diff --git a/test/org/traccar/protocol/OigoProtocolDecoderTest.java b/test/org/traccar/protocol/OigoProtocolDecoderTest.java index b75f3162b..14c34ae7c 100644 --- a/test/org/traccar/protocol/OigoProtocolDecoderTest.java +++ b/test/org/traccar/protocol/OigoProtocolDecoderTest.java @@ -16,6 +16,9 @@ public class OigoProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, binary( "7e004200000014631000258257000000ffff02d1690e00051f690e00051f0696dbd204bdfde31a070000b307100f35c0106305f500000000010908010402200104ffff8001")); + verifyPosition(decoder, binary( + "7e004200000014631000258257000000ffff0d82691300001669130000160696dbd804bdfdbb1a0800000007101035a2106905f500000000010908010402200104ffff8001")); + } } -- cgit v1.2.3 From de3171940f14fe6d559780027da3efd35bd4ab1c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 21 Sep 2016 06:27:12 +1200 Subject: Implement Aplicom E protocol --- .../traccar/protocol/AplicomProtocolDecoder.java | 146 +++++++++++++++------ .../protocol/AplicomProtocolDecoderTest.java | 17 ++- 2 files changed, 125 insertions(+), 38 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index 23397b51c..b7619b38a 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2013 - 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. @@ -27,6 +27,7 @@ import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import java.net.SocketAddress; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Date; @@ -75,7 +76,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { return unitId; } - private static final int DEFAULT_SELECTOR = 0x0002FC; + private static final int DEFAULT_SELECTOR_D = 0x0002FC; + private static final int DEFAULT_SELECTOR_E = 0x007ffc; private static final int EVENT_DATA = 119; @@ -191,44 +193,12 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } } - @Override - protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { - - ChannelBuffer buf = (ChannelBuffer) msg; - - buf.readUnsignedByte(); // marker - int version = buf.readUnsignedByte(); - - String imei; - if ((version & 0x80) != 0) { - imei = String.valueOf((buf.readUnsignedInt() << (3 * 8)) | buf.readUnsignedMedium()); - } else { - imei = String.valueOf(imeiFromUnitId(buf.readUnsignedMedium())); - } - - buf.readUnsignedShort(); // length - - int selector = DEFAULT_SELECTOR; - if ((version & 0x40) != 0) { - selector = buf.readUnsignedMedium(); - } - - Position position = new Position(); - position.setProtocol(getProtocolName()); - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); - if (deviceSession == null) { - return null; - } - position.setDeviceId(deviceSession.getDeviceId()); - - int event = buf.readUnsignedByte(); - position.set(Position.KEY_EVENT, event); - position.set("eventInfo", buf.readUnsignedByte()); + private void decodeD(Position position, ChannelBuffer buf, int selector, int event) { if ((selector & 0x0008) != 0) { position.setValid((buf.readUnsignedByte() & 0x40) != 0); } else { - return null; // no location data + getLastLocation(position, null); } if ((selector & 0x0004) != 0) { @@ -318,9 +288,111 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { if (Context.getConfig().getBoolean(getProtocolName() + ".can") && buf.readable() && (selector & 0x1000) != 0 && event == EVENT_DATA) { - decodeCanData(buf, position); } + } + + private void decodeE(Position position, ChannelBuffer buf, int selector) { + + if ((selector & 0x0008) != 0) { + position.set("tachographEvent", buf.readUnsignedShort()); + } + + if ((selector & 0x0004) != 0) { + getLastLocation(position, new Date(buf.readUnsignedInt() * 1000)); + } else { + getLastLocation(position, null); + } + + if ((selector & 0x0010) != 0) { + String time = + buf.readUnsignedByte() + "s " + buf.readUnsignedByte() + "m " + buf.readUnsignedByte() + "h " + + buf.readUnsignedByte() + "M " + buf.readUnsignedByte() + "D " + buf.readUnsignedByte() + "Y " + + buf.readByte() + "m " + buf.readByte() + "h"; + position.set("tachographTime", time); + } + + position.set("workState", buf.readUnsignedByte()); + position.set("driver1State", buf.readUnsignedByte()); + position.set("driver2State", buf.readUnsignedByte()); + + if ((selector & 0x0020) != 0) { + position.set("tachographStatus", buf.readUnsignedByte()); + } + + if ((selector & 0x0040) != 0) { + position.set(Position.KEY_OBD_SPEED, buf.readUnsignedShort() / 256.0); + } + + if ((selector & 0x0080) != 0) { + position.set(Position.KEY_OBD_ODOMETER, buf.readUnsignedInt() * 5); + } + + if ((selector & 0x0100) != 0) { + position.set(Position.KEY_TRIP_ODOMETER, buf.readUnsignedInt() * 5); + } + + if ((selector & 0x8000) != 0) { + position.set("kFactor", buf.readUnsignedShort() * 0.001 + " pulses/m"); + } + + if ((selector & 0x0200) != 0) { + position.set(Position.KEY_RPM, buf.readUnsignedShort() * 0.125); + } + + if ((selector & 0x0400) != 0) { + position.set("extraInfo", buf.readUnsignedShort()); + } + + if ((selector & 0x0800) != 0) { + position.set(Position.KEY_VIN, buf.readBytes(18).toString(StandardCharsets.US_ASCII).trim()); + } + } + + @Override + protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + ChannelBuffer buf = (ChannelBuffer) msg; + + char protocol = (char) buf.readByte(); + int version = buf.readUnsignedByte(); + + String imei; + if ((version & 0x80) != 0) { + imei = String.valueOf((buf.readUnsignedInt() << (3 * 8)) | buf.readUnsignedMedium()); + } else { + imei = String.valueOf(imeiFromUnitId(buf.readUnsignedMedium())); + } + + buf.readUnsignedShort(); // length + + int selector = DEFAULT_SELECTOR_D; + if (protocol == 'E') { + selector = DEFAULT_SELECTOR_E; + } + if ((version & 0x40) != 0) { + selector = buf.readUnsignedMedium(); + } + + Position position = new Position(); + position.setProtocol(getProtocolName()); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei); + if (deviceSession == null) { + return null; + } + position.setDeviceId(deviceSession.getDeviceId()); + + int event = buf.readUnsignedByte(); + position.set(Position.KEY_EVENT, event); + position.set("eventInfo", buf.readUnsignedByte()); + + if (protocol == 'D') { + decodeD(position, buf, selector, event); + } else if (protocol == 'E') { + decodeE(position, buf, selector); + } else { + return null; + } return position; } diff --git a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java index 26844994e..d6a29c6dd 100644 --- a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java @@ -10,6 +10,21 @@ public class AplicomProtocolDecoderTest extends ProtocolTest { AplicomProtocolDecoder decoder = new AplicomProtocolDecoder(new AplicomProtocol()); + verifyAttributes(decoder, binary( + "45c20145931876ffb2007100ffff6d00000057c6dd1970230d087b1f7d7f0000d0c1000000003580000035801f40ffff5001574442393036363035533132333435363700014142432d333435202020202020000000000000000000000000000000000000000000000001123130343632343639373030303030303100000000")); + + verifyAttributes(decoder, binary( + "45c20145931876ffb2007100ffff6d00000057c6dd9170250d087b1f7d7f0000d0c1000000003580000035801f40ffff5001574442393036363035533132333435363700014142432d333435202020202020000000000000000000000000000000000000000000000001123130343632343639373030303030303100000000")); + + verifyAttributes(decoder, binary( + "45c20145931876ffb2007100ffff6d00000057c6de0970270d087b1f7d7f0000d0c1000000003580000035801f40ffff5001574442393036363035533132333435363700014142432d333435202020202020000000000000000000000000000000000000000000000001123130343632343639373030303030303100000000")); + + verifyNothing(decoder, binary( + "48c10144b9de54e6b2008700205f710a57d23ec957d23b8d00000000300d0106ff00000000000000000000000000000000000000000000000000000000000000010a141e28323c46505a646e7801000f020104ff000000000000000000010102000f020104ff000000000000000000010103000f020104ff000000000000000000010105000f020104ff0000000000000000000101")); + + verifyAttributes(decoder, binary( + "44c3014645e8ecff3c00ea03ffffbc00f457d68a6557d68a6303bb55fa018843da1100009881000000000000000000000000000000000000000000000000000000000000000000000000000000ff0056007600000000000000014542016d0001010095070e14014645e8ecff3c57d68a6403bb55fa018843dac0010d14ff050102030405060708090a0b0c0d0e0f10112a01010730343f3c1ff5cf01020700007d007d23010103022f2e01060c67452301efcdab8967452301010b10000000007d007d007d7dffffffffffff010a2400000000000000010000000000000000ffffffffffffffff00010001ffff00000000ffff010c02fec6")); + verifyPosition(decoder, binary( "44c3014645e8e91b66002300a21f0b01f056d3e62856d3e626031f845f00c6ee440800000000000000000017bd1cb30000")); @@ -19,7 +34,7 @@ public class AplicomProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, binary( "44c3014645e8e91b66001f00221f0b01f456ba1e0d56ba1e0b031f842200c6ef550c000000000017bd1cb30004")); - verifyNothing(decoder, binary( + verifyAttributes(decoder, binary( "44c3014645e8e9bada003e03fff7070055a4f24200000081000000000000000000000000000000000000000000000000000000000000000000000000000000ff00000001000000000000000044c3014645e8e9bada003e03fff77bff55a4f24300000081000000000000000000000000000000000000000000000000000000000000000000000000000000ff00300002000000000000000044c3014645e8e9bada003e03fff7690655a4f24500000081000000000000000000000000000000000000000000000000000000000000000000000000000000ff003000030000000000000000")); verifyPosition(decoder, binary( -- cgit v1.2.3 From 208b66427643d50d2a5fd0dd29b73abe086ce9db Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 21 Sep 2016 06:29:49 +1200 Subject: Fix some style issues --- src/org/traccar/protocol/AplicomProtocolDecoder.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index b7619b38a..abd30ee45 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -76,7 +76,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { return unitId; } - private static final int DEFAULT_SELECTOR_D = 0x0002FC; + private static final int DEFAULT_SELECTOR_D = 0x0002fC; private static final int DEFAULT_SELECTOR_E = 0x007ffc; private static final int EVENT_DATA = 119; @@ -305,10 +305,9 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x0010) != 0) { - String time = - buf.readUnsignedByte() + "s " + buf.readUnsignedByte() + "m " + buf.readUnsignedByte() + "h " + - buf.readUnsignedByte() + "M " + buf.readUnsignedByte() + "D " + buf.readUnsignedByte() + "Y " + - buf.readByte() + "m " + buf.readByte() + "h"; + String time = buf.readUnsignedByte() + "s " + buf.readUnsignedByte() + "m " + buf.readUnsignedByte() + "h " + + buf.readUnsignedByte() + "M " + buf.readUnsignedByte() + "D " + buf.readUnsignedByte() + "Y " + + buf.readByte() + "m " + buf.readByte() + "h"; position.set("tachographTime", time); } -- cgit v1.2.3 From 19b17695867e00861c719292aad7ae48f33a8eeb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 21 Sep 2016 19:31:39 +1200 Subject: Implement cGuard communication protocol --- debug.xml | 1 + src/org/traccar/model/Position.java | 1 + src/org/traccar/protocol/CguardProtocol.java | 47 +++++++++++ .../traccar/protocol/CguardProtocolDecoder.java | 91 ++++++++++++++++++++++ .../protocol/CguardProtocolDecoderTest.java | 54 +++++++++++++ 5 files changed, 194 insertions(+) create mode 100644 src/org/traccar/protocol/CguardProtocol.java create mode 100644 src/org/traccar/protocol/CguardProtocolDecoder.java create mode 100644 test/org/traccar/protocol/CguardProtocolDecoderTest.java (limited to 'src/org/traccar/protocol') diff --git a/debug.xml b/debug.xml index 44f4f2c7f..5de42c027 100644 --- a/debug.xml +++ b/debug.xml @@ -457,5 +457,6 @@ 5120 5121 5122 + 5123 diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 710dd1e83..c1058aef9 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -57,6 +57,7 @@ public class Position extends Message { public static final String KEY_THROTTLE = "throttle"; public static final String KEY_MOTION = "motion"; public static final String KEY_ARMED = "armed"; + public static final String KEY_ACCURACY = "accuracy"; public static final String KEY_OBD_SPEED = "obdSpeed"; public static final String KEY_OBD_ODOMETER = "obdOdometer"; diff --git a/src/org/traccar/protocol/CguardProtocol.java b/src/org/traccar/protocol/CguardProtocol.java new file mode 100644 index 000000000..1e6d212c8 --- /dev/null +++ b/src/org/traccar/protocol/CguardProtocol.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.TrackerServer; + +import java.util.List; + +public class CguardProtocol extends BaseProtocol { + + public CguardProtocol() { + super("cguard"); + } + + @Override + public void initTrackerServers(List serverList) { + serverList.add(new TrackerServer(new ServerBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); + pipeline.addLast("stringDecoder", new StringDecoder()); + pipeline.addLast("stringEncoder", new StringEncoder()); + pipeline.addLast("objectDecoder", new CguardProtocolDecoder(CguardProtocol.this)); + } + }); + } + +} diff --git a/src/org/traccar/protocol/CguardProtocolDecoder.java b/src/org/traccar/protocol/CguardProtocolDecoder.java new file mode 100644 index 000000000..1646363e5 --- /dev/null +++ b/src/org/traccar/protocol/CguardProtocolDecoder.java @@ -0,0 +1,91 @@ +/* + * 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.channel.Channel; +import org.traccar.BaseProtocolDecoder; +import org.traccar.DeviceSession; +import org.traccar.helper.DateBuilder; +import org.traccar.helper.Parser; +import org.traccar.helper.PatternBuilder; +import org.traccar.helper.UnitsConverter; +import org.traccar.model.Position; + +import java.net.SocketAddress; +import java.util.regex.Pattern; + +public class CguardProtocolDecoder extends BaseProtocolDecoder { + + public CguardProtocolDecoder(CguardProtocol protocol) { + super(protocol); + } + + private static final Pattern PATTERN = new PatternBuilder() + .text("NV:") + .number("(dd)(dd)(dd) ") // date + .number("(dd)(dd)(dd):") // time + .number("(-?d+.d+):") // longitude + .number("(-?d+.d+):") // latitude + .number("(d+.?d*):") // speed + .number("(?:NAN|(d+.?d*)):") // accuracy + .number("(?:NAN|(d+.?d*)):") // course + .number("(?:NAN|(d+.?d*))") // altitude + .compile(); + + @Override + protected Object decode( + Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + + String sentence = (String) msg; + + if (sentence.startsWith("ID:") || sentence.startsWith("IDRO:")) { + getDeviceSession(channel, remoteAddress, sentence.substring(sentence.indexOf(':') + 1)); + return null; + } + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession == null) { + return null; + } + + Parser parser = new Parser(PATTERN, (String) msg); + if (!parser.matches()) { + return null; + } + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + DateBuilder dateBuilder = new DateBuilder() + .setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + position.setValid(true); + position.setLatitude(parser.nextDouble()); + position.setLongitude(parser.nextDouble()); + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); + + position.set(Position.KEY_ACCURACY, parser.nextDouble()); + + position.setCourse(parser.nextDouble()); + position.setAltitude(parser.nextDouble()); + + return position; + } + +} diff --git a/test/org/traccar/protocol/CguardProtocolDecoderTest.java b/test/org/traccar/protocol/CguardProtocolDecoderTest.java new file mode 100644 index 000000000..49d037f8f --- /dev/null +++ b/test/org/traccar/protocol/CguardProtocolDecoderTest.java @@ -0,0 +1,54 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class CguardProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + CguardProtocolDecoder decoder = new CguardProtocolDecoder(new CguardProtocol()); + + verifyNothing(decoder, text( + "IDRO:354868050655283")); + + verifyPosition(decoder, text( + "NV:160711 044023:54.342907:48.582590:0:NAN:0:110.1")); + + verifyPosition(decoder, text( + "NV:160711 044023:54.342907:-148.582590:0:NAN:0:110.1")); + + verifyNothing(decoder, text( + "BC:160711 044023:CSQ1:48:NSQ1:7:NSQ2:1:BAT1:98:PWR1:11.7:CLG1:NAN")); + + verifyNothing(decoder, text( + "BC:160711 044524:CSQ1:61:NSQ1:18:BAT1:98:PWR1:11.7:CLG1:NAN")); + + verifyNothing(decoder, text( + "VERSION:3.3")); + + verifyPosition(decoder, text( + "NV:160420 101902:55.799425:37.674033:0.94:NAN:213.59:156.6")); + + verifyNothing(decoder, text( + "BC:160628 081024:CSQ1:32:NSQ1:10:BAT1:100")); + + verifyNothing(decoder, text( + "BC:160628 081033:NSQ2:0")); + + verifyPosition(decoder, text( + "NV:160630 151537:55.799913:37.674267:0.7:NAN:10.21:174.9")); + + verifyNothing(decoder, text( + "BC:160630 153316:BAT1:76")); + + verifyNothing(decoder, text( + "BC:160630 153543:NSQ2:0")); + + verifyNothing(decoder, text( + "PING")); + + } + +} -- cgit v1.2.3 From 1252beec948b9e320f203fedcb4c3f3ca6e2bfa1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 23 Sep 2016 03:34:01 +1200 Subject: Remove unnecessary line break --- src/org/traccar/protocol/Gt06ProtocolEncoder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java index e478424f9..e78a1b388 100644 --- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java @@ -66,9 +66,9 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder { switch (command.getType()) { case Command.TYPE_ENGINE_STOP: - return encodeContent(alternative ? "DYD,123456#\r\n" : "Relay,1#"); + return encodeContent(alternative ? "DYD,123456#" : "Relay,1#"); case Command.TYPE_ENGINE_RESUME: - return encodeContent(alternative ? "HFYD,123456#\r\n" : "Relay,0#"); + return encodeContent(alternative ? "HFYD,123456#" : "Relay,0#"); default: Log.warning(new UnsupportedOperationException(command.getType())); break; -- cgit v1.2.3 From e3229237eb37654dbf7818fdf92a6f487a95c770 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 23 Sep 2016 06:57:16 +1200 Subject: Extend JT600 protocol support --- src/org/traccar/protocol/Jt600ProtocolDecoder.java | 90 ++++++++++++++++++---- .../traccar/protocol/Jt600ProtocolDecoderTest.java | 38 ++++++--- 2 files changed, 106 insertions(+), 22 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java index b7193d24b..b30bd7b85 100644 --- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java +++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 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. @@ -43,7 +43,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { return degrees + minutes / 60; } - private Position decodeNormalMessage(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { + private Position decodeBinary(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { Position position = new Position(); position.setProtocol(getProtocolName()); @@ -120,7 +120,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { return position; } - private static final Pattern PATTERN = new PatternBuilder() + private static final Pattern PATTERN_W01 = new PatternBuilder() .text("(") .number("(d+),") // id .text("W01,") // type @@ -138,25 +138,22 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { .number("(d+),") // gsm signal .number("(d+),") // alert type .any() - .text(")") .compile(); - private Position decodeAlertMessage(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) { + private Position decodeW01(String sentence, Channel channel, SocketAddress remoteAddress) { - Parser parser = new Parser(PATTERN, buf.toString(StandardCharsets.US_ASCII)); + Parser parser = new Parser(PATTERN_W01, sentence); if (!parser.matches()) { return null; } - Position position = new Position(); - position.setProtocol(getProtocolName()); - - position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); if (deviceSession == null) { return null; } + + Position position = new Position(); + position.setProtocol(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); position.setLongitude(parser.nextCoordinate()); @@ -176,6 +173,68 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { return position; } + private static final Pattern PATTERN_U01 = new PatternBuilder() + .text("(") + .number("(d+),") // id + .number("Udd,") // type + .number("d+,").optional() // alarm + .number("(dd)(dd)(dd),") // date (ddmmyy) + .number("(dd)(dd)(dd),") // time + .expression("([TF]),") // validity + .number("(d+.d+),([NS]),") // latitude + .number("(d+.d+),([EW]),") // longitude + .number("(d+.?d*),") // speed + .number("(d+),") // course + .number("(d+),") // satellites + .number("(d+%),") // battery + .expression("([01]+),") // status + .number("(d+),") // cid + .number("(d+),") // lac + .number("(d+),") // gsm signal + .number("(d+),") // odometer + .number("(d+)") // index + .any() + .compile(); + + private Position decodeU01(String sentence, Channel channel, SocketAddress remoteAddress) { + + Parser parser = new Parser(PATTERN_U01, sentence); + if (!parser.matches()) { + return null; + } + + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next()); + if (deviceSession == null) { + return null; + } + + Position position = new Position(); + position.setProtocol(getProtocolName()); + position.setDeviceId(deviceSession.getDeviceId()); + + DateBuilder dateBuilder = new DateBuilder() + .setDateReverse(parser.nextInt(), parser.nextInt(), parser.nextInt()) + .setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); + position.setTime(dateBuilder.getDate()); + + position.setValid(parser.next().equals("T")); + position.setLatitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); + position.setLongitude(parser.nextCoordinate(Parser.CoordinateFormat.DEG_HEM)); + + position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble())); + position.setCourse(parser.nextDouble()); + + position.set(Position.KEY_SATELLITES, parser.nextInt()); + position.set(Position.KEY_BATTERY, parser.next()); + position.set(Position.KEY_STATUS, parser.nextInt(2)); + position.set(Position.KEY_CID, parser.nextInt()); + position.set(Position.KEY_LAC, parser.nextInt()); + position.set(Position.KEY_GSM, parser.nextInt()); + position.set(Position.KEY_ODOMETER, parser.nextLong() * 1000); + position.set(Position.KEY_INDEX, parser.nextInt()); + + return position; + } @Override protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -184,9 +243,14 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder { char first = (char) buf.getByte(0); if (first == '$') { - return decodeNormalMessage(buf, channel, remoteAddress); + return decodeBinary(buf, channel, remoteAddress); } else if (first == '(') { - return decodeAlertMessage(buf, channel, remoteAddress); + String sentence = buf.toString(StandardCharsets.US_ASCII); + if (sentence.contains("W01")) { + return decodeW01(sentence, channel, remoteAddress); + } else { + return decodeU01(sentence, channel, remoteAddress); + } } return null; diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java index ba39b1846..4bbfb5627 100644 --- a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java @@ -11,15 +11,35 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest { Jt600ProtocolDecoder decoder = new Jt600ProtocolDecoder(new Jt600Protocol()); + verifyPosition(decoder, buffer( + "(3301210003,U01,040812,185302,T,22.564025,N,113.242329,E,5.21,152,9,32%,00000000000011,10133,5173,22,100,1)")); + + verifyPosition(decoder, buffer( + "(3301210003,U02,040812,185302,T,22.564025,N,113.242329,E,5,152,9,32%,00000000000011,10133,5173,22,100,1)")); + + verifyPosition(decoder, buffer( + "(3301210003,U03,040812,185302,T,22.564025,N,113.242329,E,5,152,9,32%,00000000000011,10133,5173,22,100,1)")); + + verifyNothing(decoder, buffer( + "(3301210003,U04)")); + + verifyPosition(decoder, buffer( + "(3301210003,U06,1,040812,185302,T,22.564025,N,113.242329,E,5,152,9,32%,0000000000011,10133,5173,22,100,1,300,100,10)")); + + verifyPosition(decoder, buffer( + "(3460311327,U01,220916,135251,T,9.552607,N,13.658292,W,0.31,0,9,0%,00001001000000,11012,10,27,0,0,33)")); + + verifyPosition(decoder, buffer( + "(3460311327,U01,010100,000024,F,0.000000,N,0.000000,E,0.00,0,0,100%,00000001000000,263,1,18,0,0,33)")); + verifyNothing(decoder, buffer( "(3460311327,@JT)")); - /*verifyPosition(decoder, buffer( - "(3460311327,U01,010100,000024,F,0.000000,N,0.000000,E,0.00,0,0,100%,00000001000000,263,1,18,0,0,33)"));*/ + verifyPosition(decoder, buffer( + "(3460311327,U06,11,220916,135643,T,9.552553,N,13.658265,W,0.61,0,9,100%,00000001000000,11012,10,30,0,0,126,0,30)")); - //(3460311327,U06,11,220916,135643,T,9.552553,N,13.658265,W,0.61,0,9,100%,00000001000000,11012,10,30,0,0,126,0,30) - //(3460311327,U06,10,220916,140619,T,9.552495,N,13.658227,W,0.43,0,7,0%,00101001000000,11012,10,0,0,0,126,0,30) - //(3460311327,U01,220916,135251,T,9.552607,N,13.658292,W,0.31,0,9,0%,00001001000000,11012,10,27,0,0,33) + verifyPosition(decoder, buffer( + "(3460311327,U06,10,220916,140619,T,9.552495,N,13.658227,W,0.43,0,7,0%,00101001000000,11012,10,0,0,0,126,0,30)")); verifyPosition(decoder, binary( "24311021600111001B16021105591022329862114046227B0598095080012327951435161F"), @@ -41,11 +61,11 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, buffer( "(3120820029,W01,02553.3555,E,2438.0997,S,A,171012,053339,0,8,20,6,31,5,20,20)")); - /*verifyPosition(decoder, text( ChannelBuffers.copiedBuffer( - "(3330104377,U01,010100,010228,F,00.000000,N,000.000000,E,0,0,0,0%,00001000000000,741,14,22,0,206)", StandardCharsets.US_ASCII))); + verifyPosition(decoder, buffer( + "(3330104377,U01,010100,010228,F,00.000000,N,000.000000,E,0,0,0,0%,00001000000000,741,14,22,0,206)")); - verifyPosition(decoder, text( ChannelBuffers.copiedBuffer( - "(6221107674,2,U09,129,2,A,280513113036,E,02711.0500,S,1721.0876,A,030613171243,E,02756.7618,S,2300.0325,3491,538200,14400,1)",StandardCharsets.US_ASCII))));*/ + verifyNothing(decoder, buffer( + "(6221107674,2,U09,129,2,A,280513113036,E,02711.0500,S,1721.0876,A,030613171243,E,02756.7618,S,2300.0325,3491,538200,14400,1)")); } -- cgit v1.2.3 From b15c19d95e5494ad91a9370669665b0ef6930160 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 24 Sep 2016 10:30:11 +1200 Subject: Support UDP for Cellocator protocol --- src/org/traccar/protocol/CellocatorProtocol.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/CellocatorProtocol.java b/src/org/traccar/protocol/CellocatorProtocol.java index 6d8eea8f5..69078cca0 100644 --- a/src/org/traccar/protocol/CellocatorProtocol.java +++ b/src/org/traccar/protocol/CellocatorProtocol.java @@ -15,8 +15,11 @@ */ package org.traccar.protocol; +import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.handler.codec.string.StringDecoder; +import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.TrackerServer; @@ -40,6 +43,15 @@ public class CellocatorProtocol extends BaseProtocol { }; server.setEndianness(ByteOrder.LITTLE_ENDIAN); serverList.add(server); + + server = new TrackerServer(new ConnectionlessBootstrap(), getName()) { + @Override + protected void addSpecificHandlers(ChannelPipeline pipeline) { + pipeline.addLast("objectDecoder", new CellocatorProtocolDecoder(CellocatorProtocol.this)); + } + }; + server.setEndianness(ByteOrder.LITTLE_ENDIAN); + serverList.add(server); } } -- cgit v1.2.3 From d8dd2091c36099e5f2e5eeb00734cad54f342cbb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 24 Sep 2016 10:30:46 +1200 Subject: Remove unused class imports --- src/org/traccar/protocol/CellocatorProtocol.java | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/CellocatorProtocol.java b/src/org/traccar/protocol/CellocatorProtocol.java index 69078cca0..e5f6ac8f6 100644 --- a/src/org/traccar/protocol/CellocatorProtocol.java +++ b/src/org/traccar/protocol/CellocatorProtocol.java @@ -18,8 +18,6 @@ package org.traccar.protocol; import org.jboss.netty.bootstrap.ConnectionlessBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.channel.ChannelPipeline; -import org.jboss.netty.handler.codec.string.StringDecoder; -import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.BaseProtocol; import org.traccar.TrackerServer; -- cgit v1.2.3 From 7deebcef53759e0e11702af97462b821bfad5f5d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 26 Sep 2016 04:23:29 +1300 Subject: Implement Aplicom H protocol --- .../traccar/protocol/AplicomProtocolDecoder.java | 80 ++++++++++++++++++++++ .../protocol/AplicomProtocolDecoderTest.java | 9 ++- 2 files changed, 86 insertions(+), 3 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index abd30ee45..fa512d8b1 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -348,6 +348,84 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } } + private void decodeH(Position position, ChannelBuffer buf, int selector) { + + if ((selector & 0x0004) != 0) { + getLastLocation(position, new Date(buf.readUnsignedInt() * 1000)); + } else { + getLastLocation(position, null); + } + + if ((selector & 0x0040) != 0) { + buf.readUnsignedInt(); // reset time + } + + if ((selector & 0x2000) != 0) { + buf.readUnsignedShort(); // snapshot counter + } + + int index = 1; + while (buf.readableBytes() > 0) { + + position.set("h" + index + "Index", buf.readUnsignedByte()); + + buf.readUnsignedShort(); // length + + int n = buf.readUnsignedByte(); + int m = buf.readUnsignedByte(); + + position.set("h" + index + "XLength", n); + position.set("h" + index + "YLength", m); + + if ((selector & 0x0008) != 0) { + position.set("h" + index + "XType", buf.readUnsignedByte()); + position.set("h" + index + "YType", buf.readUnsignedByte()); + position.set("h" + index + "Parameters", buf.readUnsignedByte()); + } + + boolean percentageFormat = (selector & 0x0020) != 0; + + StringBuilder data = new StringBuilder(); + for (int i = 0; i < n * m; i++) { + if (percentageFormat) { + data.append(buf.readUnsignedByte() * 0.5).append("%").append(" "); + } else { + data.append(buf.readUnsignedShort()).append(" "); + } + } + + position.set("h" + index + "Data", data.toString().trim()); + + position.set("h" + index + "Total", buf.readUnsignedInt()); + + if ((selector & 0x0010) != 0) { + int k = buf.readUnsignedByte(); + + data = new StringBuilder(); + for (int i = 1; i < n; i++) { + if (k == 1) { + data.append(buf.readByte()).append(" "); + } else if (k == 2) { + data.append(buf.readShort()).append(" "); + } + } + position.set("h" + index + "XLimits", data.toString().trim()); + + data = new StringBuilder(); + for (int i = 1; i < m; i++) { + if (k == 1) { + data.append(buf.readByte()).append(" "); + } else if (k == 2) { + data.append(buf.readShort()).append(" "); + } + } + position.set("h" + index + "YLimits", data.toString().trim()); + } + + index += 1; + } + } + @Override protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { @@ -389,6 +467,8 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { decodeD(position, buf, selector, event); } else if (protocol == 'E') { decodeE(position, buf, selector); + } else if (protocol == 'H') { + decodeH(position, buf, selector); } else { return null; } diff --git a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java index d6a29c6dd..cb39b5d2e 100644 --- a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java @@ -10,6 +10,12 @@ public class AplicomProtocolDecoderTest extends ProtocolTest { AplicomProtocolDecoder decoder = new AplicomProtocolDecoder(new AplicomProtocol()); + verifyAttributes(decoder, binary( + "48C1014143B4493145004900203F6D014B5557C20003000015060110FF00C800000000000000003D01141E283C500100260404010200000000000000000000000000C8000000000000010200110019001E0064019003E8")); + + verifyAttributes(decoder, binary( + "48c10144b9de54e6b2008700205f710a57d23ec957d23b8d00000000300d0106ff00000000000000000000000000000000000000000000000000000000000000010a141e28323c46505a646e7801000f020104ff000000000000000000010102000f020104ff000000000000000000010103000f020104ff000000000000000000010105000f020104ff0000000000000000000101")); + verifyAttributes(decoder, binary( "45c20145931876ffb2007100ffff6d00000057c6dd1970230d087b1f7d7f0000d0c1000000003580000035801f40ffff5001574442393036363035533132333435363700014142432d333435202020202020000000000000000000000000000000000000000000000001123130343632343639373030303030303100000000")); @@ -19,9 +25,6 @@ public class AplicomProtocolDecoderTest extends ProtocolTest { verifyAttributes(decoder, binary( "45c20145931876ffb2007100ffff6d00000057c6de0970270d087b1f7d7f0000d0c1000000003580000035801f40ffff5001574442393036363035533132333435363700014142432d333435202020202020000000000000000000000000000000000000000000000001123130343632343639373030303030303100000000")); - verifyNothing(decoder, binary( - "48c10144b9de54e6b2008700205f710a57d23ec957d23b8d00000000300d0106ff00000000000000000000000000000000000000000000000000000000000000010a141e28323c46505a646e7801000f020104ff000000000000000000010102000f020104ff000000000000000000010103000f020104ff000000000000000000010105000f020104ff0000000000000000000101")); - verifyAttributes(decoder, binary( "44c3014645e8ecff3c00ea03ffffbc00f457d68a6557d68a6303bb55fa018843da1100009881000000000000000000000000000000000000000000000000000000000000000000000000000000ff0056007600000000000000014542016d0001010095070e14014645e8ecff3c57d68a6403bb55fa018843dac0010d14ff050102030405060708090a0b0c0d0e0f10112a01010730343f3c1ff5cf01020700007d007d23010103022f2e01060c67452301efcdab8967452301010b10000000007d007d007d7dffffffffffff010a2400000000000000010000000000000000ffffffffffffffff00010001ffff00000000ffff010c02fec6")); -- cgit v1.2.3 From 14d317b6173badced85335bf8ef2ad478006a404 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 26 Sep 2016 06:12:18 +1300 Subject: Implement Aplicom EB protocol --- .../traccar/protocol/AplicomProtocolDecoder.java | 73 +++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/protocol') diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java index fa512d8b1..d1f92ea0a 100644 --- a/src/org/traccar/protocol/AplicomProtocolDecoder.java +++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java @@ -81,7 +81,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { private static final int EVENT_DATA = 119; - private void decodeEventData(int event, ChannelBuffer buf) { + private void decodeEventData(Position position, ChannelBuffer buf, int event) { switch (event) { case 2: case 40: @@ -108,6 +108,9 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { case 130: buf.readUnsignedInt(); // incorrect break; + case 188: + decodeEB(position, buf); + break; default: break; } @@ -283,7 +286,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } if ((selector & 0x1000) != 0) { - decodeEventData(event, buf); + decodeEventData(position, buf, event); } if (Context.getConfig().getBoolean(getProtocolName() + ".can") @@ -426,6 +429,72 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder { } } + private void decodeEB(Position position, ChannelBuffer buf) { + + if (buf.readByte() != (byte) 'E' || buf.readByte() != (byte) 'B') { + return; + } + + buf.readUnsignedByte(); // version + buf.readUnsignedShort(); // event + buf.readUnsignedByte(); // data validity + buf.readUnsignedByte(); // towed + buf.readUnsignedShort(); // length + + while (buf.readableBytes() > 0) { + buf.readUnsignedByte(); // towed position + int type = buf.readUnsignedByte(); + int length = buf.readUnsignedByte(); + + if (type == 0x01) { + position.set("brakeFlags", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x02) { + position.set("wheelSpeed", buf.readUnsignedShort() / 256.0); + position.set("wheelSpeedDifference", buf.readUnsignedShort() / 256.0 - 125.0); + position.set("lateralAcceleration", buf.readUnsignedByte() / 10.0 - 12.5); + position.set("vehicleSpeed", buf.readUnsignedShort() / 256.0); + } else if (type == 0x03) { + position.set("axleLoadSum", buf.readUnsignedShort() * 2); + } else if (type == 0x04) { + position.set("tyrePressure", buf.readUnsignedByte() * 10); + position.set("pneumaticPressure", buf.readUnsignedByte() * 5); + } else if (type == 0x05) { + position.set("brakeLining", buf.readUnsignedByte() * 0.4); + position.set("brakeTemperature", buf.readUnsignedByte() * 10); + } else if (type == 0x06) { + position.set("totalDistance", buf.readUnsignedInt() * 5); + position.set("tripDistance", buf.readUnsignedInt() * 5); + position.set("serviceDistance", (buf.readUnsignedInt() - 2105540607) * 5); + } else if (type == 0x0A) { + position.set("brakeData", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x0B) { + position.set("brakeMinMaxData", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x0C) { + position.set("missingPgn", ChannelBuffers.hexDump(buf.readBytes(length))); + } else if (type == 0x0D) { + switch (buf.readUnsignedByte()) { + case 1: + position.set("brakeManufacturer", "Wabco"); + break; + case 2: + position.set("brakeManufacturer", "Knorr"); + break; + case 3: + position.set("brakeManufacturer", "Haldex"); + break; + default: + position.set("brakeManufacturer", "Unknown"); + break; + } + buf.readUnsignedByte(); + buf.readBytes(17); // vin + position.set("towedDetectionStatus", buf.readUnsignedByte()); + } else if (type == 0x0E) { + buf.skipBytes(length); + } + } + } + @Override protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { -- cgit v1.2.3