From ed8a0952ab8ee3bd23ea9ca616252984e9fe4c70 Mon Sep 17 00:00:00 2001 From: Maarten Meersseman Date: Tue, 17 Jul 2018 13:09:22 +0200 Subject: [PATCH 1/4] Added gps status https://github.com/traccar/traccar/issues/3973 --- src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 5e9b6640e9e..5b5097b8f34 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -125,6 +125,9 @@ private void decodeOtherParameter(Position position, int id, ByteBuf buf, int le case 67: position.set(Position.KEY_BATTERY, readValue(buf, length, false) * 0.001); break; + case 69: + position.set("gpsStatus", readValue(buf, length, false)); + break; case 72: position.set(Position.PREFIX_TEMP + 1, readValue(buf, length, true) * 0.1); break; From 586eff69dde0111c6acd47ea5ecff0beac1d626c Mon Sep 17 00:00:00 2001 From: Maarten Meersseman Date: Wed, 18 Jul 2018 11:56:15 +0200 Subject: [PATCH 2/4] Mapped the gpsStatus to a validity state --- src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 5b5097b8f34..3892b107bce 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -36,6 +36,7 @@ import java.util.List; public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { + private static final long GPS_STATUS_WORKING_WITH_GPS_FIX = 3; private boolean connectionless; private boolean extended; @@ -126,7 +127,10 @@ private void decodeOtherParameter(Position position, int id, ByteBuf buf, int le position.set(Position.KEY_BATTERY, readValue(buf, length, false) * 0.001); break; case 69: - position.set("gpsStatus", readValue(buf, length, false)); + final long gpsStatus = readValue(buf, length, false); + position.set("gpsStatus", gpsStatus); + final boolean validGpsStatus = GPS_STATUS_WORKING_WITH_GPS_FIX == gpsStatus; + position.setValid(position.getValid() && validGpsStatus); break; case 72: position.set(Position.PREFIX_TEMP + 1, readValue(buf, length, true) * 0.1); From 1a87b6958947484d0ab8b5acecf5ff7c3c491fd1 Mon Sep 17 00:00:00 2001 From: Maarten Meersseman Date: Thu, 19 Jul 2018 17:34:28 +0200 Subject: [PATCH 3/4] Mapped the gpsStatus to a validity state, no longer considering satellites for validity --- src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 3892b107bce..5f0380fcd67 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -36,7 +36,6 @@ import java.util.List; public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { - private static final long GPS_STATUS_WORKING_WITH_GPS_FIX = 3; private boolean connectionless; private boolean extended; @@ -129,8 +128,7 @@ private void decodeOtherParameter(Position position, int id, ByteBuf buf, int le case 69: final long gpsStatus = readValue(buf, length, false); position.set("gpsStatus", gpsStatus); - final boolean validGpsStatus = GPS_STATUS_WORKING_WITH_GPS_FIX == gpsStatus; - position.setValid(position.getValid() && validGpsStatus); + position.setValid(gpsStatus == 3); break; case 72: position.set(Position.PREFIX_TEMP + 1, readValue(buf, length, true) * 0.1); @@ -308,9 +306,7 @@ private void decodeLocation(Position position, ByteBuf buf, int codec) { } if (BitUtil.check(locationMask, 4)) { - int satellites = buf.readUnsignedByte(); - position.set(Position.KEY_SATELLITES, satellites); - position.setValid(satellites >= 3); + position.set(Position.KEY_SATELLITES, (int) buf.readUnsignedByte()); } if (BitUtil.check(locationMask, 5)) { @@ -430,6 +426,7 @@ private List parseData( Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); + position.setValid(true); if (codec == CODEC_12) { decodeSerial(position, buf); From d1dfd6a9fb16e1682777ca361d91c1669489ca59 Mon Sep 17 00:00:00 2001 From: Maarten Meersseman Date: Fri, 20 Jul 2018 09:35:40 +0200 Subject: [PATCH 4/4] removed conversion --- src/org/traccar/protocol/TeltonikaProtocolDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java index 5f0380fcd67..19f4bd67b7c 100644 --- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -306,7 +306,7 @@ private void decodeLocation(Position position, ByteBuf buf, int codec) { } if (BitUtil.check(locationMask, 4)) { - position.set(Position.KEY_SATELLITES, (int) buf.readUnsignedByte()); + position.set(Position.KEY_SATELLITES, buf.readUnsignedByte()); } if (BitUtil.check(locationMask, 5)) {