aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-03-12 17:23:50 -0600
committerIván Ávalos <avalos@disroot.org>2024-03-12 17:23:50 -0600
commitd95ddbfc4de30af7980ec19a24cedbdfdff55c3b (patch)
tree73925f3c6efd18b5d00901116b0bd53702d68a99
parentcbdc38bfe04e95658d9308b5b5705f440d8508ff (diff)
parent823878d4f797cf2fb8e2c6e3b466b3316613d886 (diff)
downloadtrackermap-server-d95ddbfc4de30af7980ec19a24cedbdfdff55c3b.tar.gz
trackermap-server-d95ddbfc4de30af7980ec19a24cedbdfdff55c3b.tar.bz2
trackermap-server-d95ddbfc4de30af7980ec19a24cedbdfdff55c3b.zip
Merge branch 'upstream'
-rw-r--r--src/main/java/org/traccar/protocol/EskyProtocolDecoder.java2
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java38
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoFrameEncoder.java42
-rw-r--r--src/main/java/org/traccar/protocol/HuabaoProtocol.java3
-rw-r--r--src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java3
-rw-r--r--src/test/java/org/traccar/protocol/HuabaoFrameEncoderTest.java21
6 files changed, 106 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java b/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java
index 4239022d0..14b6aaa5a 100644
--- a/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/EskyProtocolDecoder.java
@@ -49,7 +49,7 @@ public class EskyProtocolDecoder extends BaseProtocolDecoder {
.number("(d+.d+)[+;]") // speed
.number("(d+)[+;]") // course
.groupBegin()
- .text("0x").number("(d+)[+;]") // input
+ .text("0x").number("(x+)[+;]") // input
.number("(d+)[+;]") // message type
.number("(d+)[+;]") // odometer
.groupEnd("?")
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 2e5ffa8d6..7a8d67cf9 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -468,7 +468,6 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
index += 1; // report type
index += 1; // can bus state
long reportMask = Long.parseLong(v[index++], 16);
- long reportMaskExt = 0;
if (BitUtil.check(reportMask, 0)) {
position.set(Position.KEY_VIN, v[index++]);
@@ -572,6 +571,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
index += 1; // electric report mask
}
}
+
+ long reportMaskExt = 0;
if (BitUtil.check(reportMask, 29) && !v[index++].isEmpty()) {
reportMaskExt = Long.parseLong(v[index - 1], 16);
}
@@ -647,6 +648,41 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(reportMaskExt, 23)) {
index += 1; // engine torque
}
+ if (BitUtil.check(reportMaskExt, 24)) {
+ index += 1; // service distance
+ }
+ if (BitUtil.check(reportMaskExt, 25)) {
+ index += 1; // ambient temperature
+ }
+ if (BitUtil.check(reportMaskExt, 26)) {
+ index += 1; // tachograph driver1 working time mask
+ }
+ if (BitUtil.check(reportMaskExt, 27)) {
+ index += 1; // tachograph driver2 working time mask
+ }
+ if (BitUtil.check(reportMaskExt, 28)) {
+ index += 1; // dtc codes
+ }
+ if (BitUtil.check(reportMaskExt, 29)) {
+ index += 1; // gaseous fuel level
+ }
+ if (BitUtil.check(reportMaskExt, 30)) {
+ index += 1; // tachograph information expand
+ }
+
+ long reportMaskCan = 0;
+ if (BitUtil.check(reportMaskExt, 31) && !v[index++].isEmpty()) {
+ reportMaskCan = Long.parseLong(v[index - 1], 16);
+ }
+ if (BitUtil.check(reportMaskCan, 0)) {
+ index += 1; // retarder usage
+ }
+ if (BitUtil.check(reportMaskCan, 1)) {
+ index += 1; // power mode
+ }
+ if (BitUtil.check(reportMaskCan, 2)) {
+ index += 1; // tachograph timestamp
+ }
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
diff --git a/src/main/java/org/traccar/protocol/HuabaoFrameEncoder.java b/src/main/java/org/traccar/protocol/HuabaoFrameEncoder.java
new file mode 100644
index 000000000..5e48a466a
--- /dev/null
+++ b/src/main/java/org/traccar/protocol/HuabaoFrameEncoder.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2024 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar.protocol;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToByteEncoder;
+
+public class HuabaoFrameEncoder extends MessageToByteEncoder<ByteBuf> {
+
+ @Override
+ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) {
+
+ int startIndex = msg.readerIndex();
+ while (msg.isReadable()) {
+ int index = msg.readerIndex();
+ int b = msg.readUnsignedByte();
+ if (b == 0x7d) {
+ out.writeByte(0x7d);
+ out.writeByte(0x01);
+ } else if (b == 0x7e && index != startIndex && msg.isReadable()) {
+ out.writeByte(0x7d);
+ out.writeByte(0x02);
+ } else {
+ out.writeByte(b);
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/traccar/protocol/HuabaoProtocol.java b/src/main/java/org/traccar/protocol/HuabaoProtocol.java
index fc12d7d71..575d15b02 100644
--- a/src/main/java/org/traccar/protocol/HuabaoProtocol.java
+++ b/src/main/java/org/traccar/protocol/HuabaoProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2024 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ public class HuabaoProtocol extends BaseProtocol {
addServer(new TrackerServer(config, getName(), false) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline, Config config) {
+ pipeline.addLast(new HuabaoFrameEncoder());
pipeline.addLast(new HuabaoFrameDecoder());
pipeline.addLast(new HuabaoProtocolEncoder(HuabaoProtocol.this));
pipeline.addLast(new HuabaoProtocolDecoder(HuabaoProtocol.this));
diff --git a/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java
index feec3ebfb..26132eb4e 100644
--- a/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class EskyProtocolDecoderTest extends ProtocolTest {
var decoder = inject(new EskyProtocolDecoder(null));
+ verifyPosition(decoder, text(
+ "ET;1;864431045310325;R;0+240303180628+-33.40958+149.56797+0.00+63+0xb+0+17814846+1168+0+0+WVWZZZ6RZFY242201+135+DTCNULL"));
+
verifyAttribute(decoder, text(
"ET;0;860337031066546;R;9+200717114059+41.32053+19.80761+0.30+0+0x2+8+40381744+0+1409+11"),
Position.KEY_BATTERY, 14.09);
diff --git a/src/test/java/org/traccar/protocol/HuabaoFrameEncoderTest.java b/src/test/java/org/traccar/protocol/HuabaoFrameEncoderTest.java
new file mode 100644
index 000000000..a2799e9a8
--- /dev/null
+++ b/src/test/java/org/traccar/protocol/HuabaoFrameEncoderTest.java
@@ -0,0 +1,21 @@
+package org.traccar.protocol;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.jupiter.api.Test;
+import org.traccar.ProtocolTest;
+
+public class HuabaoFrameEncoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ var encoder = new HuabaoFrameEncoder();
+
+ ByteBuf buf = Unpooled.buffer();
+ encoder.encode(null, binary("7e307e087d557e"), buf);
+ verifyFrame(binary("7e307d02087d01557e"), buf);
+
+ }
+
+}