diff options
Diffstat (limited to 'src/org/traccar/protocol')
7 files changed, 146 insertions, 42 deletions
diff --git a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java index e664c4734..c47764989 100644 --- a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java +++ b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java @@ -210,7 +210,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { .number("(?:[0-9A-Z]{2}xxxx)?,") // protocol version .number("(d{15}|x{14}),") // imei .expression("[^,]*,") // device name - .number("x{8},") // mask + .number("(x{8}),") // mask .number("(d+)?,") // power .number("d{1,2},") // report type .number("d{1,2},") // count @@ -730,6 +730,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { return null; } + long mask = parser.nextHexLong(); + LinkedList<Position> positions = new LinkedList<>(); int power = parser.nextInt(0); @@ -759,14 +761,35 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder { int index = 0; String[] data = parser.next().split(","); - if (data.length > 1) { - int deviceType = Integer.parseInt(data[index++]); - if (deviceType == 2) { - int deviceCount = Integer.parseInt(data[index++]); - for (int i = 1; i <= deviceCount; i++) { - index++; // id - index++; // type - position.set(Position.PREFIX_TEMP + i, (short) Integer.parseInt(data[index++], 16) * 0.0625); + + index += 1; // device type + + if (BitUtil.check(mask, 0)) { + index += 1; // digital fuel sensor data + } + + if (BitUtil.check(mask, 1)) { + int deviceCount = Integer.parseInt(data[index++]); + for (int i = 1; i <= deviceCount; i++) { + index += 1; // id + index += 1; // type + position.set(Position.PREFIX_TEMP + i, (short) Integer.parseInt(data[index++], 16) * 0.0625); + } + } + + if (BitUtil.check(mask, 2)) { + index += 1; // can data + } + + if (BitUtil.check(mask, 3) || BitUtil.check(mask, 4)) { + int deviceCount = Integer.parseInt(data[index++]); + for (int i = 1; i <= deviceCount; i++) { + index += 1; // type + if (BitUtil.check(mask, 3)) { + position.set(Position.KEY_FUEL_LEVEL, Double.parseDouble(data[index++])); + } + if (BitUtil.check(mask, 4)) { + index += 1; // volume } } } diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index 5ee663ee1..9764adf04 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -456,7 +456,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { switch (marker) { case "*": - String sentence = buf.toString(StandardCharsets.US_ASCII); + String sentence = buf.toString(StandardCharsets.US_ASCII).trim(); int typeStart = sentence.indexOf(',', sentence.indexOf(',') + 1) + 1; int typeEnd = sentence.indexOf(',', typeStart); if (typeEnd > 0) { diff --git a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java index 6e11a763c..d2f1d3d69 100644 --- a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java +++ b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java @@ -58,6 +58,23 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder { .number("(-?d+),") // tilt .number("(d+),") // trip .number("(d+),") // odometer + .groupBegin() + .number("([01]),") // overspeed + .number("[01],") // input 2 misuse + .number("[01],") // immobilizer + .number("[01],") // temperature alert + .number("[0-2]+,") // geofence + .number("([0-3]),") // harsh driving + .number("[01],") // reconnect + .number("([01]),") // low battery + .number("([01]),") // power disconnected + .number("[01],") // gps failure + .number("([01]),") // towing + .number("[01],") // server unreachable + .number("[128],") // sleep mode + .expression("([^,]+)?,") // driver id + .number("d+,") // sms count + .groupEnd("?") .any() .compile(); @@ -138,6 +155,27 @@ public class Ivt401ProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextLong()); + if (parser.hasNext(6)) { + position.set(Position.KEY_ALARM, parser.nextInt() == 1 ? Position.ALARM_OVERSPEED : null); + switch (parser.nextInt()) { + case 1: + position.set(Position.KEY_ALARM, Position.ALARM_ACCELERATION); + break; + case 2: + position.set(Position.KEY_ALARM, Position.ALARM_BRAKING); + break; + case 3: + position.set(Position.KEY_ALARM, Position.ALARM_CORNERING); + break; + default: + break; + } + position.set(Position.KEY_ALARM, parser.nextInt() == 1 ? Position.ALARM_LOW_BATTERY : null); + position.set(Position.KEY_ALARM, parser.nextInt() == 1 ? Position.ALARM_POWER_CUT : null); + position.set(Position.KEY_ALARM, parser.nextInt() == 1 ? Position.ALARM_TOW : null); + position.set(Position.KEY_DRIVER_UNIQUE_ID, parser.next()); + } + return position; } diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java index 11e38194f..3a1885d6f 100644 --- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java +++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java @@ -378,6 +378,9 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { case 0x06: position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); break; + case 0x07: + position.set(Position.KEY_RSSI, buf.readUnsignedByte()); + break; default: buf.readUnsignedByte(); break; @@ -397,6 +400,12 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { case 0x0B: position.setAltitude(buf.readShort()); break; + case 0x19: + position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01); + break; + case 0x1A: + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01); + break; default: buf.readUnsignedShort(); break; @@ -416,6 +425,9 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { case 0x04: position.setTime(new Date((946684800 + buf.readUnsignedInt()) * 1000)); // 2000-01-01 break; + case 0x0D: + position.set("runtime", buf.readUnsignedInt()); + break; default: buf.readUnsignedInt(); break; @@ -434,9 +446,9 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { return positions; } - private void requestPhotoPacket(Channel channel, String imei, int index) { + private void requestPhotoPacket(Channel channel, String imei, String file, int index) { if (channel != null) { - String content = "D00,camera_picture.jpg," + index; + String content = "D00," + file + "," + index; int length = 1 + imei.length() + 1 + content.length() + 5; String response = String.format("@@O%02d,%s,%s*", length, imei, content); response += Checksum.sum(response) + "\r\n"; @@ -458,11 +470,14 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { switch (type) { case "D00": if (photo == null) { - return null; + photo = ChannelBuffers.dynamicBuffer(); } - index = buf.indexOf(index + 1 + type.length() + 1, buf.writerIndex(), (byte) ',') + 1; + index = index + 1 + type.length() + 1; int endIndex = buf.indexOf(index, buf.writerIndex(), (byte) ','); + String file = buf.toString(index, endIndex - index, StandardCharsets.US_ASCII); + index = endIndex + 1; + endIndex = buf.indexOf(index, buf.writerIndex(), (byte) ','); int total = Integer.parseInt(buf.toString(index, endIndex - index, StandardCharsets.US_ASCII)); index = endIndex + 1; endIndex = buf.indexOf(index, buf.writerIndex(), (byte) ','); @@ -483,13 +498,13 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder { return position; } else { if ((current + 1) % 8 == 0) { - requestPhotoPacket(channel, imei, current + 1); + requestPhotoPacket(channel, imei, file, current + 1); } return null; } case "D03": photo = ChannelBuffers.dynamicBuffer(); - requestPhotoPacket(channel, imei, 0); + requestPhotoPacket(channel, imei, "camera_picture.jpg", 0); return null; case "CCC": return decodeBinaryC(channel, remoteAddress, buf); diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java index 58e670307..b739e699b 100644 --- a/src/org/traccar/protocol/SuntechProtocolDecoder.java +++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java @@ -21,6 +21,8 @@ import org.traccar.Context; import org.traccar.DeviceSession; import org.traccar.helper.BitUtil; import org.traccar.helper.UnitsConverter; +import org.traccar.model.CellTower; +import org.traccar.model.Network; import org.traccar.model.Position; import java.net.SocketAddress; @@ -156,7 +158,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { } } - private Position decode235( + private Position decode2356( Channel channel, SocketAddress remoteAddress, String protocol, String[] values) throws ParseException { int index = 0; @@ -175,7 +177,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { position.setDeviceId(deviceSession.getDeviceId()); position.set(Position.KEY_TYPE, type); - if (protocol.equals("ST300") || protocol.equals("ST500")) { + if (protocol.equals("ST300") || protocol.equals("ST500") || protocol.equals("ST600")) { index += 1; // model } @@ -186,7 +188,12 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { position.setTime(dateFormat.parse(values[index++] + values[index++])); if (!protocol.equals("ST500")) { - index += 1; // cell + int cid = Integer.parseInt(values[index++], 16); + if (protocol.equals("ST600")) { + position.setNetwork(new Network(CellTower.from( + Integer.parseInt(values[index++]), Integer.parseInt(values[index++]), + Integer.parseInt(values[index++], 16), cid, Integer.parseInt(values[index++])))); + } } position.setLatitude(Double.parseDouble(values[index++])); @@ -369,7 +376,7 @@ public class SuntechProtocolDecoder extends BaseProtocolDecoder { } else if (values[0].equals("ST910")) { return decode9(channel, remoteAddress, values); } else { - return decode235(channel, remoteAddress, values[0].substring(0, 5), values); + return decode2356(channel, remoteAddress, values[0].substring(0, 5), values); } } diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java index 9c98799fb..9555d19e9 100644 --- a/src/org/traccar/protocol/TaipProtocolDecoder.java +++ b/src/org/traccar/protocol/TaipProtocolDecoder.java @@ -47,7 +47,7 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { .groupEnd("?") .number("(d{5})") // seconds .or() - .expression("(?:RGP|RCQ|RBR)") // type + .expression("(?:RGP|RCQ|RCV|RBR)") // type .number("(dd)?") // event .number("(dd)(dd)(dd)") // date (mmddyy) .number("(dd)(dd)(dd)") // time (hhmmss) @@ -67,6 +67,19 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { .number("(ddd)") // battery .number("(x{8})") // odometer .number("[01]") // gps power + .groupBegin() + .number("[23]") // fix mode + .number("(dd)") // pdop + .number("dd") // satellites + .number("xxxx") // seconds from last + .number("[01]") // modem power + .number("[0-5]") // gsm status + .number("(dd)") // rssi + .number("([-+]dddd)") // temperature 1 + .number("xx") // seconds from last + .number("([-+]dddd)") // temperature 2 + .number("xx") // seconds from last + .groupEnd("?") .groupEnd("?") .any() .compile(); @@ -160,6 +173,13 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_ODOMETER, parser.nextLong(16, 0)); } + if (parser.hasNext(4)) { + position.set(Position.KEY_PDOP, parser.nextInt()); + position.set(Position.KEY_RSSI, parser.nextInt()); + position.set(Position.PREFIX_TEMP + 1, parser.nextInt() * 0.01); + position.set(Position.PREFIX_TEMP + 2, parser.nextInt() * 0.01); + } + position.setValid(true); String[] attributes = null; diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java index 1c5130a6c..7d8a22f8c 100644 --- a/src/org/traccar/protocol/TotemProtocolDecoder.java +++ b/src/org/traccar/protocol/TotemProtocolDecoder.java @@ -18,6 +18,7 @@ package org.traccar.protocol; 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.Parser; import org.traccar.helper.PatternBuilder; @@ -167,26 +168,12 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { switch (value) { case 0x01: return Position.ALARM_SOS; - case 0x02: - return Position.ALARM_OVERSPEED; - case 0x04: - return Position.ALARM_GEOFENCE_EXIT; - case 0x05: - return Position.ALARM_GEOFENCE_ENTER; - case 0x06: - return Position.ALARM_TOW; case 0x10: return Position.ALARM_LOW_BATTERY; case 0x11: return Position.ALARM_OVERSPEED; - case 0x12: - return Position.ALARM_LOW_POWER; - case 0x13: - return Position.ALARM_LOW_BATTERY; case 0x30: return Position.ALARM_PARKING; - case 0x40: - return Position.ALARM_SHOCK; case 0x42: return Position.ALARM_GEOFENCE_EXIT; case 0x43: @@ -259,11 +246,7 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { private boolean decode3(Position position, Parser parser) { if (parser.hasNext()) { - short alarm = Short.parseShort(parser.next(), 16); - position.set(Position.KEY_ALARM, decodeAlarm(alarm)); - if (alarm >= 0x21 && alarm <= 0x28) { - position.set(Position.PREFIX_IN + ((alarm - 0x21) / 2 + 1), alarm % 2 > 0); - } + position.set(Position.KEY_ALARM, decodeAlarm(Short.parseShort(parser.next(), 16))); } position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS)); @@ -294,7 +277,26 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { private boolean decode4(Position position, Parser parser) { - position.set(Position.KEY_STATUS, parser.next()); + long status = parser.nextHexLong(); + + position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 1) ? Position.ALARM_SOS : null); + position.set(Position.KEY_IGNITION, BitUtil.check(status, 32 - 2)); + position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 3) ? Position.ALARM_OVERSPEED : null); + position.set(Position.KEY_CHARGE, BitUtil.check(status, 32 - 4)); + position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 5) ? Position.ALARM_GEOFENCE_EXIT : null); + position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 6) ? Position.ALARM_GEOFENCE_ENTER : null); + position.set(Position.PREFIX_OUT + 1, BitUtil.check(status, 32 - 9)); + position.set(Position.PREFIX_OUT + 2, BitUtil.check(status, 32 - 10)); + position.set(Position.PREFIX_OUT + 3, BitUtil.check(status, 32 - 11)); + position.set(Position.PREFIX_OUT + 4, BitUtil.check(status, 32 - 12)); + position.set(Position.PREFIX_IN + 2, BitUtil.check(status, 32 - 13)); + position.set(Position.PREFIX_IN + 3, BitUtil.check(status, 32 - 14)); + position.set(Position.PREFIX_IN + 4, BitUtil.check(status, 32 - 15)); + position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 16) ? Position.ALARM_SHOCK : null); + position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 18) ? Position.ALARM_LOW_BATTERY : null); + position.set(Position.KEY_ALARM, BitUtil.check(status, 32 - 22) ? Position.ALARM_JAMMING : null); + + position.setValid(BitUtil.check(status, 32 - 20)); position.setTime(parser.nextDateTime()); @@ -318,7 +320,6 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder { position.set(Position.KEY_HDOP, parser.nextDouble(0)); position.set(Position.KEY_ODOMETER, parser.nextInt(0) * 1000); - position.setValid(true); position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); |