diff options
Diffstat (limited to 'src/org/traccar/protocol')
5 files changed, 71 insertions, 49 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java index d245fbdc8..31bdd9aa9 100644 --- a/src/org/traccar/protocol/H02ProtocolDecoder.java +++ b/src/org/traccar/protocol/H02ProtocolDecoder.java @@ -122,9 +122,17 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { .any() .number("(dd)(dd)(dd),") // time .expression("([AV])?,") // validity - .number("-?(d+)-?(dd.d+),") // latitude + .groupBegin() + .number("(d+)(dd.d+),") // latitude + .or() + .number("-(d+)-(d+.d+),") // latitude + .groupEnd() .expression("([NS]),") - .number("-?(d+)-?(dd.d+),") // longitude + .groupBegin() + .number("(d+)(dd.d+),") // longitude + .or() + .number("-(d+)-(d+.d+),") // longitude + .groupEnd() .expression("([EW]),") .number("(d+.?d*),") // speed .number("(d+.?d*)?,") // course @@ -155,8 +163,20 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder { position.setValid(parser.next().equals("A")); } - position.setLatitude(parser.nextCoordinate()); - position.setLongitude(parser.nextCoordinate()); + if (parser.hasNext(2)) { + position.setLatitude(parser.nextCoordinate()); + } + if (parser.hasNext(2)) { + position.setLatitude(parser.nextCoordinate()); + } + + if (parser.hasNext(2)) { + position.setLongitude(parser.nextCoordinate()); + } + if (parser.hasNext(2)) { + position.setLongitude(parser.nextCoordinate()); + } + position.setSpeed(parser.nextDouble()); position.setCourse(parser.nextDouble()); diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 2217b5ce4..e82425a54 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -81,49 +81,54 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { long time = buf.readUnsignedInt() & 0x3fffffff; time += 1167609600; // 2007-01-01 00:00:00 - position.setTime(new Date(time * 1000)); globalMask = buf.readUnsignedByte(); - if (!BitUtil.check(globalMask, 0)) { - return null; - } + if (BitUtil.check(globalMask, 0)) { - int locationMask = buf.readUnsignedByte(); + position.setTime(new Date(time * 1000)); - if (BitUtil.check(locationMask, 0)) { - position.setLatitude(buf.readFloat()); - position.setLongitude(buf.readFloat()); - } + int locationMask = buf.readUnsignedByte(); - if (BitUtil.check(locationMask, 1)) { - position.setAltitude(buf.readUnsignedShort()); - } + if (BitUtil.check(locationMask, 0)) { + position.setLatitude(buf.readFloat()); + position.setLongitude(buf.readFloat()); + } - if (BitUtil.check(locationMask, 2)) { - position.setCourse(buf.readUnsignedByte() * 360.0 / 256); - } + if (BitUtil.check(locationMask, 1)) { + position.setAltitude(buf.readUnsignedShort()); + } - if (BitUtil.check(locationMask, 3)) { - position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); - } + if (BitUtil.check(locationMask, 2)) { + position.setCourse(buf.readUnsignedByte() * 360.0 / 256); + } - if (BitUtil.check(locationMask, 4)) { - int satellites = buf.readUnsignedByte(); - position.set(Event.KEY_SATELLITES, satellites); - position.setValid(satellites >= 3); - } + if (BitUtil.check(locationMask, 3)) { + position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte())); + } - if (BitUtil.check(locationMask, 5)) { - position.set(Event.KEY_LAC, buf.readUnsignedShort()); - position.set(Event.KEY_CID, buf.readUnsignedShort()); - } + if (BitUtil.check(locationMask, 4)) { + int satellites = buf.readUnsignedByte(); + position.set(Event.KEY_SATELLITES, satellites); + position.setValid(satellites >= 3); + } - if (BitUtil.check(locationMask, 6)) { - position.set(Event.KEY_GSM, buf.readUnsignedByte()); - } + if (BitUtil.check(locationMask, 5)) { + position.set(Event.KEY_LAC, buf.readUnsignedShort()); + position.set(Event.KEY_CID, buf.readUnsignedShort()); + } + + if (BitUtil.check(locationMask, 6)) { + position.set(Event.KEY_GSM, buf.readUnsignedByte()); + } + + if (BitUtil.check(locationMask, 7)) { + position.set("operator", buf.readUnsignedInt()); + } + + } else { + + getLastLocation(position, new Date(time * 1000)); - if (BitUtil.check(locationMask, 7)) { - position.set("operator", buf.readUnsignedInt()); } } else { diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 6fa4edb06..e8d0d210d 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -154,6 +154,11 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { } position.setDeviceId(getDeviceId()); + int alarm = sentence.indexOf("BO01"); + if (alarm != -1) { + position.set(Event.KEY_ALARM, Integer.parseInt(sentence.substring(alarm + 4, alarm + 5))); + } + DateBuilder dateBuilder = new DateBuilder(); if (parser.next() == null) { dateBuilder.setDate(parser.nextInt(), parser.nextInt(), parser.nextInt()); diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java index b0c1d243b..40861bacb 100644 --- a/src/org/traccar/protocol/TytanProtocolDecoder.java +++ b/src/org/traccar/protocol/TytanProtocolDecoder.java @@ -18,10 +18,8 @@ package org.traccar.protocol; import java.net.SocketAddress; import java.nio.charset.Charset; import java.util.Date; -import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; -import java.util.Set; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; @@ -81,16 +79,8 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder { position.set("authorized", ChannelBuffers.hexDump(buf.readBytes(8))); break; case 24: - Set<Integer> temps = new LinkedHashSet<>(); - int temp = buf.readUnsignedByte(); - for (int i = 3; i >= 0; i--) { - n = (temp >> (2 * i)) & 0x03; - if (!temps.contains(n)) { - temps.add(n); - } - } - for (int i : temps) { - position.set(Event.PREFIX_TEMP + i, buf.readUnsignedByte()); + for (int i = 0; i < length / 2; i++) { + position.set(Event.PREFIX_TEMP + buf.readUnsignedByte(), buf.readByte()); } break; case 28: diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java index 5d882ffd8..dd6fb1593 100644 --- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java +++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java @@ -204,7 +204,9 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder { case DATA_EVENT: position.set(Event.KEY_EVENT, buf.readUnsignedByte()); - position.set("event-mask", buf.readUnsignedInt()); + if (length > 1) { + position.set("event-mask", buf.readUnsignedInt()); + } break; default: |