From ccaf3a078fd7c697863546108962e792cf414a66 Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Tue, 19 Apr 2022 23:55:42 +0300 Subject: - add 53-69 fields for Navtelecom protocol --- .../protocol/NavtelecomProtocolDecoder.java | 82 +++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 5fb3e771f..4bef62b5c 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -269,7 +269,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.set("freq" + (j + 2 - 35), buf.readUnsignedShortLE()); break; case 37: - position.set(Position.KEY_HOURS, buf.readUnsignedIntLE()); + position.set(Position.KEY_HOURS, buf.readUnsignedIntLE() / 60); break; case 38: case 39: @@ -295,6 +295,86 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { value = buf.readByte(); position.set(Position.PREFIX_TEMP + (j + 2 - 45), (value != 0x80) ? value : null); break; + case 53: + value = buf.readUnsignedShortLE(); + if(value == 0x7FFF){ + position.set(Position.KEY_FUEL_LEVEL + "Level", (Boolean) null); + position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); + } else if (BitUtil.check(value, 7)){ + position.set(Position.KEY_FUEL_LEVEL + "Level", BitUtil.to(value, 6)); + position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); + } + else{ + position.set(Position.KEY_FUEL_LEVEL + "Level", (Boolean) null); + position.set(Position.KEY_FUEL_LEVEL, BitUtil.to(value, 6) / 10); + } + break; + case 54: + position.set(Position.KEY_FUEL_USED, buf.readFloatLE()); + break; + case 55: + value = buf.readUnsignedShortLE(); + position.set(Position.KEY_RPM, (value != 0xFFFF) ? value : null); + break; + case 56: + value = buf.readByte(); + position.set(Position.KEY_COOLANT_TEMP, (value != 0x80) ? value : null); + break; + case 57: + position.set(Position.KEY_OBD_ODOMETER, buf.readFloatLE()); + break; + case 58: + case 59: + case 60: + case 61: + case 62: + value = buf.readUnsignedShortLE(); + position.set( + Position.KEY_AXLE_WEIGHT + (j + 2 - 58), (value != 65535) ? value : null + ); + break; + case 63: + value = buf.readUnsignedByte(); + position.set("obdAccelPos", (value != 0xFF) ? value : null); + break; + case 64: + value = buf.readUnsignedByte(); + position.set("obdBrakePos", (value != 0xFF) ? value : null); + break; + case 65: + value = buf.readUnsignedByte(); + position.set(Position.KEY_ENGINE_LOAD, (value != 0xFF) ? value : null); + break; + case 66: + value = buf.readUnsignedShortLE(); + if(value == 0x7FFF){ + position.set("obdAdBlueLevel", (Boolean) null); + position.set("obdAdBlue", (Boolean) null); + } else if (BitUtil.check(value, 7)){ + position.set("obdAdBlueLevel", BitUtil.to(value, 6)); + position.set("obdAdBlue", (Boolean) null); + } + else{ + position.set("obdAdBlueLevel", (Boolean) null); + position.set("obdAdBlue", BitUtil.to(value, 6) / 10); + } + break; + case 67: + position.set("obdHours", buf.readUnsignedIntLE() / 60); + break; + case 68: + value = buf.readUnsignedShortLE(); + position.set( + Position.KEY_ODOMETER_SERVICE, (value != 0xFFFF) ? (value * 5000) : null + ); + break; + case 69: + value = buf.readUnsignedByte(); + position.set( + Position.KEY_OBD_SPEED, + (value != 0xFF) ? UnitsConverter.knotsFromKph(value) : null + ); + break; default: buf.skipBytes(getItemLength(j + 1)); break; -- cgit v1.2.3 From 41bb8b4934ad70241f98f9cc83866fd565e79da0 Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Wed, 20 Apr 2022 23:06:21 +0300 Subject: - fix checkstyle --- .../org/traccar/protocol/NavtelecomProtocolDecoder.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 4bef62b5c..cd0c3cdcb 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -297,14 +297,13 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 53: value = buf.readUnsignedShortLE(); - if(value == 0x7FFF){ + if (value == 0x7FFF) { position.set(Position.KEY_FUEL_LEVEL + "Level", (Boolean) null); position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); - } else if (BitUtil.check(value, 7)){ + } else if (BitUtil.check(value, 7)) { position.set(Position.KEY_FUEL_LEVEL + "Level", BitUtil.to(value, 6)); position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); - } - else{ + } else { position.set(Position.KEY_FUEL_LEVEL + "Level", (Boolean) null); position.set(Position.KEY_FUEL_LEVEL, BitUtil.to(value, 6) / 10); } @@ -347,14 +346,13 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 66: value = buf.readUnsignedShortLE(); - if(value == 0x7FFF){ + if (value == 0x7FFF) { position.set("obdAdBlueLevel", (Boolean) null); position.set("obdAdBlue", (Boolean) null); - } else if (BitUtil.check(value, 7)){ + } else if (BitUtil.check(value, 7)) { position.set("obdAdBlueLevel", BitUtil.to(value, 6)); position.set("obdAdBlue", (Boolean) null); - } - else{ + } else { position.set("obdAdBlueLevel", (Boolean) null); position.set("obdAdBlue", BitUtil.to(value, 6) / 10); } -- cgit v1.2.3 From 56ff656c908b19feb2fa3dcffa48cc3bcdfe9b3b Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Thu, 21 Apr 2022 21:01:19 +0300 Subject: - used "fuelLevel" key - refactor --- .../org/traccar/protocol/NavtelecomProtocolDecoder.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index cd0c3cdcb..ecaa6cbf4 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -298,13 +298,13 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 53: value = buf.readUnsignedShortLE(); if (value == 0x7FFF) { - position.set(Position.KEY_FUEL_LEVEL + "Level", (Boolean) null); + position.set("fuelLevel", (Boolean) null); position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); } else if (BitUtil.check(value, 7)) { - position.set(Position.KEY_FUEL_LEVEL + "Level", BitUtil.to(value, 6)); + position.set("fuelLevel", BitUtil.to(value, 6)); position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); } else { - position.set(Position.KEY_FUEL_LEVEL + "Level", (Boolean) null); + position.set("fuelLevel", (Boolean) null); position.set(Position.KEY_FUEL_LEVEL, BitUtil.to(value, 6) / 10); } break; @@ -329,8 +329,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 62: value = buf.readUnsignedShortLE(); position.set( - Position.KEY_AXLE_WEIGHT + (j + 2 - 58), (value != 65535) ? value : null - ); + Position.KEY_AXLE_WEIGHT + (j + 2 - 58), (value != 65535) ? value : null); break; case 63: value = buf.readUnsignedByte(); @@ -363,15 +362,13 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 68: value = buf.readUnsignedShortLE(); position.set( - Position.KEY_ODOMETER_SERVICE, (value != 0xFFFF) ? (value * 5000) : null - ); + Position.KEY_ODOMETER_SERVICE, (value != 0xFFFF) ? (value * 5000) : null); break; case 69: value = buf.readUnsignedByte(); position.set( Position.KEY_OBD_SPEED, - (value != 0xFF) ? UnitsConverter.knotsFromKph(value) : null - ); + (value != 0xFF) ? UnitsConverter.knotsFromKph(value) : null); break; default: buf.skipBytes(getItemLength(j + 1)); -- cgit v1.2.3 From fd92fa10d8bcbe8bca5a9212e3410d17ed9d280f Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Thu, 24 Aug 2023 22:58:36 +0300 Subject: - update fork; - refactor param checks, delete nulls; - add field 4 (alarm, armed); - add field 5 (roaming); - fix hours params; - fix accelerator and brake position keys; - move fields 78-83 (fuel temperature); - add fields 163-166 (high precision temperature); - add fields 167-170 (humidity); - add field 206 (diagnostics param); - add fields 207-255 (user parameters). --- .../protocol/NavtelecomProtocolDecoder.java | 193 ++++++++++++++++----- 1 file changed, 148 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 87cccbeaa..6ef614c8d 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -208,6 +208,19 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 3: position.setDeviceTime(new Date(buf.readUnsignedIntLE() * 1000)); break; + case 4: + value = buf.readUnsignedByte(); + position.set(Position.KEY_ALARM, BitUtil.check(value, 2)); + int guardMode = BitUtil.between(value, 3, 4); + position.set( + Position.KEY_ARMED, + (0 < guardMode) && (guardMode < 3)); + break; + + case 5: + value = buf.readUnsignedByte(); + position.set(Position.KEY_ROAMING, BitUtil.check(value, 6)); + break; case 8: value = buf.readUnsignedByte(); position.setValid(BitUtil.check(value, 1)); @@ -269,7 +282,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { position.set("freq" + (j + 2 - 35), buf.readUnsignedShortLE()); break; case 37: - position.set(Position.KEY_HOURS, buf.readUnsignedIntLE() / 60); + position.set(Position.KEY_HOURS, buf.readUnsignedIntLE() * 1000); break; case 38: case 39: @@ -278,11 +291,15 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 42: case 43: value = buf.readUnsignedShortLE(); - position.set("fuel" + (j + 2 - 38), (value < 65500) ? value : null); + if (value < 65500) { + position.set("fuel" + (j + 2 - 38), value); + } break; case 44: value = buf.readUnsignedShortLE(); - position.set(Position.KEY_FUEL_LEVEL, (value < 65500) ? value : null); + if (value < 65500) { + position.set(Position.KEY_FUEL_LEVEL, value); + } break; case 45: case 46: @@ -293,29 +310,18 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 51: case 52: value = buf.readByte(); - position.set( - Position.PREFIX_TEMP + (j + 2 - 45), - (value != (byte) 0x80) ? value : null); - break; - case 78: - case 79: - case 80: - case 81: - case 82: - case 83: - position.set("fuelTemp" + (j + 2 - 78), (int) buf.readByte()); + if (value != (byte) 0x80) { + position.set(Position.PREFIX_TEMP + (j + 2 - 45), value); + } break; case 53: value = buf.readUnsignedShortLE(); - if (value == 0x7FFF) { - position.set("fuelLevel", (Boolean) null); - position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); - } else if (BitUtil.check(value, 7)) { - position.set("fuelLevel", BitUtil.to(value, 6)); - position.set(Position.KEY_FUEL_LEVEL, (Boolean) null); - } else { - position.set("fuelLevel", (Boolean) null); - position.set(Position.KEY_FUEL_LEVEL, BitUtil.to(value, 6) / 10); + if (value != 0x7FFF) { + if (BitUtil.check(value, 7)) { + position.set("fuelLevel", BitUtil.to(value, 6)); + } else { + position.set(Position.KEY_FUEL_LEVEL, BitUtil.to(value, 6) / 10); + } } break; case 54: @@ -323,11 +329,15 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 55: value = buf.readUnsignedShortLE(); - position.set(Position.KEY_RPM, (value != 0xFFFF) ? value : null); + if (value != 0xFFFF) { + position.set(Position.KEY_RPM, value); + } break; case 56: value = buf.readByte(); - position.set(Position.KEY_COOLANT_TEMP, (value != 0x80) ? value : null); + if (value != (byte) 0x80) { + position.set(Position.KEY_COOLANT_TEMP, value); + } break; case 57: position.set(Position.KEY_OBD_ODOMETER, buf.readFloatLE()); @@ -338,47 +348,140 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 61: case 62: value = buf.readUnsignedShortLE(); - position.set( - Position.KEY_AXLE_WEIGHT + (j + 2 - 58), (value != 65535) ? value : null); + if (value != 0xFFFF) { + position.set(Position.KEY_AXLE_WEIGHT + (j + 2 - 58), value); + } break; case 63: value = buf.readUnsignedByte(); - position.set("obdAccelPos", (value != 0xFF) ? value : null); + if (value != 0xFF) { + position.set("acceleratorPosition", value); + } break; case 64: value = buf.readUnsignedByte(); - position.set("obdBrakePos", (value != 0xFF) ? value : null); + if (value != 0xFF) { + position.set("brakePosition", value); + } break; case 65: value = buf.readUnsignedByte(); - position.set(Position.KEY_ENGINE_LOAD, (value != 0xFF) ? value : null); + if (value != 0xFF) { + position.set(Position.KEY_ENGINE_LOAD, value); + } break; case 66: value = buf.readUnsignedShortLE(); - if (value == 0x7FFF) { - position.set("obdAdBlueLevel", (Boolean) null); - position.set("obdAdBlue", (Boolean) null); - } else if (BitUtil.check(value, 7)) { - position.set("obdAdBlueLevel", BitUtil.to(value, 6)); - position.set("obdAdBlue", (Boolean) null); - } else { - position.set("obdAdBlueLevel", (Boolean) null); - position.set("obdAdBlue", BitUtil.to(value, 6) / 10); + if (value != 0x7FFF) { + if (BitUtil.check(value, 7)) { + position.set("obdAdBlueLevel", BitUtil.to(value, 6)); + } else { + position.set("obdAdBlue", BitUtil.to(value, 6) / 10); + } } break; case 67: - position.set("obdHours", buf.readUnsignedIntLE() / 60); + position.set("obdHours", buf.readUnsignedIntLE() * 1000); break; case 68: value = buf.readUnsignedShortLE(); - position.set( - Position.KEY_ODOMETER_SERVICE, (value != 0xFFFF) ? (value * 5000) : null); + if (value != 0xFFFF) { + position.set(Position.KEY_ODOMETER_SERVICE, (value * 5000)); + } break; case 69: value = buf.readUnsignedByte(); - position.set( - Position.KEY_OBD_SPEED, - (value != 0xFF) ? UnitsConverter.knotsFromKph(value) : null); + if (value != 0xFF) { + position.set(Position.KEY_OBD_SPEED, UnitsConverter.knotsFromKph(value)); + } + break; + case 78: + case 79: + case 80: + case 81: + case 82: + case 83: + position.set("fuelTemp" + (j + 2 - 78), (int) buf.readByte()); + break; + case 163: + case 164: + case 165: + case 166: + value = buf.readShortLE(); + if (value != (short) 0x8000) { + position.set( + Position.PREFIX_TEMP + "HighPrecision" + (j + 2 - 163), + value * 0.05); + } + break; + case 167: + case 168: + case 169: + case 170: + value = buf.readUnsignedByte(); + if (value != 0xFF) { + position.set("humidity" + (j + 2 - 167), value * 0.5); + } + break; + case 206: + position.set("diagnostic", buf.readUnsignedIntLE()); + break; + case 207: + case 208: + case 209: + case 210: + case 211: + case 212: + case 213: + case 214: + case 215: + case 216: + case 217: + case 218: + case 219: + case 220: + case 221: + case 222: + position.set("user1Byte" + (j + 2 - 207), buf.readUnsignedByte()); + break; + case 223: + case 224: + case 225: + case 226: + case 227: + case 228: + case 229: + case 230: + case 231: + case 232: + case 233: + case 234: + case 235: + case 236: + case 237: + position.set("user2Byte" + (j + 2 - 223), buf.readUnsignedShortLE()); + break; + case 238: + case 239: + case 240: + case 241: + case 242: + case 243: + case 244: + case 245: + case 246: + case 247: + case 248: + case 249: + case 250: + case 251: + case 252: + position.set("user4Byte" + (j + 2 - 238), buf.readUnsignedIntLE()); + break; + case 253: + case 254: + case 255: + position.set("user8Byte" + (j + 2 - 253), buf.readLongLE()); break; default: buf.skipBytes(getItemLength(j + 1)); -- cgit v1.2.3 From 500d563d1923503b9e835c3f4a4a894bba883bf7 Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Fri, 25 Aug 2023 15:44:48 +0300 Subject: correction of comments: - rollback, returned the condition operator; - everything that fits in one line now; - fixed the key for fields 163-166; - parsing of fields 207-255 has been moved to default. --- .../protocol/NavtelecomProtocolDecoder.java | 141 ++++++--------------- 1 file changed, 38 insertions(+), 103 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 6ef614c8d..f317bee13 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -212,9 +212,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { value = buf.readUnsignedByte(); position.set(Position.KEY_ALARM, BitUtil.check(value, 2)); int guardMode = BitUtil.between(value, 3, 4); - position.set( - Position.KEY_ARMED, - (0 < guardMode) && (guardMode < 3)); + position.set(Position.KEY_ARMED, (0 < guardMode) && (guardMode < 3)); break; case 5: @@ -291,15 +289,11 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 42: case 43: value = buf.readUnsignedShortLE(); - if (value < 65500) { - position.set("fuel" + (j + 2 - 38), value); - } + position.set("fuel" + (j + 2 - 38), (value < 65500) ? value : null); break; case 44: value = buf.readUnsignedShortLE(); - if (value < 65500) { - position.set(Position.KEY_FUEL_LEVEL, value); - } + position.set(Position.KEY_FUEL_LEVEL, (value < 65500) ? value : null); break; case 45: case 46: @@ -310,9 +304,8 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 51: case 52: value = buf.readByte(); - if (value != (byte) 0x80) { - position.set(Position.PREFIX_TEMP + (j + 2 - 45), value); - } + position.set( + Position.PREFIX_TEMP + (j + 2 - 45), (value != (byte) 0x80) ? value : null); break; case 53: value = buf.readUnsignedShortLE(); @@ -329,15 +322,11 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 55: value = buf.readUnsignedShortLE(); - if (value != 0xFFFF) { - position.set(Position.KEY_RPM, value); - } + position.set(Position.KEY_RPM, (value != 0xFFFF) ? value : null); break; case 56: value = buf.readByte(); - if (value != (byte) 0x80) { - position.set(Position.KEY_COOLANT_TEMP, value); - } + position.set(Position.KEY_COOLANT_TEMP, (value != (byte) 0x80) ? value : null); break; case 57: position.set(Position.KEY_OBD_ODOMETER, buf.readFloatLE()); @@ -348,27 +337,20 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 61: case 62: value = buf.readUnsignedShortLE(); - if (value != 0xFFFF) { - position.set(Position.KEY_AXLE_WEIGHT + (j + 2 - 58), value); - } + position.set( + Position.KEY_AXLE_WEIGHT + (j + 2 - 58), (value != 0xFFFF) ? value : null); break; case 63: value = buf.readUnsignedByte(); - if (value != 0xFF) { - position.set("acceleratorPosition", value); - } + position.set("acceleratorPosition", (value != 0xFF) ? value : null); break; case 64: value = buf.readUnsignedByte(); - if (value != 0xFF) { - position.set("brakePosition", value); - } + position.set("brakePosition", (value != 0xFF) ? value : null); break; case 65: value = buf.readUnsignedByte(); - if (value != 0xFF) { - position.set(Position.KEY_ENGINE_LOAD, value); - } + position.set(Position.KEY_ENGINE_LOAD, (value != 0xFF) ? value : null); break; case 66: value = buf.readUnsignedShortLE(); @@ -385,15 +367,15 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 68: value = buf.readUnsignedShortLE(); - if (value != 0xFFFF) { - position.set(Position.KEY_ODOMETER_SERVICE, (value * 5000)); - } + position.set( + Position.KEY_ODOMETER_SERVICE, + (value != 0xFFFF) ? (value * 5000) : null); break; case 69: value = buf.readUnsignedByte(); - if (value != 0xFF) { - position.set(Position.KEY_OBD_SPEED, UnitsConverter.knotsFromKph(value)); - } + position.set( + Position.KEY_OBD_SPEED, + (value != 0xFF) ? UnitsConverter.knotsFromKph(value) : null); break; case 78: case 79: @@ -408,84 +390,37 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 165: case 166: value = buf.readShortLE(); - if (value != (short) 0x8000) { - position.set( - Position.PREFIX_TEMP + "HighPrecision" + (j + 2 - 163), - value * 0.05); - } + position.set( + Position.PREFIX_TEMP + (j + 2 + 8 - 163), + (value != (short) 0x8000) ? value * 0.05 : null); break; case 167: case 168: case 169: case 170: value = buf.readUnsignedByte(); - if (value != 0xFF) { - position.set("humidity" + (j + 2 - 167), value * 0.5); - } + position.set("humidity" + (j + 2 - 167), (value != 0xFF) ? value * 0.5 : null); break; case 206: position.set("diagnostic", buf.readUnsignedIntLE()); break; - case 207: - case 208: - case 209: - case 210: - case 211: - case 212: - case 213: - case 214: - case 215: - case 216: - case 217: - case 218: - case 219: - case 220: - case 221: - case 222: - position.set("user1Byte" + (j + 2 - 207), buf.readUnsignedByte()); - break; - case 223: - case 224: - case 225: - case 226: - case 227: - case 228: - case 229: - case 230: - case 231: - case 232: - case 233: - case 234: - case 235: - case 236: - case 237: - position.set("user2Byte" + (j + 2 - 223), buf.readUnsignedShortLE()); - break; - case 238: - case 239: - case 240: - case 241: - case 242: - case 243: - case 244: - case 245: - case 246: - case 247: - case 248: - case 249: - case 250: - case 251: - case 252: - position.set("user4Byte" + (j + 2 - 238), buf.readUnsignedIntLE()); - break; - case 253: - case 254: - case 255: - position.set("user8Byte" + (j + 2 - 253), buf.readLongLE()); - break; default: - buf.skipBytes(getItemLength(j + 1)); - break; + if ((207 <= j) && (j <= 222)) { + position.set("user1Byte" + (j + 2 - 207), buf.readUnsignedByte()); + break; + } else if ((223 <= j) && (j <= 237)) { + position.set("user2Byte" + (j + 2 - 223), buf.readUnsignedShortLE()); + break; + } else if ((238 <= j) && (j <= 252)) { + position.set("user4Byte" + (j + 2 - 238), buf.readUnsignedIntLE()); + break; + } else if ((253 <= j) && (j <= 255)) { + position.set("user8Byte" + (j + 2 - 253), buf.readLongLE()); + break; + } else { + buf.skipBytes(getItemLength(j + 1)); + break; + } } } } -- cgit v1.2.3 From 6ac4b94179ae340157c59d995d042ed238e9696d Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Sat, 26 Aug 2023 00:13:15 +0300 Subject: correction: - fix alarm; - fix roaming; - rename field 44 to fuel without index (this is initial sensor in device); - rename field 53 to obdFuel (this is from CAN bus); - fix axle weight name; - fix breaks in default block. --- .../traccar/protocol/NavtelecomProtocolDecoder.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index f317bee13..51b7db763 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -210,14 +210,16 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 4: value = buf.readUnsignedByte(); - position.set(Position.KEY_ALARM, BitUtil.check(value, 2)); + position.set( + Position.KEY_ALARM, + BitUtil.check(value, 2) ? Position.ALARM_GENERAL : null); int guardMode = BitUtil.between(value, 3, 4); position.set(Position.KEY_ARMED, (0 < guardMode) && (guardMode < 3)); break; case 5: value = buf.readUnsignedByte(); - position.set(Position.KEY_ROAMING, BitUtil.check(value, 6)); + position.set(Position.KEY_ROAMING, BitUtil.check(value, 6) ? true : null); break; case 8: value = buf.readUnsignedByte(); @@ -293,7 +295,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { break; case 44: value = buf.readUnsignedShortLE(); - position.set(Position.KEY_FUEL_LEVEL, (value < 65500) ? value : null); + position.set("fuel", (value < 65500) ? value : null); break; case 45: case 46: @@ -311,9 +313,9 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { value = buf.readUnsignedShortLE(); if (value != 0x7FFF) { if (BitUtil.check(value, 7)) { - position.set("fuelLevel", BitUtil.to(value, 6)); + position.set("obdFuelLevel", BitUtil.to(value, 6)); } else { - position.set(Position.KEY_FUEL_LEVEL, BitUtil.to(value, 6) / 10); + position.set("obdFuel", BitUtil.to(value, 6) / 10); } } break; @@ -337,8 +339,7 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 61: case 62: value = buf.readUnsignedShortLE(); - position.set( - Position.KEY_AXLE_WEIGHT + (j + 2 - 58), (value != 0xFFFF) ? value : null); + position.set("axleWeight" + (j + 2 - 58), (value != 0xFFFF) ? value : null); break; case 63: value = buf.readUnsignedByte(); @@ -407,20 +408,16 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { default: if ((207 <= j) && (j <= 222)) { position.set("user1Byte" + (j + 2 - 207), buf.readUnsignedByte()); - break; } else if ((223 <= j) && (j <= 237)) { position.set("user2Byte" + (j + 2 - 223), buf.readUnsignedShortLE()); - break; } else if ((238 <= j) && (j <= 252)) { position.set("user4Byte" + (j + 2 - 238), buf.readUnsignedIntLE()); - break; } else if ((253 <= j) && (j <= 255)) { position.set("user8Byte" + (j + 2 - 253), buf.readLongLE()); - break; } else { buf.skipBytes(getItemLength(j + 1)); - break; } + break; } } } -- cgit v1.2.3 From b735b834755039ef54524db0f1de4484d17dec22 Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Wed, 30 Aug 2023 23:55:13 +0300 Subject: correction: - used key for fields 38-44 --- src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 51b7db763..406a0292c 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -291,11 +291,11 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 42: case 43: value = buf.readUnsignedShortLE(); - position.set("fuel" + (j + 2 - 38), (value < 65500) ? value : null); + position.set(Position.KEY_FUEL_LEVEL + (j + 2 - 38), (value < 65500) ? value : null); break; case 44: value = buf.readUnsignedShortLE(); - position.set("fuel", (value < 65500) ? value : null); + position.set(Position.KEY_FUEL_LEVEL, (value < 65500) ? value : null); break; case 45: case 46: -- cgit v1.2.3 From 987e2f9192ac3d0381235335b44f35ed83f78a3f Mon Sep 17 00:00:00 2001 From: Yuriy Piskarev Date: Thu, 31 Aug 2023 00:00:52 +0300 Subject: correction: - fix for checkstyle --- src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java index 406a0292c..2e857b212 100644 --- a/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/NavtelecomProtocolDecoder.java @@ -291,7 +291,8 @@ public class NavtelecomProtocolDecoder extends BaseProtocolDecoder { case 42: case 43: value = buf.readUnsignedShortLE(); - position.set(Position.KEY_FUEL_LEVEL + (j + 2 - 38), (value < 65500) ? value : null); + position.set( + Position.KEY_FUEL_LEVEL + (j + 2 - 38), (value < 65500) ? value : null); break; case 44: value = buf.readUnsignedShortLE(); -- cgit v1.2.3