From beb43ba371de5862a7ca6579daef20c8ffd83f2d Mon Sep 17 00:00:00 2001 From: Aaron Donnelly Date: Thu, 20 Apr 2023 12:06:41 +0100 Subject: Teltonika io30 addition --- src/main/java/org/traccar/model/Position.java | 3 ++- src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java index 2bd71f383..acb1026f2 100644 --- a/src/main/java/org/traccar/model/Position.java +++ b/src/main/java/org/traccar/model/Position.java @@ -23,7 +23,8 @@ import org.traccar.storage.StorageName; @StorageName("tc_positions") public class Position extends Message { - + + public static final String KEY_FAULT_COUNT = "faultCount"; public static final String KEY_ORIGINAL = "raw"; public static final String KEY_INDEX = "index"; public static final String KEY_HDOP = "hdop"; diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java index 969b24297..7f692a30a 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -231,6 +231,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { register(26, null, (p, b) -> p.set("bleTemp2", b.readShort() * 0.01)); register(27, null, (p, b) -> p.set("bleTemp3", b.readShort() * 0.01)); register(28, null, (p, b) -> p.set("bleTemp4", b.readShort() * 0.01)); + register(30, fmbXXX, (p, b) -> p.set(Position.KEY_FAULT_COUNT, b.readUnsignedByte())); register(66, null, (p, b) -> p.set(Position.KEY_POWER, b.readUnsignedShort() * 0.001)); register(67, null, (p, b) -> p.set(Position.KEY_BATTERY, b.readUnsignedShort() * 0.001)); register(68, fmbXXX, (p, b) -> p.set("batteryCurrent", b.readUnsignedShort() * 0.001)); -- cgit v1.2.3 From 1e992e5f83cf97b13803098edec64d68f1843e91 Mon Sep 17 00:00:00 2001 From: Kieran Dodson <128472473+K-J-Dod24@users.noreply.github.com> Date: Tue, 9 May 2023 10:18:42 +0100 Subject: Revert "Teltonika io30 fault count" --- src/main/java/org/traccar/model/Position.java | 3 +-- src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java index be995ca2a..3ed340703 100644 --- a/src/main/java/org/traccar/model/Position.java +++ b/src/main/java/org/traccar/model/Position.java @@ -25,8 +25,7 @@ import org.traccar.storage.StorageName; @StorageName("tc_positions") public class Position extends Message { - - public static final String KEY_FAULT_COUNT = "faultCount"; + public static final String KEY_ORIGINAL = "raw"; public static final String KEY_INDEX = "index"; public static final String KEY_HDOP = "hdop"; diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java index 7f692a30a..969b24297 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -231,7 +231,6 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { register(26, null, (p, b) -> p.set("bleTemp2", b.readShort() * 0.01)); register(27, null, (p, b) -> p.set("bleTemp3", b.readShort() * 0.01)); register(28, null, (p, b) -> p.set("bleTemp4", b.readShort() * 0.01)); - register(30, fmbXXX, (p, b) -> p.set(Position.KEY_FAULT_COUNT, b.readUnsignedByte())); register(66, null, (p, b) -> p.set(Position.KEY_POWER, b.readUnsignedShort() * 0.001)); register(67, null, (p, b) -> p.set(Position.KEY_BATTERY, b.readUnsignedShort() * 0.001)); register(68, fmbXXX, (p, b) -> p.set("batteryCurrent", b.readUnsignedShort() * 0.001)); -- cgit v1.2.3 From 7b935f715761120a4149e6aaced7641314c53c47 Mon Sep 17 00:00:00 2001 From: K-J-Dod24 Date: Tue, 9 May 2023 14:01:44 +0100 Subject: io30 teltonika fault count --- src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java index 969b24297..fc18424df 100644 --- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java @@ -231,6 +231,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder { register(26, null, (p, b) -> p.set("bleTemp2", b.readShort() * 0.01)); register(27, null, (p, b) -> p.set("bleTemp3", b.readShort() * 0.01)); register(28, null, (p, b) -> p.set("bleTemp4", b.readShort() * 0.01)); + register(30, fmbXXX, (p, b) -> p.set("faultCount", b.readUnsignedByte())); register(66, null, (p, b) -> p.set(Position.KEY_POWER, b.readUnsignedShort() * 0.001)); register(67, null, (p, b) -> p.set(Position.KEY_BATTERY, b.readUnsignedShort() * 0.001)); register(68, fmbXXX, (p, b) -> p.set("batteryCurrent", b.readUnsignedShort() * 0.001)); -- cgit v1.2.3 From 680fe003a7cc9da354a989936d8f7f07580110bb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 9 May 2023 07:35:17 -0700 Subject: Add Flespi event code --- src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java b/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java index a7f6c284a..95d491af7 100644 --- a/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/FlespiProtocolDecoder.java @@ -130,6 +130,9 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder { case "dout": position.set(Position.KEY_OUTPUT, ((JsonNumber) value).intValue()); return true; + case "report.reason": + position.set(Position.KEY_EVENT, ((JsonNumber) value).intValue()); + return true; case "gps.vehicle.mileage": position.set(Position.KEY_ODOMETER, ((JsonNumber) value).doubleValue()); return true; -- cgit v1.2.3 From 1e8c232e37d0f041a8518cb4790322965bdd6fd5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 9 May 2023 07:51:41 -0700 Subject: Handle missing geofences --- .../handler/events/GeofenceEventHandler.java | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java index 0ab9ca217..096f71373 100644 --- a/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java +++ b/src/main/java/org/traccar/handler/events/GeofenceEventHandler.java @@ -16,15 +16,12 @@ package org.traccar.handler.events; import io.netty.channel.ChannelHandler; -import org.traccar.config.Config; import org.traccar.helper.model.PositionUtil; import org.traccar.model.Calendar; import org.traccar.model.Event; import org.traccar.model.Geofence; import org.traccar.model.Position; -import org.traccar.session.ConnectionManager; import org.traccar.session.cache.CacheManager; -import org.traccar.storage.Storage; import javax.inject.Inject; import javax.inject.Singleton; @@ -37,18 +34,11 @@ import java.util.Map; @ChannelHandler.Sharable public class GeofenceEventHandler extends BaseEventHandler { - private final Config config; private final CacheManager cacheManager; - private final ConnectionManager connectionManager; - private final Storage storage; @Inject - public GeofenceEventHandler( - Config config, CacheManager cacheManager, ConnectionManager connectionManager, Storage storage) { - this.config = config; + public GeofenceEventHandler(CacheManager cacheManager) { this.cacheManager = cacheManager; - this.connectionManager = connectionManager; - this.storage = storage; } @Override @@ -72,12 +62,15 @@ public class GeofenceEventHandler extends BaseEventHandler { Map events = new HashMap<>(); for (long geofenceId : oldGeofences) { - long calendarId = cacheManager.getObject(Geofence.class, geofenceId).getCalendarId(); - Calendar calendar = calendarId != 0 ? cacheManager.getObject(Calendar.class, calendarId) : null; - if (calendar == null || calendar.checkMoment(position.getFixTime())) { - Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position); - event.setGeofenceId(geofenceId); - events.put(event, position); + Geofence geofence = cacheManager.getObject(Geofence.class, geofenceId); + if (geofence != null) { + long calendarId = geofence.getCalendarId(); + Calendar calendar = calendarId != 0 ? cacheManager.getObject(Calendar.class, calendarId) : null; + if (calendar == null || calendar.checkMoment(position.getFixTime())) { + Event event = new Event(Event.TYPE_GEOFENCE_EXIT, position); + event.setGeofenceId(geofenceId); + events.put(event, position); + } } } for (long geofenceId : newGeofences) { -- cgit v1.2.3 From e2402983eb53f6cd384cdd09cc0d217772023b9a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 9 May 2023 08:16:00 -0700 Subject: Expand transparent data --- .../traccar/protocol/HuabaoProtocolDecoder.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index 1aebba4e6..f0b7cf6ca 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -877,6 +877,22 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { case 0x0539: position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedShort() * 0.01); break; + case 0x052D: + position.set(Position.KEY_COOLANT_TEMP, buf.readUnsignedByte() - 40); + break; + case 0x0530: + position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001); + break; + case 0x0535: + position.set(Position.KEY_OBD_SPEED, buf.readUnsignedShort() * 0.1); + break; + case 0x0536: + position.set(Position.KEY_RPM, buf.readUnsignedShort()); + break; + case 0x0547: + case 0x0548: + position.set(Position.KEY_THROTTLE, buf.readUnsignedByte()); + break; default: switch (length) { case 1: @@ -898,6 +914,17 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { decodeCoordinates(position, buf); position.setTime(time); break; + case 0x02: + count = buf.readUnsignedByte(); + for (int i = 0; i < count; i++) { + buf.readUnsignedInt(); // system id + int codeCount = buf.readUnsignedShort(); + for (int j = 0; j < codeCount; j++) { + buf.skipBytes(16); // code + } + } + decodeCoordinates(position, buf); + break; case 0x03: count = buf.readUnsignedByte(); for (int i = 0; i < count; i++) { -- cgit v1.2.3 From 4c57f717f678969a46d9d84538a3116018dce9c1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 9 May 2023 08:19:24 -0700 Subject: Use last location info --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index f0b7cf6ca..fcbb55043 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -911,8 +911,8 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { break; } } + getLastLocation(position, time); decodeCoordinates(position, buf); - position.setTime(time); break; case 0x02: count = buf.readUnsignedByte(); @@ -923,6 +923,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { buf.skipBytes(16); // code } } + getLastLocation(position, time); decodeCoordinates(position, buf); break; case 0x03: @@ -953,8 +954,8 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } buf.skipBytes(length); } + getLastLocation(position, time); decodeCoordinates(position, buf); - position.setTime(time); break; case 0x0B: if (buf.readUnsignedByte() > 0) { -- cgit v1.2.3 From d797671b2ce6fb70ac868bb96f87be8b2a85e4f9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 9 May 2023 08:23:16 -0700 Subject: Fix unit tests --- src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java index fcbb55043..05e2fb8cc 100644 --- a/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/HuabaoProtocolDecoder.java @@ -913,6 +913,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } getLastLocation(position, time); decodeCoordinates(position, buf); + position.setTime(time); break; case 0x02: count = buf.readUnsignedByte(); @@ -925,6 +926,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } getLastLocation(position, time); decodeCoordinates(position, buf); + position.setTime(time); break; case 0x03: count = buf.readUnsignedByte(); @@ -956,6 +958,7 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder { } getLastLocation(position, time); decodeCoordinates(position, buf); + position.setTime(time); break; case 0x0B: if (buf.readUnsignedByte() > 0) { -- cgit v1.2.3