aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-05-13 21:08:52 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-05-13 21:08:52 -0700
commita7a48ccbe9bb49ed26efe997c6d00f32f88855e9 (patch)
tree0728e93a6ee2c6202d3f9aaa3ede3d2a5376e542
parente28810ff78e9bf81ae8fec3df5404a6eaf3eaeb7 (diff)
downloadtrackermap-server-a7a48ccbe9bb49ed26efe997c6d00f32f88855e9.tar.gz
trackermap-server-a7a48ccbe9bb49ed26efe997c6d00f32f88855e9.tar.bz2
trackermap-server-a7a48ccbe9bb49ed26efe997c6d00f32f88855e9.zip
Decode fuel and temperature
-rw-r--r--src/main/java/org/traccar/protocol/StartekProtocolDecoder.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
index 9b3780d0f..21b888dc8 100644
--- a/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/StartekProtocolDecoder.java
@@ -19,6 +19,7 @@ import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
+import org.traccar.helper.BitUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -66,7 +67,9 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
.number("(x+)|") // battery
.expression("([^,]+),") // adc
.number("d,") // extended
- .any()
+ .expression("([^,]+)?,") // fuel
+ .expression("([^,]+)?") // temperature
+ .number("xx") // checksum
.compile();
private String decodeAlarm(int value) {
@@ -135,6 +138,28 @@ public class StartekProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_ADC + (i + 1), Integer.parseInt(adc[i], 16) * 0.01);
}
+ if (parser.hasNext()) {
+ String[] fuels = parser.next().split("\\|");
+ for (String fuel : fuels) {
+ int index = Integer.parseInt(fuel.substring(0, 2));
+ int value = Integer.parseInt(fuel.substring(2), 16);
+ position.set("fuel" + index, value * 0.1);
+ }
+ }
+
+ if (parser.hasNext()) {
+ String[] temperatures = parser.next().split("\\|");
+ for (String temperature : temperatures) {
+ int index = Integer.parseInt(temperature.substring(0, 2));
+ int value = Integer.parseInt(temperature.substring(2), 16);
+ double convertedValue = BitUtil.to(value, 15);
+ if (BitUtil.check(value, 15)) {
+ convertedValue = -convertedValue;
+ }
+ position.set(Position.PREFIX_TEMP + index, convertedValue * 0.01);
+ }
+ }
+
return position;
}